PlatformIO Community

FreeRTOS with stm32cube framework on NucleoF767ZI

I finally managed to include the build flags in platformio.ini but when I try to build I get the following error:

Compiling .pio/build/nucleo_f767zi/src/FreeRTOS/Source/croutine.o
Compiling .pio/build/nucleo_f767zi/src/FreeRTOS/Source/event_groups.o
Compiling .pio/build/nucleo_f767zi/src/FreeRTOS/Source/list.o
Compiling .pio/build/nucleo_f767zi/src/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1/port.o
Compiling .pio/build/nucleo_f767zi/src/FreeRTOS/Source/portable/MemMang/heap_1.o
Compiling .pio/build/nucleo_f767zi/src/FreeRTOS/Source/portable/MemMang/heap_2.o
Compiling .pio/build/nucleo_f767zi/src/FreeRTOS/Source/portable/MemMang/heap_3.o’

/tmp/ccl5OtCY.s: Assembler messages:
/tmp/ccl5OtCY.s:342: Error: selected processor does not support vstmdbeq r0!,{s16-s31}' in Thumb mode /tmp/ccl5OtCY.s:344: Error: instruction not allowed in IT block -- stmdb r0!,{r4-r11,r14}’
/tmp/ccl5OtCY.s:366: Error: selected processor does not support vldmiaeq r0!,{s16-s31}' in Thumb mode /tmp/ccl5OtCY.s:368: Error: instruction not allowed in IT block -- msr psp,r0’

*** [.pio/build/nucleo_f767zi/src/FreeRTOS/Source/portable/GCC/ARM_CM7/r0p1/port.o] Error 1
I think this is related to hardware floating point config or some missing build flag.

This is my project hierarchy:

pio_nucleo_freertos/
β”œβ”€β”€ include
β”‚ β”œβ”€β”€ FreeRTOSConfig.h
β”‚ β”œβ”€β”€ main.h
β”‚ └── README
β”œβ”€β”€ lib
β”‚ └── README
β”œβ”€β”€ platformio.ini
β”œβ”€β”€ src
β”‚ β”œβ”€β”€ FreeRTOS
β”‚ β”‚ └── Source
β”‚ β”‚ β”œβ”€β”€ croutine.c
β”‚ β”‚ β”œβ”€β”€ event_groups.c
β”‚ β”‚ β”œβ”€β”€ include
β”‚ β”‚ β”œβ”€β”€ list.c
β”‚ β”‚ β”œβ”€β”€ portable
β”‚ β”‚ β”œβ”€β”€ queue.c
β”‚ β”‚ β”œβ”€β”€ stream_buffer.c
β”‚ β”‚ β”œβ”€β”€ tasks.c
β”‚ β”‚ └── timers.c
β”‚ └── main.c
└── test
└── README
And this is the code:

You’re supposed to only choose one heap implementation file here, see https://www.freertos.org/a00111.html.

As seen in https://www.freertos.org/FreeRTOS_Support_Forum_Archive/October_2011/freertos_STM32F4_with_FPU_4761747.html you must add -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp to the build_flags.

You will then also encounter the error

.pio\build\nucleo_f767zi\src\main.o: In function `SysTick_Handler':
main.c:(.text.SysTick_Handler+0x0): multiple definition of `SysTick_Handler'
.pio\build\nucleo_f767zi\src\FreeRTOS\Source\portable\GCC\ARM_CM7\r0p1\port.o:port.c:(.text.SysTick_Handler+0x0): first defined here

Because FreeRTOS needs the SysTick (also don’t forget about tickless mode using configUSE_TICKLESS_IDLE…).

So the normal SysTick_Handler in main.c must be removed and the HAL timing functions must be hooked to use the FreeRTOS tick base (or all the HAL drivers won’t work), as seen in https://community.st.com/s/question/0D50X00009XkfLqSAJ/stm32cubemx-4120-freertos-missing-halinctick-in-systickhandler-

uint32_t HAL_GetTick(void)
{
    return xTaskGetTickCount(); 
}

/**
  * dummy function to avoid the standard initialization code 
  */
HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
{
    return HAL_OK;
}

See https://github.com/kaizoku-619/PIO_FreeRTOS/pull/1.

1 Like