unable to program Arduino Nano 33 BLE using JTAG

Hi,

I have a JLINK JTAG connected to Arduino Nano 33 BLE and able to connect and flash from JLINK application.

In NRF Connect I see the connection detected.

When trying to flash (Blinky) I have errors

Flashing build to 260111299
west flash -d d:\2023\projects\Nordic\blinky2\build --skip-rebuild -r nrfjprog --dev-id 260111299

-- west flash: using runner nrfjprog
FATAL ERROR: board arduino_nano_33_ble does not support runner nrfjprog
To fix, configure this runner in C:\ncs\v2.3.0\zephyr\boards\arm\arduino_nano_33_ble\board.cmake and rebuild.

How to configure board.cmake? I was trying to modify it but no change.

Kindly advice

I modify board.cmake and restarted, but no luck, no change

# SPDX-License-Identifier: Apache-2.0

board_runner_args(jlink "--device=nRF52840_xxAA" "--speed=4000")
board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000")
board_runner_args(blackmagicprobe "--gdb-serial=/dev/ttyBmpGdb")
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake)

Parents
  • Hello,

    One option is to use nrfjprog directly, instead of west flash. 

    But if you want to use west flash, did you try to copy from the board.cmake for nrf52840dk_nrf52840:

    # SPDX-License-Identifier: Apache-2.0
    
    board_runner_args(jlink "--device=nRF52840_xxAA" "--speed=4000")
    board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000")
    include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/openocd-nrf5.board.cmake)
    

    Let me know if it doesn't work.

    Best regards,

    Edvin

  •   

    Thanks for responding.I'm using VSCode with nRFConnect on Windows. there is a button

    Everything works with nrf52840 evalution board

    after clicking flash i see in terminal

    west flash -d d:\2023\projects\Nordic\blinky1\build --skip-rebuild -r nrfjprog --dev-id 683340261

    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: Flashing file: d:\2023\projects\Nordic\blinky1\build\zephyr\zephyr.hex
    Parsing image file.
    Verifying programming.
    Verified OK.
    Enabling pin reset.
    Applying pin reset.
    -- runners.nrfjprog: Board with serial number 683340261 flashed successfully.

    Step 2 - using Arduino Nano 33 BLE

    build works well:

    ....

    163/167] Generating isr_tables.c, isrList.bin
    [164/167] Building C object zephyr/CMakeFiles/zephyr_final.dir/dev_handles.c.obj
    [165/167] Building C object zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj
    [166/167] Building C object zephyr/CMakeFiles/zephyr_final.dir/misc/empty_file.c.obj
    [167/167] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       27448 B       928 KB      2.89%
                 RAM:        6400 B       256 KB      2.44%
            IDT_LIST:          0 GB         2 KB      0.00%
     *  Terminal will be reused by tasks, press any key to close it.

    Trying to flash:

    Flashing build to 260111299
    west flash -d d:\2023\projects\Nordic\blinky2\build --skip-rebuild -r nrfjprog --dev-id 260111299 --erase

    -- west flash: using runner nrfjprog
    FATAL ERROR: board arduino_nano_33_ble does not support runner nrfjprog
    To fix, configure this runner in C:\ncs\v2.3.0\zephyr\boards\arm\arduino_nano_33_ble\board.cmake and rebuild.

     *  The terminal process terminated with exit code: 1.
     *  Terminal will be reused by tasks, press any key to close it.

    original board.cmake (located in C:\ncs\v2.3.0\zephyr\boards\arm\arduino_nano_33_ble0 is:

    # SPDX-License-Identifier: Apache-2.0

    board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000")
    board_runner_args(trace32
      "--startup-args"
        "elfFile=${PROJECT_BINARY_DIR}/${KERNEL_ELF_NAME}"
    )

    include(${ZEPHYR_BASE}/boards/common/bossac.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/trace32.board.cmake)

    After changing it to suggested by you:

    # SPDX-License-Identifier: Apache-2.0

    board_runner_args(jlink "--device=nRF52840_xxAA" "--speed=4000")
    board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000")
    include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/openocd-nrf5.board.cmake)

    rebuilding and...

    ...

    -- Configuring incomplete, errors occurred!
    See also "D:/2023/projects/Nordic/blinky2/build/CMakeFiles/CMakeOutput.log".
    See also "D:/2023/projects/Nordic/blinky2/build/CMakeFiles/CMakeError.log".
    FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.3.0\opt\bin\cmake.EXE' '-DWEST_PYTHON=c:\ncs\toolchains\v2.3.0\opt\bin\python.exe' '-Bd:\2023\projects\Nordic\blinky2\build' -GNinja -DBOARD=arduino_nano_33_ble -DNCS_TOOLCHAIN_VERSION:STRING=NONE -DCONF_FILE:STRING=d:/2023/projects/Nordic/blinky2/prj.conf '-Sd:\2023\projects\Nordic\blinky2'

    REBUILD UNSUCCESSFUL

    going back to original board.cmake - build successful, flashing error

    1. Kindly advice of possible fix

    2. How to invoke nrfjprog from Terminal ti perform flashing for this specific case?

    Cheers,

    Jan

  • Well, the flash error comes because it can't communicate it believe that it can, according to the board files.

    The build error I am not sure. Can you please copy/save the entire build log and upload it here?

    Janek said:
    2. How to invoke nrfjprog from Terminal ti perform flashing for this specific case?

    Just use either the terminal from your screenshot (the one that says "press any key to close it"), or another terminal open in the same folder as your project on your computer, and write:

    nrfjprog --program build\zephyr\zephyr.hex --verify --reset

    Best regards,

    Edvin

  •  Executing task: nRF Connect: Build [pristine]: blinky2/build (active)

    Building blinky2
    west build --build-dir d:\2023\projects\Nordic\blinky2\build d:\2023\projects\Nordic\blinky2 --pristine --board arduino_nano_33_ble -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DCONF_FILE:STRING="d:/2023/projects/Nordic/blinky2/prj.conf"

    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: D:/2023/projects/Nordic/blinky2
    -- Found Python3: C:/ncs/toolchains/v2.3.0/opt/bin/python.exe (found suitable exact version "3.8.2") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v2.3.0/zephyr/.cache
    -- Zephyr version: 3.2.99 (C:/ncs/v2.3.0/zephyr)
    -- Found west (found suitable version "0.14.0", minimum required is "0.7.1")
    -- Board: arduino_nano_33_ble
    -- Found host-tools: zephyr 0.15.2 (C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.15.2 (C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk)
    -- Found Dtc: C:/ncs/toolchains/v2.3.0/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/ncs/v2.3.0/zephyr/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble.dts
    -- Generated zephyr.dts: D:/2023/projects/Nordic/blinky2/build/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: D:/2023/projects/Nordic/blinky2/build/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: D:/2023/projects/Nordic/blinky2/build/zephyr/dts.cmake
    Parsing C:/ncs/v2.3.0/zephyr/Kconfig
    Loaded configuration 'C:/ncs/v2.3.0/zephyr/boards/arm/arduino_nano_33_ble/arduino_nano_33_ble_defconfig'
    Merged configuration 'd:/2023/projects/Nordic/blinky2/prj.conf'
    Configuration saved to 'D:/2023/projects/Nordic/blinky2/build/zephyr/.config'
    Kconfig header saved to 'D:/2023/projects/Nordic/blinky2/build/zephyr/include/generated/autoconf.h'
    -- The C compiler identification is GNU 12.1.0
    -- The CXX compiler identification is GNU 12.1.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    CMake Error at C:/ncs/v2.3.0/zephyr/boards/common/openocd-nrf5.board.cmake:13 (message):
      Can't match nrf5 subfamily from BOARD name.  To fix, set CMake variable
      OPENOCD_NRF5_SUBFAMILY.
    Call Stack (most recent call first):
      C:/ncs/v2.3.0/zephyr/boards/arm/arduino_nano_33_ble/board.cmake:8 (include)
      C:/ncs/v2.3.0/zephyr/cmake/modules/kernel.cmake:169 (include)
      C:/ncs/v2.3.0/zephyr/cmake/modules/zephyr_default.cmake:117 (include)
      C:/ncs/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      C:/ncs/v2.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:4 (find_package)


    -- Configuring incomplete, errors occurred!
    See also "D:/2023/projects/Nordic/blinky2/build/CMakeFiles/CMakeOutput.log".
    See also "D:/2023/projects/Nordic/blinky2/build/CMakeFiles/CMakeError.log".
    FATAL ERROR: command exited with status 1: 'c:\ncs\toolchains\v2.3.0\opt\bin\cmake.EXE' '-DWEST_PYTHON=c:\ncs\toolchains\v2.3.0\opt\bin\python.exe' '-Bd:\2023\projects\Nordic\blinky2\build' -GNinja -DBOARD=arduino_nano_33_ble -DNCS_TOOLCHAIN_VERSION:STRING=NONE -DCONF_FILE:STRING=d:/2023/projects/Nordic/blinky2/prj.conf '-Sd:\2023\projects\Nordic\blinky2'

     *  The terminal process terminated with exit code: 1.
     *  Terminal will be reused by tasks, press any key to close it.

    ______________________________

    CMakeErrorLog

    Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
    Compiler: C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    Build flags:
    Id flags:  

    The output was:
    1
    c:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: c:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/lib\libc.a(lib_a-exit.o): in function `exit':
    exit.c:(.text.exit+0x34): undefined reference to `_exit'
    collect2.exe: error: ld returned 1 exit status


    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
    Compiler: C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    Build flags:
    Id flags:  

    The output was:
    1
    c:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/bin/ld.exe: c:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.1.0/../../../../arm-zephyr-eabi/lib\libc.a(lib_a-exit.o): in function `exit':
    exit.c:(.text.exit+0x34): undefined reference to `_exit'
    collect2.exe: error: ld returned 1 exit status

    __________________________________

    CMakeOutput.log

    The target system is: Generic - 3.2.99 - arm
    The host system is: Windows - 10.0.19045 - AMD64
    Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded.
    Compiler: C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    Build flags:
    Id flags: -c

    The output was:
    0


    Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "CMakeCCompilerId.o"

    The C compiler identification is GNU, found in "D:/2023/projects/Nordic/blinky2/build/CMakeFiles/3.20.5/CompilerIdC/CMakeCCompilerId.o"

    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded.
    Compiler: C:/ncs/toolchains/v2.3.0/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    Build flags:
    Id flags: -c

    The output was:
    0


    Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "CMakeCXXCompilerId.o"

    The CXX compiler identification is GNU, found in "D:/2023/projects/Nordic/blinky2/build/CMakeFiles/3.20.5/CompilerIdCXX/CMakeCXXCompilerId.o"

    Checking whether the ASM compiler is GNU using "--version" matched "(GNU assembler)|(GCC)|(Free Software Foundation)":
    arm-zephyr-eabi-gcc.exe (Zephyr SDK 0.15.2) 12.1.0
    Copyright (C) 2022 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  •  

    To save our time, I think I use nrf52840dk_nrf52840 for development and after done, I will flash the code into Arduino Nano 33 BLE board using programmer (JLink or nrfjprog) Maybe with a new release of tools things will be fixed.

    Thanks for your support.

    Cheers

    Jan

  • Hello Jan,

    I see. However, I found some time to test now. 

    By just copying the board.cmake file from the nrf52840dk_nrf52840 board, I got the same build error as you posted. The reason is that "nrf5" is not part of the board name. This is checked in NCS\zephyr\boards\common\openocd-nrf5.board.cmake on line 11. 

    So to work around this, you also need to add this line:

    set(OPENOCD_NRF5_SUBFAMILY "nrf52")
    So I ended up with the following board.cmake file:
    # SPDX-License-Identifier: Apache-2.0
    
    set(OPENOCD_NRF5_SUBFAMILY "nrf52")
    board_runner_args(jlink "--device=nRF52840_xxAA" "--speed=4000")
    board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000")
    include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
    include(${ZEPHYR_BASE}/boards/common/openocd-nrf5.board.cmake)
    When using this, I could flash the nrf52840 dk with an application built for the arduino nano 33 BLE board, and it was flashed using nrfjprog.
    However, in general we recommend to keep the SDK pristine. So what I would suggest is that you copy the board files for the arduino nano out of the SDK, rename it to something custom, modify those local files, and then you can build for your "custom board". However, that is entirely up to you how you want to do it. 
    Best regards,
    Edvin
  •   

    Hi Edmin,

    Thanks, much appreciate your help. Hope the solution will serve other users as well.

    I will follow the "custom board" solution and follow it.

    Consider the case as resolved.

    Cheer,

    Jan

Reply Children
No Data
Related