Hi,
Long story Short , i want to add a V1 FreeRtos Library into my STM32L4 project, but i hit walls again and again!
main.c:(.text.startup.main+0x18): undefined reference to `osThreadCreate’
this is my paltformio.ini
[env:nucleo_l476rg]
platform = ststm32
board = nucleo_l476rg
framework = stm32cube
upload_protocol = custom
upload_command = openocd -f interface/stlink.cfg -f target/stm32l4x.cfg -c “init; reset halt; stm32l4x mass_erase 0; program {$SOURCE} 0x08000000 verify reset exit”
debug_tool = stlink
debug_init_break = tbreak main
lib_deps = FreeRTOS ;makes no diff
build_flags =
-IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
-IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F
-IMiddlewares/Third_Party/FreeRTOS/Source/include
;src_filter = <Middlewares/Third_Party/FreeRTOS/Source/> not working
; select linker file generated by CubeMX
;board_build.ldscript = STM32L476RGTx_FLASH.ld not working
this is my main
#include “cmsis_os.h”
#include “FreeRTOS.h”
#include “task.h”
#include “stm32l4xx_hal.h”
osThreadId MYTaskHandle;
osThreadId MainProcesTaskHandle;
void MYTask()
{
//DO nothing
}
int main(void)
{
osThreadDef(MYT, MYTask, osPriorityNormal, 0, 512);
MYTaskHandle = osThreadCreate(osThread(MYT), NULL);
}
the error
.pio/build/nucleo_l476rg/src/main.o: In function main': main.c:(.text.startup.main+0x18): undefined reference to
osThreadCreate’
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\nucleo_l476rg\firmware.elf] Error 1
here is the test project i am refering https://file.io/SdgvwXMpXG7a i dont understand what is the problem of paltformio and cannot include the dirs , with other IDE i just include the folders and thats it , Please Help!
This will only add those paths to the header search path of GCC, as is documented. It won’t actually build a single file in those folders, since the file is not inside the dedicated source directory (by default: src/
) or a library (by default: a folder inside lib/
).
You need to move those files to one of the aforementioned places if you want them to be included in the build.
UPDATE , i used a reference project
pio-stm32h7-stm32cube-freertos/reference_stm32cube_project at main · maxgerhardt/pio-stm32h7-stm32cube-freertos
this is using however a stm32h7 , i ported my MCU STM32L4
everything is perfect
platformio.ini
[env:nucleo_l476rg]
platform = ststm32
board = nucleo_l476rg
framework = stm32cube
upload_protocol = custom
upload_command = openocd -f interface/stlink.cfg -f target/stm32l4x.cfg -c “init; reset halt; stm32l4x mass_erase 0; program {$SOURCE} 0x08000000 verify reset exit”
debug_tool = stlink
debug_init_break = tbreak main
; select linker file generated by CubeMX
board_build.ldscript = STM32L476RGTx_FLASH.ld
; make build system use our HAL config file
board_build.stm32cube.custom_config_header = yes
; force inclusion of lib/FreeRTOS
;lib_deps = FreeRTOS
; needed compiler flags to
; correctly build the port assembly files
; and add freertos subfolders to include path
build_flags =
-mcpu=cortex-m4
-mfloat-abi=hard
-mfpu=fpv4-sp-d16
-Ilib/FreeRTOS/include
-Ilib/FreeRTOS/CMSIS_RTOS_V2
-Ilib/FreeRTOS/portable/GCC/ARM_CM4F
-Iinclude
; link FreeRTOS as objectf files, not as
; archives. otherwise weak ISR functions
; don’t get linked properly!
lib_archive = no
and when i build i get a bunch odf errror s
something to do woth Floating Point Unit (FPU) settings
I assume this is a problem with STM32L4
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: error: .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal.o uses VFP register arguments, .pio/build/nucleo_l476rg/firmware.elf does not
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: failed to merge target specific data of file .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal.o
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: error: .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_adc.o uses VFP register arguments, .pio/build/nucleo_l476rg/firmware.elf does not
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: failed to merge target specific data of file .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_adc.o
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: error: .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_adc_ex.o uses VFP register arguments, .pio/build/nucleo_l476rg/firmware.elf does not
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: failed to merge target specific data of file .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_adc_ex.o
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: error: .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_can.o uses VFP register arguments, .pio/build/nucleo_l476rg/firmware.elf does not
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: failed to merge target specific data of file .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_can.o
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: error: .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_comp.o uses VFP register arguments, .pio/build/nucleo_l476rg/firmware.elf does not
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: failed to merge target specific data of file .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_comp.o
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: error: .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_cortex.o uses VFP register arguments, .pio/build/nucleo_l476rg/firmware.elf does not
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: failed to merge target specific data of file .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_cortex.o
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: error: .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_crc.o uses VFP register arguments, .pio/build/nucleo_l476rg/firmware.elf does not
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: failed to merge target specific data of file .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_crc.o
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: error: .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_crc_ex.o uses VFP register arguments, .pio/build/nucleo_l476rg/firmware.elf does not
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: failed to merge target specific data of file .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_crc_ex.o
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: error: .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_cryp.o uses VFP register arguments, .pio/build/nucleo_l476rg/firmware.elf does not
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: failed to merge target specific data of file .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_cryp.o
c:/users/gchat/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/7.2.1/…/…/…/…/arm-none-eabi/bin/ld.exe: error: .pio/build/nucleo_l476rg/FrameworkHALDriver/Src/stm32l4xx_hal_cryp_ex.o uses VFP register arguments, .pio/build/nucleo_l476rg/firmware.elf does not
Can you post your project now?
Ok this is my new attempt to fix it
https://file.io/Eby2XHaXD7VN
i believe is imposibble , and is a kinda bug of platformio or something
There is no bug. Only configuration issues in the project.
- Move the “MiddleWares” folder inside
src/
or the files will not be built
- Adapt the paths in the build_flags accordingly
build_flags =
-Isrc/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS
-Isrc/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F
-Isrc/Middlewares/Third_Party/FreeRTOS/Source/include
- Add an extra_script to properly add the hard-floating point usage into the C/C++ compiler flags, linker flags, and assembler flags by setting
extra_scripts = pre:hardfloat.py
then creating the file hardfloat.py
in the same folder as the platformio.ini
with content
Import("env")
env.Append(
LINKFLAGS=["-mfloat-abi=hard", "-mfpu=fpv4-sp-d16"],
CCFLAGS=["-mfloat-abi=hard", "-mfpu=fpv4-sp-d16"],
ASFLAGS=["-mfloat-abi=hard", "-mfpu=fpv4-sp-d16"]
)
- Hit “Build”
Indexing .pio/build/nucleo_l476rg/libFrameworkCMSISDevice.a
Linking .pio/build/nucleo_l476rg/firmware.elf
Checking size .pio/build/nucleo_l476rg/firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM: [ ] 4.4% (used 4344 bytes from 98304 bytes)
Flash: [ ] 0.3% (used 2692 bytes from 1048576 bytes)
Building .pio/build/nucleo_l476rg/firmware.bin
=====================[SUCCESS] Took 3.57 seconds =====================
Oh Hell Nah!!!
Thanks! let me test and i will let you know