EmbeddedRelated.com
Forums
Memfault Beyond the Launch

Problem with GNU ARM Toolchain and math functions

Started by Fausto Marzoli October 29, 2007
Hi all!

I have a problem that I can't fix with GNU ARM Toolchain and math functions.
Maybe someone has experimented floating point math function with GNU ARM
Toolchain and can help me...

This is the problem: when using floating point arguments, some math functions
cause a program crash with "data abort" or "undefined instruction".

I've done some tests with the newlib math functions with float arguments, GNU
arm toolchain and ARM7 NXP LPC2106 microcontroller:
log works
log10 works
sqrt works
tan Error (uncorrect result)
cos Crash
sin Crash
pow Crash

I've tried a lot of pre-compiled toolchains: YAGARTO, Ronetix, CodeSourcery...
I also compiled myself the toolchain (under linux): I tried a lot of
different compiling options, always with the same results.

I can't fix it. My test program is a simple test program that blinks a led on
a development board and in the led delay functions makes a dummy math call
(only to test the math call speed).

If someone is interested in this argument, I can give you all the info about
compiling options or any other information you need.

Anyone tried floating point math with GNU ARM Toolchain (arm-elf) and newlib?
Thank you,

Fausto

An Engineer's Guide to the LPC2100 Series

I've had similar problems with math in a return statement using GNU on
a LPC2103.

As statement like:

return (a*b);

may fail, but 2 statements like

retval = a*b;
return retval;

will work.

--- In l..., Fausto Marzoli wrote:
>
> Hi all!
>
> I have a problem that I can't fix with GNU ARM Toolchain and math
functions.
> Maybe someone has experimented floating point math function with GNU
ARM
> Toolchain and can help me...
>
> This is the problem: when using floating point arguments, some math
functions
> cause a program crash with "data abort" or "undefined instruction".
>
> I've done some tests with the newlib math functions with float
arguments, GNU
> arm toolchain and ARM7 NXP LPC2106 microcontroller:
> log works
> log10 works
> sqrt works
> tan Error (uncorrect result)
> cos Crash
> sin Crash
> pow Crash
>
> I've tried a lot of pre-compiled toolchains: YAGARTO, Ronetix,
CodeSourcery...
> I also compiled myself the toolchain (under linux): I tried a lot of
> different compiling options, always with the same results.
>
> I can't fix it. My test program is a simple test program that blinks
a led on
> a development board and in the led delay functions makes a dummy
math call
> (only to test the math call speed).
>
> If someone is interested in this argument, I can give you all the
info about
> compiling options or any other information you need.
>
> Anyone tried floating point math with GNU ARM Toolchain (arm-elf)
and newlib?
> Thank you,
>
> Fausto
>
Alle 12:58, luned29 ottobre 2007, Leon Heller ha scritto:

> > Anyone tried floating point math with GNU ARM Toolchain (arm-elf)
> and newlib?
>
> They work OK with CrossWorks, which uses gcc.

Crossworks uses GCC but does NOT use Newlib as C standard library.
Crossworks has its own C standard library (not GPL).
--
Fausto Marzoli - 8052.it - http://www.8052.it/
Alle 12:22, luned29 ottobre 2007, aaajbell ha scritto:

> I've had similar problems with math in a return statement using GNU on
> a LPC2103.
>
> As statement like:
>
> return (a*b);
>
> may fail, but 2 statements like
>
> retval = a*b;
> return retval;
>
> will work.

!!!!!!!

If this is the reason, GNU ARM can not be used... I hope that this is not the
case.

Thanks for the suggestion, anyway. I will try to verify it somehow.
--
Fausto Marzoli - 8052.it - http://www.8052.it/
hi all,

should i write my own lib functions in assembly and call them to do all the calculations

cosmoalien(Rahul)

----- Original Message ----
From: Leon Heller
To: l...
Sent: Monday, October 29, 2007 5:28:23 PM
Subject: [lpc2000] Re: Problem with GNU ARM Toolchain and math functions

--- In lpc2000@yahoogroups .com, Fausto Marzoli wrote:
>
> Hi all!
>
> I have a problem that I can't fix with GNU ARM Toolchain and math
functions.
> Maybe someone has experimented floating point math function with
GNU ARM
> Toolchain and can help me...
>
> This is the problem: when using floating point arguments, some math
functions
> cause a program crash with "data abort" or "undefined instruction" .
>
> I've done some tests with the newlib math functions with float
arguments, GNU
> arm toolchain and ARM7 NXP LPC2106 microcontroller:
> log works
> log10 works
> sqrt works
> tan Error (uncorrect result)
> cos Crash
> sin Crash
> pow Crash
>
> I've tried a lot of pre-compiled toolchains: YAGARTO, Ronetix,
CodeSourcery. ..
> I also compiled myself the toolchain (under linux): I tried a lot
of
> different compiling options, always with the same results.
>
> I can't fix it. My test program is a simple test program that
blinks a led on
> a development board and in the led delay functions makes a dummy
math call
> (only to test the math call speed).
>
> If someone is interested in this argument, I can give you all the
info about
> compiling options or any other information you need.
>
> Anyone tried floating point math with GNU ARM Toolchain (arm-elf)
and newlib?

They work OK with CrossWorks, which uses gcc.

Leon

__________________________________________________
how is the division done in the complier code .. is it successive subtraction or is it 1's complement etc etc BOOLEAN arithmatic
there are different types of subtract functions in the arm instruction set where we can consider the carry or ignore it .. i dont know how the GNU people have written the code for the library file

can any one give me the guidelines for writing the code in assembly where my carry is considered and there should not be may missing bits for recursive calculations . the function should shaturate like in DSP processors

cosmoalien
----- Original Message ----
From: aaajbell
To: l...
Sent: Monday, October 29, 2007 4:52:46 PM
Subject: [lpc2000] Re: Problem with GNU ARM Toolchain and math functions

I've had similar problems with math in a return statement using GNU on
a LPC2103.

As statement like:

return (a*b);

may fail, but 2 statements like

retval = a*b;
return retval;

will work.

--- In lpc2000@yahoogroups .com, Fausto Marzoli wrote:
>
> Hi all!
>
> I have a problem that I can't fix with GNU ARM Toolchain and math
functions.
> Maybe someone has experimented floating point math function with GNU
ARM
> Toolchain and can help me...
>
> This is the problem: when using floating point arguments, some math
functions
> cause a program crash with "data abort" or "undefined instruction" .
>
> I've done some tests with the newlib math functions with float
arguments, GNU
> arm toolchain and ARM7 NXP LPC2106 microcontroller:
> log works
> log10 works
> sqrt works
> tan Error (uncorrect result)
> cos Crash
> sin Crash
> pow Crash
>
> I've tried a lot of pre-compiled toolchains: YAGARTO, Ronetix,
CodeSourcery. ..
> I also compiled myself the toolchain (under linux): I tried a lot of
> different compiling options, always with the same results.
>
> I can't fix it. My test program is a simple test program that blinks
a led on
> a development board and in the led delay functions makes a dummy
math call
> (only to test the math call speed).
>
> If someone is interested in this argument, I can give you all the
info about
> compiling options or any other information you need.
>
> Anyone tried floating point math with GNU ARM Toolchain (arm-elf)
and newlib?
> Thank you,
>
> Fausto
>

__________________________________________________
Hi Leon,

> > Anyone tried floating point math with GNU ARM Toolchain (arm-elf)
> and newlib?
>
> They work OK with CrossWorks, which uses gcc.

Yeah, but I coded all that floating point tomfoolery, it's our own library.
And, what's more, it *works* because it's passed a huge number of tests on
all ARM architectures.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for ARM, MSP430, AVR, MAXQ, and now Cortex-M3 processors
----- Original Message -----
From: "Rahul Gaikwad"
To:
Sent: Monday, October 29, 2007 2:47 PM
Subject: Re: [lpc2000] Re: Problem with GNU ARM Toolchain and math functions
> hi all,
>
> should i write my own lib functions in assembly and call them to do
> all the calculations

I had to do that once for an ADI DSP because the IEEE routines were far too
slow, using their old (but fast) non-standard floating-point format. It
took a long time, even though we only needed a few functions.

Leon
--
Leon Heller
Amateur radio call-sign G1HSM
Yaesu FT-817ND and FT-857D transceivers
Suzuki SV1000S motorcycle
l...@btinternet.com
http://webspace.webring.com/people/jl/leon_heller/
Alle 15:47, luned29 ottobre 2007, Rahul Gaikwad ha scritto:

> should i write my own lib functions in assembly and call them to do all the
> calculations

I don't understand what you mean: you had to write your own math library?

--
Fausto Marzoli - 8052.it - http://www.8052.it/
Fausto,
Another problem I had with my LPC2103 was with the interrupt routines.
I had to use the ISR_ENTRY and ISR_EXIT macros found by researching
messages in this forum to get the return statement in an interrupt
routine to work properly. Are you by chance using interrupts for your
blink program?

--- In l..., Fausto Marzoli wrote:
>
> Alle 12:22, luned29 ottobre 2007, aaajbell ha scritto:
>
> > I've had similar problems with math in a return statement using GNU on
> > a LPC2103.
> >
> > As statement like:
> >
> > return (a*b);
> >
> > may fail, but 2 statements like
> >
> > retval = a*b;
> > return retval;
> >
> > will work.
>
> !!!!!!!
>
> If this is the reason, GNU ARM can not be used... I hope that this
is not the
> case.
>
> Thanks for the suggestion, anyway. I will try to verify it somehow.
>
>
> --
> Fausto Marzoli - 8052.it - http://www.8052.it/
>




Memfault Beyond the Launch