[ABANDONED] "cpu_reg_set() register 0 is already marked as valid" message when loading image

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [ABANDONED] "cpu_reg_set() register 0 is already marked as valid" message when loading image

    Using nRF5340DK 0.11.0, JLink V7.00a and the following commander script


    Source Code

    1. device nRF5340_xxAA_NET
    2. if SWD
    3. speed 4000
    4. connect
    5. erase
    6. loadbin bootloader_network_core.bin, 0x01000000
    7. loadfile network_core.hex
    8. device nRF5340_xxAA_APP
    9. loadbin bootloader_application_core.bin, 0x0
    10. loadfile application_core.hex
    Display All


    I receive a GUI message "cpu_reg_set() register 0 is already marked as valid" around the time `device nRF5340_xxAA_APP` and subsequent `loadbin bootloader_application_core.bin, 0x0` command is used. Any suggestions to avoid this?
  • Hi,
    Thank you for your inquiry.

    In general:
    It is recommended to issue a reset before issuing a flash download.

    Regarding the message:
    From your question, it does not seem as if you would experience any errors or issues, correct?
    If so, is there a specific reason why you do not want this message to be shown?
    If not so, could you please provide a detailed description of the issue you are observing?

    Best regards,
    Fabian
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello, thank you for the response. There are no errors, but when running this via a script, I'd prefer not having to click a GUI button when running this script for > 1 device. Adding reset command after selecting the app core has helped. I don't see this error anymore. Thank you for advising!
  • Hi,
    Good to hear that the issue does not appear after resetting.

    However, the error message indicates that there is still something going wrong on J-Link side.

    Could you please download the latest version of the J-Link Software Pack and try if the issue still persists with it (when not resetting the device)?
    It is available for download here: segger.com/downloads/jlink#J-L…twareAndDocumentationPack

    Best regards,
    Fabian
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Another issue that I run into when using this script after the network core programming steps have completed and the app core connection begins. It doesn't happen every time, but once it hits it happens on every run. JLinks shows a message that the device needs to be unsecured and triggers an erase after connecting to the app core. The erase step has already been performed. I don't think the erase step is required again is it?
    Also, is the erase compatible with `nrfjprog` recover commands? I have noticed that JLink unsecures the devices even after I have run the recover command via `nrfjprog` for both cores. This again happens once in a while, so it could very well be some flaky chip behavior?
    Only way around that I found was to disconnect JLink.

    Source Code

    1. Disconnecting from J-Link...O.K.
    2. Device "NRF5340_XXAA_APP" selected.
    3. Connecting to target via SWD
    4. ConfigTargetSettings() start
    5. ConfigTargetSettings() end
    6. InitTarget() start
    7. InitTarget() end
    8. Found SW-DP with ID 0x6BA02477
    9. DPIDR: 0x6BA02477
    10. AP map detection skipped. Manually configured AP map found.
    11. AP[0]: AHB-AP (IDR: Not set)
    12. AP[1]: AHB-AP (IDR: Not set)
    13. AP[2]: MEM-AP (IDR: Not set)
    14. AP[3]: MEM-AP (IDR: Not set)
    15. AP[0]: Core found
    16. AP[0]: AHB-AP ROM base: 0xE00FE000
    17. CPUID register: 0x410FD214. Implementer code: 0x41 (ARM)
    18. Found Cortex-M33 r0p4, Little endian.
    19. ConfigTargetSettings() start
    20. ConfigTargetSettings() end
    21. InitTarget() start
    22. InitTarget() end
    23. Found SW-DP with ID 0x6BA02477
    24. DPIDR: 0x6BA02477
    25. AP map detection skipped. Manually configured AP map found.
    26. AP[0]: AHB-AP (IDR: Not set)
    27. AP[1]: AHB-AP (IDR: Not set)
    28. AP[2]: MEM-AP (IDR: Not set)
    29. AP[3]: MEM-AP (IDR: Not set)
    30. AP[0]: Core found
    31. AP[0]: AHB-AP ROM base: 0xE00FE000
    32. CPUID register: 0x410FD214. Implementer code: 0x41 (ARM)
    33. Found Cortex-M33 r0p4, Little endian.
    34. ****** Error: Failed to register debugger connection at J-Link because J-Link is low on memory.
    35. Cannot connect to target.
    Display All
  • Hi,

    Did you give the file download (without prior reset) on the latest version a try?
    Is the error message still shown?

    Regarding the unlock:
    As you probably know, nrfjprog is a tool developed and maintained by Nordic, so we only have limited information about what it does exactly.
    However, the device can only be unprotected by issuing a mass erase (as you already mentioned), so I would expect it to work.

    Could you tell us how often the behavior is showing up?

    rookie wrote:

    Only way around that I found was to disconnect JLink.
    Could you elaborate what exactly you mean by "disconnecting JLink" (unplug J-Link? Closing J-Link Commander? ...)?
    Do you also power-cycle the board in this case?
    Could you tell us how often you encounter this issue present itself? 1/10 times? 1/100?...

    Do you use custom hardware or an evaluation board? In the latter case which one?
    If custom hardware, do you experience the same problem on an evaluation board?
    Could you provide us with a small sample application data file (e.g. a .hex)
    this issue is reproducible with on an evaluation board?

    Best regards,
    Fabian
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Fabian,

    So I have updated to 7.50a. Per your suggestion, I removed the reset command after the appcore connection is made. It did not help. I had to bring back the reset command and then it worked without the register-0 message. See the attached screenshot "cpu-reg-error.png". As for your question about disconnection, I have physically disconnected the nRF5340DK (that I use to program external boards), as well as power cycle the external board.


    The recover command in `nrfjprog` writes an image that disables APPROTECT. Here is what I see when I run the recover command -

    Source Code

    1. $ nrfjprog --recover --coprocessor CP_NETWORK;nrfjprog --coprocessor CP_APPLICATION --recover;
    2. Recovering device. This operation might take 30s.
    3. Writing image to disable ap protect.
    4. Erasing user code and UICR flash areas.
    5. Recovering device. This operation might take 30s.
    6. Writing image to disable ap protect.
    7. Erasing user code and UICR flash areas.



    I don't know how JLink handles erase though. Ideally if this image is written, then I would expect that JLink does not find that CTRL-AP is enabled. But it does. If I run the nrfjprog recover commands, and then run the JLink script, I see the following -

    Source Code

    1. SEGGER J-Link Commander V7.50a (Compiled Jul 8 2021 18:17:01)
    2. DLL version V7.50a, compiled Jul 8 2021 18:16:55
    3. J-Link Command File read successfully.
    4. Processing script file...
    5. J-Link connection not established yet but required for command.
    6. Connecting to J-Link via USB...O.K.
    7. Firmware: J-Link OB-K22-NordicSemi compiled Jul 2 2021 10:44:28
    8. Hardware version: V1.00
    9. S/N: 960154973
    10. License(s): RDI, FlashBP, FlashDL, JFlash, GDB
    11. VTref=3.300V
    12. Selecting SWD as current target interface.
    13. Selecting 4000 kHz as target interface speed
    14. Device "NRF5340_XXAA_NET" selected.
    15. Connecting to target via SWD
    16. ConfigTargetSettings() start
    17. ConfigTargetSettings() end
    18. InitTarget() start
    19. CTRL-AP indicates that the device is secured.
    20. For debugger connection the device needs to be unsecured.
    21. Note: Unsecuring will trigger a mass erase of the internal flash, SRAM and UICR of both the application and the network core.
    Display All

    I hit the JLink low on memory error once in a while, I wouldn't say 1 in 10. I hit it in 7.50a as well, but only in the appcore. I have the nRF5340DK (rev1), and a custom board with revD. I don't see why my custom board would behave any differently than the DK. It fails to connect sometimes and says that the application core is secured (eventhough we have already done an erase in the commander script). See the attached image "appcore-jlink.png", here is the log of JLink trying several times and failing eventually. Every time it tried, I got the GUI message (attached in `appcore-jlink.png`)

    Source Code

    1. J-Link: Flash download: Program & Verify speed: 63 KiB/s
    2. O.K.
    3. Disconnecting from J-Link...O.K.
    4. Device "NRF5340_XXAA_APP" selected.
    5. Connecting to target via SWD
    6. ConfigTargetSettings() start
    7. ConfigTargetSettings() end
    8. InitTarget() start
    9. InitTarget() end
    10. Found SW-DP with ID 0x6BA02477
    11. DPIDR: 0x6BA02477
    12. AP map detection skipped. Manually configured AP map found.
    13. AP[0]: AHB-AP (IDR: Not set)
    14. AP[1]: AHB-AP (IDR: Not set)
    15. AP[2]: MEM-AP (IDR: Not set)
    16. AP[3]: MEM-AP (IDR: Not set)
    17. AP[0]: Core found
    18. AP[0]: AHB-AP ROM base: 0xE00FE000
    19. CPUID register: 0x410FD214. Implementer code: 0x41 (ARM)
    20. Found Cortex-M33 r0p4, Little endian.
    21. ConfigTargetSettings() start
    22. ConfigTargetSettings() end
    23. InitTarget() start
    24. Device will be unsecured now.
    25. InitTarget() end
    26. Found SW-DP with ID 0x6BA02477
    27. DPIDR: 0x6BA02477
    28. AP map detection skipped. Manually configured AP map found.
    29. AP[0]: AHB-AP (IDR: Not set)
    30. AP[1]: AHB-AP (IDR: Not set)
    31. AP[2]: MEM-AP (IDR: Not set)
    32. AP[3]: MEM-AP (IDR: Not set)
    33. AP[0]: Core found
    34. AP[0]: AHB-AP ROM base: 0xE00FE000
    35. CPUID register: 0x410FD214. Implementer code: 0x41 (ARM)
    36. Found Cortex-M33 r0p4, Little endian.
    37. ****** Error: Failed to register debugger connection at J-Link because J-Link is low on memory.
    38. Cannot connect to target.
    Display All

    Lastly, I cannot run this script on revA of nrf53 ie PDK with JLink 7.50a. In fact I have reported this in this post. I have to stick to 6.98c - 7.00a, to get this to run correctly on revA versions

    Source Code

    1. Cortex-M33 identified.
    2. Without any give address range, Erase Chip will be executed
    3. Erasing device...
    4. T-bit of XPSR is 0 but should be 1. Changed to 1.
    5. ****** Error: Timeout while preparing target, RAMCode did not respond in time. (PC = 0x00000040, CPSR = 0xFFFFFFFF, LR = 0x01000003)!
    6. Failed to prepare RAMCode using RAM
    7. ERROR: Erase returned with error code -1.
    8. Downloading file [bootloader_network_core.bin]...
    9. J-Link: Flash download: Bank 0 @ 0x01FF8000: Skipped. Contents already match
    10. J-Link: Flash download: Bank 1 @ 0x01000000: Skipped. Contents already match
    11. O.K.
    12. Downloading file [network_core.hex]...
    13. ****** Error: Failed to erase sectors 32 @ address 0x01010000 (unspecified error)
    14. Failed to erase sectors.
    15. Unspecified error -1
    Display All
    Images
    • cpu-reg-error.png

      235.55 kB, 1,104×568, viewed 165 times
    • appcore-jlink.png

      447.6 kB, 1,910×634, viewed 162 times