AI Briefing
KO

Floating Point Fun on Cortex-M Processors

·2026.04.17 19:32

Key point

Explains the differences between Cortex-M's soft, softfp, and hard ABIs and Zephyr configuration.

Details

This summarizes how floating point ABI differs on Arm Cortex-M, and how soft, softfp, and hard affect linker errors and generated code.

soft operates without an FPU, emulating floating-point operations via a runtime library. Arguments are passed through GPRs such as r0-r3.

softfp allows FPU instructions to be used, but the calling convention is the same as soft, so arguments are still passed via GPRs. This makes it compatible with the soft calling convention while still using a hardware FPU.

hard uses FPU registers for argument passing as well. On Armv7-M family, s0-s15 are used for argument passing, employing an FPU-specific calling convention.

This difference causes errors like ld.bfd: error: X uses VFP register arguments, Y does not. The linker determines whether ABIs are mixed by looking at the Arm attributes in object files.

In the nRF52840 example, the attributes checked with readelf appear differently per ABI.

  • hard: Tag_ABI_VFP_args: VFP registers
  • softfp: floating point instructions are allowed, but argument passing is GPR-based
  • soft: centered on software computation with no FPU calling convention

The difference is also clear with a simple float addf(float a, float b) example.

  • soft build: calls __addsf3 to perform addition in software
  • hard build: receives arguments in s0, s1 and uses vadd.f32
  • softfp build: receives arguments via GPRs but uses vadd.f32 internally

In Zephyr, enabling the FPU with CONFIG_FPU=y uses the hard ABI by default. Conversely, selecting CONFIG_FP_SOFTABI=y results in softfp. You can check the actual -mfloat-abi compiler flag value with west -v build.

Also, CONFIG_FPU is involved not only in ABI selection but also in enabling the FPU at boot time. z_arm_floating_point_init() is called from z_prep_c(), where CPACR, FPCCR, and FPSCR are configured.

The key points are as follows.

  • Even with an FPU present, the default setting may still be the soft ABI
  • Mixing objects with different ABIs will be rejected by the linker
  • In Zephyr, board configuration and Kconfig together determine the ABI and FPU activation

This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.

Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.