Unable to flash nrf5340.bin in the Getting Started example

I have tried another nRF5340DK board, I got the same error and same testing result.

Is it because of the jumper on the shield X-NUCLEO-IKS02A1? The shiled comes with this jumper, I didn’t change any. Should I change some?

Another thing I notice that both the tutorial and others comments seems has three ports shown up when running edge-impulse-run-impulse --raw or edge-impulse-daemon
But I only have two ports to choose(shown below).

Edge Impulse serial daemon v1.19.3
Endpoints:
    Websocket: wss://remote-mgmt.edgeimpulse.com
    API:       https://studio.edgeimpulse.com
    Ingestion: https://ingestion.edgeimpulse.com

? Which device do you want to connect to? (Use arrow keys)
> COM3 (SEGGER)
  COM7 (SEGGER)

Does this matter?

Hi!
I have the same issue as @Yang1991. I already tried multiple times flashing the precompiled bin and hex files but no luck at all. Connecting to first COM port, I have a Hello message from the Edge Impulse Device SDK.

1 Like

@Yang1991 ,
It looks like your QSPI Flash is fine and there shouldn’t be any problems with our firmware.
The QSPI Flash on the nRF5340DK doesn’t share any pins with Arduino connectors, so the presence of the Nucleo sensor board doesn’t impact communication with QSPI Flash.

Matt

@svenkada
Did you also try to erase the QSPI by nrfjprog and run the QSPI example from NCS?

Matt

@Yang1991 and @svenkada
Could you try to clear your boards with:

nrfjprog --recover

And then flash our pre-built firmware once again? Try to do it with nrfjprog:

nrfjprog -f NRF53 --program nrf5340-dk.hex --chiperase --reset

Then, open last enumerated serial port with any serial terminal (like picocom or minicom or Serial Terminal from nRF Connect Desktop tool), press RESET on the board and paste here your output.

Best regards,
Matt

nrfjprog --recover
Recovering device. This operation might take 30s.
Erasing user code and UICR flash areas.
Writing image to disable ap protect.
 nrfjprog -f NRF53 --program nrf5340-dk.hex --chiperase --reset
[ #################### ]   0.503s | Erase file - Done erasing
[ #################### ]   2.159s | Program file - Done programming
WARNING: A programming operation has been performed without --verify.
WARNING: Programming can fail without error.
Applying system reset.
Run.

I have used nRF Terminal plugin which adds serial connection options.
I have connected Serial terminal to COM7(which is the last enumerated serial port) which has the following configuration:

  • Baud rate: 115200 baud/sec
  • 8 bits/character, no parity, 1 stop bit (8n1)

I got following when RESET on the board is pressed.

*** Booting Zephyr OS build v2.7.99-ncs1-1  ***
Using flash device: MX25R64
Hello from Edge Impulse Device SDK.
Compiled on May 27 2022 14:14:05

Then I run edge-impulse-daemon, I still get following errors

edge-impulse-daemon
Edge Impulse serial daemon v1.19.3
Endpoints:
    Websocket: wss://remote-mgmt.edgeimpulse.com
    API:       https://studio.edgeimpulse.com
    Ingestion: https://ingestion.edgeimpulse.com

? Which device do you want to connect to? COM7 (SEGGER)
[SER] Connecting to COM7
[SER] Serial is connected, trying to read config...
[SER] Failed to get info off device Timeout when waiting for >  (timeout: 5000) onConnected
[SER] Serial is connected, trying to read config...
[SER] Failed to get info off device Timeout when waiting for >  (timeout: 5000) onConnected
[SER] Serial is connected, trying to read config...
[SER] Failed to get info off device Timeout when waiting for >  (timeout: 5000) onConnected
[SER] Serial is connected, trying to read config...

@mateusz Is there any place that I can download the source code for building nrf5340-dk.hex

I would like to add more logs to the code and check which parts went wrong.

Hi @Yang1991 ,

This issue you are having looks related to external memory, and we need to figure out what is the problem.
The previously proposed test works ok with my board.
Form the same test we can see that your board flashes, it starts the zephyr application, but for some reason it stops running. To me this looks like an issue with external memory but, you did the tests with zephyr samples and saw that there is correct communication with external memory.
I agree with you that best would be to compile the firmware on your machine and add some logs to see where the problem could be…
The nRF53-DK firmware is here: GitHub - edgeimpulse/firmware-nordic-nrf52840dk-nrf5340dk: Edge Impulse firmware for nRF52840 DK and nRF5340 DK
Please compile it with NCS 1.9.1 and try to run.
Also it could be helpful if you could debug the board (it is quite easy setup from VS Code) and see where it brakes.
One more thing please double check if there are some physical changes to jumpers connecting MCU with the external memory like described here → Nordic Semiconductor Infocenter
and if the SW6 is in the right position.

Let us know what are the results…

Cheers,
vojislav

Also when building try changing thins line https://github.com/edgeimpulse/firmware-nordic-nrf52840dk-nrf5340dk/blob/master/edge-impulse/ingestion-sdk-platform/NordicSemi-nrf52/ei_zephyr_flash_commands.cpp#L18
from:
#define SAMPLE_MEMORY SERIAL_FLASH

to:
#define SAMPLE_MEMORY RAM

so external flash is not used.

Hi,

I just post my progress here along with my questions.

I am switching to linux machine now. I just set up all the environment and start debug again.

I started with building this firmware-nrf52840-5340 with ncs at version 2.4.0. Because this is what I will use in my later project. I will also post my log when I switch ncs to 1.9.0 as suggested. In both situation, I have runned into problems when building. I hope you can figure out which step goes wrong

Below shows the building log message when I use ncs with version 1.9.0.

Building firmware-nrf52840-5340
/bin/sh -c west build --build-dir /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2 /home/yyu/TAM/T83_board/firmware-nrf52840-5340 --pristine --board nrf5340dk_nrf5340_cpuapp_ns --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DBOARD_ROOT:STRING="/home/yyu/TAM/T83_board/firmware-nrf52840-5340" -DCONF_FILE:STRING="/home/yyu/TAM/T83_board/firmware-nrf52840-5340/prj.conf"

-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/yyu/TAM/T83_board/firmware-nrf52840-5340
-- CMake version: 3.24.4
-- Found Python3: /home/yyu/anaconda3/envs/py3/bin/python3.9 (found suitable exact version "3.9.5") found components: Interpreter 
-- Cache files will be written to: /home/yyu/.cache/zephyr
-- Zephyr version: 3.3.99 (/home/yyu/ncs/zephyr)
-- Found west (found suitable version "1.1.0", minimum required is "0.7.1")
-- Board: nrf5340dk_nrf5340_cpuapp_ns
-- Found host-tools: zephyr 0.16.1 (/home/yyu/zephyr-sdk-0.16.1)
-- Found toolchain: zephyr 0.16.1 (/home/yyu/zephyr-sdk-0.16.1)
-- Found Dtc: /home/yyu/zephyr-sdk-0.16.1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/yyu/ncs/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp_ns.dts
-- Generated zephyr.dts: /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/zephyr/dts.cmake

warning: Deprecated symbol CPLUSPLUS is enabled.


warning: Deprecated symbol LIB_CPLUSPLUS is enabled.

Parsing /home/yyu/TAM/T83_board/firmware-nrf52840-5340/Kconfig
Loaded configuration '/home/yyu/ncs/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpuapp_ns_defconfig'
Merged configuration '/home/yyu/TAM/T83_board/firmware-nrf52840-5340/prj.conf'
Configuration saved to '/home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/zephyr/.config'
Kconfig header saved to '/home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/zephyr/include/generated/autoconf.h'
-- Found GnuLd: /home/yyu/zephyr-sdk-0.16.1/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: /home/yyu/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc

=== child image hci_rpmsg - CPUNET begin ===
loading initial cache file /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/hci_rpmsg/child_image_preload.cmake
Loading Zephyr default modules (Zephyr base).
-- Application: /home/yyu/ncs/zephyr/samples/bluetooth/hci_rpmsg
-- CMake version: 3.24.4
-- Found Python3: /home/yyu/anaconda3/envs/py3/bin/python3.9 (found suitable exact version "3.9.5") found components: Interpreter 
-- Cache files will be written to: /home/yyu/.cache/zephyr
-- Zephyr version: 3.3.99 (/home/yyu/ncs/zephyr)
-- Found west (found suitable version "1.1.0", minimum required is "0.7.1")
-- Board: nrf5340dk_nrf5340_cpunet
-- Found host-tools: zephyr 0.16.1 (/home/yyu/zephyr-sdk-0.16.1)
-- Found toolchain: zephyr 0.16.1 (/home/yyu/zephyr-sdk-0.16.1)
-- Found Dtc: /home/yyu/zephyr-sdk-0.16.1/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6") 
-- Found BOARD.dts: /home/yyu/ncs/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpunet.dts
-- Generated zephyr.dts: /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/hci_rpmsg/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/hci_rpmsg/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/hci_rpmsg/zephyr/dts.cmake
Parsing /home/yyu/ncs/zephyr/Kconfig
Loaded configuration '/home/yyu/ncs/zephyr/boards/arm/nrf5340dk_nrf5340/nrf5340dk_nrf5340_cpunet_defconfig'
Merged configuration '/home/yyu/ncs/zephyr/samples/bluetooth/hci_rpmsg/prj.conf'
Merged configuration '/home/yyu/ncs/nrf/subsys/partition_manager/partition_manager_enabled.conf'
Configuration saved to '/home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/hci_rpmsg/zephyr/.config'
Kconfig header saved to '/home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/hci_rpmsg/zephyr/include/generated/autoconf.h'
-- Found GnuLd: /home/yyu/zephyr-sdk-0.16.1/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: /home/yyu/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- libmetal version: 1.3.0 (/home/yyu/ncs/zephyr/samples/bluetooth/hci_rpmsg)
-- Build type:  
-- Host:    Linux/x86_64
-- Target:  Generic/arm
-- Machine: arm
-- Looking for include file stdatomic.h
-- Looking for include file stdatomic.h - found
-- open-amp version: 1.3.0 (/home/yyu/ncs/modules/lib/open-amp/open-amp)
-- Looking for include file fcntl.h
-- Looking for include file fcntl.h - found
-- Host:    Linux/x86_64
-- Target:  Generic/arm
-- Machine: arm
-- C_FLAGS :  -Wall -Wextra
CMake Warning at /home/yyu/ncs/zephyr/CMakeLists.txt:838 (message):
  No SOURCES given to Zephyr library: lib__libc__common

  Excluding target from build.


-- Configuring done
-- Generating done
-- Build files have been written to: /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/hci_rpmsg
=== child image hci_rpmsg - CPUNET end ===

-- libmetal version: 1.3.0 (/home/yyu/TAM/T83_board/firmware-nrf52840-5340)
-- Build type:  
-- Host:    Linux/x86_64
-- Target:  Generic/arm
-- Machine: arm
-- Looking for include file stdatomic.h
-- Looking for include file stdatomic.h - found
-- open-amp version: 1.3.0 (/home/yyu/ncs/modules/lib/open-amp/open-amp)
-- Looking for include file fcntl.h
-- Host:    Linux/x86_64
-- Target:  Generic/arm
-- Machine: arm
-- C_FLAGS :  -Wall -Wextra
-- Looking for include file fcntl.h - found
CMake Warning at /home/yyu/ncs/zephyr/CMakeLists.txt:838 (message):
  No SOURCES given to Zephyr library: lib__libc__common

  Excluding target from build.


CMake Warning at /home/yyu/ncs/zephyr/CMakeLists.txt:1864 (message):
  __ASSERT() statements are globally ENABLED


-- Configuring done
-- Generating done
-- Build files have been written to: /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2
-- west build: building application

After a while, the build stops at following error. There are many failure with the same error of loading <zephr.h>, I am just posting one due to the charater length limit.

[605/939] Building CXX object CMakeFiles/app.dir/edge-impulse/ingestion-sdk-c/ei_run_impulse.cpp.obj
FAILED: CMakeFiles/app.dir/edge-impulse/ingestion-sdk-c/ei_run_impulse.cpp.obj 
ccache /home/yyu/zephyr-sdk-0.16.1/arm-zephyr-eabi/bin/arm-zephyr-eabi-g++ -DARM_MATH_LOOPUNROLL -DEIDSP_LOAD_CMSIS_DSP_SOURCES=1 -DEIDSP_QUANTIZE_FILTERBANK=0 -DEIDSP_USE_CMSIS_DSP=1 -DEI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN=1 -DKERNEL -DMBEDTLS_CONFIG_FILE=\"nrf-config.h\" -DMBEDTLS_PLATFORM_ZEROIZE_ALT -DMBEDTLS_USER_CONFIG_FILE=\"nrf-config-user.h\" -DNRF5340_XXAA_APPLICATION -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DNRF_TRUSTZONE_NONSECURE -DTFM_PSA_API -DUSE_PARTITION_MANAGER=1 -D_ANSI_SOURCE -D_FORTIFY_SOURCE=1 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/edge-impulse-sdk/cmake/zephyr/../.. -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/. -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/src -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/tflite-model -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/model-parameters -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/edge-impulse/ingestion-sdk-c -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/edge-impulse/ingestion-sdk-platform/NordicSemi-nrf52 -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/edge-impulse/ingestion-sdk-platform/NordicSemi-nrf52/sensors -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/edge-impulse/mbedtls_hmac_sha256_sw -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/edge-impulse/QCBOR/inc -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/edge-impulse -I/home/yyu/ncs/zephyr/include -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/zephyr/include/generated -I/home/yyu/ncs/zephyr/soc/arm/nordic_nrf/nrf53 -I/home/yyu/ncs/zephyr/lib/libc/newlib/include -I/home/yyu/ncs/zephyr/soc/arm/nordic_nrf/common/. -I/home/yyu/ncs/zephyr/subsys/bluetooth -I/home/yyu/ncs/zephyr/subsys/settings/include -I/home/yyu/ncs/nrf/include -I/home/yyu/ncs/nrf/include/tfm -I/home/yyu/ncs/nrf/tests/include -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/tfm/generated/interface/include -I/home/yyu/ncs/modules/hal/cmsis/CMSIS/Core/Include -I/home/yyu/ncs/modules/hal/nordic/nrfx -I/home/yyu/ncs/modules/hal/nordic/nrfx/drivers/include -I/home/yyu/ncs/modules/hal/nordic/nrfx/mdk -I/home/yyu/ncs/zephyr/modules/hal_nordic/nrfx/. -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/modules/libmetal/libmetal/lib/include -I/home/yyu/ncs/modules/lib/open-amp/open-amp/lib/include -I/home/yyu/ncs/modules/debug/segger/SEGGER -I/home/yyu/ncs/modules/debug/segger/Config -I/home/yyu/ncs/zephyr/modules/segger/. -I/home/yyu/ncs/modules/crypto/tinycrypt/lib/include -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/tfm/install/interface/include -I/home/yyu/ncs/nrfxlib/softdevice_controller/include -I/home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/modules/nrfxlib/nrfxlib/nrf_security/src/include/generated -I/home/yyu/ncs/nrfxlib/nrf_security/include -I/home/yyu/ncs/nrfxlib/nrf_security/../crypto/nrf_oberon/core/include -I/home/yyu/ncs/nrfxlib/nrf_security/../crypto/nrf_oberon/core/library -I/home/yyu/ncs/modules/crypto/mbedtls/include -I/home/yyu/ncs/modules/crypto/mbedtls/library -I/home/yyu/ncs/nrfxlib/crypto/nrf_oberon/include/mbedtls -I/home/yyu/ncs/nrfxlib/crypto/nrf_oberon/include -fno-strict-aliasing -Og -fcheck-new -std=c++11 -fno-exceptions -fno-rtti -imacros /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfpu=fpv5-sp-d16 -mfloat-abi=hard --sysroot=/home/yyu/zephyr-sdk-0.16.1/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/yyu/ncs/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/home/yyu/TAM/T83_board/firmware-nrf52840-5340=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/yyu/ncs/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/yyu/ncs=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=gnu++11 -MD -MT CMakeFiles/app.dir/edge-impulse/ingestion-sdk-c/ei_run_impulse.cpp.obj -MF CMakeFiles/app.dir/edge-impulse/ingestion-sdk-c/ei_run_impulse.cpp.obj.d -o CMakeFiles/app.dir/edge-impulse/ingestion-sdk-c/ei_run_impulse.cpp.obj -c /home/yyu/TAM/T83_board/firmware-nrf52840-5340/edge-impulse/ingestion-sdk-c/ei_run_impulse.cpp
In file included from /home/yyu/TAM/T83_board/firmware-nrf52840-5340/edge-impulse/ingestion-sdk-c/ei_run_impulse.cpp:26:
/home/yyu/TAM/T83_board/firmware-nrf52840-5340/edge-impulse/ingestion-sdk-platform/NordicSemi-nrf52/sensors/ei_inertialsensor.h:28:10: fatal error: zephyr.h: No such file or directory
   28 | #include <zephyr.h>
      |          ^~~~~~~~~~
compilation terminated.
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /snap/bin/cmake --build /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_2```

For switching to NCS 1.9.1
I have done following

cd nrf
git checkout v1.9.1
cd ..
west update

When I run a new build again, I directly get an error message from cmake.

Building firmware-nrf52840-5340
/bin/sh -c west build --build-dir /home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_3 /home/yyu/TAM/T83_board/firmware-nrf52840-5340 --pristine --board nrf5340dk_nrf5340_cpuapp_ns --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION:STRING="NONE" -DCONF_FILE:STRING="/home/yyu/TAM/T83_board/firmware-nrf52840-5340/prj.conf" -DBOARD_ROOT:STRING="/home/yyu/TAM/T83_board/firmware-nrf52840-5340"

-- west build: generating a build system
CMake Error: Unknown argument --
CMake Error: Run 'cmake --help' for all supported options.
FATAL ERROR: command exited with status 1: /snap/bin/cmake -DWEST_PYTHON=/home/yyu/anaconda3/envs/py3/bin/python -B/home/yyu/TAM/T83_board/firmware-nrf52840-5340/build_3 -S/home/yyu/TAM/T83_board/firmware-nrf52840-5340 -GNinja -DBOARD=nrf5340dk_nrf5340_cpuapp_ns --no-sysbuild -- -DNCS_TOOLCHAIN_VERSION:STRING=NONE -DCONF_FILE:STRING=/home/yyu/TAM/T83_board/firmware-nrf52840-5340/prj.conf -DBOARD_ROOT:STRING=/home/yyu/TAM/T83_board/firmware-nrf52840-5340

I wonder whether you know how to fix either of the above issues for building with ncs 2.4.0 and ncs1.9.1

Hi,

Currently we support the NCS 1.9.1 and you should build with that. The move to NCS 2.4.0 is in progress and soon will be available.

Regarding your try to build firmware-nrf52840-5340 application with NCS 1.9.1 make sure your build environment is set up properly and also build for secure version meaning you use nrf5340dk_nrf5340_cpuapp as build target.

Also there is always option to use docker to build it as described in the readme of the repo

Hi,
I was able to successfully build the firmware-nrf52840-5340 application with NCS 1.9.1. After flashing it to the nrf5340DK board, it works as expected! @Yang1991, if you want to try the built firmware, you can download it from here (I hosted it on file.io). I was able to succesfully flash my nrf5340dk_edge_impulse_demo.hex using the Programmer app from the nRF Connect for Desktop suite.

3 Likes

I have successfully used docker to build firmware-nrf52840-5340.
Now I have located where the error happens

The app seems crahsed from https://github.com/edgeimpulse/firmware-nordic-nrf52840dk-nrf5340dk/blob/084adccccb6e4cdffa41c87ac596efc5963267d9/edge-impulse/ingestion-sdk-platform/NordicSemi-nrf52/ble_nus.cpp#L260C27-L260C27

I have tried to simply comment out https://github.com/edgeimpulse/firmware-nordic-nrf52840dk-nrf5340dk/blob/084adccccb6e4cdffa41c87ac596efc5963267d9/edge-impulse/ingestion-sdk-platform/NordicSemi-nrf52/ei_main.cpp#L27C12-L27C12 to disable the bluetooth initialization.

Then, everything works fine. I can get following output from running edge-impulse-daemon

Edge Impulse serial daemon v1.19.3
Endpoints:
    Websocket: wss://remote-mgmt.edgeimpulse.com
    API:       https://studio.edgeimpulse.com
    Ingestion: https://ingestion.edgeimpulse.com

? Which device do you want to connect to? COM7 (SEGGER)
[SER] Connecting to COM7
[SER] Serial is connected, trying to read config...
[SER] Retrieved configuration
[SER] Device is running AT command version 1.7.0

Setting upload host in device... OK
Configuring remote management settings... OK
Configuring API key in device... OK
Configuring HMAC key in device... OK
[SER] Device is not connected to remote management API, will use daemon
[WS ] Connecting to wss://remote-mgmt.edgeimpulse.com
[WS ] Connected to wss://remote-mgmt.edgeimpulse.com
? What name do you want to give this device? 5340DK-1
[WS ] Device "5340DK-1" is now connected to project "Yang1991-project-1". To connect to another project, run `edge-impulse-daemon --clean`.

I have tried to change code like below

    ei_printf("Hello from ble_nus_init debug 1 \r\n");
    err = bt_enable(NULL);
    ei_printf("Hello from ble_nus_init debug 2 \r\n");

Only the first logging is printed, the second logging disappeared.
Thus I think the code crshed when running err = bt_enable(NULL);

Although by simply diabling initiate bluetooth, I can run firmware-nrf52840-5340 sucessfully. But I can’t run other program like keyword spotting generated from deployment section in my dashboard. I assume all your program are initializing the bluetooth.

Thus, I have two questions:

  1. Is it possible that I can get source code for other machine learning deployment instead of only getting bin and hex file? So that I can comment out the bluetooth init part by myself.
  2. Can you think of any reason why my bluetooth failed?

BTW, I am looking at Bluetooth samples — Zephyr Project documentation (nRF Connect SDK). They did mention following note, I wonder whether this note is related to current issue or not.

If you want to run any bluetooth sample on the nRF5340 device (build using `-DBOARD=nrf5340dk_nrf5340_cpuapp` or `-DBOARD=nrf5340dk_nrf5340_cpuapp_ns` ) you must also build and program the corresponding sample for the nRF5340 network core [Bluetooth: HCI RPMsg] which implements the Bluetooth Low Energy controller.

Hi @Yang1991 ,

I am glad that you are closer to the solution.
I am not sure why BLE initialisation is causing the issue for you. It could be due to note you found, but that network core is build by default if you enable the BLE in project config. In your build log you should see part that looks something like this:

=== child image hci_rpmsg - CPUNET begin ===

This is where the building of that image starts.

Regarding your different model. You can do that of course. In short:

  1. you select C++ library as a deployment option:
  2. you take files from the generated zip and exchange them with the one you have in your application you are building locally
  3. build application locally with new files and flash it.

Vojislav

Hi, @vojislav
Thanks for your reply, I am trying to build C++ library now.
I am not sure whether I am doing it correctly and how to run the final version.
The screenshot below shows the comparison between firmware-nrf52840-5340 and the generated zip.

The zip file includes following content:

  • edge-impulse-sdk
  • model-parameters
  • tflite-model
  • CMakeLists.txt

1st try: I simply copy all the files from zip and paster over the original folders. The build failed obviously because of the incorrect CMakeLists.txt.

2nd try: I have modified CMakeLists.txt by merging these two CMakeLists into one. The merged CMake file is shown below, I have append #### Merged Code into the code where I modified compared with the original CMake file in firmware-nrf52840-5340.

cmake_minimum_required(VERSION 3.13.1)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

project(example-standalone-inferencing-zephyr)

include(utils/cmake/utils.cmake)
include(edge-impulse-sdk/cmake/utils.cmake) #### Merged Code
# Needed for colorful output
zephyr_compile_options(-fdiagnostics-color=always)

# Use hardware acceleration for DSP and Neural Network code
# You'll need to disable these on non-Arm cores
add_definitions(-DEIDSP_USE_CMSIS_DSP=1
                -DEIDSP_LOAD_CMSIS_DSP_SOURCES=1
                -DEI_CLASSIFIER_TFLITE_ENABLE_CMSIS_NN=1
                -DEIDSP_QUANTIZE_FILTERBANK=0
                -DARM_MATH_LOOPUNROLL
                -DMBEDTLS_PLATFORM_ZEROIZE_ALT
                )

# Add the Edge Impulse SDK
add_subdirectory(edge-impulse-sdk/cmake/zephyr)

# Include directories (everything in the SDK is already included here)
set(INCLUDES
    .
    src
    tflite-model
    model-parameters
    edge-impulse/ingestion-sdk-c
    edge-impulse/ingestion-sdk-platform/NordicSemi-nrf52
    edge-impulse/ingestion-sdk-platform/NordicSemi-nrf52/sensors
    edge-impulse/mbedtls_hmac_sha256_sw
    edge-impulse/QCBOR/inc
    edge-impulse
    )
include_directories(${INCLUDES})

RECURSIVE_FIND_FILE(MODEL_FILES "tflite-model" "*.cpp")

RECURSIVE_FIND_FILE(PLATFORM_FILES "edge-impulse/ingestion-sdk-platform/NordicSemi-nrf52" "*.cpp")
RECURSIVE_FIND_FILE(INGESTION_FILES "edge-impulse/ingestion-sdk-c/" "*.cpp")
RECURSIVE_FIND_FILE(QCBOR_FILES "edge-impulse/QCBOR/src" "*.c")
RECURSIVE_FIND_FILE(MBEDTLS_FILES "edge-impulse/mbedtls_hmac_sha256_sw/mbedtls/src" "*.c")
RECURSIVE_FIND_FILE(FIRMWARE_SDK_FILES "firmware-sdk" "*.cpp")
RECURSIVE_FIND_FILE_APPEND(MODEL_SOURCE "tflite-model" "*.cpp") #### Merged Code
target_include_directories(app PRIVATE .) #### Merged Code

# TODO: exlude fusion due to types conflict, remove after porting whole firmware
list(FILTER FIRMWARE_SDK_FILES EXCLUDE REGEX ".*ei_fusion\\.cpp$")

list(APPEND SOURCE_FILES ${S_FILES})
list(APPEND SOURCE_FILES ${C_FILES})
list(APPEND SOURCE_FILES ${CC_FILES})
list(APPEND SOURCE_FILES ${MODEL_FILES})
list(APPEND SOURCE_FILES ${PLATFORM_FILES})
list(APPEND SOURCE_FILES ${INGESTION_FILES})
list(APPEND SOURCE_FILES ${QCBOR_FILES})
list(APPEND SOURCE_FILES ${MBEDTLS_FILES})
list(APPEND SOURCE_FILES ${PORTING_FILES})
list(APPEND SOURCE_FILES ${FIRMWARE_SDK_FILES})

# add all sources to the project
target_sources(app PRIVATE ${SOURCE_FILES})
target_sources(app PRIVATE ${MODEL_SOURCE}) #### Merged Code
target_sources(app PRIVATE src/main.cpp)

With the 2nd try, everything is built correctly. But the end bin file works the same as previous.
I think this is probably because of the unmodified src/main.cpp

Did I build everything correctly? How can I run the deployment model instead of the original?

So when you change stuff as you did, you should have only the new model in your firmware. When you run inferencing that is the one being executed.
there should be no additional modifications in main etc.

Can you share your project ID with me, so I can check it out.

As I understand correctly you are currently building audio model and the default one is gestures.

Also you can check some info about the model with AT commands. If you send AT+INFO you will get a response like this:

AT+INFO


  • Edge Impulse firmware *

Firmware build date : xxxxx
Firmware build time : xxxxx
ML model author : xxxxx
ML model name : xxxxxx
ML model ID : xxxxx
Model deploy version : xx
Used sensor : microphone

Of course Xs being exchange with your info.

Vojislav

2 Likes

My project ID is 246032
I will check what you have shared yesterday as well.
Thanks.

Hi,
When I run edge-impulse-run-impulse --raw with my built project.
I don’t have AT+INFO available.
But I am now getting it to work now.

I just figure out that I just need to run edge-impulse-run-impulse or pass AT+RUNIMPULSE to the communication. It is running now. Thank you so much for the report.

I will work later to figure out why my Bluetooth is not working correctly. I will share you the result once I found it.

1 Like

That is good news!
Searching Nordic DevZone might help with BLE issue on the dev board.

Cheers,
Vojislav

1 Like