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. Software Design and Architecture
  3. Integration
  4. MCUXpresso IDE: Terminate and Disconnect a Debug Session

MCUXpresso IDE: Terminate and Disconnect a Debug Session

Debugging is tricky, and it's harder when terms mean different things in different implementations. PandE is mostly perfect, and Segger's shortfalls can be fixed.

Erich Styger user avatar by
Erich Styger
·
May. 11, 17 · Tutorial
Like (0)
Save
Tweet
Share
4.52K Views

Join the DZone community and get the full member experience.

Join For Free

Eclipse for C/C++ (CDT) offers two different ways to get out of a debug session: Terminate and Disconnect:

Terminate and Disconnect

Terminate and Disconnect

The terminate and disconnect behavior is not standardized and varies between Eclipse distributions and debug connections. This article is about how things are handled in the MCUXpresso IDE, and how I can influence the behavior.

This article is part of a series to get up to speed using the new NXP MCUXpresso IDE. Published so far are:

  • MCUXpresso IDE: Unified Eclipse IDE for NXPs ARM Cortex-M Microcontrollers
  • MCUXpresso IDE: S-Record, Intel Hex, and Binary Files
  • MCUXpresso IDE: Adding the Eclipse Marketplace Client
  • MCUXpresso IDE: Importing Kinetis Design Studio Projects
  • MCUXpresso IDE: Installing Processor Expert into Eclipse Neon

Outline

While debugging with Eclipse, there are two different ways to end a debug session:

  • Terminate:
    Terminate Button

    The expected behavior is to stop the target under debug and disconnect from it and leave it in the stopped state. Similar to the ‘stop button’ on audio or video devices.

  • Disconnect:
    Disconnect Button

    The expected behavior is to leave the target as it is (running, suspended) and disconnect the debugger from the target.

As said in the introduction, the behavior depends on the Eclipse distribution and run control. I know that especially ‘disconnect’ varies a lot, to the point that plugin owners even disable the ‘disconnect’ button. So here is how things are working in MCUXpresso IDE:

  • MCUXpresso IDE V10.0.0 b344
  • P&E plugin 2.9.4.201704202022
  • SEGGER J-Link software V6.14b
  • LinkServer (LPC-Link2)

The following table summarizes the behavior:

Action Expected P&E SEGGER
(MCUXpresso)
SEGGER
(GNU ARM Eclipse)
LinkServer
Terminate while suspended Halt target, disconnect OK: Halt target, disconnect Restart OK: Halt target, disconnect Target keeps running (configurable)
Terminate while running Halt target, disconnect OK: Halt target, disconnect Restart Halt Target, disconnect Target keeps running (configurable)
Disconnect while suspended Disconnect, target remains haltet Target keeps running not possible Button disabled Button disabled
Disconnect while running Disconnect, target continues running OK: Disconnect, Target continues running not possible Button disabled Button disabled


With the exception of "disconnect while suspended," the P&E connection behaves as expected. The Segger GDB connection throws an error for disconnect, and the terminate action seems to expose some race conditions. The LinkServer has the terminate button disabled.

Below are some tips to configure the behavior.

P&E

The P&E connection offers both the ‘terminate’ and ‘disconnect’ buttons, so it is close to perfect. But there are no settings I’m aware of to configure the behavior in the launch configuration.

The LinkServer (LPC-Link2/LPC-Link/CMSIS-DAP) connection offers the terminate button and the disconnect button is grayed out/disabled.

The LinkServer terminate action can be configured in the Debugger configuration settings under the ‘Debugger’ tab. The setting can be easily missed, as the ‘terminate’ action is behind the ‘disconnect’ setting:

LinkServer Terminate Behaviour

LinkServer terminate behavior

It has the following options:

  • nochange: I’m not clear on this one, but it does a ‘stop’ followed by a ‘disconnect’?
  • stop: send ‘stop’, followed by ‘disconnect’
  • cont: send ‘continue’, followed by ‘disconnect’
  • run_cont: Does a ‘restart’ (‘stop’ followed by ‘restart’ and ‘disconnect’)

While this is a very flexible way to configure the ‘terminate’ action, it would be easier to use if the ‘disconnect’ button is available. Otherwise, I always have to go into the launch configuration and change the settings.

Segger (GNU ARM Eclipse)

For Segger J-Link debugging, there is the option to install the GNU ARM Eclipse plugins (see MCUXpresso IDE: Importing Kinetis Design Studio Projects). With the GNU ARM Eclipse plugins, the disconnect button is disabled.

There is a feature request on this, and the workaround is to:

  1. Suspend the target with the toolbar button (pause button)
  2. In the arm-none-eabi-gdb console, execute ‘monitor go’
  3. Followed by ‘disconnect’

The ‘terminate’ always does a ‘restart’.

There is an option to change this so the targets do not restart. From the Segger J-Link manual:

SetRestartOnClose Manual Entry

SetRestartOnClose Manual Entry

Add the following to the ‘Startup’ tab in the ‘Run/Restart’ Commands:

monitor exec SetRestartOnClose=0


SetRestartOnClose

SetRestartOnClose

What it does for me is to reset the target but keep it halted.

The Segger J-Link plugin that comes with MCUXpresso has the disconnect button available, but it is currently not supported:

002,487 (gdb) 
006,732 31-target-detach i1
006,736 31^error,msg="Remote doesn't know how to detach"
006,737 (gdb) 
006,737 32-target-detach --thread-group i1
006,746 32^error,msg="Remote doesn't know how to detach"

Summary

Terminate and Disconnect can mean different things for different Eclipse implementations. The P&E implementation is mostly following what I expect, and the NXP LinkServer implementation has a configuration setting for the terminate action. If using the Segger J-Link in the MCUXpresso IDE, using the GNU ARM Eclipse plugin, I have a command line option to control the J-Link behavior.

Happy Terminating!

Integrated development environment Debug (command) Session (web analytics) 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 Generate Code Coverage Report Using JaCoCo-Maven Plugin
  • A Complete Guide to AngularJS Testing
  • What Should You Know About Graph Database’s Scalability?
  • Why Every Fintech Company Needs DevOps

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: