cancel
Showing results for 
Search instead for 
Did you mean: 

I have encountered an exception in CubeMX 6.2.0 migrating a project for STM32L4R7ZI CubeMX finishes the migration. the IOC file is modified. The tool seems to operate normally. If I choose "generate code" the tool crashes. What can I do to bypass this?

Johannes
Senior

Java console output excerpt.

2021-03-31 17:06:02,953 [INFO] CodeEngine:229 - oldGeneratedFile, C:\Projekte\ST_IDE_15\eifel\Core\Src\spi.c_save

2021-03-31 17:06:03,015 [ERROR] runtime:60 - Error executing FreeMarker template

FreeMarker template error:

The following has evaluated to null or missing:

==> varName [in template "ip_c.ftl" at line 419, column 78]

----

Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use [#if myOptionalVar??]when-present[#else]when-missing[/#if]. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??

----

----

FTL stack trace ("~" means nesting-related):

    - Failed at: #assign indicator = varName + "." + a... [in template "ip_c.ftl" in macro "generateConfigModelCode" at line 419, column 57]

    - Reached through: @generateConfigModelCode configModel=... [in template "ip_c.ftl" in macro "generateConfigCode" at line 654, column 6]

    - Reached through: @generateConfigCode ipName=ipName typ... [in template "ip_c.ftl" in macro "generateServiceCode" at line 859, column 3]

    - Reached through: @generateServiceCode ipName=words[0] ... [in template "ip_c.ftl" at line 1350, column 5]

----

Java stack trace (for programmers):

----

freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]

    at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)

    at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:481)

5 REPLIES 5
Khouloud ZEMMELI
ST Employee

Hello @Johannes​ 

Thanks for your post,

Could you please share your project to check it (before migration)?

Khouloud

Johannes
Senior

Sure. Please find attached. When I press "generate code" it crashes while handling Core/Src/spi.c

#t#thdma_spi1_tx.Init.Priority = DMA_PRIORITY_LOW;

#t#tif (HAL_DMA_Init(&hdma_spi1_tx) != HAL_OK)

#t#t{

#t#t#tError_Handler();

#t#t}

#n

FreeMarker template error (DEBUG mode; use RETHROW in production!):

The following has evaluated to null or missing:

==> varName [in template "ip_c.ftl" at line 419, column 78]

----

Tip: If the failing expression is known to legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use [#if myOptionalVar??]when-present[#else]when-missing[/#if]. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??

----

----

FTL stack trace ("~" means nesting-related):

- Failed at: #assign indicator = varName + "." + a... [in template "ip_c.ftl" in macro "generateConfigModelCode" at line 419, column 57]

- Reached through: @generateConfigModelCode configModel=... [in template "ip_c.ftl" in macro "generateConfigCode" at line 654, column 6]

- Reached through: @generateConfigCode ipName=ipName typ... [in template "ip_c.ftl" in macro "generateServiceCode" at line 859, column 3]

- Reached through: @generateServiceCode ipName=words[0] ... [in template "ip_c.ftl" at line 1350, column 5]

----

Java stack trace (for programmers):

----

freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]

at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134)

at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:481)

at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:401)

at freemarker.core.AddConcatExpression._eval(AddConcatExpression.java:84)

at freemarker.core.AddConcatExpression._eval(AddConcatExpression.java:57)

at freemarker.core.Expression.eval(Expression.java:101)

at freemarker.core.AddConcatExpression._eval(AddConcatExpression.java:57)

at freemarker.core.Expression.eval(Expression.java:101)

Johannes
Senior

I was able to do the migration without crash by deleting spi.c and doing the migration with cubemx 6.2.

But it keeps aborting the generation at the file spi.c

Same with CubeIDE 1.6.0

Johannes
Senior

By disabling all SPI, code generating and very slowly adding SPI features again, I was able to generate code again with CubeMX 6.2 / CubeIDE1.6.0 SW package 1.17

The only difference I found is this DMA configuration line in the old settings which is now gone in the new settings.

Maybe this line caused the migration problem.

I don't use DMAMux. This line was enabled by CubeMX when DMA have been added.

Hello @Johannes​,

First let me thank you for your feedback and your valuable inputs.

Backing to your project, you're using "Enable event" for the "SPI1_TX" DMA request as well as the "Generate peripheral initialization as a pair of .c/.h files per peripheral" option:

0693W000008yWaIQAU.png 

When using "Enable event" for the DMA Requests when "Generate peripheral initialization as a pair of .c/.h files per peripheral" option is enabled, STM32CubeMX will generate code with this exception.

This misbehavior is reported internally to be reviewed. I'll surely keep you posted with the updates.

Thus, what I can propose in this case is whether to not to use the "Enable event" or uncheck "Generate peripheral initialization as a pair of .c/.h files per peripheral" option, normally your project will be correctly generated.

Sorry for any inconvenience that this may cause.

Khouloud.