Invalid subcommand "write_image erase..." when flashing to nrf52840dk

Hello all,

I tried to compile and flash examples/blinky for the nrf52840dk (make BOARD=nrf52840dk -C examples/blinky flash) but when it gets to flashing I get the error:

invalid subcommand “write_image erase /home/erik/gitlocal/myRIOT/examples/blinky/bin/nrf52840dk/blinky.elf 0”

Did some googling etc. but could not find any hints. Any clues anyone? Below is the full log.

Thanks and best regards, ER!K

erik@dell-ubuntu:~/gitlocal/myRIOT$ make BOARD=nrf52840dk -C examples/blinky flash
make: Entering directory '/home/erik/gitlocal/myRIOT/examples/blinky'
Building application "blinky" for "nrf52840dk" with MCU "nrf52".

"make" -C /home/erik/gitlocal/myRIOT/boards/common/init
"make" -C /home/erik/gitlocal/myRIOT/boards/nrf52840dk
"make" -C /home/erik/gitlocal/myRIOT/boards/common/nrf52xxxdk
"make" -C /home/erik/gitlocal/myRIOT/core
"make" -C /home/erik/gitlocal/myRIOT/core/lib
"make" -C /home/erik/gitlocal/myRIOT/cpu/nrf52
"make" -C /home/erik/gitlocal/myRIOT/cpu/cortexm_common
"make" -C /home/erik/gitlocal/myRIOT/cpu/cortexm_common/periph
"make" -C /home/erik/gitlocal/myRIOT/cpu/nrf52/periph
"make" -C /home/erik/gitlocal/myRIOT/cpu/nrf52/vectors
"make" -C /home/erik/gitlocal/myRIOT/cpu/nrf5x_common
"make" -C /home/erik/gitlocal/myRIOT/cpu/nrf5x_common/periph
"make" -C /home/erik/gitlocal/myRIOT/drivers
"make" -C /home/erik/gitlocal/myRIOT/drivers/periph_common
"make" -C /home/erik/gitlocal/myRIOT/sys
"make" -C /home/erik/gitlocal/myRIOT/sys/auto_init
"make" -C /home/erik/gitlocal/myRIOT/sys/div
"make" -C /home/erik/gitlocal/myRIOT/sys/frac
"make" -C /home/erik/gitlocal/myRIOT/sys/malloc_thread_safe
"make" -C /home/erik/gitlocal/myRIOT/sys/newlib_syscalls_default
"make" -C /home/erik/gitlocal/myRIOT/sys/stdio_uart
"make" -C /home/erik/gitlocal/myRIOT/sys/ztimer
   text	   data	    bss	    dec	    hex	filename
  12596	    148	   2376	  15120	   3b10	/home/erik/gitlocal/myRIOT/examples/blinky/bin/nrf52840dk/blinky.elf
/home/erik/gitlocal/myRIOT/dist/tools/openocd/openocd.sh flash /home/erik/gitlocal/myRIOT/examples/blinky/bin/nrf52840dk/blinky.elf
### Flashing Target ###
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
swd
adapter speed: 10000 kHz
cortex_m reset_config sysresetreq
Info : No device selected, using first device.
Info : J-Link OB-SAM3U128-V2-NordicSemi compiled Mar 17 2020 14:43:00
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
    TargetName         Type       Endian TapName            State       
--  ------------------ ---------- ------ ------------------ ------------
 0* nrf52.cpu          cortex_m   little nrf52.cpu          halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x00000a80 msp: 0x20000400
invalid subcommand "write_image erase /home/erik/gitlocal/myRIOT/examples/blinky/bin/nrf52840dk/blinky.elf 0"
in procedure 'flash'
make: *** [/home/erik/gitlocal/myRIOT/examples/blinky/../../Makefile.include:838: flash] Error 1
make: Leaving directory '/home/erik/gitlocal/myRIOT/examples/blinky'
erik@dell-ubuntu:~/gitlocal/myRIOT$ 

Sorry, found it… Seems like “openocd” is the default programmer, but nRF52840DK has an onboard Segger J-Link. Prepending PROGRAMMER=jlink to the above command works:

PROGRAMMER=jlink make BOARD=nrf52840dk -C examples/blinky flash

Thanks, ER!K