How to make sure no floating point code is used

Float and double data types area a bad choice for embedded applications. At least in most applications, and can or should be avoided, even with hardware FPU support present.

But how can I be sure that no floating point operations are used?

wrapping float and double runtime routines

This article describes how to configure the GNU toolchain, so that no float or double operations are used, with the example of ARM Cortex-M. What I do? ‘Poisoning’ (!!!) the source code, force the gcc compiler to use software floating point operations and then catch them with the GNU linker :-).

Continue reading

Binary, do you use Hard-Float or Soft-Float?

Many cost-sensitive ARM Cortex-M devices like the M0+ do not have a hardware floating point unit, and some like the M4 only has an optional single-precision floating point unit (FPU). As outlined in “Be aware: Floating Point Operations on ARM Cortex-M4F“, using floating point operations without a hardware unit can be costly.

Looking at the disassembly for sure will tell you if the hardware is handling the float or double operation or not:

Disassembly showing runtime routines

But who wants check the all the disassembly? With the GNU tools there is an easier way: readelf.

Continue reading