Conversation
|
Sorry, seems I forgot to click on the draft button |
|
So you added a new link to an LLDBGuide but where's the guide itself? |
|
@xtremekforever I added the markdown now. I didn't create an example yet - this is why I marked it as a draft PR, sorry. Maybe this was better suited as an issue instead of a PR until I finish it - I opened it so that we could discuss and track progress on it. Either way, what board / example do you think would be best? |
Added a tutorial for using LLDB with Swift Embedded code, including prerequisites and installation instructions.
Note: RP2040 should be almost the same; there's only one register that does not exist - `pads_bank0.gpio[pin].iso`
|
I have written the guide and it should be almost ready. The guide was designed for Raspberry Pi Pico (RP2040/RP2350) boards (via conditional compilation using Swift Package traits). The tutorial guides readers through using LLDB to identify and fix some bugs in a sample I2C embedded app written with Swift MMIO. It is a simple example in which an I2C device, represented by the Pico's |
Corrected typos and enhanced clarity in LLDBGuide.md.
Updated wording for clarity and corrected minor typos in the LLDBGuide documentation.
|
👋 @iCMDdev - I read through the article/tutorial, and would like to provide feedback, but I'll preface this with a very definite I AM NOT AN EMBEDDED DEVELOPER caveat. There may be some baseline expected knowledge that I'm stumbling over. I made notes as I read through the article, trying to bundle them under section headings. Quite a lot was fairly direct to follow, but there were some places where I was really stumped, unclear on what or how I should do something, or what I should know. In several places, the order of the information presented it later in the section, so I ended up having to read forward, backward, and forward again to get a sense of what I could/should do in each section. As a general rule, I'd highly suggest removing any of the phrases "simply" or "just" - I've seen that used to make it sound easier or less imposing, but without knowing a lot of this detail already, I felt really silly and awkward. I love the overall run through the content - using LLDB (through OpenOCD I guess), but when you were presenting the bugs and what was happening, my lack of embedded knowledge and expectations may be very out of whack. I didn't understand many of the intuitive leaps that you made in the writing, although once you made them I could back track and find evidence of bits of it in the presented examples.
|
|
Hi @heckj, thanks a lot for the feedback! I would also like to preface this by saying I am not an expert embedded developer either, but rather a student still learning. And this is probably my first time writing documentation this big for a project of this nature, so your advice is greatly appreciated! First of all, I'd like to note that I added a paragraph withmore information about the setup at the beginning of this guided example, which may make this project easier to digest before reading the prerequisites. I am not sure how I should modify the prerequisites - was striking for a match between keeping things short (explaining in more detail later). Regarding this:
I changed the link to the correct build instructions. Regarding your other notes, I made some other changes based on your descriptions, so please let me know what you think! I described them below. 1. Removing "simply" / "just"
That is definitely not what I was going for, I made a few changes, let me know if this sounds better now. 2. Initial board setup - SWD connection
On the SWD debug probe side, this usually depends on the board and the users' hardware debugger. I tried to clarify this by saying "After you made the connections above, you will need to connect a debugger to the board's SWD pins. Refer to your hardware debugger's documentation for more info". The board's 3 debug pins that need to be connected are those marked as "DEBUG". 3. Uploading the firmware
Yeah, the idea is indeed that the code is ephemeral the way it's saved currently (RAM memory is erased when the board's power supply is cut), though we could modify the linker scripts to save the code in flash memory (which is persistent). I changed the wording a bit. 4. Attaching LLDB
Sorry, yes, this is meant to be updated. This depends on an OpenOCD patch that I submitted and is yet to be merged.
Yes, OpenOCD is the program that connects your hardware debugger (an extra piece of hardware connected to your board, like a dongle) to your software debugger, i.e. LLDB. It provides interface that LLDB can use, that is, the GDB remote debug port. I also made some changes to clarify this.
I added a few words about Swift vs assembly here and here. Let me know if you want me to clarify this further - the idea is that one thread is unused (running the chip's own ROM code), while the other one is running our Swift code (for which we have debug symbols + the source code itself).
I'm not exactly sure which instructions you're referring to, but yes, when the code execution is interrupted, we can see the code line(s) where the program was stopped - some commands such as 5. Setting a breakpoint on our app's entrypoint
I did describe this previously but I am not sure how to specify this without repeating myself; I would love to hear your suggestions. 6. Invesigating the second bug
This is the terminal in which you're running LLDB. I made some changes to clarify the setup here and here. There is only one other terminal, running OpenOCD.
To be clear, the problem is that 7. Finding and fixing the last bug
This was meant as "remember for later". I made some changes, tried to clarify this.
It is visible in the decode output (see the second line below): |
|
The OpenOCD patch was merged yesterday in the following commit: openocd-org/openocd@22e1e1b. |
heckj
left a comment
There was a problem hiding this comment.
The updates for explanations in the guide are great! I ran through the whole thing again this morning, and stumbled a bit with the back and forth between the tenses (jumping between we/our and you/your) - so I've made a (large) set of suggestions for changing most of the wording to use you/your, which matches the style that's common in Swift's documentation.
I may not have hit them all, but hopefully you get a sense of it. The place where I explicitly left "we" alone was in the earlier part of the article where "we" seemed to imply this project/the community and was providing recommendations.
I also dropped some of the "You can ..." to be more direct in getting to the action of what the guide is asking the reader to do. Read through with these changes, see what you think. I tried to not make any changes that significantly removed your voice from the writing, while making it more direct and consistent.
|
|
||
|
|
||
| ### Installing Swift, LLDB and SVD2LLDB | ||
| > Note: Embedded Swift is experimental. Public releases of Swift do not support Embedded Swift, yet. See <doc:InstallEmbeddedSwift> for details. |
There was a problem hiding this comment.
For this guide, I'd suggest minimizing talking about how Embedded Swift is experimental - anyone popping in here today already has a sense of that, and the key detail in this note is that public releases of Swift don't include Embedded Swift, so you need to install it directly through an open source toolchain. I don't think you need both the call out and the first paragraph, as they're redundant.
The bonus of stripping this note also gives this article better longevity - you won't need to explicitly strip this later when it advances.
There was a problem hiding this comment.
Makes sense. This warning is also present in these other (currently published on swift.org) pages:
- Introduction to Embedded Swift
- Getting started with Embedded Swift
- Raspberry Pi Pico Blink (Pico SDK) guide
Should we remove it from the Pico example? I think the first two make sense, since these are pages with general information, but once the reader approaches the precise guided examples, they already know this.
Moreover, this warning isn't present in the macOS Guided Example or the STM32 one.
There was a problem hiding this comment.
I don't think we need to go out of our way on this topic to normalize it - it'll be more places to switch once it is part of a release, my suggestion for this guide just reduces that future workload by 1 ;-)
There was a problem hiding this comment.
FWIW we should only say this once in the entire documentation catalog. Each article repeating it isn't helpful.
Additionally, that warning was introduced when embedded would crash the compiler extremely frequently. It's no longer a super helpful warning, as we're well on the way to productizing.
There was a problem hiding this comment.
I removed it from the current guide (can mark this as solved). So, do you want me to keep the others, remove them in another PR or should I rather remove them here?
Additionally, that warning was introduced when embedded would crash the compiler extremely frequently. It's no longer a super helpful warning, as we're well on the way to productizing.
It does indeed feel very robust and much less experimental nowadays :)
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
heckj
left a comment
There was a problem hiding this comment.
The updates for explanations in the guide are great! I ran through the whole thing again this morning, and stumbled a bit with the back and forth between the tenses (jumping between we/our and you/your) - so I've made a (large) set of suggestions for changing most of the wording to use you/your, which matches the style that's common in Swift's documentation.
I may not have hit them all, but hopefully you get a sense of it. The place where I explicitly left "we" alone was in the earlier part of the article where "we" seemed to imply this project/the community and was providing recommendations.
I also dropped some of the "You can ..." to be more direct in getting to the action of what the guide is asking the reader to do. Read through with these changes, see what you think. I tried to not make any changes that significantly removed your voice from the writing, while making it more direct and consistent.
Co-authored-by: Joseph Heck <j_heck@apple.com>
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Sources/EmbeddedSwift/Documentation.docc/GuidedExamples/LLDBGuide.md
Outdated
Show resolved
Hide resolved
Apply suggestions from code review: - More consistency between "we/our" and "you/your" - Add correct file link(s)
|
|
||
| OpenOCD is a program that connects to your hardware debugger, providing an interface that LLDB uses to connect and control your board. | ||
|
|
||
| > Note: OpenOCD had a bug which may have prevented LLDB from connecting to your board. Ensure you are using the latest version available. |
There was a problem hiding this comment.
| > Note: OpenOCD had a bug which may have prevented LLDB from connecting to your board. Ensure you are using the latest version available. | |
| > Note: OpenOCD had a bug which may have prevented LLDB from connecting to your board, which was fixed in commit [22e1e1b](https://review.openocd.org/q/22e1e1b33e844c343eb3f24d24f630e2471d2b27). Ensure the version you are using includes this patch. |
Note to myself: this should be updated to the latest state when this guide is published (that is, include a version number rather than a commit hash, if available). Current state is that the OpenOCD patch was merged in the aforementioned commit, but there's no tagged release containing it yet (maintainers said version 1.0.0 should be tagged soon / asap).
Also, this commit is not yet present in the Raspberry Pi fork (for the Pico / RPi Debug Probe) - linking raspberrypi/openocd#147 for reference.
This draft PR will add an example on how to use LLDB with Swift Embedded (including SVD2LLDB). I decided to create this draft PR and ask for your thoughts & feedback.
Would love to hear what you think, especially regarding: