Help: STM32F407IGT6 Compilation Error with FreeRTOS
I use CubeMX to generate project code. When not using FreeRTOS, the project compiles normally. However, when using FreeRTOS, the project fails to compile regardless of the operation.
Normal Compilation (Without FreeRTOS, Not Using PlatformIO’s HAL Library)
[platformio]
src_dir = ./
[env:genericSTM32F407IGT6]
platform = ststm32
board = genericSTM32F407IGT6
; framework = stm32cube
build_flags =
-IInc
-IDrivers/STM32F4xx_HAL_Driver/Inc
-IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy
-IDrivers/CMSIS/Device/ST/STM32F4xx/Include
-IDrivers/CMSIS/Include
Attempt After Adding FreeRTOS
Solution 1: Using Libraries Generated by CubeMX
[platformio]
src_dir = ./
[env:genericSTM32F407IGT6]
platform = ststm32
board = genericSTM32F407IGT6
; framework = stm32cube
build_flags =
-IInc
-IDrivers/STM32F4xx_HAL_Driver/Inc
-IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy
-IDrivers/CMSIS/Device/ST/STM32F4xx/Include
-IDrivers/CMSIS/Include
Error Message:
C:\Users\lemac\AppData\Local\Temp\ccVTkapf.s: Assembler messages:
C:\Users\lemac\AppData\Local\Temp\ccVTkapf.s:330: Error: selected processor does not support `vstmdbeq r0!,{s16-s31}' in Thumb mode
C:\Users\lemac\AppData\Local\Temp\ccVTkapf.s:332: Error: instruction not allowed in IT block -- `stmdb r0!,{r4-r11,r14}'
C:\Users\lemac\AppData\Local\Temp\ccVTkapf.s:352: Error: selected processor does not support `vldmiaeq r0!,{s16-s31}' in Thumb mode
C:\Users\lemac\AppData\Local\Temp\ccVTkapf.s:354: Error: instruction not allowed in IT block -- `msr psp,r0'
*** [.pio\build\genericSTM32F407IGT6\src\Middlewares\Third_Party\FreeRTOS\Source\portable\GCC\ARM_CM4F\port.o] Error 1
Consulting GPT yielded no results.
Solution 2: Using PlatformIO’s Built-in Libraries
Library Path:
C:\Users\lemac\.platformio\packages\framework-stm32cubef4\Middlewares\Third_Party\FreeRTOS\Source
Configuration:
[platformio]
src_dir = ./
[env:genericSTM32F407IGT6]
platform = ststm32
board = genericSTM32F407IGT6
framework = stm32cube
build_flags =
-I Inc
-I C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source
-I C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2
-I C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source/include
-I C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source/portable
-I C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source/portable/Tasking/ARM_CM4F
build_src_filter = +<C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2> +</>
Error Message:
Linking .pio\build\genericSTM32F407IGT6\firmware.elf
arm-none-eabi-gcc: error: C:/Users/lemac/OneDrive/Documents/PlatformIO/Projects/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.o: No such file or directory
*** [.pio\build\genericSTM32F407IGT6\firmware.elf] Error 1
======================================= [FAILED] Took 2.72 seconds
Configuration:
[platformio]
src_dir = ./
[env:genericSTM32F407IGT6]
platform = ststm32
board = genericSTM32F407IGT6
framework = stm32cube
build_flags =
-I Inc
-I C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source
-I C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2
-I C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source/include
-I C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source/portable
-I C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source/portable/Tasking/ARM_CM4F
; build_src_filter = +<C:/Users/lemac/.platformio/packages/framework-stm32cubef4/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2> +</>
Linking .pio\build\genericSTM32F407IGT6\firmware.elf
.pio/build/genericSTM32F407IGT6/src/Src/freertos.o: In function `StartDefaultTask':
freertos.c:(.text.StartDefaultTask+0x4): undefined reference to `osDelay'
.pio/build/genericSTM32F407IGT6/src/Src/freertos.o: In function `MX_FREERTOS_Init':
freertos.c:(.text.MX_FREERTOS_Init+0x8): undefined reference to `osThreadNew'
.pio/build/genericSTM32F407IGT6/src/Src/main.o: In function `main':
main.c:(.text.startup.main+0x22): undefined reference to `osKernelInitialize'
main.c:(.text.startup.main+0x2a): undefined reference to `osKernelStart'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\genericSTM32F407IGT6\firmware.elf] Error 1
======================================= [FAILED] Took 4.30 seconds
Folder Structure: