Using GDB Server Monitor Commands From the Eclipse GDB Console

With Eclipse as your IDE, it is very easy to debug an application on a board. Still sometimes, it is useful to get one level down and control the GDB server directly.

Monitor Flash Download

Monitor Flash Download

In Command Line Programming and Debugging with GDB, I used a GDB client and server for command line debugging. There is an easy way to combine this approach with Eclipse: have Eclipse do the GDB server launching and use the Eclipse debug console to control the target as needed. This can be very useful during bootloader development, for example, to load a binary or PIC (Position Independent Code) fragment into RAM.

The steps below are using the NXP MCUXpresso IDE 10.2 with the SEGGER J-Link V6.40, but it can work the same or very similar for any Eclipse-GDB combination.

First, make sure you have a connection to the target (e.g. with an attach or during a normal debug session).

If needed, make a connection to the remote target:

target remote localhost:2331

connecting to target

Connecting to target

Next, I make sure the debug monitor knows my target device:

monitor device MK64FN1M0XXX12


Because the GDB Debugger console does not report everything back, it makes sense to have a check in the console for the debug server to see what is going on:

Device Selected

Device Selected

To halt and reset the device:

monitor reset

Monitor Reset

Monitor Reset

Select the device for the flash programming:

monitor flash device = MK64FN1M0XXX12

Monitor Flash Device

Monitor Flash Device

To turn on flash downloading:

monitor flash download = 1

Monitor Flash Download

Monitor Flash Download

And finally, we need to flash the binary to the microcontroller:

load Debug/MK64FN1M0xxx12_Project.axf 0x8000

Loaded Binary

Loaded Binary

The offset at the end (0x8000) is an offset used where to load the binary. In my above case, the binary is linked to address 0x0000’0000 compiled as PIC (Position Independent Code), and that way, I can load it to a different address. I find that useful especially dealing with boot loaders.

Happy monitoring!

Helpful Links

 

 

 

 

Top