cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with X-CUBE-AI code generation

SR1218
Associate II

Hello, I installed X-CUBE-AI 10.2.0 from STM32CubeMX in STM32CubeIDE 1.18.1. After enabling X-CUBE-AI in the ioc file and performing code generation, the folders /Middlewares/ST/X-CUBE-AI/Inc and /Middlewares/ST/X-CUBE-AI/Lib are created, but no code is generated in those folders. Therefore, when building the project, I get an error such as:

fatal error: ai_platform.h: No such file or directory

In Project Manager → Code Generator → Generated files panel, I unchecked the option “Delete the previously generated files when not regenerated” and regenerated the code, but the problem was not solved. Please help me.

If there is any necessary information that I have not provided, please let me know.

This message was translated into English using generative AI. I apologize for any awkward sentences or expressions.

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @SR1218,

 

Ok, I did not understand that you had already a project and wanted to add the AI part using X Cube AI.

I think that X Cube AI is useful if starting from scratch. In your case, I would suggest using the ST Edge AI Core directly in command line (X Cube AI is just a GUI of the ST Edge AI Core).

 

Because you've already used X Cube AI, the ST Edge AI Core is already installed on your pc, you can find the .exe here:

C:\Users\your_user\STM32Cube\Repository\Packs\STMicroelectronics\X-CUBE-AI\10.2.0\2.2\utilities\windows

 

Then look at the documentation for STM32 here:

https://stedgeai-dc.st.com/assets/embedded-docs/index.html#stm32-target

 

And in particular this two:

Generate the C code model and add it to your ioc project: https://stedgeai-dc.st.com/assets/embedded-docs/stm32_command_line_interface.html#update_c_files

Use the model: https://stedgeai-dc.st.com/assets/embedded-docs/stm32_how_to_run_a_model_locally.html 

 

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.

View solution in original post

5 REPLIES 5
Julian E.
ST Employee

Hello @SR1218,

 

I just tried with a STM32F401RE and I have no issue.

 

Did you follow these steps:

  1. Select your board
  2. Enable X Cube AI and select the application template
  3. Browse for your model
  4. Click Analyze and make sure you don't get an error message
  5. Set a name and click generate

 

Maybe the model you want to use did not pass the generation which is causing the ai_platform.h not to be generated.

 

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. ,

 

I confirmed that if I create a new project and enable X-Cube-AI, the code generation works correctly.

The issue occurs when I import an existing project and then enable X-Cube-AI. My current project already uses libraries such as FreeRTOS and USB Host, and I have made related code modifications. In this case, even after enabling X-Cube-AI and performing code generation, the /Middlewares/ST/X-CUBE-AI/Inc and /Middlewares/ST/X-CUBE-AI/Lib codes are not generated, while the /X-CUBE-AI/App code is generated correctly.

For small projects, creating a new project and reusing the libraries might be a good approach. However, since I have already made significant code modifications, I would prefer not to move everything to a new project.

I would appreciate your guidance on this.

Thank you.

Hello @SR1218,

 

Ok, I did not understand that you had already a project and wanted to add the AI part using X Cube AI.

I think that X Cube AI is useful if starting from scratch. In your case, I would suggest using the ST Edge AI Core directly in command line (X Cube AI is just a GUI of the ST Edge AI Core).

 

Because you've already used X Cube AI, the ST Edge AI Core is already installed on your pc, you can find the .exe here:

C:\Users\your_user\STM32Cube\Repository\Packs\STMicroelectronics\X-CUBE-AI\10.2.0\2.2\utilities\windows

 

Then look at the documentation for STM32 here:

https://stedgeai-dc.st.com/assets/embedded-docs/index.html#stm32-target

 

And in particular this two:

Generate the C code model and add it to your ioc project: https://stedgeai-dc.st.com/assets/embedded-docs/stm32_command_line_interface.html#update_c_files

Use the model: https://stedgeai-dc.st.com/assets/embedded-docs/stm32_how_to_run_a_model_locally.html 

 

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.

Sorry, Problem unsolved..

When I select a model in the .ioc file and generate code with Compression: High and Optimize: RAM, the code is successfully generated in the X-CUBE-AI/App folder. Validation through the .ioc file (both Desktop and Target) also works fine.

However, in the Middlewares/ST/AI folder, only the Inc and Lib directories are created, but no actual code is generated inside them.

I also tried the following command:

$ stedgeai generate -m <model_path> --target stm32f -n <name> -c high -O ram -o <root_project_folder>

But still, no code was generated inside Middlewares/ST/AI.

This issue occurs when I import an existing project and then add the X-CUBE-AI library through the .ioc file. On the other hand, if I create a new project from scratch and add X-CUBE-AI, the code seems to be generated correctly.

Note 1. When running the above command, the console shows that network_data_params.h and network_data_params.c were generated in <root_project_folder>, but in reality, they were not created. Those files only exist under the X-CUBE-AI/App folder from a previous .ioc code generation attempt.

Note 2. I am also experiencing issues saving the .ioc file after performing X-CUBE-AI tasks (Analyze, Validation, etc.). When I try to save the .ioc file, a dialog asks whether to generate code, but even after clicking OK, neither the .ioc file is saved nor the code generated. Sometimes I have to repeat this process multiple times before the .ioc file is saved, and in some cases, it does not save at all even after five or more attempts. I am not sure if this is a bug in X-CUBE-AI itself or a problem with my STM32CubeIDE environment.

Note 3. This project also contains the USB Host library, which was generated through the .ioc file as well.

Note 4. Just in case, I am attaching both the project files and the ONNX model file I am trying to use.

Any help would be greatly appreciated.

Hello @SR1218,

 

Thank you for reporting this issue. I have seen a few threads lately with a similar issue.

I transmitted it to the dev team. 

 

Any fix will in any case come with the next version of X Cube AI.

 

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.