Skip to main content
Vasile Guta_Ciucur
Senior
September 9, 2017
Question

STM32CubeMX generate incomplete code for an LL based STM32L1 project

  • September 9, 2017
  • 7 replies
  • 5725 views
Posted on September 09, 2017 at 06:39

Update:

 As the below error appeared when I tried to make a Low Layer project for Nucleo L152RE board using STM32CubeMX in generating a code for a Makefile project, and, it was solved by an update to both STM32CubeMX and LL driver, the generated code remains unusable so, I chose a more appropriate title.

Original topic:

- undefined reference to `LL_RCC_GetSystemClocksFreq'

This function is referenced inside LL_I2C_Init function. I am using the last version of STM32CubeMX and I'm writing code for Nucleo L152RE board using Low Layer drivers.

I generated code for using the I2C1 peripheral, and I did a compilation without adding my own code. And it trows the error specified in the title at linker time. I also use the last version of ARM gcc compiler from the gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 archive under Linux Fedora 26. 

I attached the project archive.

#stm32cubemx #i2c #timer #incomplete-code #undeleted-temporary-files #missing-files #beta-quality #nucleo-l152re #linker-error
This topic has been closed for replies.

7 replies

Vangelis Fortounas
Associate II
September 9, 2017
Posted on September 09, 2017 at 10:58

Hello!

For some reason  ''stm32l1xx_ll_rcc.c'' is not referenced from your project.

I found that the problem starts when you choose the highlighted options at settings.(first and second)

It is not enough to just change the option in your project.

0690X00000608BCQAY.png

Make a project without choose this settings  and will be ok

regards

vf

Vasile Guta_Ciucur
Senior
September 9, 2017
Posted on September 09, 2017 at 11:25

Thank you very much Vangelis for the detective work and workaround solution! It allows me to go further without waiting for ST update on STM32CubeMX. I will mark your reply as the answer and hope that ST saw this 'bug report'.

Vasile Guta_Ciucur
Senior
September 10, 2017
Posted on September 11, 2017 at 00:13

I suppose, problems are deeper. Even with the third option, I don't get the required file included in the Makefile. Yes, the compilation goes ok, no complains, but not a functional code for my board, not even for toggling the included LD2 LED. With, or without the rcc file included in the Makefile. All I add in the while loop is the following:

 /* Infinite loop */ 
 /* USER CODE BEGIN WHILE */ 
 while (1) { /* USER CODE END WHILE */
 /* USER CODE BEGIN 3 */ 
 LL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin); 
 LL_mDelay(500); 
 } 
 /* USER CODE END 3 */
�?�?�?�?�?�?�?�?�?�?

And this, with a newly generated project, without the I2C activated, where all setup was the default one, for my nucleo board (well, I set the OSC32 using the STM32CubeMX interface as having a crystal, as is on board). The LED does not blink.

Is not the LL implementation for this board/micro functional yet when generated for Makefile project?

Tesla DeLorean
Guru
September 11, 2017
Posted on September 11, 2017 at 03:31

Does the makefile even explicitly call out the .C files, or just build *.c

Perhaps step the code in the debugger to understand what is happening?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Vasile Guta_Ciucur
Senior
September 11, 2017
Posted on September 11, 2017 at 05:06

I can't debug it yet, I am at the beginnings with this microcontroller, only programed PIC and AVR 8bit micros. The project is similar to the one attached already, but without I2C enabled. Basically, The STM32CubeMX loads the initial configuration for selected board and is ready to generate the code. And I generated the code for the Makefile and inserted only those two lines of code. For the same board default configuration I generate code using HAL driver and I get an working application for the OpenSTM32 IDE 

https://github.com/funlw65/my_nucleo_l152re

  . It should work also for the LL driver but it seems this wasn't tested enough before release...
Vasile Guta_Ciucur
Senior
September 15, 2017
Posted on September 15, 2017 at 04:26

Man, is really hard when you are a beginner, the language stays in your way and the ST team considers that is a waste of time to look into a problem that they consider solved with the 1.8.0 version of the driver!

Of course the driver is ok. And of course the provided LL examples within the driver archive are functional and compiles ok.

And of course, I found the error and is in the code generated by STM32CubeMX for a Makefile project. Specifically, in the SystemClock_Config function. As I don't have a debug setup, I copied from a functional LL blink example the SystemClock_Config function and renamed it SystemClock_Config2. Now the LED blinks. I'm attaching the project for the team to figure it. In the main.c file you will have both the original function generated by the Cube and the copied one from the LL example for comparison.

Edit: examining the two function, the Cube's generator code omits to insert the

'LL_FLASH_Enable64bitAccess();'

line of code inside the SystemClock_Config function and the result is non-functional. No big of a deal once you know the reason, but enough for a new version of CubeMX software.

________________

Attachments :

ll_blink.tar.gz : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyRq&d=%2Fa%2F0X0000000b7l%2F97u94mhvYtpxwiRzblGu8RDIK2xxn64h9f2Rm2KwY.A&asPdf=false
Vasile Guta_Ciucur
Senior
September 16, 2017
Posted on September 16, 2017 at 04:13

Further info on this:

There is a correlation between LL_FLASH_Enable64bitAccess() and LL_mDelay() function. If you omit to insert the LL_FLASH_Enable64bitAccess() at the beginning of the SystemClock_Config function, the following code from inside LL_mDelay function will cause a crash of your app:

 __IO uint32_t tmp = SysTick->CTRL; /* Clear the COUNTFLAG first */ 
 /* Add this code to indicate that local variable is not used */ 
 ((void)tmp); �?�?�?

Vasile Guta_Ciucur
Senior
October 8, 2017
Posted on October 08, 2017 at 03:32

When you create an I2C project, the omitting of stm32l1xx_ll_rcc.c is still a current problem in 4.22.1 :

 

Well, I loaded a similar project in CubeMX and activated the I2C peripheral, specified the LL driver, saved the project as a new project and generated the code. The required .c file was omitted (but not his header).

Amel NASRI
Technical Moderator
October 11, 2017
Posted on October 11, 2017 at 15:21

Hi

Guta_Ciucur.Vasile

‌,

Thanks for the follow of this thread and all the entries you shared, that should help us to fix the reported issues.

These are the resultsof the quick analysis I made:

  1. based on the .ioc file you shared in the packagemk_ll_pcf8583_lcd.tar.gz, I confirm the error you reported using Keil as toolchain.
  2. I agree with you that a call toLL_FLASH_Enable64bitAccess has to be added as the Flash latency cannot be updated (with the call ofLL_FLASH_SetLatency in SystemClock_Config) unless the ACC64 is set.

These 2 bugs are reported internally.

For the 3rd case related to TIM, I suggest that yo add the code into a 'User code' section to avoid its overwriting.

-Amel

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.
Vasile Guta_Ciucur
Senior
October 12, 2017
Posted on October 12, 2017 at 04:18

Thank you Amel, much appreciated!

As for TIM, please consider that you deal with a beginner that doesn't know yet what is needed for a TIM to start working and anyway, I understand that that is the minimum code (at least. for exactly that reason) that must be generated by the CubeMX. Then it comes the user addition. In fact that was what I wanted to underline: the CubeMX doesn't do yet a complete job regarding generating LL based code. But I know it is a matter of time.

Thank you again!

Vasile Guta_Ciucur
Senior
November 12, 2017
Posted on November 12, 2017 at 09:31

The version 4.23 generate a broken Makefile for a new project - includes duplicate source files like bellow:

######################################
# source
######################################
# C sources
C_SOURCES = \
Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_ll_exti.c \
Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_ll_pwr.c \
Src/system_stm32l1xx.c \
Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_ll_utils.c \
Src/main.c \
Src/main.c \
Src/stm32l1xx_it.c \
Src/stm32l1xx_it.c \
Drivers/STM32L1xx_HAL_Driver/Src/stm32l1xx_ll_gpio.c 
�?�?�?�?�?�?�?�?�?�?�?�?�?�?

And specifies the main.c file in the path section:

#######################################
# paths
#######################################
# source path
SOURCES_DIR = \
Drivers/CMSIS \
Drivers \
Drivers/STM32L1xx_HAL_Driver \
Application/User/Src \
Application/User \
Application/User/Src/main.c \
Application/MAKEFILE \
Application/User/Src/stm32l1xx_it.c \
Application
�?�?�?�?�?�?�?�?�?�?�?�?�?�?

It doesn't affect me, as I copy a similar Makefile from the previous version (that had a functional Makefile), but this

prevents me from presenting STM32CubeMX as a solution in generating IDE agnostic LL applications.

:(

sad, as I have the sensation that this is what you want right now...
Sirma Siang
ST Employee
November 15, 2017
Posted on November 15, 2017 at 17:37

Hello

,

Great thanks for your feedback.

I have tested your ioc on what will be CubeMX4.0.

Missing rcc file and source file duplication have been corrected.

I attached the generated makefile to that post.

Kind regards

Sirma

________________

Attachments :

Makefile.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyIj&d=%2Fa%2F0X0000000b5l%2Fssg6YAWqPDSv9do6ymufuoKeT12mPtZglVLmT1.cOsA&asPdf=false
Vasile Guta_Ciucur
Senior
November 16, 2017
Posted on November 16, 2017 at 02:57

These are great news, thank you very much Sirma!

I will continue to report the bugs I find. Hopefully, with the next version I will get the much desired basic functionality.

Michael B.
Associate
December 3, 2018

Now it is more than one year later and Cube still creates broken LL projects. Does no-one from ST care?

Amel NASRI
Technical Moderator
December 5, 2018

Hi @Michael Bürschgens​ ,

Could you please explain the reason behind this assessment?

Does the problem reported in this discussion still being faced?

We are continuously working to improve the solutions offered by ST.

Nevertheless, if you find any limitation, please submit it in a new question here and use relevant topics like: STM32CubeHAL/LL or LL-Drivers (if it is related to LL).

Thanks for your understanding.

-Amel

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.
Michael B.
Associate
December 6, 2018

Hi

Thanks for replying. My comment relates to the issue that STM32CubeMX, even in the most recent version 5.0.0, still creates projects which don't compile from the beginning because of missing library references.

I had opened a ticket with Sysprogs, the maker of VisualGDB because an empty imported STM32CubeMX project didn't compile and I thought it was an import issue. They analyzed the files provided by me and stated:

---------------

Thanks for providing the 100% repro case.

We have reproduced the problem on our side, however it looks like it's caused by the STM32CubeMX generator: the .gpdsc file produced by it does is missing one definition and several source files.

You can get the imported project to build by defining the USE_FULL_LL_DRIVER macro via VisualGDB Project Properties (or VS Project Properties) and then adding the stm32f3xx_hal_rcc, *rcc_ex and *ll_gpio.c files to the project.

---------------

Since then I add the missing references to every STM32CubeMX generated project using the low layer API before starting with my code.

Best Regards

Michael