Skip to main content
User1655833706281357277
Associate III
November 20, 2020
Question

I would like to turn the FPU in the STM32L486 completely off and want to be sure that the compiler is not generating ANY floating point instructions. Is the FPU completely off if I leave the CPACR alone after reset? Is there a flag I can pass to gcc?

  • November 20, 2020
  • 2 replies
  • 1426 views

..

This topic has been closed for replies.

2 replies

TDK
November 20, 2020

The floating point implementation for the compiler to use is passed as an argument. Passing -mfloat-abi=soft will prevent it from generating hardware FPU instructions. This is done within project settings in STM32CubeIDE.

Leaving CPACR alone will keep the FPU off. Enabling it is done within SystemInit if you have the appropriate defines enabled.

 /* FPU settings ------------------------------------------------------------*/
 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
 SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */
 #endif
 /* Reset the RCC clock configuration to the default reset state ------------*/

"If you feel a post has answered your question, please click ""Accept as Solution""."
User1655833706281357277
Associate III
November 20, 2020

Just curious, is there any gcc option to completely prevent any floating point code generation at all -- maybe throw an error or warning? It looks like some ARM architectures support a -march=<blah>+nofp to do that.

Thank you,

--b