2025-08-19 11:24 PM
Hi,
I am finding STM32CubeMX is hanging when generating code in my project. I have had this in the past and managed to work around it by adjusting main.c so it didn't complain however that isn't working this time.
If I run it in the console I see..
2025-08-20 15:48:29,933 [INFO] CodeEngine:265 - oldGeneratedFile, /Users/oconnd1/work/micro/hv_psu/hv_psu01/Core/Inc/main.h_save
2025-08-20 15:48:30,033 [INFO] CodeEngine:289 - Generated code: /Users/oconnd1/work/micro/hv_psu/hv_psu01/Core/Inc/main.h
2025-08-20 15:48:30,037 [INFO] CodeEngine:265 - oldGeneratedFile, /Users/oconnd1/work/micro/hv_psu/hv_psu01/Core/Src/main.c_save
2025-08-20 15:48:30,208 [INFO] CodeEngine:289 - Generated code: /Users/oconnd1/work/micro/hv_psu/hv_psu01/Core/Src/main.c
2025-08-20 15:48:30,215 [ERROR] ProjectBuilder:2238 -
java.lang.NullPointerException: Cannot read the array length because "<local4>" is null
at com.st.microxplorer.codegenerator.CodeGenerator.cleanDir(CodeGenerator.java:2746) ~[STM32CubeMX:?]
at com.st.microxplorer.codegenerator.CodeGenerator.cleanDir(CodeGenerator.java:2752) ~[STM32CubeMX:?]
at com.st.microxplorer.codegenerator.CodeGenerator.cleanDir(CodeGenerator.java:2752) ~[STM32CubeMX:?]
at com.st.microxplorer.codegenerator.CodeGenerator.cleanDirectory(CodeGenerator.java:2612) ~[STM32CubeMX:?]
at com.st.microxplorer.codegenerator.CodeGenerator.generateDefaultConfig(CodeGenerator.java:10992) ~[STM32CubeMX:?]
at com.st.microxplorer.codegenerator.CodeGenerator.generateCode(CodeGenerator.java:1593) ~[STM32CubeMX:?]
at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.generateCode(ProjectBuilder.java:3343) ~[?:?]
at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.createCode(ProjectBuilder.java:2235) ~[?:?]
at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.createProject(ProjectBuilder.java:819) ~[?:?]
at com.st.microxplorer.plugins.projectmanager.engine.GenerateProjectThread.run(GenerateProjectThread.java:61) ~[?:?]
2025-08-20 12:54 AM
Hello @Darius121
Could you please share your IOC file so that I can reproduce the behavior you are experiencing and investigate the issue further?
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.
2025-08-20 3:30 AM
2025-08-20 5:41 AM
Did you remove USER CODE start/stop comment blocks from the source file?
2025-08-20 6:05 AM
I tried deleting main.c, main.h and stm32l0xx_it.c and it still crashed - after that I tried a blank directory and it worked.
It is not a very useful tool if it can't even tell me file and line the issue is at - seems like a basic exception catch around the file processing and printing the filename (and roughly where in the file) would make it a lot easier to work around.
2025-08-20 6:14 AM
I think the tool is still useful despite some issues. If users modify source files in a non-compatible manner, there are bound to be problems. If modified in the correct manner, the tool works, and that's the most important thing.
2025-08-20 6:35 AM
I didn't say it was useless, but it wastes a lot of time the way it behaves now.
How does one determine what the "correct" manner is if the tool doesn't give any clue what is wrong?
Is there an internal bug tracking this issue? It would be nice to know there is hope it will be fixed at some point rather than hand waved away as operator error.