cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX hangs generating source

Darius121
Visitor

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) ~[?:?]
6 REPLIES 6
Ghofrane GSOURI
ST Employee

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.

Darius121
Visitor

Hi Ghofrane,

I tried the ioc file in a new directory and it works so I think it must be choking on some of the source files but I can't tell which file (let alone what part of it).

 

I've attached the IOC file, I can send you the whole project directory but would prefer not to publish it.

 

TDK
Super User

Did you remove USER CODE start/stop comment blocks from the source file?

If you feel a post has answered your question, please click "Accept as Solution".
Darius121
Visitor

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.

TDK
Super User

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.

If you feel a post has answered your question, please click "Accept as Solution".
Darius121
Visitor

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.