4 years, 8 months ago.

Disable FPU

I want to disable FPU on an F411 CPU for performance evaluation. How can I tell the compiler to avoid using FPU instructions? I want it to use the software floating-point library.

1 Answer

4 years, 8 months ago.

Hello Elias,

To avoid using FPU instructions and use the floating-point library the -mfloat-abi=soft flag shall be passed to the compiler. A user-defined profile is used in mbed for that purpose. A quick and dirty way is to modify an existing profile located in the mbed-os\tools\profiles folder of your project and use that one for compilation. For example, if you would like to create a release build with the GCC ARM toolchain then add the -mfloat-abi=soft flag to the common flags section of that toolchain in the mbed-os\tools\profiles\release.json file and save it:

release.json

{
    "GCC_ARM": {
        "common": ["-c", "-Wall", "-Wextra",
                   "-Wno-unused-parameter", "-Wno-missing-field-initializers",
                   "-fmessage-length=0", "-fno-exceptions",
                   "-ffunction-sections", "-fdata-sections", "-funsigned-char",
                   "-MMD", "-fno-delete-null-pointer-checks",
                   "-fomit-frame-pointer", "-Os", "-DNDEBUG", "-g",
                   "-mfloat-abi=soft"],
        "asm": ["-x", "assembler-with-cpp"],

        ...

Then you should tell the compiler to use the release profile when building the program offline with mbed-cli:

mbed compile -t GCC_ARM -m NUCLEO_F411RE --profile release

Use the -mfloat-abi=hard flag when you'd like to use the FPU.

Once you have finished with testing, remember to remove all the changes to the mbed-os\tools\profiles\release.json file and save it.