maxgerhardt / pio-stm32h7-stm32cube-freertos

11 stars 2 forks source link

Is softfp required? #1

Open JBKingdon opened 11 months ago

JBKingdon commented 11 months ago

Hi Max, Many thanks for making this project, it's exactly what I needed. I was curious about the use of

-mfloat-abi=softfp

which presumably disables the use of the hardware floating point unit and comes at a performance cost? I was wondering what the issues are that require that option.

Regards, James

maxgerhardt commented 11 months ago

soft would disable the usage of hardware floating point instructions. softfp will generate hardware floating point instructions but uses the soft ABI, i.e. integer registers to pass arguments, instead of FPU registers (that would be hard). So the performance should only be lightly impacted. See https://embeddedartistry.com/blog/2017/10/11/demystifying-arm-floating-point-compiler-options/.

I think the initial reason for this was to make something in https://github.com/maxgerhardt/pio-stm32h7-stm32cube-freertos/tree/main/lib/FreeRTOS/portable/GCC/ARM_CM4F compile properly. This may be outdated though by now. In fact, the whole project is 2 years old already.

JBKingdon commented 11 months ago

Many thanks for the reply. I'd completely missed the difference between soft and softfp. I'll try testing without the option and see if anything still breaks (once I get my project back together again, I broke everything trying to add VCP support).

JBKingdon commented 11 months ago

I confirmed that trying to use hard float failed compilation at the link stage, although I couldn't see why. I'd expect failure if trying to link objects or libraries that had been compiled with mismatched settings, but as far as I could see everything had been freshly compiled with the same settings. I found some hints online that freertos should work with hard float on stm32 using vPortTaskUsesFPU() to flag fpu usage per task, so I have some more digging to do. Edit - I may have been mistaken, I'm struggling to find many references to vPortTaskUsesFPU, it might be specific to some non-stm32 ports

maxgerhardt commented 11 months ago

FreeRTOS definitely has FPU capable code ("Cortex_M4F"), as a task scheduler it needs to know about the usage of FPU registers so that it can properly save and restore them when one task is switched out for another. I can try and update the project to what STM32Cube would now generate as FreeRTOS project and enable hardfloat there.