Unable to flash nrf5340.bin in the Getting Started example

Hello @Yang1991,

You need to attach the shield to use edge-impulse-daemon.
Can you make sure you have this exact version of the shield?
X-NUCLEO-IKS02A1?

Best,

Louis

HI @louis
Thanks for reply. Yes, the version is X-NUCLEO-IKS02A1.
I have uploaded two pictures to show how it looks like.

Another Image for another direction

@louis

Do you know what I should test next?

Hello @Yang1991,

Unfortunately, I have not that board anymore, I’ll check with our embedded team if they can reproduce and find a solution.

Best,

Louis

Hi @Yang1991
It looks like your nRF5340DK is faulty. We are observing in a few cases that external QSPI Flash memory on the nRF5340DK could be broken. Our firmware is using this memory to store the configuration (like sampling rate, sensor type etc.).
We tried to flash our pre-built firmware on a few boards, and there is no issue. Only one board has the same issue, and we confirmed that it’s QSPI Flash is broken.

One thing that you can try is to run the simple example from Zephyr. To do that, first install nRF Connect SDK, then go to the Zephyr directory, build and flash the example:

west build -b nrf5340dk_nrf5340_cpuapp
west flash

Then check on UART if you see a successful test.

Best regards,
Matt

@Yang1991
One more thing, you can try to run the following command (with nRF5340DK connected to your computer):

nrfjprog --qspieraseall

It will take some time and try to erase a whole QSPI memory. Check if it succeed.

Best regards,
Matt

Thanks, I am building this example via VS code and NRF connect plugins.

Image above is the build configuration I used for building.

The build succeeds with following output in the end:

Memory region         Used Size  Region Size  %age Used
           FLASH:       36520 B       960 KB      3.72%
             RAM:        4696 B       480 KB      0.96%
        IDT_LIST:          0 GB         2 KB      0.00%
[253/254] Generating zephyr/tfm_nonsecure.hex
[254/254] Generating zephyr/merged.hex

Then I flash it using VS code as well with following output in the terminal:

Building spi_flash
C:\Windows\system32\cmd.exe /d /s /c "west build --build-dir f:\TAM\NRF_research\first_app\spi_flash\build f:\TAM\NRF_research\first_app\spi_flash"

[0/20] Performing build step for 'tfm'
ninja: no work to do.
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: nRF Connect: Flash: spi_flash/build (active) 

Flashing build to 1050019043
C:\Windows\system32\cmd.exe /d /s /c "west flash -d f:\TAM\NRF_research\first_app\spi_flash\build --skip-rebuild --dev-id 1050019043"

-- west flash: using runner nrfjprog
-- runners.nrfjprog: Flashing file: f:\TAM\NRF_research\first_app\spi_flash\build\zephyr\merged.hex
[ #################### ]   3.326s | Erase file - Done erasing                                                          
[ #################### ]   0.611s | Program file - Done programming                                                    
[ #################### ]   0.502s | Verify file - Done verifying                                                       
Applying pin reset.
-- runners.nrfjprog: Board with serial number 1050019043 flashed successfully.

Then I run edge-impulse-run-impulse --raw and press reset button when connected, I got following output.

edge-impulse-run-impulse --raw
Edge Impulse impulse runner v1.19.3
? Which device do you want to connect to? COM6 (SEGGER)
[SER] Connecting to COM6
[SER] Connected to COM6
*** Booting Zephyr OS build v3.3.99-ncs1 ***

mx25r6435f@0 SPI flash testing
==========================

Perform test on single sector
Test 1: Flash erase
Flash erase succeeded!

Test 2: Flash write
Attempting to write 4 bytes
Data read matches data written. Good!!

Does this mean that the QSPI Flash memory is not faulty?

I have also run this command, output is shown below:

nrfjprog --qspieraseall
WARNING: An operation that can take up to several minutes is being executed.
WARNING: Please remain patient.
Initializing the QSPI peripheral.
Erasing.
Uninitializing the QSPI peripheral.

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