I've recently gotten the Segger J-Link GDB server and was trying to get it to connect to my hardware. The reason I want to try to GDB server is that I want an OSX-native GDB interface (up to now I have been using the P&E GDB Server for Kinetis, which only runs on Windows), I want to be able to connect to targets besides the Kinetis targets (STMF32 and LPC) and I wanted a backup interface. Also I was getting frustrated with the P&E device as it seemed not very well supported and somewhat flaky (for a while it was crashing during routine debugging, forcing me to completely reset hardware and software).
I received my J-Link in the mail. I also ordered the 20-pin to 10-pin SWD adapter as all of my designs use the 10 pin SWD interface.
I installed the JLink MacOSX software package and the directory contains several tools:
JLinkExe - a command line interface to the J-Link
JLinkGDBServer - GDB server which can connect to various targets and listens for GDB clients
JLinkRemoteServer
JLinkRTTClient
JLinkSWOViewer
as well as a number of sample .gdbinit files (so when you run GDB it can automatically connect to a target, reset, etc)
The first problem I ran into was that while JLinkGDBServer would connect to the USB dongle fine, it would not connect to the target:
I installed the JLink MacOSX software package and the directory contains several tools:
JLinkExe - a command line interface to the J-Link
JLinkGDBServer - GDB server which can connect to various targets and listens for GDB clients
JLinkRemoteServer
JLinkRTTClient
JLinkSWOViewer
as well as a number of sample .gdbinit files (so when you run GDB it can automatically connect to a target, reset, etc)
The first problem I ran into was that while JLinkGDBServer would connect to the USB dongle fine, it would not connect to the target:
JlinkGDBServer SEGGER J-Link GDB Server V4.96c Command Line Version JLinkARM.dll V4.96c (DLL compiled Jan 28 2015 19:28:00) -----GDB Server start settings----- GDBInit file: none GDB Server Listening port: 2331 SWO raw output listening port: 2332 Terminal I/O port: 2333 Accept remote connection: yes Generate logfile: off Verify download: off Init regs on start: on Silent mode: off Single run mode: off Target connection timeout: 0 ms ------J-Link related settings------ J-Link Host interface: USB J-Link script: none J-Link settings file: none ------Target related settings------ Target device: unspecified Target interface: JTAG Target interface speed: 1000kHz Target endian: little Connecting to J-Link... J-Link is connected. Firmware: J-Link V9 compiled Jan 27 2015 18:19:29 Hardware: V9.30 S/N: 269302200 OEM: SEGGER-EDU Feature(s): FlashBP, GDB Checking target voltage... Target voltage: 4.06 V Listening on TCP/IP port 2331 Connecting to target...ERROR: Could not connect to target. Target connection failed. GDBServer will be closed...Restoring target state and closing J-Link connection... Shutting down... Could not connect to target.
The JLinkExe program -was- able to find the target so it was not a hardware fault. After a quick search in the Segger forum it turns out that the JLinkGDBServer searches for both JTAG and SWD interfaces - but in some cases, like if there is only an SWD interface, this can cause the target to get 'confused'. Once I specified to only look for an SWD target using the '-if SWD' parameter it worked fine!
JlinkGDBServer -if SWD SEGGER J-Link GDB Server V4.96c Command Line Version JLinkARM.dll V4.96c (DLL compiled Jan 28 2015 19:28:00) -----GDB Server start settings----- GDBInit file: none GDB Server Listening port: 2331 SWO raw output listening port: 2332 Terminal I/O port: 2333 Accept remote connection: yes Generate logfile: off Verify download: off Init regs on start: on Silent mode: off Single run mode: off Target connection timeout: 0 ms ------J-Link related settings------ J-Link Host interface: USB J-Link script: none J-Link settings file: none ------Target related settings------ Target device: unspecified Target interface: SWD Target interface speed: 1000kHz Target endian: little Connecting to J-Link... J-Link is connected. Firmware: J-Link V9 compiled Jan 27 2015 18:19:29 Hardware: V9.30 S/N: 269302200 OEM: SEGGER-EDU Feature(s): FlashBP, GDB Checking target voltage... Target voltage: 4.08 V Listening on TCP/IP port 2331 Connecting to target...Connected to target Waiting for GDB connection...
Now that I've the server running, I can now use GDB to load and test my program.
(gdb) target extended-remote localhost:2331 Remote debugging using localhost:2331 __thumb_startup () at ../startup/startup.S:42 42 movs r1, #0 (gdb) monitor reset Resetting target (gdb) load Loading section .interrupts, size 0xc0 lma 0x0 Loading section .text, size 0x1f88 lma 0x800 Loading section .romp, size 0x18 lma 0x2788 Start address 0x18e8, load size 8288 Transfer rate: 476 KB/sec, 2072 bytes/write. (gdb)
There are a bunch of things I notice right away:
Happy debugging!
- I don't have to start up a Windows VM. This was always a huge pain, as I would also have to redirect the USB connection to the Windows VM, etc.
- The reset sequence seems a lot faster. Every time I program the P&E Server it goes through an entire long sequence.
- The download speed is a lot faster - 476KB/sec - in contrast when I run the P&E server I am getting 387bytes/sec. It's the difference between 5-10 seconds and nearly instantaneous.
Happy debugging!