How to compile & link for hardware FPU (STM32L4 - Bosch BSEC library)

After reading another related topic Hardware floating point implementation problem on ST Nucleo L432KC, I’ve found the solution:

  • remove the ‘projenv’ stuff from the extra script.
  • run the script as pre:

contents of .github/workflows/fpuflags.py

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",
    ]
    )

section in platformio.ini to add libalgosec.a to linker

build_flags =
	-lalgobsec
	-L "lib\bsec3210\algo\bsec_IAQ\bin\gcc\Cortex_M4F"

section to run extra script to enable FPU

extra_scripts = 
	pre:.github/workflows/fpuflags.py