nrf52840 dongle flashing via Segger J-link and VSCode

HW:

  • J-link standard
  • nRF52840 Dongle 

SW Support Info:

IMPORTANT: The data below could contain sensitive or confidential information about your environment.
If you do not wish this to be seen by others, please make sure to remove it before sharing.

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

{
  "platform": {
    "os": "darwin",
    "osVersion": "Darwin Kernel Version 22.5.0: Thu Jun  8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000",
    "osKernel": "22.5.0",
    "vscode": "1.81.1",
    "electron": "22.3.18",
    "node": "v16.17.1"
  },
  "system": {
    "date": "2023-08-27T23:08:53.167Z",
    "vscodeRoot": "/Applications/Visual Studio Code.app/Contents/Resources/app",
    "nrfConnectForDesktopInstalled": true,
    "vscodeUptime": "03:11:11",
    "osUptime": "436:31:14",
    "cpu": {
      "model": "Apple M1 Max",
      "speed": "24 MHz",
      "count": 5
    },
    "memory": {
      "total": "64.00 GB",
      "free": "0.29 GB"
    }
  },
  "workspace": {
    "name": "lights",
    "workspaceFile": null,
    "folders": [
      "/Users/josh/Code/hw/nrf/lights"
    ]
  },
  "extensions": {
    "internal": {
      "nordic-semiconductor.nrf-connect": {
        "version": "2023.7.129",
        "path": "/Users/josh/.vscode/extensions/nordic-semiconductor.nrf-connect-2023.7.129-darwin-arm64",
        "isActive": true
      },
      "nordic-semiconductor.nrf-terminal": {
        "version": "2023.7.47",
        "path": "/Users/josh/.vscode/extensions/nordic-semiconductor.nrf-terminal-2023.7.47",
        "isActive": true
      },
      "nordic-semiconductor.nrf-devicetree": {
        "version": "2023.7.56",
        "path": "/Users/josh/.vscode/extensions/nordic-semiconductor.nrf-devicetree-2023.7.56",
        "isActive": true
      },
      "nordic-semiconductor.nrf-kconfig": {
        "version": "2023.6.51",
        "path": "/Users/josh/.vscode/extensions/nordic-semiconductor.nrf-kconfig-2023.6.51",
        "isActive": true
      }
    },
    "external": {
      "marus25.cortex-debug": null,
      "ms-vscode.cpptools": "1.17.4",
      "ms-vscode.js-debug": "1.81.0",
      "ms-vscode.js-debug-companion": "1.1.2",
      "ms-vscode.vscode-js-profile-table": "1.0.3",
      "alefragnani.Bookmarks": "13.4.1",
      "ambooth.git-rename": "1.3.0",
      "bmalehorn.shell-syntax": "1.0.5",
      "chouzz.vscode-better-align": "1.4.2",
      "christian-kohler.path-intellisense": "2.8.4",
      "coder.coder-remote": "0.1.21",
      "CodeStream.codestream": "14.28.0",
      "DavidAnson.vscode-markdownlint": "0.51.0",
      "dbaeumer.vscode-eslint": "2.4.2",
      "donjayamanne.githistory": "0.6.20",
      "eamodio.gitlens": "14.2.1",
      "eg2.vscode-npm-script": "0.3.29",
      "emilast.LogFileHighlighter": "2.16.0",
      "esbenp.prettier-vscode": "10.1.0",
      "everettjf.filter-line": "2.0.1",
      "foxundermoon.shell-format": "7.2.5",
      "genieai.chatgpt-vscode": "0.0.8",
      "GitHub.copilot": "1.105.350",
      "Gruntfuggly.todo-tree": "0.0.226",
      "hoovercj.vscode-settings-cycler": "1.0.1",
      "jbockle.jbockle-format-files": "3.4.0",
      "KevinRose.vsc-python-indent": "1.18.0",
      "mhutchie.git-graph": "1.30.0",
      "mohsen1.prettify-json": "0.0.3",
      "ms-dotnettools.csharp": "2.0.413",
      "ms-dotnettools.vscode-dotnet-runtime": "1.7.1",
      "ms-python.isort": "2023.10.1",
      "ms-python.python": "2023.14.0",
      "ms-python.vscode-pylance": "2023.8.40",
      "ms-toolsai.jupyter": "2023.7.1002162226",
      "ms-toolsai.jupyter-keymap": "1.1.2",
      "ms-toolsai.jupyter-renderers": "1.0.17",
      "ms-toolsai.vscode-jupyter-cell-tags": "0.1.8",
      "ms-toolsai.vscode-jupyter-slideshow": "0.1.5",
      "ms-vscode-remote.remote-containers": "0.304.0",
      "ms-vscode-remote.remote-ssh": "0.102.0",
      "ms-vscode-remote.vscode-remote-extensionpack": "0.24.0",
      "ms-vscode.cpptools-extension-pack": "1.3.0",
      "ms-vscode.cpptools-themes": "2.0.0",
      "ms-vscode.remote-explorer": "0.4.1",
      "ms-vscode.remote-server": "1.4.3",
      "ms-vscode.test-adapter-converter": "0.1.8",
      "ms-vsliveshare.vsliveshare": "1.0.5883",
      "neptunedesign.vs-sequential-number": "1.1.0",
      "nick-rudenko.back-n-forth": "3.1.1",
      "njpwerner.autodocstring": "0.6.1",
      "PKief.material-icon-theme": "4.30.0",
      "quicktype.quicktype": "12.0.46",
      "rvest.vs-code-prettier-eslint": "5.1.0",
      "searKing.preview-vscode": "2.2.5",
      "shaharkazaz.git-merger": "0.4.1",
      "shd101wyy.markdown-preview-enhanced": "0.6.10",
      "streetsidesoftware.code-spell-checker": "2.20.5",
      "trond-snekvik.gnu-mapfiles": "1.1.0",
      "Trottero.dotnetwatchattach": "0.2.6",
      "twxs.cmake": "0.0.17",
      "Tyriar.vscode-terminal-here": "0.2.4",
      "vscode-icons-team.vscode-icons": "12.5.0",
      "vscodeshift.material-ui-snippets": "3.3.8",
      "YuTengjing.vscode-colorize-plus": "0.12.13",
      "ZainChen.json": "2.0.2"
    }
  },
  "tools": {
    "/opt/nordic/ncs/toolchains/4ef6631da0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc": "0.16.0",
    "/Applications/SEGGER/JLink/JLinkExe": "7.92a",
    "/usr/local/bin/nrfjprog": "10.23.0",
    "nrfutil": "Not found",
    "/opt/nordic/ncs/toolchains/4ef6631da0/bin/cmake": "3.20.5",
    "/opt/nordic/ncs/toolchains/4ef6631da0/bin/west": "1.0.0",
    "/opt/nordic/ncs/toolchains/4ef6631da0/bin/python3": "3.9.6",
    "/opt/nordic/ncs/toolchains/4ef6631da0/bin/ninja": "1.10.2",
    "/opt/nordic/ncs/toolchains/4ef6631da0/bin/gperf": "3.1",
    "/opt/nordic/ncs/toolchains/4ef6631da0/bin/dtc": "1.6.1",
    "/opt/nordic/ncs/toolchains/4ef6631da0/bin/gn": "2106",
    "/opt/nordic/ncs/toolchains/4ef6631da0/bin/git": "2.37.3",
    "gdbPath": "/opt/nordic/ncs/toolchains/4ef6631da0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gdb"
  },
  "sdks": [
    {
      "version": "2.4.0",
      "path": "/opt/nordic/ncs/v2.4.0"
    },
    {
      "version": "2.4.1",
      "path": "/opt/nordic/ncs/v2.4.1"
    },
    {
      "version": "2.4.1",
      "path": "/Users/josh/Code/hw/nrf/lights"
    },
    {
      "version": "3.4.99",
      "path": "/Users/josh/zephyrproject"
    }
  ],
  "toolchains": [
    {
      "version": "2.4.0",
      "path": "/opt/nordic/ncs/toolchains/4ef6631da0"
    }
  ],
  "connectedDevices": [
    {
      "serialNumber": "000260117435",
      "boardVersion": "Unknown",
      "deviceFamily": "NRF52_FAMILY",
      "deviceVersion": null,
      "jlinkObFirmwareVersion": "J-Link V10 compiled Jan 30 2023 11:28:07"
    }
  ],
  "deviceProvider": "nrfutil",
  "config": {
    "nordic-semiconductor.nrf-connect": {
      "topdir": "${nrf-connect.sdk:2.4.1}",
      "toolchain": {
        "path": "${nrf-connect.toolchain:2.4.0}"
      },
      "ozonePath": "",
      "applications": [
        "${workspaceFolder}/blinky"
      ],
      "applicationOptions": {},
      "kconfig": {
        "interface": "kconfig",
        "executeInDefaultShell": false
      },
      "welcome": {
        "showOnStartup": true
      },
      "west": {
        "env": {
          "$base": "terminal"
        }
      },
      "boardRoots": [],
      "taskBindings": {},
      "debugging": {
        "flash": true,
        "bindings": {}
      },
      "activeAppFollowActiveEditor": true,
      "deviceProvider": "nrfutil"
    },
    "nordic-semiconductor.nrf-terminal": {
      "terminalMode": "character"
    }
  },
  "environment": {
    "westEnv": {
      "ELECTRON_RUN_AS_NODE": "1",
      "GIT_EXEC_PATH": "/opt/nordic/ncs/toolchains/4ef6631da0/Cellar/git/2.37.3/libexec/git-core",
      "HOME": "/Users/josh",
      "PATH": "/opt/nordic/ncs/toolchains/4ef6631da0/bin:/opt/nordic/ncs/toolchains/4ef6631da0/usr/bin:/opt/nordic/ncs/toolchains/4ef6631da0/usr/local/bin:/opt/nordic/ncs/toolchains/4ef6631da0/opt/bin:/opt/nordic/ncs/toolchains/4ef6631da0/opt/nanopb/generator-bin:/opt/nordic/ncs/toolchains/4ef6631da0/opt/zephyr-sdk/aarch64-zephyr-elf/bin:/opt/nordic/ncs/toolchains/4ef6631da0/opt/zephyr-sdk/x86_64-zephyr-elf/bin:/opt/nordic/ncs/toolchains/4ef6631da0/opt/zephyr-sdk/arm-zephyr-eabi/bin:/Users/josh/.nvm/versions/node/v18.12.1/bin:/opt/homebrew/Cellar/pyenv-virtualenv/1.2.1/shims:/Users/josh/.pyenv/shims:/usr/local/opt/llvm/bin:/usr/local/texlive/2019/bin/x86_64-darwin:/Users/josh/Library/Android/sdk/platform-tools:/opt/homebrew/bin:/Users/josh/esp/esp-idf/tools:/Users/josh/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Little Snitch.app/Contents/Components:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/josh/.cargo/bin:/Users/josh/.dotnet/tools:/opt/homebrew/opt/fzf/bin:/Users/josh/.nvm/versions/node/v18.12.1/bin:/opt/homebrew/Cellar/pyenv-virtualenv/1.2.1/shims:/Users/josh/.pyenv/shims:/usr/local/opt/llvm/bin:/usr/local/texlive/2019/bin/x86_64-darwin:/Users/josh/Library/Android/sdk/platform-tools:/opt/homebrew/bin:/Users/josh/esp/esp-idf/tools:/Users/josh/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Little Snitch.app/Contents/Components:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/josh/.cargo/bin:/Users/josh/.dotnet/tools:/opt/homebrew/opt/fzf/bin",
      "ZEPHYR_BASE": "/Users/josh/Code/hw/nrf/lights/zephyr",
      "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
      "ZEPHYR_SDK_INSTALL_DIR": "/opt/nordic/ncs/toolchains/4ef6631da0/opt/zephyr-sdk",
      "USER": "josh"
    },
    "inherited": {
      "ELECTRON_RUN_AS_NODE": "1",
      "HOME": "/Users/josh",
      "PATH": "/Users/josh/.nvm/versions/node/v18.12.1/bin:/opt/homebrew/Cellar/pyenv-virtualenv/1.2.1/shims:/Users/josh/.pyenv/shims:/usr/local/opt/llvm/bin:/usr/local/texlive/2019/bin/x86_64-darwin:/Users/josh/Library/Android/sdk/platform-tools:/opt/homebrew/bin:/Users/josh/esp/esp-idf/tools:/Users/josh/bin:/usr/local/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Little Snitch.app/Contents/Components:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/josh/.cargo/bin:/Users/josh/.dotnet/tools:/opt/homebrew/opt/fzf/bin",
      "USER": "josh"
    },
    "toolchainPath": "/opt/nordic/ncs/toolchains/4ef6631da0",
    "toolchainBinPath": "/opt/nordic/ncs/toolchains/4ef6631da0/opt/zephyr-sdk/arm-zephyr-eabi/bin",
    "toolchainVersion": "2.4.0"
  },
  "terminal": {
    "defaultProfile": null
  }
}

I can successfully program the dongle using nRFConnect. However, when I try to program with J-Link via VSCode, I get the following error:

Flashing build to 260117435
/bin/sh -c west flash -d /Users/josh/Code/hw/nrf/lights/blinky/build --skip-rebuild --dev-id 260117435

-- west flash: using runner nrfjprog
-- runners.nrfjprog: Flashing file: /Users/josh/Code/hw/nrf/lights/blinky/build/zephyr/zephyr.hex
[error] [ Client] - Encountered error -90: Command read_device_info executed for 12 milliseconds with result -90
[error] [ Client] - Encountered error -90: Command read_memory_descriptors executed for 11 milliseconds with result -90
[error] [ Worker] - Access protection is enabled, can't read device version.
[error] [ Worker] - Can't read memory descriptors, ap-protection is enabled.
[error] [ Client] - Encountered error -90: Command erase_file executed for 23 milliseconds with result -90
[ ###### ] 0.000s | Erase file - Check image [ ##### ] 0.000s | Check image validity - Initialize devic[ ########## ] 0.000s | Check image validity - Check region 0 s[ ############### ] 0.000s | Check image validity - block 1 of 2 [error] [ nRF52] - Failed while detecting device memory block protection status!
[error] [ nRF52] - Failed while erasing device. -90: Access protection is enabled, can't read device version.
[error] [ Worker] - Access protection is enabled, can't read device version.
ERROR: The operation attempted is unavailable due to readback protection in
ERROR: your device. Please use --recover to unlock the device.
NOTE: For additional output, try running again with logging enabled (--log).
NOTE: Any generated log error messages will be displayed.
ERROR: runners.nrfjprog: Flashing failed because the target must be recovered.
To fix, run "west flash --recover" instead.
Note: this will recover and erase all flash memory prior to reflashing.
FATAL ERROR: command exited with status 24: nrfjprog --program /Users/josh/Code/hw/nrf/lights/blinky/build/zephyr/zephyr.hex --sectoranduicrerase --verify -f NRF52 --snr 260117435

I then run west flash --recover and I can connect to the device. However, when I successfully flash, the program never runs (simple blinky example). If I revert back to factory dfu bootloader and reflash with nRFConnect, it works again... however, I can't debug/access using the jlink.

Goal: be able to keep DFU bootloader, while also able to flash/debug using J-Link in VSCode... any help much appreciated!

  • Hi  ,

    I've been giving this a shot as I come back around to the project (got very sidetracked on an I2S implementation).

    You said

    The alternative is of course just to use MCUboot instead, which will nicely integrate with the nRF Connect SDK, and lets you program using J-Link and West to program without issue.

    However, I'm not quite figuring out how to do this. Do I need to do a one-time flash of the MCUboot loader? When I build an NCS project, is this not included directly? Do you know if there's a way to make this included in the compiled binary so that when anyone on the project builds/flashes, it automatically insures the devices has the MCU bootloader? Maybe you have links for where to figure this out? I was looking in the Zephyr docs (https://docs.zephyrproject.org/latest/boards/arm/nrf52840dongle_nrf52840/doc/index.html) and they were saying you need to modify the .dts files for the boards, which I would like to avoid doing...

  • The default method here is to enable MCUboot in a project, and then the project will be build as two parts: MCUboot and the application. Both these will be merged into merged.hex, which is automatically flashed to the nRF chip when you flash it.

    parksj10 said:
    Maybe you have links for where to figure this out? I was looking in the Zephyr docs (https://docs.zephyrproject.org/latest/boards/arm/nrf52840dongle_nrf52840/doc/index.html) and they were saying you need to modify the .dts files for the boards, which I would like to avoid doing...

    See official docs on bootloaders or my unofficial explanations.

    The nRF Connect SDK use the Partition Manager and Multi-Image builds to automatically handle a lot of this, so you would generally not need to do any of that yourself.

  • Thanks  , I pulled down the nrf connect template repo:

    Note I redacted main.c to the following to avoid build errors with other boards:

    /*
     * Copyright (c) 2021 Nordic Semiconductor ASA
     * SPDX-License-Identifier: Apache-2.0
     */
    
    #include <zephyr/kernel.h>
    #include <zephyr/drivers/sensor.h>
    #include <app_version.h>
    
    #include <zephyr/logging/log.h>
    LOG_MODULE_REGISTER(main, CONFIG_APP_LOG_LEVEL);
    
    int main(void)
    {
    	printk("Zephyr Example Application %s\n", APP_VERSION_STRING);
    
    	while (1)
    	{
    
    		k_sleep(K_MSEC(1000));
    	}
    
    	return 0;
    }
    


    It builds fine when I run
    west build -b nrf52840dk_nrf52840 app --pristine

    it also builds fine when I add the following configs to prj.conf:

    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_SECURE_BOOT=y

    However, when use the following command to build:

    west build -b nrf52840dongle_nrf52840 app --pristine

    I get this error output:

    ╰─ west build -b nrf52840dongle_nrf52840 app --pristine                                                               ─╯
    -- west build: making build dir /Users/josh/Code/hw/scratch/ncs-example-application/build pristine
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: /Users/josh/Code/hw/scratch/ncs-example-application/app
    -- CMake version: 3.27.3
    -- Using NCS Toolchain 2.5.20231017.141038581733 for building. (/opt/nordic/ncs/toolchains/20d68df7e5/cmake)
    -- Found Python3: /opt/nordic/ncs/toolchains/20d68df7e5/bin/python3 (found suitable version "3.9.6", minimum required is "3.8") found components: Interpreter 
    -- Cache files will be written to: /Users/josh/Library/Caches/zephyr
    -- Zephyr version: 3.4.99 (/Users/josh/Code/hw/scratch/ncs-example-application/zephyr)
    -- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
    -- Board: nrf52840dongle_nrf52840
    -- Found host-tools: zephyr 0.16.1 (/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.1 (/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk)
    -- Found Dtc: /opt/nordic/ncs/toolchains/20d68df7e5/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6") 
    -- Found BOARD.dts: /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/boards/arm/nrf52840dongle_nrf52840/nrf52840dongle_nrf52840.dts
    -- Generated zephyr.dts: /Users/josh/Code/hw/scratch/ncs-example-application/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /Users/josh/Code/hw/scratch/ncs-example-application/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /Users/josh/Code/hw/scratch/ncs-example-application/build/zephyr/dts.cmake
    Parsing /Users/josh/Code/hw/scratch/ncs-example-application/app/Kconfig
    Loaded configuration '/Users/josh/Code/hw/scratch/ncs-example-application/zephyr/boards/arm/nrf52840dongle_nrf52840/nrf52840dongle_nrf52840_defconfig'
    Merged configuration '/Users/josh/Code/hw/scratch/ncs-example-application/app/prj.conf'
    Configuration saved to '/Users/josh/Code/hw/scratch/ncs-example-application/build/zephyr/.config'
    Kconfig header saved to '/Users/josh/Code/hw/scratch/ncs-example-application/build/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38") 
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    CMake Warning at /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/subsys/usb/device/CMakeLists.txt:22 (message):
      CONFIG_USB_DEVICE_VID has default value 0x2FE3.
    
      This value is only for testing and MUST be configured for USB products.
    
    
    CMake Warning at /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/subsys/usb/device/CMakeLists.txt:28 (message):
      CONFIG_USB_DEVICE_PID has default value 0x100.
    
      This value is only for testing and MUST be configured for USB products.
    
    
    
    === child image b0 -  begin ===
    loading initial cache file /Users/josh/Code/hw/scratch/ncs-example-application/build/b0/child_image_preload.cmake
    Loading Zephyr default modules (Zephyr base).
    -- Application: /Users/josh/Code/hw/scratch/ncs-example-application/nrf/samples/bootloader
    -- CMake version: 3.27.3
    -- Using NCS Toolchain 2.5.20231017.141038581733 for building. (/opt/nordic/ncs/toolchains/20d68df7e5/cmake)
    -- Found Python3: /opt/nordic/ncs/toolchains/20d68df7e5/bin/python3 (found suitable version "3.9.6", minimum required is "3.8") found components: Interpreter 
    -- Cache files will be written to: /Users/josh/Library/Caches/zephyr
    -- Zephyr version: 3.4.99 (/Users/josh/Code/hw/scratch/ncs-example-application/zephyr)
    -- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
    -- Board: nrf52840dongle_nrf52840
    -- Found host-tools: zephyr 0.16.1 (/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.1 (/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk)
    -- Found Dtc: /opt/nordic/ncs/toolchains/20d68df7e5/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6") 
    -- Found BOARD.dts: /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/boards/arm/nrf52840dongle_nrf52840/nrf52840dongle_nrf52840.dts
    -- Generated zephyr.dts: /Users/josh/Code/hw/scratch/ncs-example-application/build/b0/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /Users/josh/Code/hw/scratch/ncs-example-application/build/b0/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /Users/josh/Code/hw/scratch/ncs-example-application/build/b0/zephyr/dts.cmake
    
    warning: HW_STACK_PROTECTION (defined at arch/Kconfig:264) was assigned the value 'y' but got the
    value 'n'. Check these unsatisfied dependencies: ARCH_HAS_STACK_PROTECTION (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_HW_STACK_PROTECTION and/or look up
    HW_STACK_PROTECTION in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.
    
    Parsing /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/Kconfig
    Loaded configuration '/Users/josh/Code/hw/scratch/ncs-example-application/zephyr/boards/arm/nrf52840dongle_nrf52840/nrf52840dongle_nrf52840_defconfig'
    Merged configuration '/Users/josh/Code/hw/scratch/ncs-example-application/nrf/samples/bootloader/prj.conf'
    Merged configuration '/Users/josh/Code/hw/scratch/ncs-example-application/nrf/subsys/partition_manager/partition_manager_enabled.conf'
    Merged configuration '/Users/josh/Code/hw/scratch/ncs-example-application/build/b0/zephyr/misc/generated/extra_kconfig_options.conf'
    Configuration saved to '/Users/josh/Code/hw/scratch/ncs-example-application/build/b0/zephyr/.config'
    Kconfig header saved to '/Users/josh/Code/hw/scratch/ncs-example-application/build/b0/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38") 
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    CMake Warning at /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/subsys/usb/device/CMakeLists.txt:22 (message):
      CONFIG_USB_DEVICE_VID has default value 0x2FE3.
    
      This value is only for testing and MUST be configured for USB products.
    
    
    CMake Warning at /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/subsys/usb/device/CMakeLists.txt:28 (message):
      CONFIG_USB_DEVICE_PID has default value 0x100.
    
      This value is only for testing and MUST be configured for USB products.
    
    
    CMake Warning at /Users/josh/Code/hw/scratch/ncs-example-application/nrf/lib/flash_patch/CMakeLists.txt:8 (message):
      
    
            ----------------------------------------------------------
            --- WARNING: To maintain the integrity of secure boot, ---
            --- enable CONFIG_DISABLE_FLASH_PATCH in production.   ---
            ----------------------------------------------------------
    
    
    -- Configuring done (3.7s)
    -- Generating done (0.1s)
    -- Build files have been written to: /Users/josh/Code/hw/scratch/ncs-example-application/build/b0
    === child image b0 -  end ===
    
    CMake Warning at /Users/josh/Code/hw/scratch/ncs-example-application/nrf/subsys/bootloader/cmake/debug_keys.cmake:36 (message):
      
    
          --------------------------------------------------------------
          --- WARNING: Using generated NSIB public/private key-pair. ---
          --- It should not be used for production.                  ---
          --- See CONFIG_SB_SIGNING_KEY_FILE                         ---
          --------------------------------------------------------------
          
    
    Call Stack (most recent call first):
      /Users/josh/Code/hw/scratch/ncs-example-application/nrf/subsys/bootloader/cmake/provision_hex.cmake:47 (include)
      /Users/josh/Code/hw/scratch/ncs-example-application/nrf/subsys/CMakeLists.txt:20 (include)
    
    
    -- Found Python3: /opt/nordic/ncs/toolchains/20d68df7e5/bin/python3 (found version "3.9.6") found components: Interpreter 
    
    === child image mcuboot -  begin ===
    loading initial cache file /Users/josh/Code/hw/scratch/ncs-example-application/build/mcuboot/child_image_preload.cmake
    Loading Zephyr default modules (Zephyr base).
    -- Application: /Users/josh/Code/hw/scratch/ncs-example-application/bootloader/mcuboot/boot/zephyr
    -- CMake version: 3.27.3
    -- Using NCS Toolchain 2.5.20231017.141038581733 for building. (/opt/nordic/ncs/toolchains/20d68df7e5/cmake)
    -- Found Python3: /opt/nordic/ncs/toolchains/20d68df7e5/bin/python3 (found suitable version "3.9.6", minimum required is "3.8") found components: Interpreter 
    -- Cache files will be written to: /Users/josh/Library/Caches/zephyr
    -- Zephyr version: 3.4.99 (/Users/josh/Code/hw/scratch/ncs-example-application/zephyr)
    -- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
    -- Board: nrf52840dongle_nrf52840
    -- Found host-tools: zephyr 0.16.1 (/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.1 (/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk)
    -- Found Dtc: /opt/nordic/ncs/toolchains/20d68df7e5/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6") 
    -- Found BOARD.dts: /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/boards/arm/nrf52840dongle_nrf52840/nrf52840dongle_nrf52840.dts
    -- Found devicetree overlay: /Users/josh/Code/hw/scratch/ncs-example-application/nrf/modules/mcuboot/usb.overlay
    -- Generated zephyr.dts: /Users/josh/Code/hw/scratch/ncs-example-application/build/mcuboot/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /Users/josh/Code/hw/scratch/ncs-example-application/build/mcuboot/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /Users/josh/Code/hw/scratch/ncs-example-application/build/mcuboot/zephyr/dts.cmake
    
    warning: LOG_DEFAULT_LEVEL (defined at subsys/logging/Kconfig.filtering:13) was assigned the value
    '0' but got the value ''. Check these unsatisfied dependencies: LOG (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_DEFAULT_LEVEL and/or look up
    LOG_DEFAULT_LEVEL in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.
    
    
    warning: USB_COMPOSITE_DEVICE (defined at subsys/usb/device/Kconfig:51) was assigned the value 'n'
    but got the value 'y'. See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_USB_COMPOSITE_DEVICE and/or look up
    USB_COMPOSITE_DEVICE in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.
    
    
    warning: The choice symbol MCUBOOT_LOG_LEVEL_INF (defined at
    subsys/logging/Kconfig.template.log_config:17) was selected (set =y), but no symbol ended up as the
    choice selection. See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_MCUBOOT_LOG_LEVEL_INF
    and/or look up MCUBOOT_LOG_LEVEL_INF in the menuconfig/guiconfig interface. The Application
    Development Primer, Setting Configuration Values, and Kconfig - Tips and Best Practices sections of
    the manual might be helpful too.
    
    
    warning: The choice symbol LOG_MODE_MINIMAL (defined at subsys/logging/Kconfig.mode:28) was selected
    (set =y), but no symbol ended up as the choice selection. See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_MODE_MINIMAL and/or look up
    LOG_MODE_MINIMAL in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.
    
    Parsing /Users/josh/Code/hw/scratch/ncs-example-application/bootloader/mcuboot/boot/zephyr/Kconfig
    Loaded configuration '/Users/josh/Code/hw/scratch/ncs-example-application/zephyr/boards/arm/nrf52840dongle_nrf52840/nrf52840dongle_nrf52840_defconfig'
    Merged configuration '/Users/josh/Code/hw/scratch/ncs-example-application/bootloader/mcuboot/boot/zephyr/prj.conf'
    Merged configuration '/Users/josh/Code/hw/scratch/ncs-example-application/bootloader/mcuboot/boot/zephyr/boards/nrf52840dongle_nrf52840.conf'
    Merged configuration '/Users/josh/Code/hw/scratch/ncs-example-application/nrf/subsys/bootloader/image/multi_image_mcuboot.conf'
    Merged configuration '/Users/josh/Code/hw/scratch/ncs-example-application/nrf/subsys/bootloader/image/fw_info.conf'
    Merged configuration '/Users/josh/Code/hw/scratch/ncs-example-application/nrf/subsys/partition_manager/partition_manager_enabled.conf'
    Merged configuration '/Users/josh/Code/hw/scratch/ncs-example-application/build/mcuboot/zephyr/misc/generated/extra_kconfig_options.conf'
    Configuration saved to '/Users/josh/Code/hw/scratch/ncs-example-application/build/mcuboot/zephyr/.config'
    Kconfig header saved to '/Users/josh/Code/hw/scratch/ncs-example-application/build/mcuboot/zephyr/include/generated/autoconf.h'
    -- Found GnuLd: /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd (found version "2.38") 
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    CMake Warning at /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/subsys/usb/device/CMakeLists.txt:22 (message):
      CONFIG_USB_DEVICE_VID has default value 0x2FE3.
    
      This value is only for testing and MUST be configured for USB products.
    
    
    CMake Warning at /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/subsys/usb/device/CMakeLists.txt:28 (message):
      CONFIG_USB_DEVICE_PID has default value 0x100.
    
      This value is only for testing and MUST be configured for USB products.
    
    
    CMake Warning at /Users/josh/Code/hw/scratch/ncs-example-application/nrf/lib/flash_patch/CMakeLists.txt:8 (message):
      
    
            ----------------------------------------------------------
            --- WARNING: To maintain the integrity of secure boot, ---
            --- enable CONFIG_DISABLE_FLASH_PATCH in production.   ---
            ----------------------------------------------------------
    
    
    MCUBoot bootloader key file: /Users/josh/Code/hw/scratch/ncs-example-application/bootloader/mcuboot/root-ec-p256.pem
    -- Configuring done (3.8s)
    -- Generating done (0.1s)
    -- Build files have been written to: /Users/josh/Code/hw/scratch/ncs-example-application/build/mcuboot
    === child image mcuboot -  end ===
    
    CMake Warning at /Users/josh/Code/hw/scratch/ncs-example-application/nrf/modules/mcuboot/CMakeLists.txt:320 (message):
      
    
              ---------------------------------------------------------
              --- WARNING: Using default MCUBoot key, it should not ---
              --- be used for production.                           ---
              ---------------------------------------------------------
              
    
    
    
    CMake Warning at /Users/josh/Code/hw/scratch/ncs-example-application/nrf/cmake/partition_manager.cmake:79 (message):
      
    
              ---------------------------------------------------------------------
              --- WARNING: Using a bootloader without pm_static.yml.            ---
              --- There are cases where a deployed product can consist of       ---
              --- multiple images, and only a subset of these images can be     ---
              --- upgraded through a firmware update mechanism. In such cases,  ---
              --- the upgradable images must have partitions that are static    ---
              --- and are matching the partition map used by the bootloader     ---
              --- programmed onto the device.                                   ---
              ---------------------------------------------------------------------
              
    
    Call Stack (most recent call first):
      /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/cmake/modules/kernel.cmake:247 (include)
      /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/cmake/modules/zephyr_default.cmake:138 (include)
      /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:8 (find_package)
    
    
    Traceback (most recent call last):
      File "/Users/josh/Code/hw/scratch/ncs-example-application/nrf/scripts/partition_manager.py", line 2045, in <module>
        main()
      File "/Users/josh/Code/hw/scratch/ncs-example-application/nrf/scripts/partition_manager.py", line 1034, in main
        solution.update(solve_region(pm_config, region, region_config,
      File "/Users/josh/Code/hw/scratch/ncs-example-application/nrf/scripts/partition_manager.py", line 977, in solve_region
        get_region_config(partitions, region_config, static_partitions, system_reqs=pm_config)
      File "/Users/josh/Code/hw/scratch/ncs-example-application/nrf/scripts/partition_manager.py", line 764, in get_region_config
        solve_complex_region(pm_config, start, size, placement_strategy, region_name, device, static_conf, dp, system_reqs)
      File "/Users/josh/Code/hw/scratch/ncs-example-application/nrf/scripts/partition_manager.py", line 871, in solve_complex_region
        solution, sub_partitions = resolve(pm_config, dp, system_reqs)
      File "/Users/josh/Code/hw/scratch/ncs-example-application/nrf/scripts/partition_manager.py", line 313, in resolve
        solve_direction(reqs, sub_partitions, unsolved, solution, 'after')
      File "/Users/josh/Code/hw/scratch/ncs-example-application/nrf/scripts/partition_manager.py", line 199, in solve_direction
        anchor = current if current in solution else next(solved for solved in reversed(solution)
    StopIteration
    CMake Error at /Users/josh/Code/hw/scratch/ncs-example-application/nrf/cmake/partition_manager.cmake:323 (message):
      Partition Manager failed, aborting.  Command:
      /opt/nordic/ncs/toolchains/20d68df7e5/bin/python3;/Users/josh/Code/hw/scratch/ncs-example-application/nrf/scripts/partition_manager.py;--input-files;/Users/josh/Code/hw/scratch/ncs-example-application/build/b0/zephyr/include/generated/pm.yml;/Users/josh/Code/hw/scratch/ncs-example-application/build/b0/modules/nrf/subsys/partition_manager/pm.yml.nrf5_mbr;/Users/josh/Code/hw/scratch/ncs-example-application/build/b0/modules/nrf/subsys/partition_manager/pm.yml.secure_boot_storage;/Users/josh/Code/hw/scratch/ncs-example-application/build/mcuboot/zephyr/include/generated/pm.yml;/Users/josh/Code/hw/scratch/ncs-example-application/build/mcuboot/modules/nrf/subsys/partition_manager/pm.yml.nrf5_mbr;/Users/josh/Code/hw/scratch/ncs-example-application/build/zephyr/include/generated/pm.yml;/Users/josh/Code/hw/scratch/ncs-example-application/build/modules/nrf/subsys/partition_manager/pm.yml.nrf5_mbr;--regions;sram_primary;flash_primary;--output-partitions;/Users/josh/Code/hw/scratch/ncs-example-application/build/partitions.yml;--output-regions;/Users/josh/Code/hw/scratch/ncs-example-application/build/regions.yml;--sram_primary-size;0x40000;--sram_primary-base-address;0x20000000;--sram_primary-placement-strategy;complex;--sram_primary-dynamic-partition;sram_primary;--flash_primary-size;0x100000;--flash_primary-base-address;0x0;--flash_primary-placement-strategy;complex;--flash_primary-device;flash_controller;--flash_primary-default-driver-kconfig;CONFIG_SOC_FLASH_NRF
    Call Stack (most recent call first):
      /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/cmake/modules/kernel.cmake:247 (include)
      /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/cmake/modules/zephyr_default.cmake:138 (include)
      /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      /Users/josh/Code/hw/scratch/ncs-example-application/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:8 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: /Users/josh/.pyenv/shims/cmake -DWEST_PYTHON=/Users/josh/.pyenv/versions/3.9.6/Library/Frameworks/Python.framework/Versions/3.9/bin/python -B/Users/josh/Code/hw/scratch/ncs-example-application/build -GNinja -DBOARD=nrf52840dongle_nrf52840 -S/Users/josh/Code/hw/scratch/ncs-example-application/app
                                                                                                                      ─╯

    this seems to be board specific, but I can't identify what the issue is... and it still seems like it will build an image that isn't compatible with external debuggers unless I use fstab_debugger.dtsi based on this comment

    Also note, when I only have CONFIG_BOOTLOADER_MCUBOOT=y enabled, the dongle still fails to build with a different error, 

    /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/zephyr_pre0.elf section `text' will not fit in region `FLASH'
    /opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: region `FLASH' overflowed by 10972 bytes
    collect2: error: ld returned 1 exit status

    making me thing it's a dongle dts error, perhaps something like this?:

    Noting for later: seems like the dongle has a smaller partition for boot than the dk. Initial attempts at manually changing map in nrf local west folder fstab-stock.dtsi did not help...

    ..

    ..

    ..

    Note: in order to make this more easy for you to reproduce, simply pull down this repo:
    https://github.com/parksj10/nrfdongle_build_error/tree/main

    and follow the README...

    Digging farther, it seems like A) there's a misconfiguration in the dongle dts's somewhere (, or b) there is a bug in the partition_manager.py

  • parksj10 said:
    I pulled down the nrf connect template repo:

    Can you link to the repo?

Related