ARM Technical Support Knowledge Articles

Undefined Instruction in "_fp_init()"

Applies to: DS-5, RealView Development Suite (RVDS)


During the C library initialisation, _fp_init() is called to initialise the floating-point status register before performing any floating-point operations. This is performed for both software floating-point and hardware VFP. When using hardware VFP, a VFP coprocessor instruction is used to initialise the floating-point status register. If you build your code for hardware VFP but the VFP coprocessor has not been enabled or is not present, the coprocessor instruction will cause an undefined instruction exception at run-time.

If your target contains a VFP coprocessor you will need ensure that it has been correctly enabled before attempting to initialise the C library. This should normally be done by assembler code in your reset handler before branching to __main().

However if your target does not contain a VFP coprocessor you will need to ensure that all the objects you are linking are built for software floating-point and not for hardware VFP. If any objects are linked in that are built for hardware VFP the linker will upgrade the entire image to hardware VFP. The linker will then include a version of _fp_init() that uses a coprocessor instruction.

To avoid this you need to be careful when specifying the CPU you are building for, for example --cpu ARM1136JF-S implies hardware VFP whereas --cpu ARM1136J-S implies software VFP. Also specifying a specific VFP type using --fpu will override the type specified by the CPU, for example --cpu ARM1136JF-S --fpu softvfp will build code for software VFP, however --cpu ARM1136J-S --fpu vfpv2 will build code for hardware VFP.

For more information on VFP please refer to Application Note 133 - 'Using VFP with RVDS'.

Article last edited on: 2011-09-27 20:11:12

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential