5.5 Enabling NEON and FPU for bare-metal

If the compiler knows that an FPU or NEON is available, for example if you use the --cpu option to specify a processor with an FPU, then the compiler might introduce FPU or NEON instructions into your code.

These instructions can be introduced even if you are not deliberately performing any floating-point operations.

If you want to build an image that does not use any FPU or NEON instructions, and does not require that the FPU and NEON be enabled, you can use the --fpu=none option when building all your source files.

When targeting bare-metal and compiling for a processor with an FPU or NEON, you must enable the FPU and NEON in your startup code before you can execute FPU or NEON instructions. See the Technical Reference Manual for your processor.

For example, the following startup code enables NEON and FPU hardware for a Cortex-A8 processor:

__asm void StartHere(void)
{
MRC p15,0,r0,c1,c0,2    // Read CP Access register
ORR r0,r0,#0x00f00000   // Enable full access to NEON/VFP (Coprocessors 10 and 11)
MCR p15,0,r0,c1,c0,2    // Write CP Access register
ISB
MOV r0,#0x40000000      // Switch on the VFP and NEON hardware
MSR FPEXC,r0            // Set EN bit in FPEXC
IMPORT __main
B __main                // Enter normal C run-time environment & library start-up
}

To compile this code:

armcc -c --cpu=Cortex-A8 main.c
armlink --entry=StartHere main.o
Non-ConfidentialPDF file icon PDF versionARM DUI0472M
Copyright © 2010-2016 ARM Limited or its affiliates. All rights reserved.