Help with ONNX Model Integration and Debugging in STM32CubeIDE
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!
