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.
Join the DZone community and get the full member experience.
Join For FreeEclipse for C/C++ (CDT) offers two different ways to get out of a debug session: 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:
- Disconnect:
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:
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:
- Suspend the target with the toolbar button (pause button)
- In the arm-none-eabi-gdb console, execute ‘monitor go’
- 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:
Add the following to the ‘Startup’ tab in the ‘Run/Restart’ Commands:
monitor exec SetRestartOnClose=0
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!
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments