Semihosting with GNU ARM Embedded (LaunchPad) and GNU ARM Eclipse Debug Plugins
Join the DZone community and get the full member experience.Join For Free
in “ semihosting with kinetis design studio ” i used printf() to exchange text and data between the target board and the host using the debug connection. kinetis design studio (kds) has that semihosting baked into its libraries. what about if using the gnu arm embedded (launchpad) tools and libraries (see “ switching arm gnu tool chain and libraries in kinetis design studio “)? actually it requires two more steps, but is very easy too.
there are three things to be in place to use semihosting with the gnu arm embedded (launchpad) libraries:
- option in the gnu linker settings
- enabling semihosting in the debugger settings
- initializing the gnu libraries
to enable semihosting for the gnu arm embedded ( launchpad ) libraries, i need to add
to the linker options:
in case i’m using newlib-nano and want to use printf() and/or scanf() with floating point support, i need to pull in some symbols explicitly with the linker options ‘u':
-u _scanf_float -u _printf_float
in the gnu arm eclipse plugins, i need to enable semihosting.
for segger j-link, i enable the console in the launch configuration:
additionally i enable semihosting options in the startup options of the debugger:
for p&e the following settings are used:
settings for openocd
the following settings are used for openocd:
initializing the gnu libraries
if you would now try to use semihosting with running the debugger, you probably will get error messages like this (e.g. from segger j-link):
warning: semihosting command sys_flen failed. handle is 0. warning: semihosting command sys_write failed. handle is 0. warning: semihosting command sys_write failed. handle is 0. warning: semihosting command sys_write failed. handle is 0.
the reason is that the semihosting needs to be enabled by the application. i need to call
before i’m using
with this, i can use printf() and scanf() through a debugger connection.
while i don’t like printf() for many reasons, sometimes it is useful to exchange data with the host. using semihosting no physical connection is required, as the communication goes through the debugger. it is somewhat intrusive, and adds code and data overhead, but the gnu arm embedded (launchpad) libraries (both newlib and newlib-nano) have semihosting built-in. it is a matter to enable it in the linker and debugger settings, and to initialize the handles in the application.
happy semihosting :-)
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Competing Consumers With Spring Boot and Hazelcast
Health Check Response Format for HTTP APIs
Writing a Vector Database in a Week in Rust
Step Into Serverless Computing