FLOATING POINT with rtems
Mohammed Khoory
mkhoory at eiast.ae
Mon Dec 2 01:05:03 UTC 2013
I've had this issue before as well. The main reason this is happening is
because with a default build of RTEMS, the FPU doesn't get enabled on
startup, and so when you try to use any hardware fpu instructions, you get a
trap. I followed this wiki article to help fix it
http://www.rtems.org/wiki/index.php/Floating_Point_Support
What I did was:
1. In the RTEMS Source, go to cpukit/score/cpu/sparc/rtems/score/sparc.h,
and add the following
#define SPARC_HAS_FPU 1
This will cause the RTEMS build to add a few instructions on bootup so that
the FPU is enabled. Also, it will also make sure that context switches will
also store the FPU context. You can see this in cpu.h line 119, and in
cpu_asm.S
2. Before building RTEMS, set these environment variables
CFLAGS_FOR_BUILD="-mhard-float -mcpu=v8"
CFLAGS_FOR_TARGET="-mhard-float -mcpu=v8"
3. After building and installing RTEMS, make sure that when building your
application, you also pass "-mhard-float -mcpu=v8" to the compiler options
This isn't exactly an elegant solution but it has worked for me. Ideally
this whole process would be managed by the build process.
I hope this helps.
More information about the users
mailing list