-
-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Semihosting in BMP #1686
Fix: Semihosting in BMP #1686
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new/extra debug info for syscalls looks quite handy - nice addition. There's a small problem your patch for hostio_reply() introduces, for which we have a suggested fix, but this is looking good overall and explains in the code comments why what we did before was broken (subtly) which is excellent.
It's looking good and with the review item addressed, we'll be happy to merge this.
66b07ab
to
cfc6a42
Compare
When we merge this we'll backport it to v1.10 as part of the first point release for that firmware - seeing how broken this is in that release. It would be helpful if @xobs could please give this patch a spin and let us know how it interacts on Farpatch. We are inclined to merge this fix and then any further work that's needed to make Farpatch happy as a second pass. |
No issues on Farpatch -- still works just fine, though I've never used semihosting. |
* Add a reduced loop like the one in bmp_poll_loop(), allowing BMP to service GDB accessing syscall buffers in target memory; * Use both F-reply and Detach as exit conditions, passing a corresponding result code for the target to see when we resume it
cfc6a42
to
374f319
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, merging and backporting. Thanks for the contribution and all your hard work making it!
The loop is only reachable from (most of) semihosting calls, and it's harder for me to check that it won't cause issue for your platform/RTOS watchdog. If you don't have your own firmware with semihosting, but you have some targets compatible with Arduino cores like stm32duino, then you could just spin Koen's SemihostingTest.ino like I usually do. Although you're welcome to write a simpler testcase, just verify it accesses desktop GDB (some calls like errno and iserror are handled purely inside BMP) |
Detailed description
main()
#1284. Some attempt was made in Fix: Semihosting #1432 to make it at least not crash the adapter.I based the WIP tree on PR1432 single commit v1.9.0-435-g906f8878 backported to just past PR1284 merge, v1.9.0-55-g5cf0dd27. I had to enable DEBUG_GDB, DEBUG_GDB_WIRE and drop a bunch of drivers to fit into
swlink
, because my adapter of choice (blackpill-f411ce) did not exist until approximately v1.9.0-700 in usable form. The logs from BMP internals were critical for understanding how RSP packets go missing.Current patch adds a
while(true)
loop at stack depth of 9 functions to allow for parsing the 1-4 packets GDB has to emit before finishing the semihosting File-I/O syscall and returning its result code. AFAIK this has to be avoided in out-of-tree projects like Farpatch which will reboot due to watchdog timeouts from not going through the superloop often enough. But this variant seems to work, and you all can decide how to improve it, because it provides some starting/reference point.The less related change replaces the
syscall 0lx1 (800289c 0 3 20000054)
printswith more readable
syscall SYS_OPEN (800289c 0 3 20000054)
. Since v1.10.0 release I don't care about flash space much; it can be dropped in case of backporting, but it shouldn't affect release firmware because it's in DEBUG_INFO (and I could gate it on ENABLE_DEBUG for 332 bytes).Tested on
swlink
attached to Nucleo-G071RB target running SemihostingTest.ino over SWD (with its onboard JLinkReflash idling), using GDB-8/10/12 (NuttX, ST, GNU-RM).Your checklist for this pull request
make PROBE_HOST=native
)make PROBE_HOST=hosted
) and should not affect itClosing issues
Fixes #1678.