cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX does NOT work in quiet mode

dvescovi
Senior

Follow-on from CubeMX code generation from command line.


I am posting again in hopes of getting meaningful answer.

I tried creating a simple script text file to automate code generation for my project. The script file has all of three lines:

config load DCC_tester.ioc
generate code .
exit

The feedback I got on why it did not work was my .ico file was corrupted. To prove this was not the case I used a very simple project file using one of your example projects from one of your released STM32H5 bundles.

The only modification I made was changing the name and making it a cmake project.

I am running on Windows 11 with CubeMX installed using all defaults.

I can click on the .ioc file from Windows Explorer and the MX IDE opens just fine. I can click the "GENERATE CODE" button and that also works just fine. All the files are generated as expected.

I try launching using the -q using ether a PowerShell script or a command line batch file and neither completes although it looks like its trying.  Seems to stall leaving a MXTmpFiles folder. cmake and other files like startup and linker file are not generated.

I have attached the .ioc  the script  text file as well as PowerShell and batch file ... none work as expected.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @dvescovi 

Just use "exit" instead of "exit_mx"

Please remember to mark the reply that helped you as the Best Answer so that other users can more easily find this solution.

THX

Ghofrane

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

6 REPLIES 6
Ghofrane GSOURI
ST Employee

Hello @dvescovi 

In your script , just do the following modification :

config load <filename>
generate code <path>
exit_mx

Example

config load "C:\Users\gsourigh\OneDrive - STMicroelectronics\Desktop\Thread\testcodegen\DCC_tester.ioc"
generate code "C:\Users\gsourigh\OneDrive - STMicroelectronics\Desktop\Thread\testcodegen"
exit_mx

 

Then launch the following command after cd the installation path of MX6.16.0 

jre\bin\java -jar .\STM32CubeMX.exe -q "script path"

example 

jre\bin\java -jar .\STM32CubeMX.exe -q "C:\Users\gsourigh\OneDrive - STMicroelectronics\Desktop\Thread\testcodegen\generatecode.txt"

As you can see , the code will be generated successfully.

GhofraneGSOURI_0-1765457590478.png

 

 

THX

Ghofrane

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.

looks like you have cubemx installed in a different location. I have mine at:

C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX\STM32CubeMX.exe

which is Windows standard location for everyone.

I have ioc and script in my c:/tmp/testcodegen

generatecode.txt now looks like:

config load C:\tmp\testcodegen\DCC_tester.ioc
generate code C:\tmp\testcodegen
exit_mx

launched by cd to 

C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX>

then

C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX>jre\bin\java -jar .\STM32CubeMX.exe -q "C:\tmp\testcodegen\generatecode.txt"

Tried again using my correct full paths and I get some source code generated but not cmake, linker startup etc.

dvescovi_0-1765481417752.png

 

dvescovi_1-1765481924636.png

you can src and inc folders and files created within but NO cmake, linker, or start up files.

 

 

did not have quotes around path in generatecode.txt but even after adding them ... same results.

 

Hello @dvescovi 

In your script , let's try to use "project generate" instead of "generate code"

GhofraneGSOURI_0-1765523991164.png

 

GhofraneGSOURI_1-1765524264562.png

 

THX

Ghofrane

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.

Yes, that is much better. Looks like everything is being generated.

Does not seem to exit gracefully though.

Attached is revised Cube32MX and PowerShell script.

projectgen.jpg

 

Hello @dvescovi 

Just use "exit" instead of "exit_mx"

Please remember to mark the reply that helped you as the Best Answer so that other users can more easily find this solution.

THX

Ghofrane

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.