Skip to content

Instantly share code, notes, and snippets.

@natersoz
Last active February 4, 2023 01:12
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save natersoz/076cee47d47f87fd67b99c9de61c4d86 to your computer and use it in GitHub Desktop.
Save natersoz/076cee47d47f87fd67b99c9de61c4d86 to your computer and use it in GitHub Desktop.
Mutiple Debug Sessions with JLinkGDBServer

Running Multiple JLinkGDBServer Sessions

The documentation for the JLinkGDBServer command line options is incomplete. Getting multiple debug sessions running using JLinkGDBServer is a trial/error/google and repeat process. Here are bare-bones instructions for getting multiple JLinkGDBServer sessions over USB running on an OSX host. An ethernet configuration will differ. These instructions should work for Linux and Windows as well but have not been tested in those environments.

Get the debug interface serial number

The serial number is printed whenever the JLinkGDBServer program is started and it attaches to a SEGGER JLink debug interface (either a USB connected pod or on-boad SWO interface). Attach only one of the units for debugging and run the JLinkGDBServer program. The serial number of the JLink debug interface is a 9 digit number prefixed with the text S/N:.

The Serial Number may also be printed on the debug interface itself.

Once the serial numbers of the debug interfaces are known, the GDB server can be started with the following example command line:

JLinkGDBServerCLExe -device NRF52 -if swd -endian little -port 2431 -swoport 2432 -telnetport 2433 -RTTTelnetport 2434 -vd -noir -localhostonly 1 -strict -timeout 0 -select USB=XXXXXXXXX

Where XXXXXXXXX is the SEGGER JLink debug interface serial number. This example is for the Nordic Semiconductor nRF52832 which is identified by the --device parameter.

  • Each GDB server instance needs to have the SEGGER serial number specified.
  • Each GDB server will require a unique set of IP ports. Here [2431, 2434] are specified. I find it useful to increment the port set by 100 for each GDB server instance started. The next instance would use the port set [2531, 2534].

Running GDB

The gdb debugger can be started and attached to the GDB server with the command line option:

target remote localhost:2431

Where 2431 matches the GDB server -port XXXX command line option.

Running JLinkRTTClient

JLinkRTTClient is actually a telnet program. You can use telnet instead and get the same results. Start the JLinkRTTClient with the command line option:

JLinkRTTClient -RTTTelnetPort 2434

or, using Telnet:

telnet localhost 2434

Where the port number 2434 must match the -RTTTelnetport 2434 command line option when the GDB server was started.

You should now have simultaneous GDB debug sessions and JLinkRTTClient sessions running at the same time.

Notes

The command line parameter -RTTTelnetport is case insensetive and can be specified as -rtttelnetport.

@Mark-G1
Copy link

Mark-G1 commented Feb 1, 2023

This is great! Very helpful, thanks for sharing!

@nersoz-impinj
Copy link

I'm glad you found it. Did my page show up in google results? I did not know this had any exposure.

@Mark-G1
Copy link

Mark-G1 commented Feb 4, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment