I'm new to baremetal development and also without much experience on ARM as a whole.
I've managed to setup and get running the example program from briadwiddas here https://github.com/brianwiddas/pi-baremetal which includes driving the framebuffer.
I'm trying to modify this program to call some hardware floating point functions so I started by grabbing some assembler code I found at DWelch's float02 example (https://github.com/dwelch67/raspberrypi ... er/float02) as below to initialise the floating point unit
Code: Select all
/* Enable the vector floating point (VFP) unit */
mrc p15, 0, r0, c1, c0, 2 /* R0 = Access Control Register */
orr r0,r0,#0x300000 /* Single precision */
orr r0,r0,#0xC00000 /* Double precision */
mcr p15, 0, r0, c1, c0, 2 /* Access Control Register = R0 */
mov r0,#0x40000000 /* Enable VFP */
fmxr fpexc,r0 /* FPEXC = R0 */
I have also added some entry points in assembler for all of the (single precision) floating point functions I need, like mult, add, subtract etc. here's an example of the multiply one (named "m4mul").
Code: Select all
/* multiply */
.global m4mul
m4mul:
vmov s0,r0
vmov s1,r1
vmul.f32 s2,s0,s1
vmov r0,s2
bx lr
Code: Select all
extern unsigned int m4mul(unsigned int, unsigned int);
Code: Select all
unsigned int fb = (unsigned int)0x41c80000; // 25.0
unsigned int xc = m4mul(fb, fb); // <== Program hangs here. Expected result ... 25 * 25 = 625 = 0x441c4000
Is there something incompatible with how the floating point unit is called when used from this program?
Any help most appreciated, thanks.
Harvey