cancel
Showing results for 
Search instead for 
Did you mean: 

STM32N6 + YOLOv8n ONNX Model. Issues with PNG Input and Code Generation

TerZer
Associate III

Hi everyone,

I'm working with an STM32N6 board and trying to deploy a custom YOLOv8n model in ONNX format using CubeMX and STM32 Edge AI. I’ve run into a few issues and was hoping someone could help clarify the process.

Here’s what I’ve done so far:

I successfully imported my yolov8n.onnx model into CubeMX + Edge AI.

When I try to test the model using a .PNG image, I get an error saying PNG format is not supported. When I generate the C code using the model, I see a line in network.c where -inf is not defined, causing compilation errors.

My Questions:

How can I test my model using a PNG image, either on the STM32N6 device or on a desktop simulation?

Do I need to convert the PNG to raw input data manually?

What’s the correct way to prepare a PNG image as an input buffer for use with STM32 inference code?

How do I resolve the -inf not defined issue in the generated network.c?

Any help, code snippets, or documentation pointers would be greatly appreciated!

Thanks in advance!

16 REPLIES 16

@TerZer,

It should be ok next week.

 

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.

Hello @TerZer,

 

You can find the tutorial here:

How to build an AI application from scratch on the... - STMicroelectronics Community

 

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.
TerZer
Associate III

Hello @Julian E. ,

First off, thanks for your tutorial — it was really helpful! However, I ran into an issue. I tried to create a TouchGFX application, and when I attempted to add the X-CUBE-AI component in STM32CubeMX, I got the following message:

This component cannot be selected:

- This application cannot be selected while the application Application from pack STMicroelectronics.X-CUBE-TOUCHGFX.4.25.0 is selected.

Is there a known workaround or specific setup needed to use both X-CUBE-AI and TouchGFX in the same project?

P.S.
All software is on latest version:
X-CUBE-AI version 10.2.0

X-CUBE-TOUCHGFX 4.25.0

Hello @TerZer,

You are right, I am asking the dev of X Cube AI the reason for that. I'll keep you updated.

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.

Hello @TerZer,

 

It seems complicated to use both X Cube AI and TouchGFX at the same time.

Both tools uses complicated configuration in CubeMX and STM32CubeMX do not support both at the same time.

 

I've looked at all the demo firmware we propose for the N6 and none of them use both packages.

Even the out of the box demo is using 2 different firmwares and switch between the touchGFX and X Cube AI ones.

 

I contacted both touchGFX and AI team but none of them tried to implement both.

I transmitted the needs to the marketing for a potential need to spend resources and people to develop an example application.

 

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.

Hello @Julian E. ,

Could you explain how this was implemented in the demo version? Specifically, how the switching between AI and TouchGFX is handled.

Also, will it be possible to use TouchGFX and AI simultaneously, and if so, is there an expected timeline for that support?

Thanks in advance!

Hello @TerZer,

 

I don't think that we will see a support for both touchgfx and cubeAI.

 

I will transmit the idea to use touchgfx in a AI demo to the dev team.

If they see an interest, they may add a bit of touchgfx to a getting started demo in the future.

 

Concerning the out of the box N6 demo:

CubeMX doesn’t support generating both together, so we used two separate firmwares.

STM32N6 boot model:

  • No internal flash.
  • Boots from external OctoSPI/HyperFlash in XiP mode.
  • Has large internal SRAM (several MB), so you can copy code there and execute from RAM (faster).

 

Demo architecture:

  • FSBL (First Stage Bootloader / launcher app):
    • Lives at 0x70000000 (external flash, I think that the address is correct).
    • Initializes clocks, SDRAM, OSPI.
    • Runs TouchGFX menu XiP from flash.
  • App slots in external flash:
    • App1 (TouchGFX launcher).
    • App2 (AI demo) 

 

4. Switching mechanism

  • User selects “AI Demo” in TouchGFX.
  • Menu sets a flag (e.g. in backup SRAM).
  • Calls NVIC_SystemReset().
  • On reset, FSBL checks flag:
    • If UI → stay in TouchGFX.
    • If AI demo:
      • Copy App2 binary from external flash → internal SRAM (0x24000000).
      • Read vector table from SRAM.
      • Jump to it (set MSP + PC).
    •  

 

Where to execute each app:

  • XiP is fine for GUI (I think)
  • For the AI application, it is highly recommended to run it in internal RAM.

When you use the st edge ai core to convert your model, you will see the size of activations and weights.

The weights can be stored in external flash and stay there (they are only read once, so no issues), the activations need to fit in internal RAM, else you will lose quite a lot in performance.

All the model in the ST Model fit in internal RAM for this reason.

 

You can find tutorials on how to create an AI app on the DK or Nucleo N6 app that execute in internal RAM.

DK:How to build an AI application from scratch on the... - STMicroelectronics Community

Nucleo: How to build an AI application from scratch on the... - STMicroelectronics Community

 

I don't know much about TouchGFX, but you can most likely create the template application.

 

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.