cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX FreeRTOS and __weak

Posted on September 13, 2017 at 14:49

When enabling the FreeRTOS idle hook STM32CubeMX generates a function with the following prototype in the freertos.c file:

__weak void vApplicationIdleHook( void )

However __weak isn't defined in any one of the included header files (I'm using GCC with Makefile target) so the file can't be compiled until defining the __weak as __attribute__((weak)) somewhere.

#idle-hook #freertos
1 ACCEPTED SOLUTION

Accepted Solutions
Jeanne Joly
Senior III
Posted on February 01, 2018 at 10:17

Hi

sweden

,

There is a post where I have just answered for the same topic. Please refer to it (

https://community.st.com/0D50X00009XkfyISAR

) and tell me if you still have issues.

BR. Jeanne

View solution in original post

5 REPLIES 5
Imen.D
ST Employee
Posted on September 13, 2017 at 17:41

Hi,

Which tools version are you using ?

Kind Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on September 14, 2017 at 09:58

STM32CubeMX v4.1 on Linux, STM32CubeL0 v1.0, STM32L IOC file is attached.

________________

Attachments :

freertos-test.ioc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyRl&d=%2Fa%2F0X0000000b7i%2Ftr_9r_LmjEqa8bXEfgQvMx82hTOzf8zPbiZ.QjfT.qg&asPdf=false
Jeanne Joly
Senior III
Posted on February 01, 2018 at 10:17

Hi

sweden

,

There is a post where I have just answered for the same topic. Please refer to it (

https://community.st.com/0D50X00009XkfyISAR

) and tell me if you still have issues.

BR. Jeanne

Posted on February 01, 2018 at 10:49

Thanks,

Joly.Jeanne

‌, the problem with __weak seems to be gone: after removing all those duplicate filename definitions (a new bug?) from the Makefile I was able to compile the binary.

Hi I have the same problem with missing __weak for STM32G071 project.

I looked at your link, but I don't have any custom makefile to modify. I use CUBE IDE to generate the build script precisely to avoid having to maintain one :-).

I use only LL API to write my drivers, so I suspect that may be a possible condition for the problem to appear (no HAL drivers).

When searching for __weak definition there is none in the entire project. So it is not missing an include. Looks like a bug in code generator not checking for its use in app_freertos.c

Fortunately the __weak line is in /* USER CODE BEGIN  */ block so I can comment entire function and get rid of the error and make sure that the function is actually correctly defined somewhere. I would actually prefer a compile warning with an explicit message to define these functions. Using __weak may hide the need to handle it. The comments inside them are good.

I use Cube version 15.1 but I recall it was there in several past versions too.