How to use a J-Link SWD connection to debug the Photon

Just thought I’d share how to open up a GDB connection over J-Link (instead of stlink) on OS X. The nordic dev kits for instance all come with J-Links so may be relevant to some.

step one - openocd

After installing openocd go to the scripts
cd /usr/local/share/openocd/scripts

We need to make a slight change to the config to tell jlink to use SWD. The “jlink.cfg” file has only the (uncommented) line:
interface jlink
… so add
transport select swd
on the following line in that file.

Now I use the following command to open the debug session:
openocd -f interface/jlink.cfg -f target/stm32f2x.cfg -c "telnet_port 4444"

Finally connect to the session using telnet:
telnet localhost 4444

Now, after some info from Julien Vanier at
… try to open a GDB session:
arm-none-eabi-gdb -ex "target remote localhost:3333" ../build/target/main/platform-6-m/main.elf

In this case that uses the *.elf file from photon firmware repository.

Happy hacking!