Flashing failed due to protection on the device

OS: Windows 10
NCS: 2.0.0

I am working on the Nordic DFU NCS Guide on a nRF52833 DK  devzone.nordicsemi.com/.../ncs-dfu

After flashing/debugging several times, I started seeing the message below.  I responded with "yes".   Now I am not able to "debug".  I can only "flash" it. 

I thought something was wrong with the board, so I used a brand new nRF52833DK.  The same thing started happening.  

Any idea of what is going on?

  • Hi Garvit, 

    Thank you for providing required information.

    I am not able to reproduce your issue.

    Have you tried to recover your boards before flashing?

    Best regards,
    Dejan

  • I have a similar issue.

    I am working with an nRF5340 DK (PCA10095 - 2.0.0 - 2022.4).

    I have to use "nrfjprog --recover" every 2nd time. In other words, it fails the first flash, then after the recover, it usually flashes successfully, once. Then next time it will fail. 

    And trying to use Debug is almost impossible.

  • Hi  ,

    Could you provide all required steps for reproducing the issue?

    Best regards,
    Dejan

  • Hi Dejan,

    Here is what I did just now:

    My setup:

    VS Code: 1.85.2 (user setup).

    nRF Connect for VS Code: v2023.11.301.

    NCS: 2.4.1.

    Set up steps

    Create new applicaiton.

    Copy  sample: nrf/samples/bluetooth/peripheral uart.

    Add to workspace.

    Build configuration: nrf5340dk_nrf5340_cpuapp_ns:

    • default config settings
    • Configuration: use build system default

    Connect nRF5340 DK board.

    Select Flash

    Result = Fail

    Building peripheral_del
    west build --build-dir c:/dev/nordic/apps241/peripheral_del/build c:/dev/nordic/apps241/peripheral_del
    
    [0/24] Performing build step for 'tfm'
    ninja: no work to do.
    [1/5] Performing build step for 'hci_rpmsg_subimage'
    ninja: no work to do.
     *  Terminal will be reused by tasks, press any key to close it. 
    
     *  Executing task: nRF Connect: Flash: peripheral_del/build (active) 
    
    Flashing build to 1050071243
    west flash -d c:\dev\nordic\apps241\peripheral_del\build --skip-rebuild --dev-id 1050071243
    
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: Flashing file: c:\dev\nordic\apps241\peripheral_del\build\zephyr\merged_domains.hex
    -- runners.nrfjprog: c:\dev\nordic\apps241\peripheral_del\build\zephyr\merged_domains.hex targets both nRF53 coprocessors; splitting it into: c:\dev\nordic\apps241\peripheral_del\build\zephyr\GENERATED_CP_NETWORK_merged_domains.hex and c:\dev\nordic\apps241\peripheral_del\build\zephyr\GENERATED_CP_APPLICATION_merged_domains.hex
    [ #################### ]  12.505s | Erase file - Done erasing                                                          
    [ #################### ]   1.266s | Program file - Done programming                                                    
    [ #################### ]   1.285s | Verify file - Done verifying                                                       
    [ #################### ]   7.297s | Erase file - Done erasing                                                          
    [error] [ Client] - Encountered error -102: Command program_file executed for 235 milliseconds with result -102        
    [error] [  nRF53] - The write access failed, but no cause could be determined.
    [error] [  nRF53] - It may be due to an unaligned access, accessing a nonexistent memory, or a communication issue.
    [error] [  nRF53] - Failed while performing 'Write' operation on target address 0x00000000. 
    -102: An unknown error.
    [error] [  nRF53] - Failed while reading device information.
    [error] [ Worker] - An unknown error.
    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.
    NOTE: For additional output, try running again with logging enabled (--log).
    NOTE: Any generated log error messages will be displayed.
    FATAL ERROR: command exited with status 33: nrfjprog --program 'c:\dev\nordic\apps241\peripheral_del\build\zephyr\GENERATED_CP_APPLICATION_merged_domains.hex' --sectorerase --verify -f NRF53 --coprocessor CP_APPLICATION --snr 1050071243
    
     *  The terminal process terminated with exit code: 33. 
     *  Terminal will be reused by tasks, press any key to close it. 
    

    Ran the recover script:

    nrfjprog --recover
    
    Recovering device. This operation mig
    Erasing user code and UICR flash area
    Writing image to disable ap protect.
    

    Select Flash

    Result = Success

     *  Executing task: nRF Connect: Build: peripheral_del/build (active) 
    
    Building peripheral_del
    west build --build-dir c:/dev/nordic/apps241/peripheral_del/build c:/dev/nordic/apps241/peripheral_del
    
    [0/24] Performing build step for 'tfm'
    ninja: no work to do.
    [1/5] Performing build step for 'hci_rpmsg_subimage'
    ninja: no work to do.
     *  Terminal will be reused by tasks, press any key to close it. 
    
     *  Executing task: nRF Connect: Flash: peripheral_del/build (active) 
    
    Flashing build to 1050071243
    west flash -d c:\dev\nordic\apps241\peripheral_del\build --skip-rebuild --dev-id 1050071243
    
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: Flashing file: c:\dev\nordic\apps241\peripheral_del\build\zephyr\merged_domains.hex
    -- runners.nrfjprog: c:\dev\nordic\apps241\peripheral_del\build\zephyr\merged_domains.hex targets both nRF53 coprocessors; splitting it into: c:\dev\nordic\apps241\peripheral_del\build\zephyr\GENERATED_CP_NETWORK_merged_domains.hex and c:\dev\nordic\apps241\peripheral_del\build\zephyr\GENERATED_CP_APPLICATION_merged_domains.hex
    [ #################### ]  12.571s | Erase file - Done erasing                                                          
    [ #################### ]   1.263s | Program file - Done programming                                                    
    [ #################### ]   1.285s | Verify file - Done verifying                                                       
    [ #################### ]   7.190s | Erase file - Done erasing                                                          
    [ #################### ]   1.359s | Program file - Done programming                                                    
    [ #################### ]   1.208s | Verify file - Done verifying                                                       
    Applying pin reset.
    -- runners.nrfjprog: Board with serial number 1050071243 flashed successfully.
     *  Terminal will be reused by tasks, press any key to close it. 
    

    Select Flash

    Result = Fail

    -- runners.nrfjprog: Flashing file: c:\dev\nordic\apps241\peripheral_del\build\zephyr\merged_domains.hex
    -- runners.nrfjprog: c:\dev\nordic\apps241\peripheral_del\build\zephyr\merged_domains.hex targets both nRF53 coprocessors; splitting it into: c:\dev\nordic\apps241\peripheral_del\build\zephyr\GENERATED_CP_NETWORK_merged_domains.hex and c:\dev\nordic\apps241\peripheral_del\build\zephyr\GENERATED_CP_APPLICATION_merged_domains.hex
    [ #################### ]  12.533s | Erase file - Done erasing                                                          
    [ #################### ]   1.264s | Program file - Done programming                                                    
    [ #################### ]   1.286s | Verify file - Done verifying                                                       
    [ #################### ]   7.279s | Erase file - Done erasing                                                          
    [error] [ Client] - Encountered error -102: Command program_file executed for 204 milliseconds with result -102        
    [error] [  nRF53] - The write access failed, but no cause could be determined.
    [error] [  nRF53] - It may be due to an unaligned access, accessing a nonexistent memory, or a communication issue.
    [error] [  nRF53] - Failed while performing 'Write' operation on target address 0x00000000. 
    -102: An unknown error.
    [error] [  nRF53] - Failed while reading device information.
    [error] [ Worker] - An unknown error.
    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.
    NOTE: For additional output, try running again with logging enabled (--log).
    NOTE: Any generated log error messages will be displayed.
    FATAL ERROR: command exited with status 33: nrfjprog --program 'c:\dev\nordic\apps241\peripheral_del\build\zephyr\GENERATED_CP_APPLICATION_merged_domains.hex' --sectorerase --verify -f NRF53 --coprocessor CP_APPLICATION --snr 1050071243
    
     *  The terminal process terminated with exit code: 33. 
     *  Terminal will be reused by tasks, press any key to close it. 
    

    Ran the recover script:

    nrfjprog --recover
    
    Recovering device. This operation mig
    Erasing user code and UICR flash area
    Writing image to disable ap protect.
    

    Select Flash

    Result = Success

    I repeated these steps - and it failed every second time, etc.

    At one stage, I was prompted to recover the device and reflash.

    If I select Yes - the flash succeeds but fails next time.

    However, if I select "Always in this session", then it succeeds for the next three flashes (I didn't try any more).

    However, when I then select Debug, instead of Flash, it fails again:

     *  Executing task: nRF Connect: Flash: peripheral_del/build (active) 
    
    Flashing build to 1050071243
    west flash -d c:\dev\nordic\apps241\peripheral_del\build --skip-rebuild --dev-id 1050071243
    
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: Flashing file: c:\dev\nordic\apps241\peripheral_del\build\zephyr\merged_domains.hex
    -- runners.nrfjprog: c:\dev\nordic\apps241\peripheral_del\build\zephyr\merged_domains.hex targets both nRF53 coprocessors; splitting it into: c:\dev\nordic\apps241\peripheral_del\build\zephyr\GENERATED_CP_NETWORK_merged_domains.hex and c:\dev\nordic\apps241\peripheral_del\build\zephyr\GENERATED_CP_APPLICATION_merged_domains.hex
    [ #################### ]  11.502s | Erase file - Done erasing                                                          
    [ #################### ]   1.254s | Program file - Done programming                                                    
    [ #################### ]   1.280s | Verify file - Done verifying                                                       
    [ #################### ]   5.929s | Erase file - Done erasing                                                          
    [error] [  nRF53] - The write access failed, but no cause could be determined.                                         
    [error] [  nRF53] - It may be due to an unaligned access, accessing a nonexistent memory, or a communication issue.
    [error] [  nRF53] - Failed while performing 'Write' operation on target address 0x00000000. 
    -102: An unknown error.
    

  • Hi  ,

    --program might require some erase option. You could try to either add erase option to --program or you could try to combine --program with --recover option as shown in this ticket.

    Best regards,
    Dejan

Related