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

nRF5340 debug network core

Hi,

I'm seeking help on debugging the network core with Visual Studio Code. My project is not based on a standard SDK and hence I think VS code will be easier to setup than Segger IDE. The project builds for nRF52840 and nRF5340 with makefiles.

I use the Cortex-Debug plugin and have created a launch.json file. This works perfectly for the nRF52840 which only use a single core, but I would like to use the nRF5340 instead.

I'm able to debug the app core on the nRF5340 without any problems, but I can't find a way to debug the network core.

My application is only running in the network core and hence the app core image is based on the "empty app core project" which just starts the network core and suspends afterwards.

I'm only interestered in debugging the network core if that makes things easier. 

I have tried the following "start debug sequence" without any success.

1) Recover device to remove app protection

2) Build, flash and reset app core

3) Build network core

4) Flash and start debugging of network core.

When I start the debug session I get the following: Launching server: "JLinkGDBServerCL.exe" "-if" "swd" "-port" "50000" "-swoport" "50001" "-telnetport" "50002" "-device" "nRF5340_xxAA_NET" but i am not able to start debugging. I have attached my launch.json config below

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Cortex Debug",
            "cwd": "${workspaceRoot}",
            "preLaunchTask": "build",
            "executable": "light.elf",
            "request": "launch",
            "type": "cortex-debug",
            "servertype": "jlink",
            "device": "nRF5340_xxAA_NET",
            "interface": "swd",
            "runToMain": true,
        }
    ]
}
   

  • Hi

    Does your empty_app_core project handle SW/HW app protection as well? If not, you are likely re-enabling it by disconnecting the debugger between steps 2 and 3 in your start debug sequence.

    Best regards,

    Simon

  • I haven't changed the empty_app_core project. Do the SDK have a way to handle this, such that it is not reenabled after the device is reset?

    I have observed the following:

    After recovery, I can reflash the APP core as many times as I want until I manually do a reset on the button or remove the power. (nrfjprog --reset is used).

    I can reflash the NET core as many times as i want until i manually do a reset, however the app core needs to be flashed once before I can flash the NET core without getting an error with readback protection.

    Yesterday I found a way to attach a debug session to the network core by using the following procedure. 

    1) Recover device to remove app protection

    2) Build, flash and reset app core

    3) Build, flash and reset net core

    4) Start debugging with attach to network core.

    This is however still not ideal, as i can't observe the start up and restart the debug session without going through all the steps again.

  • Okay, the empty_app_core project should not cause any problems. Could you check if the network core is protected? This nrfjprog command should give you an inidication.

    nrfjprog --memrd 0x01000000 --coprocessor CP_NETWORK

    Please let me know what that returns.

    I think there should be a more standard way to debug the network core, but I'll have to double check with my colleagues. I'll get back to you.

    Best regards,

    Simon

  • After recover: 0x01000000: 21010000                              |...!|

    After app flash: 0x01000000: 21010000                              |...!|

    After net flash: 0x01000000: 21010000                              |...!|

    After reset button: ERROR: The operation attempted is unavailable due to readback protection in
    ERROR: your device. Please use --recover to unlock the device.

  • Okay, looks like your network application isn't correctly handling the hardened AP protection then. After programming your application, could you check the value of NET_UICR->APPROTECT? This should be 0x01FF8000. This value will be used by the systeminit code to set up ap protection unless ENABLE_APPROTECT or ENABLE_APPROTECT_USER_HANDLING c macros are set.

    Best regards,

    Simon

Related