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

Replacing nrfjprog with JLinkExe

Hello,

I've been evaluating the speed of nrfjprog vs JLinkExe to flash multiple devices and found out that i could use JLinkExe with .jlink scripts to save roughly 50% of the time spent on flashing. It makes a huge difference for me since I'll be flashing quite a few of devices in series. Now everything seems fine and flashed devices seem to be working but I would like to ask if there is something which nrfjprog does which is not so obvious and if I skip it I'll potentially have some issues? My .hex file is already merged with bootloader and softdevice so it is self contained.

I'm pasting the .jlink scripts and a bash on to control the process which I'm using as a replacement to the following commands:

nrfjprog --recover
nrfjprog -e
nrfjprog --program fw_merged_with_BL_SD_AP.hex
nrfjprog -r
nrfjprog --rbp ALL

Flash.jlink

r
h
loadfile fw_merged_with_BL_SD_AP.hex
sleep 100
r
g
exit

erase.jlink

h
w4 4001e504 2
w4 4001e50c 1
sleep 100
r
exit

Then just the bash function which I call which does the job and enables RBP which I yet haven't found how to do via JLinkExe

function flash_jlink(){
  JLINK="JLinkExe -device nrf52832_XXAA -if swd -speed 4000"
  $JLINK erase.jlink
  $JLINK flash.jlink
  nrfjprog --rbp ALL
}

Parents Reply Children
  • Hello Håkon,

    Thank you for pointing me for your answers.

    need to provide the equivalent to "nrfjprog --recover" in order to unlock the device

    Regarding this part I've found that i can just erase everything with JLinkExe without clearing RBP which first confused me since nrfjprog can't do that but on the other hand it makes some sense since it's erasing and not reading the memory contents. I will read more on the references you provided to understand it better because maybe i just didn't reset after rbp all so the setting didn't latch.

    Is it a good idea to mix flashing with JLinkExe and later applying RBP with nrfjprog? Because on the outside everything seems great so far. I'm just worried that some register normally written by nrfjprog won't get written by JLink script and I'll learn that late in the process of flashing Slight smile and have to redo everything from the beginning.

  • Hi,

     

    PB said:
    Regarding this part I've found that i can just erase everything with JLinkExe without clearing RBP which first confused me since nrfjprog can't do that but on the other hand it makes some sense since it's erasing and not reading the memory contents. I will read more on the references you provided to understand it better because maybe i just didn't reset after rbp all so the setting didn't latch.

    Sounds like you haven't reset the device after writing to APPROTECT or that JLink recovered it for you. 

    Some versions of JLink Commander might also unlock the device, which should be in the log file:

    Connecting to target via SWD
    InitTarget() start
    Device will be unsecured now.
    

    The above is performed using JLink v6.64b, where it automatically unlocked the device (ie: erased it).

     

    Kind regards,

    Håkon

Related