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

What are the raw JLink.exe commands sent by nrfjprog.exe?

My devices require calibration and self test to be carried out after programming. To implement this, my device checks the JLink reset pin (configured as a GPIO on my NRF52 device) if it has been pulled low on startup - if it has, it performs calibration and self test.

In order to automate this process, I have implemented a script which takes the JLink reset pin high (using Jlink.exe command), performs a chip recovery by NRFJPROG, programs the chip by NRFJPROG, takes reset pin low (using JLink.exe) and then finally power cycles the board with a Python script written to interface with the Nordic PPK (at which point it performs self test and calibration).

Currently the calls to Jlink.exe, followed by nrfjprog and Jlink.exe result in establishing a new jlink connection with each call. This slows the script down. As I'd like to use this script in production, this script needs to be as fast as possible.

I was hoping to combine all the JLink commands (namely those in the nrfjprog program) into a single JLink script, so I only need to establish one connection to this JLink.

Is there a way to find out what jlink.exe commands are being sent by the nrfjprog.exe? I am particulary interested in the recover and programming commands.

Parents
  • I have cobbled together some code found on the devzone and have something which seems to work (it also removes the need to power cycle my board, so makes my programming and calibration sequence take less than half as long as my original script):

    r0
    //Clear App Protect and Erase All
    SWDSelect //Selects the SWD Interface
    SWDWriteDP 1 0x50000000 //Enables power
    SWDWriteDP 2 0x01000000 //Selects the 0x01XXXXXX Access Port and 0xXXXX00XX Register bank in the access port
    SWDWriteAP 1 0x00000001 //CTRL-AP Bank 0, register offset 1 (ERASEALL 0x004): Erase all command
    sleep 1000 
    SWDReadAP 2 //CTRL-AP Bank 0, register offset 2 (ERASEALL 0x008): Erase all command status
    SWDReadAP 2 //Second read returns the value
    SWDWriteAP 0 0x00000001 
    SWDWriteAP 0 0x00000000 
    SWDWriteAP 1 0x00000000 
    SWDReadAP 3 //CTRL-AP Bank 0, register offset 3 (APPROTECTSTATUS 0x00C): Access port protection status
    SWDReadAP 3 //Second read returns the value: 0: enabled 1: not enabled
    
    sleep 500
    
    //Program Device
    device nrf52
    speed 50000
    w4 4001e504 1
    w4 4001e504 2
    w4 4001e50c 1
    sleep 100
    r
    loadfile myCombinedHexFile.hex //softdevice and application combined using mergehex.exe
    sleep 100
    verifybin myCombinedHexFile.bin 0x00000000 //converted using JFlash
    r
    r0
    g
    exit

    Is someone from Nordic able just to double check this is sensible please (particularly the programming sequence part)?

Reply
  • I have cobbled together some code found on the devzone and have something which seems to work (it also removes the need to power cycle my board, so makes my programming and calibration sequence take less than half as long as my original script):

    r0
    //Clear App Protect and Erase All
    SWDSelect //Selects the SWD Interface
    SWDWriteDP 1 0x50000000 //Enables power
    SWDWriteDP 2 0x01000000 //Selects the 0x01XXXXXX Access Port and 0xXXXX00XX Register bank in the access port
    SWDWriteAP 1 0x00000001 //CTRL-AP Bank 0, register offset 1 (ERASEALL 0x004): Erase all command
    sleep 1000 
    SWDReadAP 2 //CTRL-AP Bank 0, register offset 2 (ERASEALL 0x008): Erase all command status
    SWDReadAP 2 //Second read returns the value
    SWDWriteAP 0 0x00000001 
    SWDWriteAP 0 0x00000000 
    SWDWriteAP 1 0x00000000 
    SWDReadAP 3 //CTRL-AP Bank 0, register offset 3 (APPROTECTSTATUS 0x00C): Access port protection status
    SWDReadAP 3 //Second read returns the value: 0: enabled 1: not enabled
    
    sleep 500
    
    //Program Device
    device nrf52
    speed 50000
    w4 4001e504 1
    w4 4001e504 2
    w4 4001e50c 1
    sleep 100
    r
    loadfile myCombinedHexFile.hex //softdevice and application combined using mergehex.exe
    sleep 100
    verifybin myCombinedHexFile.bin 0x00000000 //converted using JFlash
    r
    r0
    g
    exit

    Is someone from Nordic able just to double check this is sensible please (particularly the programming sequence part)?

Children
No Data
Related