Over a million developers have joined DZone.

MCUXpresso IDE: Terminate and Disconnect a Debug Session

DZone's Guide to

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.

· IoT Zone ·
Free Resource

Digi-Key Electronics’ Internet of Things (IoT) Resource Center Inspires the Future: Read More

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:


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
  • SEGGER J-Link software V6.14b
  • LinkServer (LPC-Link2)

The following table summarizes the behavior:

Action Expected P&E SEGGER
(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 expose some race conditions. The LinkServer has the terminate button disabled.

Below are some tips to configure the behavior.


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



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"


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!

Digi-Key’s IoT Component Selector is your one-stop-shop for the IoT

eclipse ,iot ,debugging ,mcuxpresso ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}