cancel
Showing results for 
Search instead for 
Did you mean: 

STM32N6570-DK AI Model Flashing Error

WUCHENGXUAN
Associate II

 STM32N6570-DK Custom AI Model Flashing Error

 Background / Official Requirements

According to the official documentation for flashing the AI model onto the DK, three key .HEX files are required:

  1. ai_fsbl.hex

  2. STM32N6570-DK_network_data.hex

  3. STM32N6570-DK_GettingStarted_ObjectDetection.hex

 Steps I Have Taken to Integrate My Custom Model

  1. Model Conversion:

    • I successfully imported my custom model(st_yolo_x_nano_480_1.0_0.25_3_st_int8.tflite-STM32N6570-DK-code) into the ST Edge AI Developer Cloud.

    • After quantization, I obtained a folder containing the three necessary files for the network data: network.c, network_ecblobs.h, and network_atonbuf.xSPI2.raw.

    • Following the official guide, I used PowerShell to convert these three files into the single STM32N6570-DK_network_data.hex file.

    • This file was designated to be flashed at the correct memory address: 0x70380000

  2. Application Code Modification:

    • I modified the application configuration file: Inc/app_config.h.

    • I used GPT to assist with the code modifications to ensure the project would successfully build in the IDE (to get a successful compilation).

    • The IDE build was successful, generating the required application files, including the $GettingStarted\_ObjectDetection.hex$ (I chose the .hex file for easier flashing without needing to manually select the address).

  3. Flashing Sequence:

    • I used the programmer to flash the files in the following sequence:

      1. ai_fsbl.hex (The official version from the Object Detection example).

      2. STM32N6570-DK_network_data.hex (My self-generated data file).

      3. STM32N6570-DK_GettingStarted_ObjectDetection.hex (My self-generated application file).

 Result

After flashing, the camera and display both start up correctly, but the object detection output consistently displays the label "person" in a repeating loop, even when no person is present, suggesting the new model or its data is not being loaded/executed correctly.

 My Self-Diagnosis / Hypotheses for Failure

  1. Need for ai\_fsbl.hex Modification?

    • I haven't seen any posts on forums suggesting a need to modify the ai_fsbl.hex file. However, perhaps it needs to be adapted based on the architecture or requirements of my specific custom model.

  2. Incorrect Application Code (Inc/app\_config.h:(

    • Even though the compilation was successful (0 errors), the content of the Inc/app_config.h (or other application code) might not be fundamentally correct for interfacing with my custom model, leading to this unexpected behavior.

 

4 REPLIES 4
Julian E.
ST Employee

Hi @WUCHENGXUAN,

 

To answer your question, no you don't need to update the ai_fsbl.

 

In your case I think that the issue comes from the fact that you used the ST developer cloud to convert the model. 

The option used are not the same than the one provided in the getting started.

 

In /model of the getting started you have: 

JulianE_0-1765310235095.png

if you look at the .sh for the DK you will see this:


stedgeai generate --model st_yolo_x_nano_480_1.0_0.25_3_st_int8.tflite --target stm32n6 --st-neural-art default@user_neuralart_STM32N6570-DK.json --input-data-type uint8 --output-data-type int8
cp st_ai_output/network.c STM32N6570-DK/
cp st_ai_output/network_ecblobs.h STM32N6570-DK/
cp st_ai_output/network_atonbuf.xSPI2.raw STM32N6570-DK/network_data.xSPI2.bin
arm-none-eabi-objcopy -I binary STM32N6570-DK/network_data.xSPI2.bin --change-addresses 0x70380000 -O ihex STM32N6570-DK/network_data.hex

You can see that the generate uses the default profile of "user_neuralart_STM32N670-DK.json" which itself uses the memory description in /my_mpools.

 

Please try to do the generation of the file locally using the right ST Edge AI Core version (should be version 2.2) and these exact command and let me know if this helps.

 

Have a good day,

Julian


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
WUCHENGXUAN
Associate II

Hello Julian E,

Thank you very much for your reply! From your response, I understand that the issue lies with what I generated on the ST Edge AI Developer Cloud, which subsequently caused an error in the final network_data.hex file.

Today, I decided to try the STM32N6-ObjectDetection files you provided. I used the model inside, st_yolo_x_nano_480_1.0_0.25_3_st_int8.tflite, and performed the following steps:

Bash
 
stedgeai generate --model st_yolo_x_nano_480_1.0_0.25_3_st_int8.tflite --target stm32n6 --st-neural-art default@user_neuralart_STM32N6570-DK.json --input-data-type uint8 --output-data-type int8
cp st_ai_output/network.c STM32N6570-DK/
cp st_ai_output/network_ecblobs.h STM32N6570-DK/
cp st_ai_output/network_atonbuf.xSPI2.raw STM32N6570-DK/network_data.xSPI2.bin
arm-none-eabi-objcopy -I binary STM32N6570-DK/network_data.xSPI2.bin --change-addresses 0x70380000 -O ihex STM32N6570-DK/network_data.hex

The resulting network_data.hex file was then flashed onto the device using the programmer. However, the object detection (of people, specifically) does not work. (I have already flashed the ai_fsbl.hex and STM32N6570-DK_GettingStarted_ObjectDetection.hex files that you provided.)

Could you please point out where I might have made a mistake in the process above? Any guidance would be greatly appreciated!

Thank you for your time and help!

Hi @WUCHENGXUAN,

 

Please look at my last answer in this thread:

https://community.st.com/t5/edge-ai/custom-model-object-detection-on-stm32n6-dk-error/td-p/856875

 

Seeing the image you shared, you probably need to edit app_config.h and adapt the threshold and number of boxes to display.

 

I would suggest to use ST Model Zoo services to deploy your model.

 

Have a good day,

Julian


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi Julian,

Thanks for your reply!

I’ve spent the last few days experimenting with and modifying the config.h file, but unfortunately, the results still show that my required model cannot be recognized. Could you please provide more detailed instructions on how to properly modify it?

Specifically, taking the app_config.h from your project: STM32N6-GettingStarted-ObjectDetection-main\Application\STM32N6570-DK\Inc\app_config.h as an example, how would you suggest I modify it? (I am still using your official model for this).

Additionally, I am attaching another model file for your reference. Could you also advise on how the config.h should be adjusted to support this specific model?

Thank you so much for your help!