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

Failed to erase flash for nRF5340

Hi,

I was trying to program my sample to nRF5340's flash using nRF connect v3.4.1 and got this problem:

21:06:02.948
Application data folder: C:\Users\tuan.duong\AppData\Roaming\nrfconnect\pc-nrfconnect-programmer
21:06:03.113
Using nrfjprog library 10.9.0, pc-nrfjprog-js 1.7.3
21:06:07.565
Using nrfjprog to communicate with target
21:06:07.976
Using J-Link Software version 6.80
21:06:08.651
Segger serial: 960129049
21:06:08.652
Segger speed: 2000 kHz
21:06:08.652
Segger version: J-Link OB-K22-NordicSemi compiled Jan 21 2020 17:33:01
21:06:08.654
Error when getting device info: Error: Error: Error occured when get device info. Errorcode: CouldNotCallFunction (0x9) Lowlevel error: NOT_AVAILABLE_BECAUSE_PROTECTION (ffffffa6)
21:06:08.655
Could not fetch memory size of target devkit: Cannot read property 'family' of undefined
21:06:08.657
Error when closing nrfjprog: Error: Error occured when close opened device. Errorcode: CouldNotResetDevice (0x5) Lowlevel error: NOT_AVAILABLE_BECAUSE_PROTECTION (ffffffa6)
Then I tried to use nrfjprog -e to erase the flash but failed:
D:\nrf5x\bin>nrfjprog -e --log
ERROR: JLinkARM DLL reported an error. Try again. If error condition
ERROR: persists, run the same command again with argument --log, contact Nordic
ERROR: Semiconductor and provide the generated log.log file to them.
Here is the log of nrfjprog:
--------------------------------------------------------------------------------
nrfjprog -e --log
nrfjprog verion 8.5.0
--------------------------------------------------------------------------------
FUNCTION: open_dll.
FUNCTION: open_dll.
FUNCTION: enum_emu_snr.
FUNCTION: enum_emu_snr.
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 SW-DP with ID 0x6BA02477
DPIDR: 0x6BA02477
Scanning AP map to find all available APs
AP[4]: Stopped AP scan as end of AP map has been reached
AP[0]: AHB-AP (IDR: 0x84770001)
AP[1]: AHB-AP (IDR: 0x84770001)
AP[2]: JTAG-AP (IDR: 0x12880000)
AP[3]: JTAG-AP (IDR: 0x12880000)
Iterating through AP map to find AHB-AP to use
AP[0]: Skipped. Could not read CPUID register
AP[1]: Core found
AP[1]: AHB-AP ROM base: 0xE00FF000
CPUID register: 0x410FD214. Implementer code: 0x41 (ARM)
Found Cortex-M33 r0p4, Little endian.
Identified core does not match configuration. (Found: Cortex-M33, Configured: Cortex-M0)
FPUnit: 8 code (BP) slots and 0 literal slots
Security extension: not implemented
CoreSight components:
ROMTbl[0] @ E00FF000
ROMTbl[0][0]: E000E000, CID: B105900D, PID: 000BBD21 Cortex-M33
ROMTbl[0][1]: E0001000, CID: B105900D, PID: 000BBD21 DWT
ROMTbl[0][2]: E0002000, CID: B105900D, PID: 000BBD21 FPB
ROMTbl[0][6]: E0042000, CID: B105900D, PID: 000BBD21 CTI
RBPCONF register indicates that the device is secured.
For accessing memory the device needs to be unsecured.
Note: Unsecuring will trigger a mass erase of the internal flash.

Executing default behavior previously saved in the registry.
Device will be unsecured now.
CPU could not be halted
CPU could not be halted
JLinkARM.dll Halt returned error 1.
FUNCTION: close_dll.
FUNCTION: close_dll.
Can anyone advise how to solve erase flash problem?
  • Hi,

    I would not have expected this. Can you try to run the following two commands:

    nrfjprog.exe --coprocessor CP_NETWORK --recover
    nrfjprog.exe --coprocessor CP_APPLICATION --recover

    Does that help? Or do you get an error in this case as well?

  • Hi Einar Thorsrud,

    Thanks for your suggestion. Which version of nrfjprog you are using? Mine is 9.5.0 and it seems does not have --coprocessor option. Anyway, I tried with --recover option alone and still have the problem. Here is the log.

    nrfjprog --recover --log
    nrfjprog verion 8.5.0
    --------------------------------------------------------------------------------
    FUNCTION: open_dll.
    FUNCTION: open_dll.
    FUNCTION: enum_emu_snr.
    FUNCTION: enum_emu_snr.
    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.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    Found SW-DP with ID 0x6BA02477
    DPIDR: 0x6BA02477
    Scanning AP map to find all available APs
    AP[4]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x84770001)
    AP[1]: AHB-AP (IDR: 0x84770001)
    AP[2]: JTAG-AP (IDR: 0x12880000)
    AP[3]: JTAG-AP (IDR: 0x12880000)
    Iterating through AP map to find AHB-AP to use
    AP[0]: Skipped. Could not read CPUID register
    AP[1]: Core found
    AP[1]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x410FD214. Implementer code: 0x41 (ARM)
    Found Cortex-M33 r0p4, Little endian.
    Identified core does not match configuration. (Found: Cortex-M33, Configured: Cortex-M0)
    FPUnit: 8 code (BP) slots and 0 literal slots
    Security extension: not implemented
    CoreSight components:
    ROMTbl[0] @ E00FF000
    ROMTbl[0][0]: E000E000, CID: B105900D, PID: 000BBD21 Cortex-M33
    ROMTbl[0][1]: E0001000, CID: B105900D, PID: 000BBD21 DWT
    ROMTbl[0][2]: E0002000, CID: B105900D, PID: 000BBD21 FPB
    ROMTbl[0][6]: E0042000, CID: B105900D, PID: 000BBD21 CTI
    RBPCONF register indicates that the device is secured.
    For accessing memory the device needs to be unsecured.
    Note: Unsecuring will trigger a mass erase of the internal flash.

    Executing default behavior previously saved in the registry.
    Device will be unsecured now.
    CPU could not be halted
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.
    Debugger tries to select target interface JTAG.
    This interface is not supported by the connected emulator.
    Selection will be ignored by the DLL.
    CPU could not be halted
    JLinkARM.dll Halt returned error 1.

    Do you have any idea what cause this problem and any solution to fix it?

    Thanks and regards

  • Hi,

    Duong said:
    Which version of nrfjprog you are using? Mine is 9.5.0

    Ah, that is relevant. Your nrfjprog is too old. Please update to the latest (10.9.0) by installing the latest nRF Command Line Tools.

  • Hi Einar Thorsrud,

    It doesn't help much even with the latest version of nrfjprog 10.9.0.

    C:\Program Files\Nordic Semiconductor\nrf-command-line-tools\bin>nrfjprog -v
    nrfjprog version: 10.9.0
    JLinkARM.dll version: 6.80a

    C:\Program Files\Nordic Semiconductor\nrf-command-line-tools\bin>nrfjprog.exe --coprocessor CP_NETWORK --recover
    Failed to enable coprocessor with unknown error.
    ERROR: Access to the selected address is blocked by the SPU.

    C:\Program Files\Nordic Semiconductor\nrf-command-line-tools\bin>nrfjprog.exe --coprocessor CP_APPLICATION --recover
    Recovering device. This operation might take 30s.
    ERROR: Recover failed. Please make sure that the correct device family is given
    ERROR: and try again.

    C:\Program Files\Nordic Semiconductor\nrf-command-line-tools\bin>nrfjprog.exe -f NRF53 --recover
    Recovering device. This operation might take 30s.
    ERROR: Recover failed. Please make sure that the correct device family is given
    ERROR: and try again.

    Any idea?

    Thank you and regards

  • Hi,

    I see. Then there is another problem, but I have no good suggestions on what the problem could be. Did this suddenly happen, or has the board always been like this?

    Just for reference, this shows the sequence of protecting and recovering the application core, including testing that both works:

    >nrfjprog.exe --coprocessor CP_APPLICATION --memrd 0x00FF8000
    0x00FF8000: FFFFFFFF                              |....|
    
    >nrfjprog.exe --coprocessor CP_APPLICATION --memwr 0x00FF8000 --val 0x00000000
    Parsing parameters.
    Writing.
    
    >nrfjprog.exe --coprocessor CP_APPLICATION --memrd 0x00FF8000
    0x00FF8000: 00000000                              |....|
    
    <Reset board to make UICR changes take effect>
    
    >nrfjprog.exe --coprocessor CP_APPLICATION --memrd 0x00FF8000
    ERROR: The operation attempted is unavailable due to readback protection in
    ERROR: your device. Please use --recover to unlock the device.
    
    >nrfjprog.exe --coprocessor CP_APPLICATION --recover
    Recovering device. This operation might take 30s.
    Erasing user code and UICR flash areas.
    
    >nrfjprog.exe --coprocessor CP_APPLICATION --memrd 0x00FF8000
    0x00FF8000: FFFFFFFF                              |....|

Related