Help with ONNX Model Integration and Debugging in STM32CubeIDE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-13 7:41 PM - last edited on ‎2025-01-14 12:54 AM by Andrew Neil
Hi everyone,
I'm new to STM32CubeIDE and working on integrating an ONNX model. I have generated the C code for the model using STM32CUBEMX on the STM32F746NGHx and noticed that the main function includes functions like:
MX_X_CUBE_AI_Init();
MX_X_CUBE_AI_Process();
However, this differs from the default main function mentioned in the document.
void main_loop() {
aiInit();
while (1) {
/* 1 - Acquire, pre-process and fill the input buffers */
acquire_and_process_data(in_data);
/* 2 - Call inference engine */
aiRun(in_data, out_data);
/* 3 - Post-process the predictions */
post_process(out_data);
}
aiDeinit();
}
I'm unable to find these functions in the generated code. (using the latest versions)
I want to:
- Understand the flow of the generated code, especially how the inputs are processed.
- Test the model with different inputs.
- Measure the number of cycles taken for execution with varying inputs.
When I build the code, I get an output.
STMicroelectronics ST-LINK GDB server. Version 7.9.0
Copyright (c) 2024, STMicroelectronics. All rights reserved.
Starting server with the following options:
Persistent Mode : Disabled
Logging Level : 1
Listen Port Number : 61234
Status Refresh Delay : 15s
Verbose Mode : Disabled
SWD Debug : Enabled
InitWhile : Enabled
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
Debugger connected
Waiting for debugger connection...
-------------------------------------------------------------------
STM32CubeProgrammer v2.18.0
-------------------------------------------------------------------
Log output file: C:\Users\mkothuri\AppData\Local\Temp\STM32CubeProgrammer_a13396.log
ST-LINK SN : 066BFF505252836687124633
ST-LINK FW : V2J45M30
Board : 32F746GDISCOVERY
Voltage : 3.23V
SWD freq : 4000 KHz
Connect mode: Under Reset
Reset mode : Hardware reset
Device ID : 0x449
Revision ID : Rev Z
Device name : STM32F74x/STM32F75x
Flash size : 1 MBytes
Device type : MCU
Device CPU : Cortex-M7
BL Version : 0x90
Debug in Low Power mode enabled
Opening and parsing file: ST-LINK_GDB_server_a13396.srec
Memory Programming ...
File : ST-LINK_GDB_server_a13396.srec
Size : 43.30 KB
Address : 0x08000000
Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 1]
Download in Progress:
File download complete
Time elapsed during download operation: 00:00:01.087
Verifying ...
Download verified successfully
Shutting down...
Exit.
Can someone guide me on:
- How to debug the code to understand its flow?
- How to print and measure the execution cycles for different inputs?
Additionally, please correct me if I'm wrong in any of these steps or processes. Your guidance would be greatly appreciated!
- Labels:
-
STM32F7 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-13 8:05 PM
The program size 43 KB is too small. Looks like the needed libraries are not included into the project.
> Download verified successfully
> Shutting down...
Are you sure that you start *debugging*, not *run*? In the debug configuration dialog make sure that "Set breakpoint at main" is checked. It should be by default. Once you stop on main, you can debug further.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-13 8:33 PM
Thanks, Pavel, for your response!
I have a few follow-up questions and clarifications regarding my setup:
- How can I verify that all the necessary libraries for the ONNX model are included in the project?
- Would using a larger model be a better approach in this case?
Steps I’ve followed so far:
- Added the AI extension to my STM32CubeIDE project.
- Checked for system performance to ensure compatibility.
- Uploaded the model and selected UART4 under the connectivity settings.
I’ve attached the relevant screenshots for better context. Could you guide me in completing this process? If using a larger model is required, I can make the adjustments as needed.
Thanks for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-01-16 8:03 PM - edited ‎2025-01-16 8:04 PM
> How can I verify that all the necessary libraries for the ONNX model are included in the project?
Look at the map file produced by linker. Is the binary size reasonable?
> Would using a larger model be a better approach in this case?
Larger is better - but is there enough memory for it?
> Could you guide me in completing this process?
Sorry I cannot. Hope other forum members can help. Also, more help is available here.
