cancel
Showing results for 
Search instead for 
Did you mean: 

freertos.c uses undefined __weak attribute

Rob.Riggs
Senior
Posted on June 25, 2017 at 23:49

I am using STM32CubeMX 4.21.0 for STM32L4.  When using FreeRTOS with tickless support, the freertos.c file is generated with functions decleared __weak, but this macro is not defined.  I am generating for GCC.  I am running on Linux.

__weak void PostSleepProcessing(uint32_t *ulExpectedIdleTime)

{

/* place for user code */

}

I am getting annoyed at having to add

/* USER CODE BEGIN Includes */

&sharpdefine __weak __attribute__((weak))

/* USER CODE END Includes */

Can you reproduce the problem?

#freertos #stm32cubemx #linux #gcc
6 REPLIES 6
john doe
Lead
Posted on June 26, 2017 at 03:05

Odd that that is the only one that bothers you [or maybe the first one when compiling?] since the HAL is chock full o' weakly defined functions.

Posted on June 26, 2017 at 03:40

Other files include the header that defines the macro.  freertos.c does not include the proper header.

misagh
Associate III
Posted on June 26, 2017 at 10:45

Hi,

The definition is placed in 'stm32f1xx_hal_def.h' header file. so it would be helpful if you add following line at the top of your freertos.c file:

#include 'stm32l4xx_hal.h'

Bests,

Misagh

Posted on June 26, 2017 at 12:45

I know how to work around the problem.  This is a cube-generated file and needs to be fixed in the cube.

Jeanne Joly
Senior III
Posted on February 01, 2018 at 10:15

Hi

Riggs.Rob

,

I tried to reproduce your issue on top of the latest CubeMX release (cubeMX4.24).

I took a STM32L441CCTx, activated FreeRTOS, generated the code with Makefile under Linux.

FreeRTOS.c does not contain any function with __weak.

And then, I tried to compile the Makefile with make. Some changes need to be done under the Makefile :

  • under the C sources, delete the files that are mentionned twice (Src/main.c, Src/freertos.c,
  • under the source paths, deleteApplication/User/Src/main.c, Application/User/Src/stm32l4xx_hal_msp.c,

After those changes done, you can compile and obtain the binary you need.

I hope it will help you.

BR. Jeanne

Posted on April 10, 2018 at 09:04

 ,

 ,

I have Cube 4.25 and I generate for a STM32F746G-DISCO using ,STM32Cube_FW_F7_V1.11.0.

Cube is setting defaults for the board.

I still have the issue with __weak not being defined in freertos.c.

Problem was solved by moving ' ♯ include 'stm32f7xx_hal.h' from main.c to main.h.

List of files needed to be removed from C_SOURCES are:

Src/bsp_driver_sd.c \

 ,

Src/fatfs.c \

 ,

Src/fatfs_platform.c \

 ,

Src/freertos.c \

 ,

Src/main.c \

 ,

Src/sd_diskio.c \

 ,

Src/stm32f7xx_hal_msp.c \

 ,

Src/stm32f7xx_hal_timebase_TIM.c \

 ,

Src/stm32f7xx_it.c \

 ,

Src/usbh_conf.c \

 ,

Src/usb_host.c \

 ,

Src/usbh_platform.c \

 ,

 ,

Is Cube intended to generate a project that is ready to build and download to target, without functionality of course?