Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

nRF52-DK "Failed to connect to target" and "Access protection is enabled, can't read device version"

Hello Nordic developers,

Last week, I got a new nRF52-DK development board from Mouser Electronics UK. I could use this board for a while with SEGGER Embedded Studio for ARM 5.68 and nRF5_SDK_17.1.0_ddde560. I could run "blinky" and other examples from the SDK successfully. Also a program I wrote was successfully programmed in the chip. A day later, I could not program the chip anymore. SEGGER showed the following screen:

After a click "Yes" I got the same screen again:

Then SEGGER showed the following screen:

I read in this forum that this is related to some new "Access Protection" feature and that to disable I should recover the board using nrfjprog. This is what I did as you can see in the following commands:

Fullscreen
1
2
3
> nrfjprog --version
nrfjprog version: 10.14.0 external
JLinkARM.dll version: 7.56b
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
3
4
5
6
> nrfjprog --recover --family NRF52 --log
Recovering device. This operation might take 30s.
ERROR: [ nRF52] - Access protection is enabled, can't read device version.
ERROR: [ nRF52] - Failed to write UICR after recovering.
ERROR: Recover failed. Please make sure that the correct device family is given
ERROR: and try again.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

As a result, it looks like I cannot recover the chip because Access protection is enabled. The logs generated by nrfjprog are the following:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[2023-Feb-21 13:24:26] [ info] --------------------------------------------------------------------------------
[2023-Feb-21 13:24:26] [ info] nrfjprog --recover --family NRF52 --log
[2023-Feb-21 13:24:26] [ info] nrfjprog version 10.14.0 external
[2023-Feb-21 13:24:26] [ info] --------------------------------------------------------------------------------
[2023-Feb-21 13:24:26] [ info] Load library at /opt/nrf-command-line-tools/lib/libnrfjprogdll.so.
[2023-Feb-21 13:24:26] [ info] Library loaded, loading member functions.
[2023-Feb-21 13:24:26] [ info] Member functions succesfully loaded.
[2023-Feb-21 13:24:26] [debug] [ Client] - open
[2023-Feb-21 13:24:26] [debug] [ Client] - start
[2023-Feb-21 13:24:26] [ info] [ Client] - stdout: Jlinkarm nRF Worker ready. Handling sequence ef6619eb-0374-4e27-963e-8131679c07f5.
[2023-Feb-21 13:24:26] [trace] [ Client] - Command open executed for 6 milliseconds with result 0
[2023-Feb-21 13:24:26] [debug] [ Client] - enum_emu_snr
[2023-Feb-21 13:24:26] [debug] [SeggerBackend] - Logger sink registered in Segger backend logger
[2023-Feb-21 13:24:26] [debug] [ JLink] - Logger sink registered in JLink logger
[2023-Feb-21 13:24:26] [debug] [ nRF52] - open
[2023-Feb-21 13:24:26] [debug] [SeggerBackend] - open_dll
[2023-Feb-21 13:24:26] [debug] [SeggerBackend] - No J-Link DLL path was provided. Attempting to auto detect.
[2023-Feb-21 13:24:26] [ info] [SeggerBackend] - Load library at /opt/SEGGER/JLink/libjlinkarm.so.
[2023-Feb-21 13:24:26] [ info] [SeggerBackend] - Library loaded, loading member functions.
[2023-Feb-21 13:24:26] [ info] [SeggerBackend] - Member functions succesfully loaded.
[2023-Feb-21 13:24:26] [debug] [SeggerBackend] - dll_version
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Also I tried to "Erase" the chip using nrfConnect's Programmer as you can see in the following screenshots with no success.

After clicking "Erase All"  I get the following log:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2023-02-21T13:32:20.529Z DEBUG Application data folder: /home/suso/.config/nrfconnect/pc-nrfconnect-programmer
2023-02-21T13:32:20.623Z DEBUG App pc-nrfconnect-programmer v3.0.6 local
2023-02-21T13:32:20.623Z DEBUG App path: /home/suso/.nrfconnect-apps/node_modules/pc-nrfconnect-programmer
2023-02-21T13:32:20.623Z DEBUG nRFConnect 4.0.0, required by the app is (>=4.0.0)
2023-02-21T13:32:20.623Z DEBUG nRFConnect path: /tmp/.mount_nrfcon8Blgte/resources/app.asar
2023-02-21T13:32:20.623Z DEBUG HomeDir: /home/suso
2023-02-21T13:32:20.624Z DEBUG TmpDir: /tmp
2023-02-21T13:32:20.805Z INFO Using nrf-device-lib-js version: 0.5.0
2023-02-21T13:32:20.805Z INFO Using nrf-device-lib version: 0.13.11
2023-02-21T13:32:20.806Z INFO Using nrfjprog DLL version: 10.18.2
2023-02-21T13:32:20.806Z INFO Using JLink version: JLink_V7.56b
2023-02-21T13:32:20.844Z INFO Installed JLink version does not match the provided version (V7.66a)
2023-02-21T13:32:24.342Z INFO Using @nordicsemiconductor/nrf-device-lib-js to communicate with target via JLink
2023-02-21T13:32:24.343Z INFO JLink OB firmware version J-Link OB-nRF5340-NordicSemi compiled Jul 2 2021 10:55:25
2023-02-21T13:32:24.343Z INFO Device family NRF52_FAMILY
2023-02-21T13:32:24.343Z INFO Device version NRF51xxx_xxAA_REV1
2023-02-21T13:32:24.343Z INFO Board version PCA10040
2023-02-21T13:32:24.343Z INFO Loading readback protection status for Application core
2023-02-21T13:32:25.479Z INFO Readback protection status: NRFDL_PROTECTION_STATUS_ALL
2023-02-21T13:32:25.485Z INFO Parse memory regions for Application core
2023-02-21T13:32:25.491Z INFO Update files regions according to Application core
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I know that the nrf52832 chip is working correctly because it is currently executing the last program I flashed. This program sends data via the UART port and I can read it correctly from my computer. The issue is that I cannot program the board again due to the Access Protection issue.

This is the image of the board:

Do you have an idea how I can "resurrect" this board so I program software again?

Parents
  • Have you tried  nrfjprog --recover

    The response you should get should be: 

    Recovering device. This operation might take 30s.
    Erasing user code and UICR flash areas.
    Writing image to disable ap protect.

  • I tried that command and I get this Error message

    Fullscreen
    1
    2
    3
    4
    5
    > nrfjprog --recover --log
    Recovering device. This operation might take 30s.
    [error] [ nRF52] - Access protection is enabled, can't read device version.
    ERROR: Recover failed. Please make sure that the correct device family is given
    ERROR: and try again.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    The log file is the following:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    [2023-Feb-22 16:43:25] [debug] --------------------------------------------------------------------------------
    [2023-Feb-22 16:43:25] [debug] ./nrfjprog --recover --log
    [2023-Feb-22 16:43:25] [debug] nrfjprog version 10.19.0 external
    [2023-Feb-22 16:43:25] [debug] --------------------------------------------------------------------------------
    [2023-Feb-22 16:43:25] [ info] Load library at /home/suso/intellegens/BATERY/nrf-command-line-tools/lib/libnrfjprogdll.so.
    [2023-Feb-22 16:43:25] [ info] Library loaded, loading member functions.
    [2023-Feb-22 16:43:25] [ info] Member functions succesfully loaded.
    [2023-Feb-22 16:43:25] [debug] [ Client] - open
    [2023-Feb-22 16:43:25] [debug] [ Client] - start
    [2023-Feb-22 16:43:25] [ info] [ Client] - stdout: Jlinkarm nRF Worker ready. Handling sequence a69e85e9-196d-46a9-9690-f5f8a1813ed0.
    [2023-Feb-22 16:43:25] [debug] [SeggerBackend] - Logger sink registered in Segger backend logger
    [2023-Feb-22 16:43:25] [debug] [ JLink] - Logger sink registered in JLink logger
    [2023-Feb-22 16:43:25] [debug] [ nRFXX] - open
    [2023-Feb-22 16:43:25] [debug] [ nRFXX] - just_check_family
    [2023-Feb-22 16:43:25] [debug] [SeggerBackend] - open_dll
    [2023-Feb-22 16:43:25] [debug] [SeggerBackend] - No J-Link DLL path was provided. Attempting to auto detect.
    [2023-Feb-22 16:43:25] [trace] [ Client] - Command open executed for 4 milliseconds with result 0
    [2023-Feb-22 16:43:25] [debug] [ Client] - config
    [2023-Feb-22 16:43:25] [trace] [ Client] - Command config executed for 2 milliseconds with result 0
    [2023-Feb-22 16:43:25] [debug] [ Client] - enum_emu_snr
    [2023-Feb-22 16:43:25] [ info] [SeggerBackend] - Load library at /opt/SEGGER/JLink/libjlinkarm.so.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • I'm just brainstorming, One thing you can try that worked for me was loading RTT viewer. If I have a protected application, it prompts me to clear the device.

Reply
  • I'm just brainstorming, One thing you can try that worked for me was loading RTT viewer. If I have a protected application, it prompts me to clear the device.

Children
  • HI Shahin97,

    Thank you for your suggestion. It does not work though.

    When I start RTT Viewer, it prompts me to clear the device as you said:

    A few seconds after clicking "Yes" button I get the message "Could not connect to the target":

    These are the logs for RTT Viewer:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    LOG: J-Link RTT Viewer V7.86a: Logging started.
    LOG: Terminal 0 added.
    LOG: Connecting to J-Link via USB...
    LOG: Updating firmware: J-Link OB-nRF5340-NordicSemi compiled Nov 7 2022 16:22:01
    LOG: Replacing firmware: J-Link OB-nRF5340-NordicSemi compiled Jul 2 2021 10:55:25
    LOG: Waiting for new firmware to boot
    LOG: New firmware booted successfully
    LOG: Device "NRF52832_XXAA" selected.
    LOG: InitTarget() start
    LOG: Device will be unsecured now.
    LOG: InitTarget() end - Took 11522ms
    LOG: Connect failed. Resetting via Reset pin and trying again.
    LOG: InitTarget() start
    LOG: Device will be unsecured now.
    LOG: InitTarget() end - Took 6403ms
    ERROR: Could not connect to target device.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Thanks for the information.

    It would be very useful if we could get the log output from nRF Util, as I mentioned in the other ticket regarding the same issue (Error "failed to connect to target")

    You can upload the logs here, and I can forward it to our developers.

    Br,
    Joakim

  • HI Joakim,

    Thank you for you suggestion.

    I installed the latest version of nrfUtil and executed the recover command as follows:

    Fullscreen
    1
    2
    3
    > ./nrfutil device recover --log-level trace --serial-number 1050385806
    ❌ Failed to recover 1050385806, [jlink] RECOVER_FAILED
    Error: One or more recover tasks failed
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    The generated logs are these:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    [2023-02-23T09:29:41.529Z] [nrfutil-device] INFO - nrfutil-device (version = 1.0.1, platform = x86_64-unknown-linux-gnu) invoked with recover --log-level trace --serial-number 1050385806
    [2023-02-23T09:29:41.529Z] [nrfutil-device] DEBUG - cargo = false, force_libnrfdl_lookup = false, force_nrfutil_libdir = false
    [2023-02-23T09:29:41.529Z] [nrfutil-device] DEBUG - Creating the nrfdl context via nrfdl_create_context_with_config: Plugin location is assumed to be /home/suso/.nrfutil/lib/nrfutil-device
    [2023-02-23T09:29:41.557Z] [nrfutil-device] DEBUG - [jlink] No SEGGER instance provided
    [2023-02-23T09:29:41.557Z] [nrfutil-device] DEBUG - [jlink] [NRFJPROG][HighLevel][] dll_version
    [2023-02-23T09:29:41.559Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [SeggerBackend] [Debug] Logger sink registered in Segger backend logger
    [2023-02-23T09:29:41.559Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [JLink] [Debug] Logger sink registered in JLink logger
    [2023-02-23T09:29:41.559Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [nRFXX] [Debug] open
    [2023-02-23T09:29:41.559Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [nRFXX] [Debug] just_check_family
    [2023-02-23T09:29:41.559Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [SeggerBackend] [Debug] open_dll
    [2023-02-23T09:29:41.559Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [SeggerBackend] [Debug] No J-Link DLL path was provided. Attempting to auto detect.
    [2023-02-23T09:29:41.559Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [SeggerBackend] [Info] Load library at /opt/SEGGER/JLink/libjlinkarm.so.
    [2023-02-23T09:29:41.562Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [SeggerBackend] [Info] Library loaded, loading member functions.
    [2023-02-23T09:29:41.562Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [SeggerBackend] [Info] Member functions succesfully loaded.
    [2023-02-23T09:29:41.562Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [SeggerBackend] [Debug] dll_version
    [2023-02-23T09:29:41.562Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [SeggerBackend] [Info] Segger dll version 7.86.a loaded.
    [2023-02-23T09:29:41.562Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [nRFXX] [Debug] dll_version
    [2023-02-23T09:29:41.562Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [SeggerBackend] [Debug] is_connected_to_emu
    [2023-02-23T09:29:41.562Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [SeggerBackend] [Debug] dll_version
    [2023-02-23T09:29:41.562Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [SeggerBackend] [Debug] is_connected_to_emu
    [2023-02-23T09:29:41.562Z] [nrfutil-device] TRACE - [jlink] [NRFJPROG] [nRFXX] [Debug] close
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    It looks like the device cannot be recovered because Access Protection is active during the recovery process?

    Let me know if you have any tips to fix this issue. It is currently blocking me to deliver a prototype to a client.

    Best,

    Jesus 

  • Thank you!

    I'll forward the logs to our developers and get back to you with any information from them.

    Br,
    Joakim

  • Hello Jesus

    I have one question for you. How can i show this log registers in my board? What is the correct command?

    I try to use:


    -- nrfutil device --log-output=file 

    -- nrfutil device --log-level trace --log-output=file recover --serial-number 1050301640 

    in the termninal but it doesn't work, it doesn't show me anything.