Computer Vision application demonstrating the deployment of several object detection models execution in series on the STM32N6570-DK or NUCLEO-N657X0-Q board. The chosen use case is multiple-faces landmark detection. It consists of two models that execute sequentially:
- A face detection (fd) model is executed in the first stage to detect the faces.
- A face landmark (fl) detection model is executed in the second stage to identify the landmarks of the faces detected during the first stage. After the execution of the first model, a resize operation takes place to provide the expected input to the second model. On STM32N6570-DK GPU2D is used to also perform a rotation to orient face vertically.
This top README gives an overview of the app. Additional documentation is available in the Doc folder.
- Multi-threaded application flow (FreeRTOS)
- NPU-accelerated quantized AI model inference
- GPU2D usage to perform resize and rotation
- Execute multiple models in series
- Dual DCMIPP pipelines
- DCMIPP cropping, decimation, and downscaling
- DCMIPP ISP usage
- LTDC dual-layer implementation
- Development mode
- Boot from external flash
Supported development platforms:
- STM32N6570-DK Discovery Board
- Connect to the onboard ST-LINK debug adapter (CN6) using a USB-C to USB-C cable for sufficient power.
- OTP fuses are configured for xSPI IOs to achieve maximum speed (200MHz) on xSPI interfaces.
- NUCLEO-N657X0-Q Nucleo Board
- Connect to the onboard ST-LINK debug adapter (CN9) using a USB-C to USB-C cable for sufficient power.
- OTP fuses are configured for xSPI IOs to achieve maximum speed (200MHz) on xSPI interfaces.
STM32N6570-DK board with MB1854B IMX335.
Supported camera modules:
- Provided IMX335 camera module
- STEVAL-55G1MBI
- STEVAL-66GYMAI
- STEVAL-1943-MC1
For the Nucleo board, one of the following displays is required:
- A USB host for data transmission via USB/UVC (using the USB OTG port CN8)
NUCLEO-N657X0-Q board with USB/UVC display.
- X-NUCLEO-GFX01M2 SPI display
NUCLEO-N657X0-Q board with SPI display.
- IAR Embedded Workbench for Arm (EWARM 9.40.1) + N6 patch (EWARMv9_STM32N6xx_V1.0.0)
- STM32CubeIDE (v1.17.0)
- STM32CubeProgrammer (v2.18.0)
- STEdgeAI (v3.0.0)
The STM32N6 series does not have internal flash memory. To retain firmware after a reboot, program it into the external flash. Alternatively, you can load firmware directly into SRAM (development mode), but note that the program will be lost if the board is powered off in this mode.
Development Mode: used for loading firmware into RAM during a debug session or for programming firmware into external flash.
Boot from Flash: used to boot firmware from external flash.
| STM32N6570-DK | NUCLEO-N657X0-Q | |
|---|---|---|
| Boot from flash | ![]() |
![]() |
| Development mode | ![]() |
![]() |
You can see application messages by attaching a console application to the ST-Link console output. Use the following console parameters:
- Baud rate of 115200 bps.
- No parity.
- One stop bit.
The prebuilt binaries are an assembly of several binaries:
- FSBL (First Stage Boot Loader, loading the application from flash to RAM)
- The application
- The weights of the neural network models
To program the board's external flash, follow these steps:
- Set the board to development mode.
- Program
Binary/STM32N6570-DK/x-cube-n6-ai-face-landmarks-dk.hex. - Set the board to boot from flash mode.
- Power cycle the board.
To program the board's external flash, follow these steps:
- Set the board to development mode.
- Program
Binary/NUCLEO-N657X0-Q/USB-UVC-Display/x-cube-n6-ai-face-landmarks-nucleo-uvc.hex. - Set the board to boot from flash mode.
- Connect a USB cable to the USB OTG port (CN8), next to the RJ45 port. Connect the other end to a USB host (PC, USB hub, etc.) for data transmission via USB/UVC.
- Power cycle the board.
- Start the camera application on the host. On Windows, search for "camera" in the Start menu.
To program the board's external flash, follow these steps:
- Set the board to development mode.
- Program
Binary/NUCLEO-N657X0-Q/SPI-Display/x-cube-n6-ai-face-landmarks-nucleo-spi.hex. - Set the board to boot from flash mode.
- Power cycle the board.
See How to program hex files STM32CubeProgrammer.
Ensure the STM32CubeProgrammer bin folder is in your PATH.
export DKEL="<STM32CubeProgrammer_N6 Install Folder>/bin/ExternalLoader/MX66UW1G45G_STM32N6570-DK.stldr"
# Application Firmware
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $DKEL -hardRst -w Binary/STM32N6570-DK/x-cube-n6-ai-face-landmarks-dk.hexEnsure the STM32CubeProgrammer bin folder is in your PATH.
export NUEL="<STM32CubeProgrammer_N6 Install Folder>/bin/ExternalLoader/MX25UM51245G_STM32N6570-NUCLEO.stldr"
# USB/UVC display
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $NUEL -hardRst -w Binary/NUCLEO-N657X0-Q/USB-UVC-Display/x-cube-n6-ai-face-landmarks-nucleo-uvc.hex
# SPI display
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $NUEL -hardRst -w Binary/NUCLEO-N657X0-Q/SPI-Display/x-cube-n6-ai-face-landmarks-nucleo-spi.hexBefore building and running the application, you must program Model/face_detector_data.hex and Model/face_landmark_data.hex (models weights and biases). This only needs to be done once unless you change the AI model. See Quickstart using prebuilt binaries for details.
For more information about boot modes, see Boot Overview.
Set your board to development mode.
Double-click STM32CubeIDE/<board_name>/.project to open the project in STM32CubeIDE. Build and run the project.
Double-click EWARM/<board_name>/x-cube-n6-ai-face-landmarks-dk.eww to open the project in IAR. Build and run the project.
Run the following commands (ensure required tools are in your PATH):
- Build the project:
make -j8
- Start a GDB server connected to the STM32 target:
ST-LINK_gdbserver -p 61234 -l 1 -d -s -cp <path-to-stm32cubeprogramer-bin-dir> -m 1 -g
- In a separate terminal, launch a GDB session to load the firmware:
$ arm-none-eabi-gdb build/Project.elf (gdb) target remote :61234 (gdb) monitor reset (gdb) load (gdb) continue
Note: To select the board, specify BOARD=STM32N6570-DK or BOARD=NUCLEO-N657X0-Q as a Makefile option.
Note: To select the NUCLEO-N657X0-Q display interface, specify SCR_LIB_SCREEN_ITF=UVCL or SCR_LIB_SCREEN_ITF=SPI as a Makefile option.
Set your board to development mode.
Double-click STM32CubeIDE/<board_name>/.project to open the project in STM32CubeIDE. Build the project.
Double-click EWARM/<board_name>/x-cube-n6-ai-face-landmarks-dk.eww to open the project in IAR. Build the project.
Ensure all required tools are in your PATH, then build the project:
make -j8After building the application, you must add a signature to the binary file:
STM32_SigningTool_CLI -bin build/Project.bin -nk -t ssbl -hv 2.3 -o build/Project_sign.binProgram the signed binary at address 0x70100000, as well as the FSBL and network parameters.
On STM32N6570-DK:
export DKEL="<STM32CubeProgrammer_N6 Install Folder>/bin/ExternalLoader/MX66UW1G45G_STM32N6570-DK.stldr"
# First Stage Boot Loader
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $DKEL -hardRst -w FSBL/ai_fsbl.hex
# Adjust build path as needed
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $DKEL -hardRst -w build/Project_sign.bin 0x70100000
# Network parameters and biases
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $DKEL -hardRst -w Model/face_detector_data.hex
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $DKEL -hardRst -w Model/face_landmark_data.hexOn NUCLEO-N657X0-Q:
export NUEL="<STM32CubeProgrammer_N6 Install Folder>/bin/ExternalLoader/MX25UM51245G_STM32N6570-NUCLEO.stldr"
# First Stage Boot Loader
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $NUEL -hardRst -w FSBL/ai_fsbl.hex
# Adjust build path as needed
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $NUEL -hardRst -w build/Project_sign.bin 0x70100000
# Network parameters and biases
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $NUEL -hardRst -w Model/face_detector_data.hex
STM32_Programmer_CLI -c port=SWD mode=HOTPLUG -el $NUEL -hardRst -w Model/face_landmark_data.hexNote: Only the application binary needs to be programmed if fsbl and networks data have already been programmed.
Set your board to boot from flash mode and power cycle to boot from external flash.
The neural network models files (face_detector.c, stai_face_detector.c/h, etc.) included in this project were generated using STEdgeAI version 3.0.0.
Using a different version of STEdgeAI to generate these models files may result in the following compile-time error:
Possible mismatch in ll_aton library used.
If you encounter this error, please follow the STEdgeAI instructions on How to update my project with a new version of ST Edge AI Core to update your project.




