EmbDev.net

Forum: ARM programming with GCC/GNU tools Problem with double precision floats in Yagarto


von Klaus Roy-Poulsen (Guest)


Rate this post
useful
not useful
I'm having problem with double precision constants when using Yagarto 
and associated libraries.

The problem seems to be that the lower 4 bytes are swapped with the 
upper 4 bytes, compared to what the libraries and GDB expects.

A simple line of code
1
  double d = 10.0;
results in GDB reporting the value as 5.31664595E-315

whereas lines like:
1
  int i = 10;
2
  double d = i;
has the wanted result. Manually entering values in GDB results in values 
GDB understands.

This is probably caused by some wrong or missing compiler option(s), but 
I haven't figured out what I'm missing.

Currently the following CFLAGS are used:
CFLAGS= -g -O0 -mcpu=arm7tdmi -mthumb-interwork

And the following linker flags:
LFLAGS= -L $(YAGARTO_DIR)/lib/gcc/arm-elf/4.4.2/thumb/interwork

I have tried this with other/older version of Yagarto and the GNU tools, 
but with same result.

Does anyone know which options to use and/or the options used to 
generated the libraries?

Regards,
Klaus

von Clifford S. (clifford)


Rate this post
useful
not useful
The older ARM FPA used a strange cross-endian format that differs from 
the more conventional format used by the VFP, but even without FP 
hardware, the emulation will match the format of what it is emulating. 
I would have thought that specifying -mcpu=arm7tdmi would have been 
enough to specify the FP format used.

I have used hardware with VFP with an older release of WinARM and I had 
to rebuild Newlib for VFP support (and GDB did not support VFP doubles), 
so the default was at that time FPA and I do not expect that to have 
changed.

However it may not hurt to experiment with the FP settings; try perhaps: 
-mfpu=fpa -msoft-float, and if that does not make it all match up switch 
to -mfpu=vfp -msoft-float.

von Klaus R. (krp)


Rate this post
useful
not useful
Thank you for the input. -mfpu=fpa did the job.

Regards,
Klaus

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.