cancel
Showing results for 
Search instead for 
Did you mean: 

Help with ONNX Model Integration and Debugging in STM32CubeIDE

mkothuri
Associate

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:

  1. Understand the flow of the generated code, especially how the inputs are processed.
  2. Test the model with different inputs.
  3. 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!

2 REPLIES 2
Pavel A.
Evangelist III

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.

 

 

mkothuri
Associate

Thanks, Pavel, for your response!

I have a few follow-up questions and clarifications regarding my setup:

  1. How can I verify that all the necessary libraries for the ONNX model are included in the project?
  2. Would using a larger model be a better approach in this case?

Steps I’ve followed so far:

  1. Added the AI extension to my STM32CubeIDE project.
  2. Checked for system performance to ensure compatibility.
  3. 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!