DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Debug Like a Pro in 2025: 10 New Eclipse Java Debugger Features to Enhance Your Productivity (With Spring Boot Examples)
  • How to Debug the Spring Boot Application in Eclipse? [Video]
  • LLMs for Debugging Code
  • Debugging Distributed ML Systems

Trending

  • The Missing `bandit` for AI Agents: How I Built a Static Analyzer for Prompt Injection
  • PWA on iOS, Part 5: Service Worker Updates, Cache, and Push
  • How to Format Articles for DZone
  • Member Spotlight: Pavan Belagatti

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Frameworks
  4. Semihosting with GNU ARM Embedded (LaunchPad) and GNU ARM Eclipse Debug Plugins

Semihosting with GNU ARM Embedded (LaunchPad) and GNU ARM Eclipse Debug Plugins

By 
Erich Styger
·
Sep. 17, 14 · Interview
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
8.9K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

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.

semihosting output

semihosting output

there are three things to be in place to use semihosting with the gnu arm embedded (launchpad) libraries:

  1. option in the gnu linker settings
  2. enabling semihosting in the debugger settings
  3. initializing the gnu libraries

linker option

to enable semihosting for the gnu arm embedded ( launchpad ) libraries, i need to add

--specs=rdimon.specs 

to the linker options:

linker option to enable semihosting

linker option to enable semihosting

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 


debugger settings

in the gnu arm eclipse plugins, i need to enable semihosting.

segger j-link

for segger j-link, i enable the console in the launch configuration:

allocated semihosting console for segger

allocated semihosting console for segger


additionally i enable semihosting options in the startup options of the debugger:


enabled semihosting in the startup options for segger

enabled semihosting in the startup options for segger


p&e multilink

for p&e the following settings are used:

semihosting settings for pne

semihosting settings for pne


settings for openocd

the following settings are used for openocd:

openocd semihosting settings

openocd semihosting settings

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 initialise_monitor_handles() before i’m using printf() :

1
2
3
4
5
6
7
8
extern void initialise_monitor_handles( void ); /* prototype */
int main( void ) {
initialise_monitor_handles(); /* initialize handles */
for (;;) {
printf ( "hello world!\r\n" );
}
}


with this, i can use printf() and scanf() through a debugger connection.


semihosting printf output

semihosting printf output

summary

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 :-)

GNU Arm (geography) Debug (command) Eclipse Launchpad (macOS)

Published at DZone with permission of Erich Styger. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Debug Like a Pro in 2025: 10 New Eclipse Java Debugger Features to Enhance Your Productivity (With Spring Boot Examples)
  • How to Debug the Spring Boot Application in Eclipse? [Video]
  • LLMs for Debugging Code
  • Debugging Distributed ML Systems

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook