how to enable FPU in cubemx
Perhaps the CubeMX is missing this feature and it should add some code in SystemInit.

This is from Keil forum:

void SystemInit(void)
{
  /* FPU settings ------------------------------------------------------------*/
  #if (__FPU_PRESENT == 1) &amp;&amp; (__FPU_USED == 1)
    SCB-&gt;CPACR |= ((3UL &lt;&lt; 10*2)|(3UL &lt;&lt; 11*2));  /* set CP10 and CP11 Full Access */
  #endif
..


Somewhere in the compiler/linker you should enable the flags FPU_PRESENT and FPU_USED.