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
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
  1. DZone
  2. Coding
  3. Frameworks
  4. Debugging the Startup Code With Eclipse and GDB

Debugging the Startup Code With Eclipse and GDB

Learn more about debugging embedded applications.

Erich Styger user avatar by
Erich Styger
·
Feb. 20, 19 · Tutorial
Like (2)
Save
Tweet
Share
6.00K Views

Join the DZone community and get the full member experience.

Join For Free

By default, when debugging an embedded application, the target usually stops at main():

stopped in main

That's usually fine, but what if I want to debug the code out of reset?

I'm using the Eclipse-based NXP MCUXpresso IDE 10.3 in this article, but same or similar things apply to most modern gdb + Eclipse-based IDEs.

Why does the application stop at main? This is because the debugger has set a temporary breakpoint on the main symbol (or function):

TemporaryBreakpoint

Temporary Breakpoint

This is confirmed by the Log in the Debugger Console view:

Temporary Breakpoint in Debugger Console

Temporary Breakpoint in Debugger Console

So what happens is:

  1. Debugger downloads the binary
  2. Debugger sets a temporary breakpoint at main
  3. Debugger issues a reset to the target followed by a 'run'
  4. The target will stop at the temporary breakpoint

Obviously, a simple way to debug the startup code is to set a breakpoint in the startup code itself:

Breakpoint on ResetISR

Breakpoint on ResetISR

Another way is to inspect and change the debugger launch configuration. Because this might be different for each debug configuration, I'll show it for LinkServer, Segger, and PEMicro.

LinkServer

The LinkServer (CMSIS-DAP, LPC-Link2) connection does not have a dedicated 'run' setting. To debug the startup code, I have to change the 'main' to the 'ResetISR' Symbol. To revert back, change the symbol back to 'main'.

Stop on Startup at

Stop on Startup at

Segger

With the GNU Mcu Eclipse plugins, the settings are as shown below and easy to change:

GnuMcuEclipseSegger

GnuMcuEclipseSegger

To do startup code debugging, disable the 'Continue' option.

P&E (PEMicro)

The screenshot below shows the setting for P&E to set the temporary breakpoint and the 'run on reset' setting, which is easy to find and change:

PEMicro Launch Config

PEMicro Launch Config

To start debugging from the reset vector, simply disable the 'Run on reset' option.

Summary

In order to debug the startup code with Eclipse and GDB, I could set a breakpoint in the reset routine, or better, I can change the setting in the Eclipse CDT launch configuration to halt in the ResetISR (or whatever the reset function name is).

Happy Startuping!

Additional Links

  • MCUXpresso IDE: http://www.nxp.com/mcuxpresso/ide
  • GNU MCU Eclipse plugins: https://gnu-mcu-eclipse.github.io/
Eclipse

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

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Submit a Post to DZone
  • The Quest for REST
  • How To Check Docker Images for Vulnerabilities
  • How Observability Is Redefining Developer Roles

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
  • +1 (919) 678-0300

Let's be friends: