Hardware floating point implementation problem on ST Nucleo L432KC

Greetings!

I’m trying to use the FPU unit of my ST Nucleo L432KC development board in one of my projects, unfortunately without any success so far.

The following community topics were the basics of the additional script creation and platformio.ini file setup:
https://community.platformio.org/t/changing-mfloat-abi-build-option-not-working/26306/2
https://community.platformio.org/t/building-stm32f4-with-hard-floating-point/5338

here is my additional script:

Import("env")
Import("projenv")

for e in [env, projenv, DefaultEnvironment()]:
    e.Append(
        CCFLAGS=[
        "-mfloat-abi=hard",
        "-mfpu=fpv4-sp-d16"
        ],
        LINKFLAGS=[
        "-mfloat-abi=hard",
        "-mfpu=fpv4-sp-d16"
        ]
    ) 

here is my platformio.ini file:

[env]
platform = ststm32
board = nucleo_l432kc
framework = cmsis
extra_scripts = post:link_hardfloat.py

[env:testing_debug]
build_type = debug
build_flags = -D WAVE_TRIG
    

[env:RGB_led_test]
build_type = debug
build_flags = -D LED_TEST

[env:release_version]
build_type = release

this is the arrangement of my project files:
kép

and here is the error message that I’m getting:

c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: error: .pio\build\testing_debug\firmware.elf uses VFP register arguments, .pio\build\testing_debug\libfa1\libADC.a(adc.o) does not
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/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\testing_debug\libfa1\libADC.a(adc.o)
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: error: .pio\build\testing_debug\firmware.elf uses VFP register arguments, .pio\build\testing_debug\lib4fa\libclocks.a(clocks.o) does not
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/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\testing_debug\lib4fa\libclocks.a(clocks.o)
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: error: .pio\build\testing_debug\firmware.elf uses VFP register arguments, .pio\build\testing_debug\lib3b4\libcontroller.a(controller.o) does not
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/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\testing_debug\lib3b4\libcontroller.a(controller.o)
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: error: .pio\build\testing_debug\firmware.elf uses VFP register arguments, .pio\build\testing_debug\lib5c1\libGPIO.a(gpio.o) does not
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/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\testing_debug\lib5c1\libGPIO.a(gpio.o)
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: error: .pio\build\testing_debug\firmware.elf uses VFP register arguments, .pio\build\testing_debug\libdf7\libHW_Interrupt.a(hw_interrupt.o) does not
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/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\testing_debug\libdf7\libHW_Interrupt.a(hw_interrupt.o)
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: error: .pio\build\testing_debug\firmware.elf uses VFP register arguments, .pio\build\testing_debug\lib0f6\libpwm.a(pwm.o) does not
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/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\testing_debug\lib0f6\libpwm.a(pwm.o)
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: error: .pio\build\testing_debug\firmware.elf uses VFP register arguments, .pio\build\testing_debug\lib643\libserial.a(serial.o) does not
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/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\testing_debug\lib643\libserial.a(serial.o)
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: error: .pio\build\testing_debug\firmware.elf uses VFP register arguments, .pio\build\testing_debug\lib55c\libsystick.a(systick.o) does not
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/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\testing_debug\lib55c\libsystick.a(systick.o)
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: error: .pio\build\testing_debug\firmware.elf uses VFP register arguments, .pio\build\testing_debug\lib37b\libtimer.a(timer.o) does not
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/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\testing_debug\lib37b\libtimer.a(timer.o)
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/../lib/gcc/arm-none-eabi/7.2.1/../../../../arm-none-eabi/bin/ld.exe: error: .pio\build\testing_debug\firmware.elf uses VFP register arguments, .pio\build\testing_debug\lib519\libwave_data.a(wave_data.o) does not
c:/users/marto/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/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\testing_debug\lib519\libwave_data.a(wave_data.o)
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\testing_debug\firmware.elf] Error 1

The libraries that I’ve written only using the device header, as far as I know none of them has a strict soft floating point library requirement.

Can somebody help me what I’m missing to make this work?

I could reproduce your error when libraries in lib/ are involved – they are indeed not built with hardfloat.

arm-none-eabi-gcc -o .pio\build\testing_debug\lib7b8\ADCTestLib\ADCTestLib.o -c -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -Og -g2 -ggdb2 -DPLATFORMIO=60112 -DSTM32L432xx -DWAVE_TRIG -DF_CPU=80000000L -D__PLATFORMIO_BUILD_DEBUG__ -Ilib\ADCTestLib -IC:\Users\Max.platformio\packages\framework-cmsis@2.50501.200527\CMSIS\Include -IC:\Users\Max.platformio\packages\framework-cmsis-stm32l4\Include lib\ADCTestLib\ADCTestLib.c

However, the fix seems simple: It has to be a pre: script instead of a post: script to properly affect libary sources too. Then, the projenv environment can be removed too.

I.e., I tested with

[env]
platform = ststm32@17.1.0
board = nucleo_l432kc
framework = cmsis
extra_scripts = pre:link_hardfloat.py

[env:testing_debug]
build_type = debug
build_flags = -D WAVE_TRIG

and script

Import("env")

for e in [env, DefaultEnvironment()]:
    e.Append(
        CCFLAGS=[
        "-mfloat-abi=hard",
        "-mfpu=fpv4-sp-d16"
        ],
        LINKFLAGS=[
        "-mfloat-abi=hard",
        "-mfpu=fpv4-sp-d16"
        ]
    ) 
1 Like

Thank you very much, it worked! :slight_smile:

1 Like