Deploying Edge Impulse models on NUCLEO-N657X0-Q

Hi, I am new to the world of Edge Impulse and STM32. I see that the STM32N6570-DK is officially supported in Edge Impulse, i have the NUCLEO-N657X0-Q which has the same NPU chip as the DK. Is it possible to reuse the edge impulse repos edgeimpulse/firmware-st-stm32n6 or edgeimpulse/example-standalone-st-stm32n6: Example standalone for STM32N6570-DK for the NUCLEO board? What would i need to change if this was possible?

Hi @willisk0612

I think you can use it, in the Makefile change this line

C_DEFS += -DNUCLEO_N6_CONFIG=1

and this line

to

C_DEFS += -DUSE_STM32N6570_NUCLEO_REV_B01

The rest should be ok.

regards,
fv

Hi, thanks for the answer. I did make those changes, and also changed GCC path to my local arm toolchain. I did get this error when trying to build:

$ make
  CC build/Src/main.o
In file included from Src/main.c:28:
Inc/misc_toolbox.h:27:10: fatal error: stm32n6xx_nucleo.h: No such file or directory
   27 | #include "stm32n6xx_nucleo.h"
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:195: build/Src/main.o] Error 1

Update: I tried creating my own project with the nucleo board in STM32CubeIDE, and copied edgeimpulse folder here. I did have to fight some compiler errors, now i am stuck at this:

C:/Users/willi/STM32CubeIDE/workspace_1.19.0/nucleo_mnist_cpp/FSBL/edgeimpulse/edge-impulse-sdk/classifier/ei_aligned_malloc.h:81:(.text._ZN12_GLOBAL__N_117ei_aligned_callocEjj+0x42): undefined reference to `ei_calloc'
C:/ST/STM32CubeIDE_1.19.0/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.13.3.rel1.win32_1.0.0.202411081344/tools/bin/../lib/gcc/arm-none-eabi/13.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/ei_main.o: in function `(anonymous namespace)::ei_aligned_free(void*)':
C:/Users/willi/STM32CubeIDE/workspace_1.19.0/nucleo_mnist_cpp/FSBL/edgeimpulse/edge-impulse-sdk/classifier/ei_aligned_malloc.h:119:(.text._ZN12_GLOBAL__N_115ei_aligned_freeEPv+0x2e): undefined reference to `ei_free'

Would appreciate some help.

Hi @willisk0612

I have fixed the errors for the Nucleo board in this branch

For the link error, it seems this file is not compiled

To make things easy, you can copy ei_classifier_porting.cpp into your Src folder.

regards,
fv

Thanks for the answer. I did make some modifications to the makefile that were windows specific, and tried to upload my model from edge impulse. I tested that the UART communication worked well without edge impulse folder, but the UART communication broke down when i included the edge impulse folder (using TEST_CONNECTION variable in makefile that i created myself). Here is the link to the fork I made, would appreciate some thoughts on what might be wrong: willisk0612/edgeimpuse-nucleo-stm32n6

@ei_francesco Did you get compilation errors on this branch? Would be interesting to hear, because I fighted pretty long before i got mine to build.

Hi @willisk0612

I updated the branch, I can debug it (so running from RAM), but I’m having issue when loading from external flash.

Regarding your fork, I checked, I think there is something wrong with one of the peripheral that leads to a freeze or hard fault, probably the external mem init or the risaf.
I’m checking example fro the nucleo from ST to compare what is not working.

I’ll post here if I can fix it.

regards,
fv

@ei_francesco How far away is the current branch from working? Did make some updates to my fork, but those were mostly model specific. I am not sure what the features array was for, testing purposes?

Hi @willisk0612

the features array is to test inference on a specific sample.

I have fixed the last issue on the branch for the Nucleo, you can have a look.
There’s a fix needed for the aton.h from our Edge Impulse SDK which is not yet in production, it should be delivered soon.

fv