This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Floating point in static initializers

Hi all,

I have some classes that I recently converted to floating point.
These classes have an initizalizer constructor, that fill some floating point members with constants.
Constants are declared integer, and I cannot change that, so the constructor may use the FPU to convert from integer to float as part of the initialization.

Unfortunately if the class is declared in global scope, the initializer is called "before" main.
What I see is that if I start from the debugger everything is ok, while if I cycle the power without the debugger the processor is stuck in fault.
I tried to  follow the debugger debugger after a core reset following the C startup and I saw that at the first FPU instruction the processor jumps to Fault.

My guess, is that the C startup does not initialize the FPU.
Is there any compiler or linker option to enable FPU during startup execution?

While on the subject what --float-support option is to be used and where I can find documentation about the differences?
I am using FPv4SPD16 and support library <automatic>. Any better choice?

Regards.

Mau.

  • Sorry if I reply to myself.

    I found that forcing the  link with the rtsv7M4_T_le_v4SPD16_eabi.lib library, adds the suitable code to enable the FPU right after the first jump to _c_int00.
    Originally I had <automatic> setting, that probably ended up with the wrong lib.

    This fixes the problem I had.

    Unfortunately it is not easy to find documentation about these settings, since one must look into library, tools, processor, and generic ARM documentation, not always being able to match the different nomenclature.

    Regards.
    Mau.