nRF Connect VSCode plugin flashing on nRF5340 not working with runner jlink or nrfutil

I don't want to use nrfjprog as the runner. I want to use jlink runner when flashing. However it doesn't work, neither do nrfutil.

nRF Connect for VSCode doesn't work when runner is NOT nrfjprog with nRF5340. Neither using nrfutil or jlink as runner works. 

I'm on nRF Connect SDK v2.6.0

I have this issue in a custom board, but can be easily reproduced on nRF5340 dk. Easiest way to choose which runner to use is to directly modify zephyr/boards/arm/nrf5340dk_nrf5340/board.cmake.

You will see following:

include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
include(${ZEPHYR_BASE}/boards/common/nrfutil.board.cmake)
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
Simply comment out the two not wanted to try the different runners. The top one will be used, so changing order should also work.
I'm using the zephyr/samples/bluetooth/peripheral_dis sample to reproduce

Using JLink runner

- I added some extra logging to see exactly, jlink runner works when it's a single image build (hex file called merged.hex) but building with Bluetooth doesn't work as it tries to flash the merged_domain.hex, which fails.

- If I go in and manually edit the zephyr/scripts/west_commands/runners/jlink.py 

- As you can see in the log, it successfully flashes the app core image, but fails with the net core it seems

Flashing build_dk to 960158604
west flash -d /home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk --skip-rebuild -i 960158604

-- west flash: using runner jlink
-- runners.jlink: JLink version: 7.88k
Do reset False
['ExitOnError 1', 'r', 'loadfile "/home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk/zephyr/merged_domains.hex"', 'g', 'writeDP 1 0', 'readDP 1', 'q']
-- runners.jlink: Flashing file: /home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk/zephyr/merged_domains.hex
SEGGER J-Link Commander V7.88k (Compiled Jul  5 2023 15:00:37)
DLL version V7.88k, compiled Jul  5 2023 15:00:17


J-Link Command File read successfully.
Processing script file...
J-Link>ExitOnError 1
J-Link Commander will now exit on Error
J-Link>r
J-Link connection not established yet but required for command.
Connecting to J-Link via USB...O.K.
Firmware: J-Link OB-K22-NordicSemi compiled Oct 30 2023 12:12:53
Hardware version: V1.00
J-Link uptime (since boot): 0d 00h 33m 27s
S/N: 960158604
License(s): RDI, FlashBP, FlashDL, JFlash, GDB
USB speed mode: Full speed (12 MBit/s)
VTref=3.300V
Target connection not established yet but required for command.
Device "NRF5340_XXAA_APP" selected.


Connecting to target via SWD
ConfigTargetSettings() start
ConfigTargetSettings() end - Took 13us
InitTarget() start
InitTarget() end - Took 1.59ms
Found SW-DP with ID 0x6BA02477
DPIDR: 0x6BA02477
CoreSight SoC-400 or earlier
AP map detection skipped. Manually configured AP map found.
AP[0]: AHB-AP (IDR: Not set)
AP[1]: AHB-AP (IDR: Not set)
AP[2]: MEM-AP (IDR: Not set)
AP[3]: MEM-AP (IDR: Not set)
AP[0]: Core found
AP[0]: AHB-AP ROM base: 0xE00FE000
CPUID register: 0x410FD214. Implementer code: 0x41 (ARM)
Feature set: Mainline
Cache: No cache
Found Cortex-M33 r0p4, Little endian.
FPUnit: 8 code (BP) slots and 0 literal slots
Security extension: implemented
Secure debug: enabled
CoreSight components:
ROMTbl[0] @ E00FE000
[0][0]: E00FF000 CID B105100D PID 000BB4C9 ROM Table
ROMTbl[1] @ E00FF000
[1][0]: E000E000 CID B105900D PID 000BBD21 DEVARCH 47702A04 DEVTYPE 00 Cortex-M33
[1][1]: E0001000 CID B105900D PID 000BBD21 DEVARCH 47701A02 DEVTYPE 00 DWT
[1][2]: E0002000 CID B105900D PID 000BBD21 DEVARCH 47701A03 DEVTYPE 00 FPB
[1][3]: E0000000 CID B105900D PID 000BBD21 DEVARCH 47701A01 DEVTYPE 43 ITM
[1][5]: E0041000 CID B105900D PID 002BBD21 DEVARCH 47724A13 DEVTYPE 13 ETM
[1][6]: E0042000 CID B105900D PID 000BBD21 DEVARCH 47701A14 DEVTYPE 14 CSS600-CTI
[0][1]: E0040000 CID B105900D PID 000BBD21 DEVARCH 00000000 DEVTYPE 11 TPIU
Memory zones:
  Zone: "Default" Description: Default access mode
Cortex-M33 identified.
Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Reset: ARMv8M core with Security Extension enabled detected.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
J-Link>loadfile "/home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk/zephyr/merged_domains.hex"
'loadfile': Performing implicit reset & halt of MCU.
Reset: ARMv8M core with Security Extension enabled detected.
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
Downloading file [/home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk/zephyr/merged_domains.hex]...
Comparing flash   [100%] Done.
Erasing flash     [100%] Done.
Programming flash [100%] Done.
J-Link: Flash download: Bank 2 @ 0x00000000: 1 range affected (73728 bytes)
J-Link: Flash download: Total: 0.685s (Prepare: 0.067s, Compare: 0.006s, Erase: 0.000s, Program & Verify: 0.565s, Restore: 0.046s)
J-Link: Flash download: Program & Verify speed: 127 KB/s
Writing target memory failed.

Script processing completed.

FATAL ERROR: command exited with status 1: /opt/SEGGER/JLink_V788k/JLinkExe -USB 960158604 -nogui 1 -if swd -speed 4000 -device nrf5340_xxaa_app -CommanderScript /tmp/tmpr50rillvjlink/runner.jlink -nogui 1

 *  The terminal process terminated with exit code: 1. 

Using nrfutil runner (nrfutil downloaded from here today https://www.nordicsemi.com/Products/Development-tools/nRF-Util/Download)

- Doesn't work at all

Flashing build_dk to 960158604
west flash -d /home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk --skip-rebuild -i 960158604

-- west flash: using runner nrfutil
-- runners.nrfutil: reset after flashing requested
-- runners.nrfutil: Flashing file: /home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk/zephyr/merged_domains.hex
-- runners.nrfutil: /home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk/zephyr/merged_domains.hex targets both nRF53 coprocessors; splitting it into: /home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk/zephyr/GENERATED_CP_NETWORK_merged_domains.hex and /home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk/zephyr/GENERATED_CP_APPLICATION_merged_domains.hex
error: unrecognized subcommand 'execute-batch'

  tip: some similar subcommands exist: 'x-execute', 'x-execute-batch'

Usage: nrfutil device [OPTIONS] [COMMAND]

For more information, try '--help'.
FATAL ERROR: command exited with status 2: nrfutil --json device execute-batch --batch-path /home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk/zephyr/generated_nrfutil_batch.json --serial-number 960158604

VSCode debug generate:

For help and support, visit the Nordic DevZone at https://devzone.nordicsemi.com/.

{
  "platform": {
    "os": "linux",
    "osVersion": "#29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr  4 14:39:20 UTC 2",
    "osKernel": "6.5.0-28-generic",
    "vscode": "1.89.1",
    "electron": "28.2.8",
    "node": "v18.18.2"
  },
  "system": {
    "date": "2024-05-12T13:17:31.923Z",
    "vscodeRoot": "/snap/code/159/usr/share/code/resources/app",
    "nrfConnectForDesktopInstalled": "unknown",
    "vscodeUptime": "25:08:19",
    "osUptime": "28:46:55",
    "cpu": "Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz"
  },
  "workspace": {
    "name": "project",
    "workspaceFile": null,
    "folders": [
      "/home/jakkra/Documents/project"
    ]
  },
  "sdks": [
    {
      "version": "v2.6.0",
      "path": "/home/jakkra/ncs/v2.6.0"
    },
    {
      "version": "v0.7.0-0",
      "path": "/home/jakkra/Documents/project"
    }
  ],
  "activeBuild": "/home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk",
  "apps": [
    {
      "workspace": "/home/jakkra/Documents/project",
      "uri": "/home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis",
      "buildConfigurations": [
        {
          "id": "/home/jakkra/Documents/project/zephyr/samples/bluetooth/peripheral_dis/build_dk",
          "name": "build_dk",
          "boardId": "nrf5340dk_nrf5340_cpuapp",
          "type": "Zephyr",
          "isChild": false,
          "isStale": false,
          "taskBindings": {
            "build": [],
            "pristineBuild": [],
            "flash": [],
            "eraseAndFlash": []
          }
        }
      ]
    },
  ],
  "topdir": "/home/jakkra/Documents/project",
  "workspaceState": "workspace-ready",
  "toolchains": [
    {
      "version": "2.6.0",
      "path": "/home/jakkra/ncs/toolchains/2be090971e"
    },
    {
      "version": "2.4.2",
      "path": "/home/jakkra/ncs/toolchains/1f9b40e71a"
    },
    {
      "version": "2.4.0",
      "path": "/home/jakkra/ncs/toolchains/1f9b40e71a"
    }
  ],
  "connectedDevices": [
    {
      "serialNumber": "000960158604"
    }
  ],
  "deviceProvider": "nrfutil",
  "tools": {
    "/home/jakkra/ncs/toolchains/2be090971e/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc": "0.16.5",
    "/opt/SEGGER/JLink/JLinkExe": "7.88k",
    "/usr/local/bin/nrfjprog": "10.22.0",
    "/usr/bin/nrfutil": "7.7.1",
    "/home/jakkra/ncs/toolchains/2be090971e/usr/local/bin/cmake": "3.21.0",
    "/home/jakkra/ncs/toolchains/2be090971e/usr/local/bin/west": "1.2.0",
    "/home/jakkra/ncs/toolchains/2be090971e/usr/local/bin/python3": "3.9.18",
    "/home/jakkra/ncs/toolchains/2be090971e/usr/local/bin/ninja": "1.10.2",
    "/home/jakkra/ncs/toolchains/2be090971e/usr/bin/gperf": "3.1",
    "/home/jakkra/ncs/toolchains/2be090971e/usr/bin/dtc": "1.5.0",
    "/home/jakkra/ncs/toolchains/2be090971e/opt/bin/gn": "2132",
    "/home/jakkra/ncs/toolchains/2be090971e/usr/local/bin/git": "2.37.3",
    "gdbPath": "/home/jakkra/ncs/toolchains/2be090971e/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb"
  },
  "nrfutil": {
    "nrfutil-device": {
      "version": "2.0.0",
      "binPath": "/home/jakkra/.vscode/extensions/nordic-semiconductor.nrf-connect-2024.3.25-linux-x64/platform/nrfutil/bin/nrfutil-device"
    },
    "nrfutil-toolchain-manager": {
      "version": "0.14.1",
      "binPath": "/home/jakkra/.vscode/extensions/nordic-semiconductor.nrf-connect-2024.3.25-linux-x64/platform/nrfutil/bin/nrfutil-toolchain-manager"
    }
  },
  "environment": {
    "westEnv": {
      "ELECTRON_RUN_AS_NODE": "1",
      "GIT_EXEC_PATH": "/home/jakkra/ncs/toolchains/2be090971e/usr/local/libexec/git-core",
      "HOME": "/home/jakkra",
      "PATH": "/home/jakkra/ncs/toolchains/2be090971e/usr/bin:/home/jakkra/ncs/toolchains/2be090971e/usr/bin:/home/jakkra/ncs/toolchains/2be090971e/usr/local/bin:/home/jakkra/ncs/toolchains/2be090971e/opt/bin:/home/jakkra/ncs/toolchains/2be090971e/opt/nanopb/generator-bin:/home/jakkra/ncs/toolchains/2be090971e/opt/zephyr-sdk/aarch64-zephyr-elf/bin:/home/jakkra/ncs/toolchains/2be090971e/opt/zephyr-sdk/x86_64-zephyr-elf/bin:/home/jakkra/ncs/toolchains/2be090971e/opt/zephyr-sdk/arm-zephyr-eabi/bin:/home/jakkra/ncs/toolchains/2be090971e/opt/zephyr-sdk/riscv64-zephyr-elf/bin:/home/jakkra/.local/bin:/home/jakkra/.local/bin:/home/jakkra/.local/lib/python3.10/site-packages:/home/jakkra/.local/bin:/home/jakkra/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/jakkra/.local/bin:/home/jakkra/.local/bin:/home/jakkra/.local/bin:/home/jakkra/.local/bin:/home/jakkra/.local/lib/python3.10/site-packages:/home/jakkra/.local/bin:/home/jakkra/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/jakkra/.local/bin:/home/jakkra/.local/bin",
      "ZEPHYR_BASE": "/home/jakkra/Documents/project/zephyr",
      "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
      "ZEPHYR_SDK_INSTALL_DIR": "/home/jakkra/ncs/toolchains/2be090971e/opt/zephyr-sdk",
      "PYTHONPATH": "/home/jakkra/ncs/toolchains/2be090971e/usr/local/lib/python3.9:/home/jakkra/ncs/toolchains/2be090971e/usr/local/lib/python3.9/site-packages",
      "USER": "jakkra"
    },
    "inherited": {
      "ELECTRON_RUN_AS_NODE": "1",
      "HOME": "/home/jakkra",
      "PATH": "/home/jakkra/.local/bin:/home/jakkra/.local/bin:/home/jakkra/.local/lib/python3.10/site-packages:/home/jakkra/.local/bin:/home/jakkra/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/jakkra/.local/bin:/home/jakkra/.local/bin",
      "USER": "jakkra"
    },
    "toolchainPath": "/home/jakkra/ncs/toolchains/2be090971e",
    "toolchainBinPath": "/home/jakkra/ncs/toolchains/2be090971e/opt/zephyr-sdk/arm-zephyr-eabi/bin",
    "toolchainVersion": "2.6.0"
  },
  "terminal": {
    "defaultProfile": null
  },
  "config": {
    "nordic-semiconductor.nrf-connect": {
      "topdir": "",
      "toolchain": {
        "path": "${nrf-connect.toolchain:2.6.0}"
      },
      "ozonePath": "",
      "applications": [
        "${workspaceFolder}/app",
        "${workspaceFolder}\\app",
        "${workspaceFolder}/zephyr/samples/bluetooth/peripheral_dis",
        "${workspaceFolder}/zephyr/samples/subsys/usb/mass"
      ],
      "applicationOptions": {},
      "kconfig": {
        "interface": "kconfig"
      },
      "west": {
        "env": {
          "$base": "terminal"
        }
      },
      "boardRoots": [
        "${workspaceFolder}/app",
        "${workspaceFolder}\\app",
        "${workspaceFolder}/zephyr",
        "${workspaceFolder}\\zephyr"
      ],
      "taskBindings": {},
      "buildTerminal": {
        "condensedProgress": true
      },
      "debugging": {
        "flash": false,
        "bindings": {
          "${workspaceFolder}/app/build": "Launch build"
        },
        "justMyCode": false
      },
      "activeAppFollowActiveEditor": true,
      "deviceProvider": "",
      "flash": {
        "softreset": false,
        "erase": false,
        "recover": false
      },
      "enableTelemetry": true,
      "thirdpartyIntegration": {},
      "toolchainManager": {
        "indexURL": null,
        "installDirectory": null
      },
      "nrfutil": {
        "home": null
      },
      "defaultOpenAction": "ask",
      "welcome": {
        "showOnStartup": true
      }
    },
    "nordic-semiconductor.nrf-terminal": {
      "terminalMode": "character"
    }
  },
  "extensions": {
    "internal": {
      "nordic-semiconductor.nrf-connect": {
        "version": "2024.3.25",
        "path": "/home/jakkra/.vscode/extensions/nordic-semiconductor.nrf-connect-2024.3.25-linux-x64",
        "isActive": true
      },
      "nordic-semiconductor.nrf-terminal": {
        "version": "2024.3.15",
        "path": "/home/jakkra/.vscode/extensions/nordic-semiconductor.nrf-terminal-2024.3.15",
        "isActive": true
      },
      "nordic-semiconductor.nrf-devicetree": {
        "version": "2024.3.78",
        "path": "/home/jakkra/.vscode/extensions/nordic-semiconductor.nrf-devicetree-2024.3.78",
        "isActive": true
      },
      "nordic-semiconductor.nrf-kconfig": {
        "version": "2024.3.21",
        "path": "/home/jakkra/.vscode/extensions/nordic-semiconductor.nrf-kconfig-2024.3.21",
        "isActive": true
      }
    },
    "external": {
      "marus25.cortex-debug": null,
      "ms-vscode.cpptools": "1.20.5",
      "ms-vscode.js-debug": "1.89.0",
      "ms-vscode.js-debug-companion": "1.1.2",
      "ms-vscode.vscode-js-profile-table": "1.0.9",
      "chiehyu.vscode-astyle": "0.9.0",
      "GitHub.copilot": "1.188.0",
      "GitHub.copilot-chat": "0.15.1",
      "ms-python.debugpy": "2024.6.0",
      "ms-python.python": "2024.6.0",
      "ms-python.vscode-pylance": "2024.5.1",
      "ms-vscode-remote.remote-containers": "0.362.0",
      "ms-vscode.hexeditor": "1.10.0",
      "smcpeak.default-keys-windows": "0.0.10",
      "trond-snekvik.gnu-mapfiles": "1.1.0",
      "twxs.cmake": "0.0.17",
      "webfreak.debug": "0.27.0"
    }
  }
}

EDIT: After writing this ticker I saw that nRF COnnect 2.6.1 was released also, so I tried it, but flashing still fails there.

Parents
  • Ok, after some debugging/searching I found the fix in upstream Zephyr for the nrfutil flashing https://github.com/zephyrproject-rtos/zephyr/commit/0387214bfcafa30e11f8b4d11889f8b55a998fff

    Anyway, I want to use jlink and it doesn't work. 

  • Hi,

    Is there a particular reason you want to use the jlink runner instead of nrfjprog?

    Using nrfutil as runner worked out of the box when I tested the Peripheral LBS sample in nRF Connect SDK v2.6.1, so I do not know why you get the error regarding execute-batch.

    The script for the jlink runner does not use the NrfBinaryRunner class from nrf_common.py. In nrf_common.py, the merged_domains.hex file is split into two separate files that are programmed to each core separately by program_hex_nrf53():

    -- runners.nrfjprog: Flashing file: /home/mamy/ncs/nrf/samples/bluetooth/peripheral_lbs/build/zephyr/merged_domains.hex
    -- runners.nrfjprog: /home/mamy/ncs/nrf/samples/bluetooth/peripheral_lbs/build/zephyr/merged_domains.hex targets both nRF53 coprocessors; splitting it into: /home/mamy/ncs/nrf/samples/bluetooth/peripheral_lbs/build/zephyr/GENERATED_CP_NETWORK_merged_domains.hex and /home/mamy/ncs/nrf/samples/bluetooth/peripheral_lbs/build/zephyr/GENERATED_CP_APPLICATION_merged_domains.hex

    -- runners.nrfutil: Flashing file: /home/mamy/ncs/nrf/samples/bluetooth/peripheral_lbs/build/zephyr/merged_domains.hex
    -- runners.nrfutil: /home/mamy/ncs/nrf/samples/bluetooth/peripheral_lbs/build/zephyr/merged_domains.hex targets both nRF53 coprocessors; splitting it into: /home/mamy/ncs/nrf/samples/bluetooth/peripheral_lbs/build/zephyr/GENERATED_CP_NETWORK_merged_domains.hex and /home/mamy/ncs/nrf/samples/bluetooth/peripheral_lbs/build/zephyr/GENERATED_CP_APPLICATION_merged_domains.hex

    The jlink runner does not have a way to handle the two cores, which causes it to fail when flashing applications for both cores.

    Best regards,
    Marte

  • Hi and thank you. I fixed the issue with nrfutil of you check me last comment.

    2 Reasons I want to use JLink Runner:

    1. I want to use jlink runner is because it's alot faster.

    jlink: 0m25,406s (NOTE excluding net core, looking at nrfjprog log, it takes about 10s for net core, so add that here then). So let's say JLINK is 35s, so pretty much half time of the other two.

    nrfutil: 1m12,801s

    nrfjprog: 1m18,912s

    Full log from all of them:

    jlink:
    jakkra@jakkra-XPS-15-9560:~/Documents/project$ time west flash -d /home/jakkra/Documents/project/app/build_debug_v5_rtt --skip-rebuild -i 760208501
    -- west flash: using runner jlink
    -- runners.jlink: JLink version: 7.88k
    -- runners.jlink: Flashing file: /home/jakkra/Documents/project/app/build_debug_v5_rtt/zephyr/merged.hex
    Downloading file [/home/jakkra/Documents/project/app/build_debug_v5_rtt/zephyr/merged.hex]...
    Comparing flash   [100%] Done.
    Erasing flash     [100%] Done.
    Programming flash [100%] Done.
    J-Link: Flash download: Bank 2 @ 0x00000000: 5 ranges affected (790528 bytes)
    J-Link: Flash download: Total: 24.172s (Prepare: 0.118s, Compare: 0.223s, Erase: 16.617s, Program & Verify: 7.120s, Restore: 0.093s)
    J-Link: Flash download: Program & Verify speed: 108 KB/s
    O.K.
    J-Link>g
    J-Link>writeDP 1 0
    Writing DP register 1 = 0x00000000 (0 write repetitions needed)
    J-Link>readDP 1
    Reading DP register 1 = 0x00000040 (0 read repetitions needed)
    J-Link>q
    
    Script processing completed.
    
    
    real    0m25,406s
    user    0m1,141s
    sys     0m1,548s
    
    nrfutil:
    jakkra@jakkra-XPS-15-9560:~/Documents/dproject$ time west flash -d /home/jakkra/Documents/dproject/app/build_debug_v5_rtt --skip-rebuild -i 760208501
    -- west flash: using runner nrfutil
    -- runners.nrfutil: reset after flashing requested
    -- runners.nrfutil: Flashing file: /home/jakkra/Documents/dproject/app/build_debug_v5_rtt/zephyr/merged_domains.hex
    -- runners.nrfutil: /home/jakkra/Documents/dproject/app/build_debug_v5_rtt/zephyr/merged_domains.hex targets both nRF53 coprocessors; splitting it into: /home/jakkra/Documents/dproject/app/build_debug_v5_rtt/zephyr/GENERATED_CP_NETWORK_merged_domains.hex and /home/jakkra/Documents/dproject/app/build_debug_v5_rtt/zephyr/GENERATED_CP_APPLICATION_merged_domains.hex
    -- runners.nrfutil: Upload image.
    -- runners.nrfutil: Upload image.
    -- runners.nrfutil: Started
    -- runners.nrfutil: Board with serial number 760208501 flashed successfully.
    
    real    1m12,801s
    user    0m7,425s
    sys     0m5,426s
    
    nrfjprog:
    jakkra@jakkra-XPS-15-9560:~/Documents/dproject$ time west flash -d /home/jakkra/Documents/dproject/app/build_debug_v5_rtt --skip-rebuild -i 760208501
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: reset after flashing requested
    -- runners.nrfjprog: Flashing file: /home/jakkra/Documents/dproject/app/build_debug_v5_rtt/zephyr/merged_domains.hex
    -- runners.nrfjprog: /home/jakkra/Documents/dproject/app/build_debug_v5_rtt/zephyr/merged_domains.hex targets both nRF53 coprocessors; splitting it into: /home/jakkra/Documents/dproject/app/build_debug_v5_rtt/zephyr/GENERATED_CP_NETWORK_merged_domains.hex and /home/jakkra/Documents/dproject/app/build_debug_v5_rtt/zephyr/GENERATED_CP_APPLICATION_merged_domains.hex
    [ #################### ]  10.910s | Erase file - Done erasing                                                          
    [ #################### ]   1.497s | Program file - Done programming                                                    
    [ #################### ]   1.477s | Verify file - Done verifying                                                       
    [ #################### ]  39.834s | Erase file - Done erasing                                                          
    [ #################### ]   8.724s | Program file - Done programming                                                    
    [ #################### ]   8.654s | Verify file - Done verifying                                                       
    Applying pin reset.
    -- runners.nrfjprog: Board with serial number 760208501 flashed successfully.
    
    real    1m18,912s
    user    0m6,498s
    sys     0m5,105s

    2. I quite often have issues where it randomly get into a state where I need to recover my board when developing. I don't have reset line connected, hence always doing softreset. I'm also most of the time doing a full chip erase when flashing to save time. This is the reason I wanted to try using JLink instead to see if this issue goes away.

    But anyway, thanks for checking. I'll try to patch Zephyr so it works for me using JLink. Thanks for the help.

  • Hi,

    Thank you for clarifying.

    The only option I see for using JLink is to modify the script to handle multiple cores. Since we recommend using nrfjprog, and this works, we can unfortunately not prioritize resources for this at the moment.

    Best regards,
    Marte

Reply Children
  • I understand that, however you should look into why nrfjprog is so much slower than jlink to flash. Since Nordic customers will reflash their FW ALOT, saving a few seconds each time makes a huge difference in the user experience.

  • Hi,

    The main culprit when using nrfjprog as runner is the erase type that west uses as default, which is --sectoranduicrerase for the nRF52 device family and --sectorerase for other device families. Here you can see the time it takes to program the Matter light bulb sample on the nRF52840 DK using nrfjprog directly with sectoranduicrerase:

    ~/ncs/nrf/samples/matter/light_bulb/build/zephyr$ time nrfjprog --program merged.hex --sectoranduicrerase --verify
    [ #################### ]  22.069s | Erase file - Done erasing                                                          
    [ #################### ]  10.054s | Program file - Done programming                                                    
    [ #################### ]   9.856s | Verify file - Done verifying                                                       
    
    real	0m43,825s
    user	0m0,943s
    sys	0m1,267s
    

    If you use west --erase instead of west, it will use the --chiperase flag, which should reduce the time:

    ~/ncs/nrf/samples/matter/light_bulb/build/zephyr$ time nrfjprog --program merged.hex --chiperase --verify
    [ #################### ]   0.207s | Erase file - Done erasing                                                          
    [ #################### ]  10.052s | Program file - Done programming                                                    
    [ #################### ]   9.856s | Verify file - Done verifying                                                       
    
    real	0m21,863s
    user	0m0,522s
    sys	0m1,067s

    ~/ncs/nrf/samples/matter/light_bulb/build$ time west flash --skip-rebuild --erase
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: mass erase requested
    -- runners.nrfjprog: reset after flashing requested
    Using board 683635785
    -- runners.nrfjprog: Flashing file: /home/marte/ncs/nrf/samples/matter/light_bulb/build/zephyr/merged.hex
    [ #################### ]   0.206s | Erase file - Done erasing                                                          
    [ #################### ]  10.051s | Program file - Done programming                                                    
    [ #################### ]   9.852s | Verify file - Done verifying                                                       
    Enabling pin reset.
    Applying pin reset.
    -- runners.nrfjprog: Board with serial number 683635785 flashed successfully.
    
    real	0m25,646s
    user	0m1,637s
    sys	0m3,439s
    

    It is still not as good as jlink, but it is an improvement.

    Using --erase is the same as the 'Erase and Flash to Board' action in the vscode extension:

    Best regards,
    Marte

  • Yes this I'm aware of. Experimented with JLink, and doing an erase and then program using JLink takes: 

    time /opt/SEGGER/JLink_V788k/JLinkExe -nogui 1 -if swd -speed 4000 -device nrf5340_xxaa_app -CommanderScript jlink_erase -nogui 1 && time /opt/SEGGER/JLink_V788k/JLinkExe -nogui 1 -if swd -speed 4000 -device nrf5340_xxaa_app -CommanderScript jlink_file_flash -nogui 1

     0m1,393s(erase) +  0m8,581s(program+verify) = ~10s

    Vs.

    time nrfjprog --program app/build_debug/zephyr/merged.hex --chiperase --verify

    real    0m21,907s

    So there are defenately room for improvement by getting the jlink runner functional for nRF53.

    I'll file a bug into Zephyr instead for getting jlink runner functional, and hopefully I get some time myself to fix this.

    You can close this ticket, thank you Slight smile

Related