September 28, 2019 at 11:26 #25948
I’m targeting the NRF51 to build fruitymesh ( https://github.com/mwaylabs/fruitymesh )
Now NRF51 devices use the NRF5x legacy BSP.
For compatibility reasons, I’m using their startup.s file, system_nrf51.c and linker script.
It builds and debugs perfectly well, however, I cannot get it to run standalone because it is being built with semi-hosting.
How do I turn off semi-hosting? The usual options to control the level of semi-hosting don’t appear.
I’ve attached a screenshot of the embedded project page.
I’m fine with manually editing the project files,September 28, 2019 at 15:56 #25952
It looks like you are using an old toolchain that doesn’t provide fine-grain control over semihosting calls. Please try unchecking the “Provide default stubs for system calls” checkbox (bottom of the 1st screenshot) and then either manually provide dummy syscall implementations, or manually specify “–specs=nosys.specs” via VS Project Properties (not VisualGDB Project Properties) -> Linker -> Command Line.September 28, 2019 at 19:42 #25953
Thank you for the suggestion.
I had already tried ‘–specs=nosys.specs’ in vcxproj link options.
I had also converted this to a standalone project and specified nosys in LDFLAGS. (picture attached)
Both require semihosting. Still no luck, I’m afraid. NRF51 sdk only links properly on GCC 4.9, so I can’t upgrade to get the newer options.
Is there anything else I could try?September 29, 2019 at 15:40 #25957
Thanks for confirming your license key. Specifying –specs=nosys.specs manually should normally work.
If it doesn’t, please let us know:
- What exactly you are trying to achieve? I.e. why simply not calling printf() is not an option?
- What is the expected/observed behavior when you use the settings on the screenshot (e.g. expect the project to build, got a specific error)?
This should help us understand what is going on.September 30, 2019 at 07:52 #25964
Thank you for your support.
Application runs without debugger.
No build errors or warning.
Application crashes without debugger attached.
Specifically, application crashes without semi-hosting console support enabled.
What’s happening, I think, is that newlib being used here still links with semi-hosting calls.
I think, irrespective of me specifying nosys, it’s using rdimon. (Please see attached)
libc is supposed to use RTT.
Could I have missed something?September 30, 2019 at 15:31 #25968
Thanks for clarifying this. It could be that the old toolchain you are using does not come with dummy syscall implementations that would not trigger the semihosting calls.
We could recommend 3 ways of solving it:
November 5, 2019 at 19:58 #26406
- Run the program without debugging, reproduce the crash, attach to it and examine the call stack. You will likely see a call to printf() somewhere that triggered the semihosting call. Simply comment it out, or make it conditional in order to remove it.
- Do not specify the –specs=nosys.specs at all and try building the project. Once it complains about missing _write() and other similar syscalls, provide your own implementations for them that will simply discard the data passed to them.
- Try using our Advanced Semihosting and Profiler framework and select the option to ignore semihosting calls when the debugger is not attached.
So after spending some time on and off on this, and eliminating all possible sources of calling initialise_monitor_handles and the like, I finally tracked down the problem to crt0.S in the toolchain.
Looks like the version that was shipped has a bkpt 0xab instruction baked in. So no matter what I did, it would always trigger semi-hosting. I replaced lib\thumb\cortex_m0\crt0.o with a version from a newer arm-eabi-gcc, and the problem has now gone away.
Thank you for your guidance and clues.
- This reply was modified 6 months, 4 weeks ago by asti.
You must be logged in to reply to this topic.