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
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
Securing Your Software Supply Chain with JFrog and Azure
Register Today

Trending

  • 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

Trending

  • 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
  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

Erich Styger user avatar by
Erich Styger
·
Sep. 17, 14 · Interview
Like (0)
Save
Tweet
Share
7.54K Views

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.

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, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • 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

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: