cancel
Showing results for 
Search instead for 
Did you mean: 

Cube IDE 1.12.1 codegenerator crashing (stm32cube.common.mx_6.8.1.202304191431)

mfreitas
Associate II

Hi,

I have a cube ide project that has started to consistently crash the codegenerator module whenever I try to reopen the .ioc file. It displays the usual dialogs about rendering interface then nothing happens. At the console I can see the backtrace of the crash:

 

java.util.NoSuchElementException: No value present
        at java.base/java.util.Optional.get(Optional.java:148)
        at com.st.microxplorer.codegenerator.CodeGenerator.sortFunctionList(CodeGenerator.java:7386)
        at com.st.microxplorer.codegenerator.CodeGenerator.getAllFunctionList(CodeGenerator.java:7495)
        at com.st.microxplorer.plugins.projectmanager.gui.CodeGenSorting.updateSettings(CodeGenSorting.java:827)
        at com.st.microxplorer.plugins.projectmanager.gui.ProjectSettingsPanel.UpdateDialog(ProjectSettingsPanel.java:247)
        at com.st.microxplorer.plugins.projectmanager.engine.MainProjectManager.loadConfig(MainProjectManager.java:588)
        at com.st.stm32cube.common.mx.editor.CubeMxEditor.setProjectSettings(CubeMxEditor.java:1342)
        at com.st.stm32cube.common.mx.editor.CubeMxEditor.getMxTabbedPaneInstance(CubeMxEditor.java:1198)
        at com.st.stm32cube.common.mx.editor.CubeMxEditor$12$1.createSwingComponent(CubeMxEditor.java:1071)
        at com.st.stm32cube.common.mx.oss.core.awtswtbridge.EmbeddedSwingComposite.doComponentCreation(EmbeddedSwingComposite.java:492)
        at com.st.stm32cube.common.mx.oss.core.awtswtbridge.EmbeddedSwingComposite$4.run(EmbeddedSwingComposite.java:291)
        at com.st.stm32cube.common.mx.oss.core.awtswtbridge.AwtEnvironment$2.run(AwtEnvironment.java:166)
        at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
        at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
        at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
        at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
        at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
        at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
        at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
        at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

 

I have been able to reproduce the crash in a different computer by copying the entire project. I think the .ioc file might be enough to reproduce it so i'm attaching it here, but I may provide the full project if needed.

Thanks!

 

 

3 REPLIES 3
mfreitas
Associate II

Uncompiling java class com.st.microxplorer.codegenerator.CodeGenerator.sortFunctionList gives a hint of the problem:

 public static ArrayList<fctDefinition> sortFunctionList(final ArrayList<fctDefinition> functionList) {
        int previous_rank = 1;
        previous_rank += (int)functionList.stream().filter(o -> CodeGenerator.FIRST_RANKED_IP.contains(o.getIpName())).count();
        if (previous_rank >= 2) {
            for (final fctDefinition fct : functionList) {
                if (CodeGenerator.FIRST_RANKED_IP.contains(fct.getIpName())) {
                    int dmaRank = fct.getRank();
                    for (final fctDefinition f : functionList) {
                        if (!f.getIpName().equals("RCC") && !CodeGenerator.IP_WITHOUT_INIT.contains(f.getIpName()) && !CodeGenerator.FIRST_RANKED_IP.contains(f.getIpName()) && functionList.indexOf(fct) > functionList.indexOf(f) && dmaRank > f.getRank()) {
                            Collections.swap(functionList, functionList.indexOf(fct), functionList.indexOf(f));
                            fct.setRank(f.getRank());
                            f.setRank(dmaRank);
                            dmaRank = fct.getRank();
                        }
                    }
                }
            }
        }
        if (functionList.stream().filter(o -> o.getIpName().equals("PKA") || o.getIpName().equals("RNG")).count() > 1L) {
            final fctDefinition pka = functionList.stream().filter(o -> o.getIpName().equals("PKA")).findAny().get();
            final fctDefinition rng = functionList.stream().filter(o -> o.getIpName().equals("RNG")).findAny().get();
            if (rng.getRank() > pka.getRank()) {
                final int pkaRank = pka.getRank();
                Collections.swap(functionList, functionList.indexOf(pka), functionList.indexOf(rng));
                pka.setRank(rng.getRank());
                rng.setRank(pkaRank);
            }
        }
        return functionList;
    }

I'm no Java programmer, but the logic seems flawed. It seems to be looking for some sort of occurrences for "PKA" and "RNG" with count() > 1, presumably the programmer expected at least one occurrence of each kind, so he could filter them individually and then call findAny().get() on each. I think it is possible the count()>1 test might be true when multiple occurrences of either "PKA" or "RNG" but one of them might actually be missing, therefore the "No value present" exception.

mfreitas
Associate II

It seems I was right on target. By manually removing RNG from M4 core I was able to open the ioc editor again.

CortexM4.IPs=FATFS_M4\:I,FREERTOS_M4\:I,IWDG2\:I,RCC,WWDG2\:I,DMA,BDMA,MDMA,NVIC2\:I,USART3,ETH,DEBUG,USB_DEVICE_M4\:I,USB_HOST_M4\:I,PDM2PCM_M4\:I,PWR,RESMGR_UTILITY,SYS_M4\:I,CORTEX_M4\:I,OPENAMP_M4\:I,VREFBUF,GPIO,SDMMC1,TIM1,TIM2,RNG
CortexM7.IPs=FATFS_M7\:I,FREERTOS_M7\:I,IWDG1\:I,RCC\:I,WWDG1\:I,DMA\:I,BDMA\:I,MDMA\:I,NVIC1\:I,SYS\:I,USART3\:I,USB_OTG_FS\:I,ETH\:I,CORTEX_M7\:I,DEBUG\:I,USB_DEVICE_M7\:I,USB_HOST_M7\:I,PDM2PCM_M7\:I,PWR\:I,RESMGR_UTILITY\:I,OPENAMP_M7\:I,VREFBUF\:I,GPIO\:I,SDMMC1\:I,TIM1\:I,TIM2\:I,RNG\:I

But the code is still buggy...

 

Semer CHERNI
ST Employee

Hello @mfreitas 

First let me thank you for posting.

In fact I am able to reproduce the issue you have described. And as you mentioned, the issue is related to the activation of the RNG with the CM4.

However, as a temporary solution, I advise you to make use the STM32CubeMX as a standalone application for code generation. This misbehavior is exclusive to the plugin in STM32CubeIDE.

With this been said, the issue is raised internally for review and correction 151263 (This is an internal tracking number and is not accessible or usable by customers).

Kind regards,

Semer.

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.