Unable to recover device using nrfutil or nrfjprog but desktop GUI works

I've been using "nrfutil device program" from the command line to flash the nrf5340dk. This has been working fine but recently encountered problems. It will fail to program due to readback protection. Nothing I do resolves this.

Experiment 1:

$ nrfutil device recover && nrfutil device program --traits jlink --firmware build_dk/zephyr/merged_domains.hex
Heavy check mark️ Recovered 1050047412
[00:00:01] ------   0% [1050047412] Failed, [jlink] The operation is unavailable due to readback protection
Error: One or more program tasks failed

The operation was unavailable for some of the devices because they had readback protection enabled. These devices can be unlocked using the `recover` subcommand. See `nrfutil device recover --help` for more information.

Experiment 2:

$ nrfutil device recover --core Application && nrfutil device recover --core Network && nrfutil device program --traits jlink --firm
ware build_dk/zephyr/merged_domains.hex
Heavy check mark️ Recovered 1050047412
Heavy check mark️ Recovered 1050047412
[00:00:01] ------   0% [1050047412] Failed, [jlink] The operation is unavailable due to readback protection
Error: One or more program tasks failed

The operation was unavailable for some of the devices because they had readback protection enabled. These devices can be unlocked using the `recover` subcommand. See `nrfutil device recover --help` for more information.

Experiment 3:

$ nrfutil device recover --core Network && nrfutil device recover --core Application && nrfutil device program --traits jlink --firm
ware build_dk/zephyr/merged_domains.hex
Heavy check mark️ Recovered 1050047412
Heavy check mark️ Recovered 1050047412
[00:00:01] ------   0% [1050047412] Failed, [jlink] The operation is unavailable due to readback protection
Error: One or more program tasks failed

The operation was unavailable for some of the devices because they had readback protection enabled. These devices can be unlocked using the `recover` subcommand. See `nrfutil device recover --help` for more information.

Experiment 4:

$ nrfjprog -f NRF53 -s 1050047412 --recover && nrfutil device program --traits jlink --firmware build_dk/zephyr/merged_domains.hex
Recovering device. This operation might take 30s.
Erasing user code and UICR flash areas.
Writing image to disable ap protect.
[00:00:01] ------   0% [1050047412] Failed, [jlink] The operation is unavailable due to readback protection
Error: One or more program tasks failed

The operation was unavailable for some of the devices because they had readback protection enabled. These devices can be unlocked using the `recover` subcommand. See `nrfutil device recover --help` for more information.

If using the Programmer GUI application that is part of nRF Connect Desktop, everything works fine, but it is not a preferable workflow.

  • Hello,

    Could you try recovering the network core separately before recovering the application core using nrfjprog? See this page.

    Kind Regards,

    Abhijith

  • Well, I just had the issue occur again and tried your suggestion. I got some weird results.

    $ nrfjprog --recover --coprocessor CP_NETWORK && nrfjprog --recover && nrfutil device program --traits jlink --firmware build_dk/zep
    hyr/merged_domains.hex
    Recovering device. This operation might take 30s.
    Erasing user code and UICR flash areas.
    Writing image to disable ap protect.
    Recovering device. This operation might take 30s.
    Erasing user code and UICR flash areas.
    Writing image to disable ap protect.
    [00:00:01] ------   0% [1050047412] Failed, [jlink] JLINKARM_DLL_READ_ERROR
    Error: One or more program tasks failed

    The JLINKARM_DLL_READ_ERROR is new and different. I did a sanity check running jlink from the command line to see if I could connect to nRF5340_xxAA_APP, and that worked. So I tried just nrfutil device program again. No JLink DLL error this time, but it still complained of readback protection, so I ran your suggestion again. This time I got completely different output.

    $ nrfjprog --recover --coprocessor CP_NETWORK && nrfjprog --recover && nrfutil device program --traits jlink --firmware build_dk/zephyr/merged_domains.hex
    [error] [ Worker] - Application core access protection is enabled, can't enable coprocessor.
    [error] [ Client] - Encountered error -90: Command enable_coprocessor executed for 15 milliseconds with result -90
    Recovering device. This operation might take 30s.
    [error] [ Client] - Encountered error -21: Command recover executed for 1041 milliseconds with result -21
    [error] [  nRF53] - Application core access protection is enabled, can't enable coprocessor.
    [error] [ Worker] - Encountered error during recovery cleanup, -90: Exception encountered while enabling coprocessor
    ERROR: Recover failed. Please make sure that the correct device family is given
    ERROR: and try again.
    NOTE: For additional output, try running again with logging enabled (--log).
    NOTE: Any generated log error messages will be displayed.

  • Hello,

    That's strange. Have you tried checking this on any other device? Or is this issue happening only with this device? I will try to test this tomorrow.

    Kind Regards,

    Abhijith

  • I only have one nRF5340 DevKit. As I said, the desktop programmer app is always able to erase and reflash the device. It's just when this "readback protection" issue occurs, I'm not able to get to it from the command line.

    I'll try and pay more attention to the circumstances when it occurs.

  • Hello,

    Have you tried recovering the device using the command line and nrfjprog? If you have installed the nRF command line tools, then you can recover the device using nrfjprog.

    See the screenshot below, and I am not using the desktop programmer app here.

    Kind Regards,

    Abhijith

Related