This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Having trouble using openocd with the nrf52 on OSX

Hi all,

I'm running into trouble using openocd to flash code onto the nrf52840 and then step through it. I'm running High Sierra (although I doubt that's important), and using a jlink (from segger) as my debug tool. My config file is very simple, and is shown below.

source [find interface/jlink.cfg]

transport select swd

source [find target/nrf52.cfg]

I know that this works on a Linux machine, but whenever I run it on mine it seems to arbitrarily exit with no error code. The full command is

openocd -f ./openocd.cfg -c "init; \
reset halt; \
sleep 500; \
flash write_image erase build/nrf52840_xxaa.hex; \
reset run; \
shutdown"

(excuse the backslashes - it's from a Makefile). The return that I get is

Open On-Chip Debugger 0.10.0-dev-g90071eb (2017-03-13-12:28)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : J-Link V10 compiled Apr 20 2018 16:47:09
Info : Hardware version: 10.10
Info : VTarget = 0.000 V
Info : clock speed 10000 kHz
in procedure 'init' 
in procedure 'ocd_bouncer'

I've found the same error elsewhere on this site, but it was related to a memory protection bit that needed to be overwritten, and I don't think that's the case here as I tried running nrfjprog --recover and that had no effect, and also it's working fine on linux. Any help would be appreciated. Thank you!

UPDATE 7/12

So it turns out that I was running into a very simple problem; I was using the jlink whereas it was working on the linux machine over the usb plug into the nrf52 devkit, hence the difference in results. However, when I run openocd on my mac with the usb connected to the devkit, I get the output below, with an "invalid subcommand" error on my flash write_image erase. It seems like my install of openocd is missing a few things maybe? 

openocd -f ./openocd.cfg -c \
	"init; \
	reset halt; \
	sleep 500; \
	flash write_image erase build/nrf52840_xxaa.hex; \
	reset run; \
	shutdown"
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : J-Link OB-SAM3U128-V2-NordicSemi compiled Jan 12 2018 16:05:20
Info : Hardware version: 1.00
Info : VTarget = 3.300 V
Info : Reduced speed from 10000 kHz to 1000 kHz (maximum).
Info : Reduced speed from 10000 kHz to 1000 kHz (maximum).
Info : clock speed 10000 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000002e0 msp: 0x20010000
invalid subcommand "write_image erase build/nrf52840_xxaa.hex"
in procedure 'flash'

Related