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

Flash external nrf51422 with nrf51-dk

Hello,

I'm trying to flash external nrf51422 module. I want to flash both softdevice and application. I used below commands:

mergehex -m %SOFTDEVICE_NAME% %APP_NAME% -o %MERGE_NAME%
nrfjprog --recover -f NRF51
nrfjprog --program %MERGE_NAME% --verify --chiperase -f NRF51

and I got:

Parsing hex file.
Erasing code flash area.
Erasing UICR flash area.
Applying system reset.
Checking that the area to write is not protected.
ERROR: The operation attempted is unavailable due to readback protection in
ERROR: your device. Please use --recover to unlock the device.

recover command completed fine, but I'm not able to flash. Why recover command doesn't remove readback protection?

When I look into NRF Studio I see information 'ANT device with pre-programed SoftDevice'. My external chip is: nRF51422 QFAACO 1319AJ

Best regards, Marcin

  • split your last command

    nrfjprog --program %MERGE_NAME%  --verify --chiperase -f NRF51 
    

    into

    nrfjprog --chiperase -f NRF51
    nrfjprog --program %MERGE_NAME% --verify -f NRF51
    

    Then --chiperase will ensure to remove the readback protection before --program takes over

    The draw back of mixing many commands into one is that IT DOES NOT NECESSARILY EXECUTE IN THE SAME ORDER. If you want to ensure the order of the commands, then do not mix them.

  • Hello Aryan,

    Thanks for the answer, but it seems that those splitting is not correct:

    nrfjprog --chiperase -f NRF51
    ERROR: One or several arguments are missing. Use --help to read about the valid
    ERROR: argument combinations.
    

    I tried also:

    nrfjprog --eraseall -f NRF51
    Erasing addresses 0xA000 to 0x3FFFF.
    Erasing UICR flash area.
    Applying system reset.
    nrfjprog --program test.hex --verify -f NRF51
    Parsing hex file.
    Reading flash area to program to guarantee it is erased.
    ERROR: The area to write is not erased.
    

    Doesn't work. Any more sugestions?

    Regards, Marcin

    1. Which version of nrfjprog are you using (nrfjprog -v) ?
    2. Can you run again the command with the extra option --log (or --logeverything if --log gives error) and post the generated log here? Thanks.
  • Also, do not --chiperase when programmed. After the --recover the device is also erased.

  • Hello David,

    nrfjprog version: 7.5.2
    JLinkARM.dll version: 5.10i
    

    Recover log:

    --------------------------------------------------------------------------------
    nrfjprog --recover -f NRF51 --log
    nrfjprog verion 7.5.2
    --------------------------------------------------------------------------------
    FUNCTION: open_dll.
    FUNCTION: open_dll.
    FUNCTION: dll_version.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_without_snr.
    FUNCTION: enum_emu_snr.
    Device "NRF51822_XXAA" selected.
    FUNCTION: recover.
    FUNCTION: recover.
    Found SWD-DP with ID 0x0BB11477
    Found Cortex-M0 r0p0, Little endian.
    FPUnit: 4 code (BP) slots and 0 literal slots
    CoreSight components:
    ROMTbl 0 @ F0000000
    ROMTbl 0 [0]: F00FF000, CID: B105100D, PID: 000BB471 ROM Table
    ROMTbl 1 @ E00FF000
    ROMTbl 1 [0]: FFF0F000, CID: B105E00D, PID: 000BB008 SCS
    ROMTbl 1 [1]: FFF02000, CID: B105E00D, PID: 000BB00A DWT
    ROMTbl 1 [2]: FFF03000, CID: B105E00D, PID: 000BB00B FPB
    ROMTbl 0 [1]: 00002000, CID: B105900D, PID: 000BB9A3 ???
    Found SWD-DP with ID 0x0BB11477
    Found Cortex-M0 r0p0, Little endian.
    FPUnit: 4 code (BP) slots and 0 literal slots
    CoreSight components:
    ROMTbl 0 @ F0000000
    ROMTbl 0 [0]: F00FF000, CID: B105100D, PID: 000BB471 ROM Table
    ROMTbl 1 @ E00FF000
    ROMTbl 1 [0]: FFF0F000, CID: B105E00D, PID: 000BB008 SCS
    ROMTbl 1 [1]: FFF02000, CID: B105E00D, PID: 000BB00A DWT
    ROMTbl 1 [2]: FFF03000, CID: B105E00D, PID: 000BB00B FPB
    ROMTbl 0 [1]: 00002000, CID: B105900D, PID: 000BB9A3 ???
    FUNCTION: close_dll.
    FUNCTION: close_dll.
    

    Flash log:

    --------------------------------------------------------------------------------
    nrfjprog --program test.hex --verify -f NRF51 --log
    nrfjprog verion 7.5.2
    --------------------------------------------------------------------------------
    FUNCTION: open_dll.
    FUNCTION: open_dll.
    FUNCTION: dll_version.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_with_snr.
    FUNCTION: connect_to_emu_without_snr.
    FUNCTION: enum_emu_snr.
    Device "NRF51822_XXAA" selected.
    FUNCTION: read_device_version.
    FUNCTION: read_device_version.
    Found SWD-DP with ID 0x0BB11477
    Found Cortex-M0 r0p0, Little endian.
    FPUnit: 4 code (BP) slots and 0 literal slots
    CoreSight components:
    ROMTbl 0 @ F0000000
    ROMTbl 0 [0]: F00FF000, CID: B105100D, PID: 000BB471 ROM Table
    ROMTbl 1 @ E00FF000
    ROMTbl 1 [0]: FFF0F000, CID: B105E00D, PID: 000BB008 SCS
    ROMTbl 1 [1]: FFF02000, CID: B105E00D, PID: 000BB00A DWT
    ROMTbl 1 [2]: FFF03000, CID: B105E00D, PID: 000BB00B FPB
    ROMTbl 0 [1]: 00002000, CID: B105900D, PID: 000BB9A3 ???
    FUNCTION: readback_status.
    FUNCTION: readback_status.
    FUNCTION: read.
    FUNCTION: read.
    FUNCTION: close_dll.
    FUNCTION: close_dll.
    

    Regards, Marcin

Related