If you’re doing any project with networking, you’ve probably had a moment where you wanted to debug two targets at once. I was debugging picoTCP on an 802.15.4 capable target which meant all communication was wireless. Up till now I could only debug one target at the time (while the other kept running), which was incredibly annoying!
So my little investigation how to run multiple Segger JLinks together on the same system began. First impression: why is everyone using Windows with GUIs?
It seemed there wasn’t a lot of documentation, and of course the Segger command line tools in Linux didn’t implement the usual API you’d expect from Linux tools (–help anyone?). Finally I figured out how to do this; based on the serial number of the Segger JLinks!
It’s time to open multiple terminals:
term1$ sudo JLinkGDBServer -select usb=XXXXXXXX -if SWD -device NANO120LE3BN -port 2331 term2$ sudo JLinkGDBServer -select usb=YYYYYYYY-if SWD -device NANO120LE3BN -port 2334 term3$ arm-none-eabi-gdb --init-eval-command="target ext :2331" term4$ arm-none-eabi-gdb --init-eval-command="target ext :2334"
A couple of notes:
- To find out the USB serial number, plug in the Segger and check the output of the dmesg command
- If you choose port numbers, it seems that GDB by default uses 2331, 2332 and 2333. So your next one is 2334 for the second session.
- If you’re using a .gdbinit file (you should), then you have to remove the instruction that connects to the remote system, or you’ll get stuck
- –init-eval-command gets executed before .gdbinit, so you can still use the .gdbinit file!
- Get a bigger screen. 4 of these windows are a lot for one screen at Full HD resolution.
- You can do this with a lot of Jlinks if your budget allows!