2025-12-08 7:18 AM - last edited on 2025-12-08 7:45 AM by Andrew Neil
I would like to automate code generation of my .ioc file using CubeMX from command line or PowerShell.
AI says its possible with the -q (quiet mode) option but it does not seem to work.
2025-12-08 7:37 AM - edited 2025-12-08 7:38 AM
Hello @dvescovi
Yes, as stated in UM1718 "3.3.2 Running STM32CubeMX in command-line mode" you can run STM32CubeMX in command-line mode without UI:
– On Windows:
cd <STM32CubeMX installation path>
jre\bin\java -jar STM32CubeMX.exe –q <script filename>
– On Linux and macOS:
./STM32CubeMX –q <script filename
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.
2025-12-08 7:47 AM
@dvescovi wrote:AI says its possible with the -q (quiet mode) option but it does not seem to work.
What version are you using?
Please show the command you actually used, and the results you got.
How to write your question to maximize your chances to find a solution
2025-12-08 12:11 PM - last edited on 2025-12-09 1:03 AM by Andrew Neil
can you show me what a powershell script would look like if I have CubeMX installed at:
C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX
and my .ioc at:
C:\GitHub\STM32\debug\tester\test.ioc
I tried:
# Path to CubeMX executable
$CubeMX = "C:\Program Files\STMicroelectronics\STM32Cube\STM32CubeMX\STM32CubeMX.exe"
# Path to your .ioc project file
$Project = "C:\GitHub\STM32\debug\tester\test.ioc"
# Run CubeMX in quiet mode (-q) to generate code without opening the GUI
Start-Process -FilePath $CubeMX -ArgumentList "-q `"$Project`"" -Wait
but I know that is wrong ...
Show me formatted correctly
2025-12-09 1:04 AM - edited 2025-12-09 1:07 AM
@dvescovi wrote:but I know that is wrong ...
So, again, what response do you get when you run that command?
@dvescovi wrote:Show me formatted correctly
Did you try what @Souhaib MAZHOUD already showed you:
@Souhaib MAZHOUD wrote:– On Windows:
cd <STM32CubeMX installation path>
jre\bin\java -jar STM32CubeMX.exe –q <script filename>
If that doesn't work for you, show what result you get.
2025-12-09 3:28 AM
I suggest you actually try it before offering it as a solution.
Here is what I get:
Dumps a lot of *** ... opens the CubeMX IDE ... which I do not want ... does nothing no code generated!
2025-12-09 4:20 AM
So I tried to launch in interactive mode copying the line from UM1718
I get:
Tried several variations assuming it was the CR/LF in copy/paste causing problems ... sill cannot get it right.
2025-12-09 4:46 AM
So next I tried launching a simple script. ...
I know the .ioc file at C:\GitHub\STM32\debug\DCC_tester\DCC_tester.ioc is perfectly valid as I can just click on it in Windows Explorer and CubeMX launches and loads it just fine.
I created a simple script named CubeMXGenerateCode.txt with the following two line:
config load "C:\GitHub\STM32\debug\DCC_tester\DCC_tester.ioc"
exit
I placed it in the same folder as my other project and .ioc files.
Tried to launch it with:
I get:
dump window:
??
2025-12-09 8:23 AM
Hello @dvescovi
It seems that your IOC is corrupted or you tried to open it with a non-compatible version. Could you attach your ioc to investigate the problem?
Otherwise, to generate code you should add a line in your script as bellow:
generate code <path>
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.
2025-12-09 8:50 AM
Duh .. as I stated before "I know the .ioc file at C:\GitHub\STM32\debug\DCC_tester\DCC_tester.ioc is perfectly valid as I can just click on it in Windows Explorer and CubeMX launches and loads it just fine."