cancel
Showing results for 
Search instead for 
Did you mean: 

X-Cube-AI Not generating application for F302R8 but works for G070RB

marchold
Associate II

I've been working on a project that involves classifying accelerometer data for activity detection. I have some python code that generates a trained model in both keras and tflite formats. 

Initially I was developing with a NUCLEO-G070RB board. With that board I can open up the .ioc file, select X-CUBE-AI Core as well as the application for validation. 

Screenshot 2024-01-10 at 4.35.13 PM.png

With this I can add a network with my .tflite model. Upon saving the .ioc file and selecting yes to generating code, I get a main that calls MX_X_CUBE_AI_Init(); at startup and in the while loop it calls MX_X_CUBE_AI_Process(); 

When i try the same process with a project created for the NUCLEO-F302R8 or a project created for a custom board with a STM32F302K8 and go through the same steps I run in to some problems. 

The first problem I run in to is that it says i don't have enough Flash or Ram. It's weird because it reports needing 4.37KiB of RAM and 35.85KiB of flash and this board has 64K flash and 16K RAM. Well ok maybe the flash is used up for other stuff in the validation application template so maybe its not so weird.

Since this one has a floating point unit i tried with the Keras not quantized model. With medium compression It seems happy about the flash requirement and the Analyze step completes successfully.  Next I close the .ioc file. It asks me if I want to save it and i select yes. There is no popup about generating code and my main is left with the default stuff with no calls to the MX_X_CUBE_AI functions. Right clicking on the .ioc file shows the generate code option is grayed out. 

Any advice about how i might be able to get this code generation to work on this hardware would be greatly appreciated.

4 REPLIES 4
Rim LANDOLSI
ST Employee

Hello @marchold and welcome to the community,

 

I will look into this issue and get back to you as soon as possible.

 

Thanks,

Rim.

Rim LANDOLSI
ST Employee

Hello @marchold ,

I have tried to reproduce the problem but code generation works successfully for X-CUBE-AI for validation template Application with stm32CubeIDE 1.14.0 , stm32CubeMX 6.10.0 and the MCU STM32F302K8.

Could you please specify which CubeIDE and CubeMX you are using for this project.

 

marchold
Associate II

When I wrote the question I was on IDE version 1.13 under Mac OS Ventura. Since it worked for you I assumed it must have had something to do with my version or something with my computer setup, so I tried on a windows 10 PC and installed a fresh copy of 1.14.0. I ran in to the same problem. Here are my repro steps:

  1. Create a new project (Project Explorer right click -> new -> stm32 project)
  2. in the MCU/MPU Selector. Under commercial part number I type: STM32F302K8 and select the first item on the list in the lower right, and click next
  3. project name I type "test" and click finish and wait for it to do its thing
  4. The test.ioc file opens up and i select Connectivity->USUART2, and under mode i select Asynchronous, and under baud rate i change it to 115200
  5.  Close the tab for test.ioc with the X icon on the tab bar. At the popup for do you want to save i select save. Then the popup for do you want to generate code comes up and I select yes, also yes at the popup about the perspective
  6. Inspecting my main.c I see that the init function for UART comes up. So its all good here
  7. Double click the test.ioc file to open that view again. 
  8. Select Middleware and software packages
  9. Click X-CUBE-AI and click core and in the application dropdown select validation. Like the image in my earlier post. Then select OK to close that view.
  10. Again select Middleware and software packages and click on X-CUBE-AI
  11. A popup about parameters not set for best performance comes up and I select yes
  12. On the bottom where it says platform settings I select USUART2 under found solutions
  13. click the Add Network button. 
  14. Select TFLite and choose my model.tflite file (note I made the model a little smaller so it will fit)
  15. click the Analyze button and wait for it to do its thing and click ok to close it
  16. Close the test.ioc file by clicking the X icon in the tab bar
  17. save ioc file popup shows up and I click the Save button
  18. A progress spinner shows up for about 15 seconds. No popup about generating code
  19. There is a popup about the perspective and I click Yes
  20. Inspect main.c and nothing has changed.
  21. Right click on the test.ioc and Generate Code is greyed out
  22. Try clicking on the project menu to select Generate Code but its greyed out too
  23. At this point my .ioc code generation seems basically broken. If I do any changes to it like add a GPIO input pin it still does not ask to generate code.

 

I eventually did find a workaround. If I re-open the .ioc file the Generate Code under the project menu will not be greyed out and i can select it. This sort of unlocks the .ioc code generation and I am able to make changes to it and get the popup about generating code again.

Its the same on my mac. 

I think that somehow when i went through the process for the NUCLEO-G070RB I did not trigger the bug because my repro steps were slightly different. I think if i follow the exact same steps for but use this board it will reproduce the same way. So it seems to have something to do with the order I do things instead of having anything to do with the STM32F302K8.

 

löns
Associate II

I have the exact same issue as @marchold, also using a .tflite model in Cube.AI. His workaround also works for me. I just updated my IDE to the newest version, so the bug still persists.

I am glad I found his answer, otherwise I would have given up, since not being able to generate code from the .ioc file makes all further development impossible.