2025-12-11 3:49 AM - last edited on 2025-12-11 4:11 AM by Andrew Neil
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.
2025-12-11 3:54 AM - edited 2025-12-11 4:55 AM
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.
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.