cancel
Showing results for 
Search instead for 
Did you mean: 

How to integrate Cube AI Studio generated Neural-ART code into an existing project?

userskin1
Associate

Hello,

I am trying to integrate a model generated by STM32Cube AI Studio into an existing STM32N6 DC-DC converter control project, but I am not sure what the correct integration flow is
for a Neural-ART / NPU-based model.

I am attaching the following 3 files/projects:

1. My existing STM32CubeIDE project
2. The folder generated by STM32Cube AI Studio
3. The ONNX model used for generation

My setup is:

- MCU/board: NUCLEO-N657X0-Q
- Existing project: test_BOOSTXL_ACM_AI_0
- The existing control loop is already running correctly
- ADC + DMA + TIM based DC-DC converter control is implemented
- The control calculation is currently executed inside the ADC DMA interrupt handler
- I trained a small 1D CNN in PyTorch, exported it to ONNX, and then used STM32Cube AI Studio to generate code

Model information:

- Input shape: (1, 1, 64)
- Output shape: (1, 2)
- Input data: 64 current samples at 5 us interval
- Output: 2-class logits for resistance estimation

What I tried:

- I copied the generated folders into my existing FSBL project:
- AI/App
- generated
- Middlewares/ST
- I also added the include paths in STM32CubeIDE

However, the build fails with many errors such as:

ATON_BASE undeclared
CDNN0_IRQn undeclared
LL_ATON_PLATFORM undeclared
LL_ATON_OSAL undeclared

From these errors, it seems that the generated Neural-ART code requires additional platform/NPU configuration that is not present in my existing project.

My questions are:

1. Where exactly should the files generated by STM32Cube AI Studio be copied inside an existing project?
For example, which generated folders/files should go into the existing project, and where should they be placed?
2. After copying those files, what needs to be configured in STM32CubeMX and STM32CubeIDE?
For example, what include paths, source folders, middleware settings, linker settings, or other project settings are required?
3. Since my control loop currently runs inside the ADC DMA interrupt, is it correct to keep the control loop in the ISR and run AI inference only in the background/main loop after
collecting 64 samples?
4. Right now I used Generate model code in STM32Cube AI Studio.
Would the correct workflow instead be to use Generate project, create a new AI project, and then port my existing converter control project into that generated project?
If so, what is the recommended way to port it?
Do I need to repeat the STM32CubeMX configuration from the beginning and rebuild the project around the generated AI project structure?

My target architecture is:

- Keep the existing DC-DC converter control loop
- Collect 64 current samples
- Run inference to estimate the load resistance class
- Use the estimated resistance in the control logic

At this point I am mainly looking for the correct integration method for STM32N6 Neural-ART generated code into an existing project.

Any guidance on the expected project structure or recommended workflow would be very helpful.

Thank you.

Attachments:

- Existing STM32CubeIDE project
- STM32Cube AI Studio generated folder
- ONNX model

0 REPLIES 0