Freescale has released the v3.0.0 version of the Kinetis Design Studio: this one comes with a great positive change: instead of a custom toolchain, it is coming with the standard GNU ARM Embedded (launchpad) toolchain from ARM. Beside of better code density and less RAM needed, there is one change which affects semihosting. Previously, semihosting was enabled by default in the V2.0.0 libraries. Now semihosting needs to be turned on. This post is how to do this.
With the GNU ARM Embedded (launchpad) toolchain used in KDS v3.0.0, there are several differences compared to the KDS v2.0.0 version, outlined in https://community.freescale.com/docs/DOC-103698.
Linker Options to Enable Semihosting
As for semihosting, the difference is that in KDS v2.0.0 libraries it is enabled by default in the libraries, while in the launchpad tools it needs to be turned on.
💡 Semihosting is a technique to use printf() through the debugger connection. So instead using a physical UART, as communication channel the debugger is used.
To enable semihosting, check your linker options in the project properties (menu Project > Properties > C/C++ Build > Settings > Tool Settings). By default, it is using
Tells the linker to replace the ‘system’ stubs (reading/writing files, etc) with ‘no operation’ ones. Effectively, this disables semihosting.
💡 if using floating point support with nano library, turn on -u _printf_float and/or -u _scanf_float.
The linker option -specs=nosys.specs need now to be changed to specify
💡 the latest GNU ARM Eclipse plugins have a check box option for the newlib-nano option which I have used in the above screenshot.
With this, semihosting is turned on in the libraries.
All three debug connections in KDS (OpenOCD/CMSIS-DAP, P&E and Segger) have an option to enable semihosting in the debugger.
💡 If not using semihosting in your application, it would make sense to *disable* the semihosting option in the debugger.
The option is found in the Debug Configuration (menu Run > Debug Configurations).
For OpenOCD it is in the Startup tab:
For P&E it is here:
And for Segger it is here:
Debugging with Semihosting
Now while debugging, there should be a ‘Semihosting’ thread visible in the ‘Debug’ view, and output written to the Semihosting console on the bottom:
If the Semihosting output is not visible, you can bring it to the foreground with selecting the Semihosting thread in the Debug view:
Another tip is to select the semihosting console from the console view icon:
Another tip: To avoid that the console is changing depending on the current thread/view selected, I pin that console:
Happy Hosting 🙂
- Differences between Kinetis Design Studio v2.0.0 and v3.0.0: https://community.freescale.com/docs/DOC-103698
- Semihosting with Kinetis Design Studio v2.0.0: Semihosting with GNU ARM Embedded (Launchpad) and Kinetis Design Studio
- Semihosting with stock Eclipse and GNU ARM Embedded: Semihosting with GNU ARM Embedded (LaunchPad) and GNU ARM Eclipse Debug Plugins