Eclipse for C/C++ (CDT) offers two different ways to get out of a debug session: Terminate and Disconnect:
The terminate and disconnect behaviour is not standardized, and varies between Eclipse distributions and debug connection. This article is about how things are handled in MCUXpresso IDE, and how I can influence the behaviour.
MCUXpresso IDE Series
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
- MCUXpresso IDE: Terminate and Disconnect a Debug Session
- MCUXpresso IDE: Blinky the NXP LPC800-DIP Board
With debugging with Eclipse, there are two different ways to end a debug session:
The expected behaviour is to stop the target under debug and disconnect from it and leave it in the stopped state. Similar like the ‘stop button’ on audio or video devices.
The expected behaviour is to leave the target as it is (running, suspended) and disconnect the debugger from the target.
Behaviour in MCUXpresso IDE V10.0.0
As said in the introduction text, the behaviour 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 184.108.40.206704202022
- SEGGER J-Link software V6.14b
- LinkServer (LPC-Link2)
The following table summarizes the behaviour:
(GNU ARM Eclipse)
|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 exposes some race conditions. The LinkServer has the terminate button disabled.
Below some tips how to configure the behaviour.
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 behaviour 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 would be 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 (https://sourceforge.net/p/gnuarmeclipse/feature-requests/106/), 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 does 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 which comes with MCUXpresso has the disconnect button available, but 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"
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 configuration setting for the terminate action. If using the Segger J-Link in MCUXpresso IDE, with using the GNU ARM Eclipse plugin I have a command line option to control the J-Link behaviour.
Happy Terminating 🙂
- MCUXpresso IDE web page: http://www.nxp.com/mcuxpresso/ide
- MCUXpresso IDE community: http://www.nxp.com/mcuxpresso/ide/forum
- GNU ARM Eclipse Plugins: http://gnuarmeclipse.github.io/
- Installing GNU ARM Eclipse Plugins in MCUXpresso IDE: Search MCUXpresso IDE: Importing Kinetis Design Studio Projects