cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX 6.10.0 hangs on "Generating user source code..."

Reneb
Associate III

The STM32CubeMX tool (I'm using 6.10.0) continuously hangs after GENERATE CODE on "Generating user source code..."

The STMCubeMX.log file (within the .stm32cubemx directory) shows a java.lang.NullPointerException:

 

 

2024-02-20 08:52:19,505 [ERROR] CodeEngine:200 - catch error: There are no more files
2024-02-20 08:52:19,505 [ERROR] ProjectBuilder:2205 - 
java.lang.NullPointerException: Cannot invoke "com.st.microxplorer.codegenerator.TemplateFile.getPath()" because "this.template" is null
	at com.st.microxplorer.codegenerator.CodeEngine.genCode(CodeEngine.java:243) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeGenerator.generateOutputCode(CodeGenerator.java:5673) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeGenerator.generatePeriphConfigCode(CodeGenerator.java:2876) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeGenerator.generateCodeFiles(CodeGenerator.java:1964) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeGenerator.generateDefaultConfig(CodeGenerator.java:9768) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeGenerator.generateCode(CodeGenerator.java:1485) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.generateCode(ProjectBuilder.java:2827) ~[?:?]
	at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.createCode(ProjectBuilder.java:2202) ~[?:?]
	at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.createProject(ProjectBuilder.java:830) ~[?:?]
	at com.st.microxplorer.plugins.projectmanager.engine.GenerateProjectThread.run(GenerateProjectThread.java:61) ~[?:?]

 

Occasionally the hang situation isn't reported with a java.lang.NullPointerException but with a java.io.IOException:

 

2024-02-20 08:54:20,963 [ERROR] ProjectBuilder:2205 - 
java.io.IOException: There are no more files
	at java.io.WinNTFileSystem.canonicalize0(Native Method) ~[?:?]
	at java.io.WinNTFileSystem.canonicalize(WinNTFileSystem.java:463) ~[?:?]
	at java.io.File.getCanonicalPath(File.java:626) ~[?:?]
	at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1079) ~[STM32CubeMX.exe:?]
	at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1038) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeEngine.genCode(CodeEngine.java:249) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeGenerator.generateOutputCode(CodeGenerator.java:5673) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeGenerator.generateMSPCode(CodeGenerator.java:4685) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeGenerator.generateCodeFiles(CodeGenerator.java:2171) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeGenerator.generateDefaultConfig(CodeGenerator.java:9768) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeGenerator.generateCode(CodeGenerator.java:1485) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.generateCode(ProjectBuilder.java:2827) ~[?:?]
	at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.createCode(ProjectBuilder.java:2202) ~[?:?]
	at com.st.microxplorer.plugins.projectmanager.engine.ProjectBuilder.createProject(ProjectBuilder.java:830) ~[?:?]
	at com.st.microxplorer.plugins.projectmanager.engine.GenerateProjectThread.run(GenerateProjectThread.java:61) ~[?:?]

 

I don't know why this happens, but I get the feeling it has something to do with amount of files to be generated. The larger the number of "Pinout & Configuration" settings the more likely the hang situation seems to occur. Maybe also in combination with the "Project Manager" option "Generate peripheral initialization as a pair of '.c/.h' files per peripheral"

How can this be fixed? Or is there a work around?

9 REPLIES 9
Mahmoud Ben Romdhane
ST Employee

Hello @Reneb ,

First let me thank you for posting.

For more investigation I suggest that you provide your ioc.file.

Thanks.

Mahmoud.

 

Reneb
Associate III

Hello @Mahmoud Ben Romdhane,

Here is the ioc-file. I use this with Keil MDK.

Hello @Reneb ,

Further to your comment.

I reproduced your request, and the issue was not reproduced.

No exceptions found in the STMCubeMX.log file and the code generation was successfully done.

Thanks.

Mahmoud.

 

 

Reneb
Associate III

Hello @Mahmoud Ben Romdhane,

What could be the cause for these exceptions, or what are the circumstances which can lead to these exceptions? This must be located within the java source of STM32CubeMX as both occur from within the CodeEngine.java source. And both seem to have something to do with files. The NullPointerException has something to do with a TemplateFile,

java.lang.NullPointerException: Cannot invoke "com.st.microxplorer.codegenerator.TemplateFile.getPath()" because "this.template" is null
	at com.st.microxplorer.codegenerator.CodeEngine.genCode(CodeEngine.java:243) ~[STM32CubeMX.exe:?]

and the IOException with copying a file.

	at org.apache.commons.io.FileUtils.copyFile(FileUtils.java:1038) ~[STM32CubeMX.exe:?]
	at com.st.microxplorer.codegenerator.CodeEngine.genCode(CodeEngine.java:249) ~[STM32CubeMX.exe:?]

So what can cause these exceptions?

 

Hello @Reneb ,

Can you provide please the log.File.

Thanks.

Mahmoud.

Reneb
Associate III

Hello @Mahmoud Ben Romdhane,

Attached you'll find the log file, and the ioc file.

Kind regards,

Reneb

Fladek
Associate II

Hey I am having exactly the same problem, did you find any fix yet?

I am trying to add modbus communication via USB to a program running on a STM32F49I Discovery Board. This error only seems to occur after having added the USB_DEVICE or USB_HOST Software Pack to the project. For a project without using a display (so without TouchGFX) code generation works fine, but this combination doesn't seem to work. 

 

Probably unrelated, but before adding the USB Library i also sometimes got the following error while CubeMX was generating the code 

[ERROR] Middleware:2969 - Invalid RefComponent liste

this error did however not stop the code generation and did not lead to any problems when running the project on my device. 

 

I have spend hours trying to find the fault but I can't seem to get any closer, so any ideas or help would be greately appreciated.

Hello @Fladek,

I didn't find a fix, but a workaround. I don't use the USB middleware though.

I create my designs on our server (like a NAS) and so use a network drive under Windows 10. Since the exceptions seem to be related to the creation of files, maybe the file access to the network drive caused the exceptions. Maybe a delay in time during the access?

So to test this, I copied the project (including the ioc file) to the local disk. And during GENERATE CODE the tool seems to respond faster, and no exceptions occur anymore. So I have a workaround.

In my opinion the occurrence of these exceptions can only be described as a bug within STM32CubeMX. Any exception which is not caught by the program itself shows a problem. If the NullPointerException is related to a network drive access, STM32CubeMX should be made more robust to be able to handle such accesses.

I'm not sure ST sees it that way, and I don't know if ST will try to fix this bug. It is hard to reproduce the problem if the circumstances at the ST helpdesk are not the same as within my network. The ST helpdesk didn't reproduce the problem. Diving into the java source code and analysing what could cause these exceptions is a much harder and more time consuming approach.

But for now I can work with this workaround I found.

 

Hey @Reneb,

thanks for the fast reply. 

You are right, I also had the project on a server. Copying the project to local and running the code generation there worked fine. 

Really annoying bug but thanks a lot for the workaround!