EmbeddedRelated.com
Forums

Build U-Boot with soft floating point - help!

Started by Dennis C April 6, 2004
I am building U-Boot for my embedded ARM9 target. The build is done
using Linux Redhat 9 running on a PC.

When I installed my GNU C compiler, I did:
../gcc-$GCC_VER/configure --target=$TARGET --with-newlib
--prefix=$PREFIX --with-gnu-as --with-gnu-ld --nfp
make all
make install

I want the compiler to generate floating point library calls instead
of using the hardware FP.

I get this error at the end of the U-Boot link:

        arm-unknown-elf-ld -Bstatic -T
/home/dchou/atmel/u-boot-1.0.0/board/at91rm9200dk/u-boot.lds -Ttext
0x21f00000  $UNDEF_SYM cpu/at91rm9200/start.o \
                --start-group board/at91rm9200dk/libat91rm9200dk.a
cpu/at91rm9200/libat91rm9200.a lib_arm/libarm.a fs/jffs2/libjffs2.a
fs/fdos/libfdos.a fs/fat/libfat.a net/libnet.a disk/libdisk.a
rtc/librtc.a dtt/libdtt.a drivers/libdrivers.a
drivers/sk98lin/libsk98lin.a post/libpost.a post/cpu/libcpu.a
common/libcommon.a lib_generic/libgeneric.a -L
/usr/local/arm/lib/gcc-lib/arm-unknown-elf/3.3.2 -lgcc --end-group \
                -Map u-boot.map -o u-boot
arm-unknown-elf-ld: ERROR:
/usr/local/arm/lib/gcc-lib/arm-unknown-elf/3.3.2/libgcc.a(_udivsi3.o)
uses hardware FP, whereas u-boot uses software FP
File in wrong format: failed to merge target specific data of file
/usr/local/arm/lib/gcc-lib/arm-unknown-elf/3.3.2/libgcc.a(_udivsi3.o)
arm-unknown-elf-ld: ERROR:
/usr/local/arm/lib/gcc-lib/arm-unknown-elf/3.3.2/libgcc.a(_umodsi3.o)
uses hardware FP, whereas u-boot uses software FP
File in wrong format: failed to merge target specific data of file
/usr/local/arm/lib/gcc-lib/arm-unknown-elf/3.3.2/libgcc.a(_umodsi3.o)
arm-unknown-elf-ld: ERROR:
/usr/local/arm/lib/gcc-lib/arm-unknown-elf/3.3.2/libgcc.a(_dvmd_tls.o)
uses hardware FP, whereas u-boot uses software FP
File in wrong format: failed to merge target specific data of file
/usr/local/arm/lib/gcc-lib/arm-unknown-elf/3.3.2/libgcc.a(_dvmd_tls.o)
make: *** [u-boot] Error 1

Help!
Dennis
I haven't used gcc, but I'm guessing it's not so much your compiler as it is
your makefile. The compiler is probably generating floating point library calls
but you're handing it the wrong library.
Dennis C wrote:
> I am building U-Boot for my embedded ARM9 target. The build is done > using Linux Redhat 9 running on a PC. > > When I installed my GNU C compiler, I did: > ../gcc-$GCC_VER/configure --target=$TARGET --with-newlib > --prefix=$PREFIX --with-gnu-as --with-gnu-ld --nfp > make all > make install > > I want the compiler to generate floating point library calls instead > of using the hardware FP. > > I get this error at the end of the U-Boot link: > ... > arm-unknown-elf-ld: ERROR: > /usr/local/arm/lib/gcc-lib/arm-unknown-elf/3.3.2/libgcc.a(_udivsi3.o) > uses hardware FP, whereas u-boot uses software FP > File in wrong format: failed to merge target specific data of file
I seem to recall Robert Schwebel ran into this and posted something about it. Ah, yes, here it is: http://kegel.com/crosstool/current/patches/gcc-3.3.2/gcc-3.3.2-arm-softfloat.patch That's the usual softfloat patch for recent gcc plus a hunk or two Robert added to solve the problem you're facing, I think. Let us know whether that helps. - Dan
Dan:

Thanks for the tip. The patch was what I was looking for.

However I am new to linux, so how do I apply the patch? Can you
provide line by line instruction on how I can apply this patch?

Thanks a mil!
Dennis

Dan Kegel <dank-news@kegel.com> wrote in message news:<pcOcc.87849$JO3.45399@attbi_s04>...
> Dennis C wrote: > > I am building U-Boot for my embedded ARM9 target. The build is done > > using Linux Redhat 9 running on a PC. > > > > When I installed my GNU C compiler, I did: > > ../gcc-$GCC_VER/configure --target=$TARGET --with-newlib > > --prefix=$PREFIX --with-gnu-as --with-gnu-ld --nfp > > make all > > make install > > > > I want the compiler to generate floating point library calls instead > > of using the hardware FP. > > > > I get this error at the end of the U-Boot link: > > ... > > arm-unknown-elf-ld: ERROR: > > /usr/local/arm/lib/gcc-lib/arm-unknown-elf/3.3.2/libgcc.a(_udivsi3.o) > > uses hardware FP, whereas u-boot uses software FP > > File in wrong format: failed to merge target specific data of file > > I seem to recall Robert Schwebel ran into this and posted > something about it. Ah, yes, here it is: > > http://kegel.com/crosstool/current/patches/gcc-3.3.2/gcc-3.3.2-arm-softfloat.patch > > That's the usual softfloat patch for recent gcc > plus a hunk or two Robert added to solve the > problem you're facing, I think. Let us know whether > that helps. > - Dan
Dennis C wrote:
> Thanks for the tip. The patch was what I was looking for. > > However I am new to linux, so how do I apply the patch? Can you > provide line by line instruction on how I can apply this patch? > >>http://kegel.com/crosstool/current/patches/gcc-3.3.2/gcc-3.3.2-arm-softfloat.patch
Does this help? http://kegel.com/academy/opensource.html#patches.using If not, post the steps you used to build your gcc, and we'll show you where to apply the patch. - Dan
Dan:

Thanks for your help. I have successfully patched the GNC GCC and
completely rebuilt it. However I am still getting the linker error
regarding the clash between HW and SW floating point.

This is how I am configuring my GCC and GLIB:

cd gcc
../gcc-$GCC_VER/configure --target=$TARGET --with-newlib
--prefix=$PREFIX --with-gnu-as --with-gnu-ld --nfp
make all
make install
cd ..

# newlib
mkdir newlib
cd newlib
../newlib-$NEWLIB_VER/configure --target=$TARGET --prefix=$PREFIX
--nfp
make all
make install
cd ..

And these are my C flags when I compile the UBoot code:

arm-unknown-elf-gcc -g  -Os   -fno-strict-aliasing  -fno-common
-ffixed-r8 -mshort-load-bytes -msoft-float -D__KERNEL__
-DTEXT_BASE=0x21f00000 -I/home/dchou/atmel/u-boot-1.0.0/include
-fno-builtin -ffreestanding -nostdinc -isystem
/usr/local/arm/lib/gcc-lib/arm-unknown-elf/3.3.2/include -pipe 
-DCONFIG_ARM -D__ARM__ -mapcs-32 -march=armv4 -mtune=arm7tdmi -Wall
-Wstrict-prototypes -c -o string.o string.c

I think I have done everything to tell it to use soft floating point.
Am I still missing something?

Thanks
Dennis

Dan Kegel <dank-news@kegel.com> wrote in message news:<4074E222.1080609@kegel.com>...
> Dennis C wrote: > > Thanks for the tip. The patch was what I was looking for. > > > > However I am new to linux, so how do I apply the patch? Can you > > provide line by line instruction on how I can apply this patch? > > > >>http://kegel.com/crosstool/current/patches/gcc-3.3.2/gcc-3.3.2-arm-softfloat.patch > > Does this help? > > http://kegel.com/academy/opensource.html#patches.using > > If not, post the steps you used to build your gcc, and we'll > show you where to apply the patch. > - Dan
Dennis C wrote:
> > Thanks for your help. I have successfully patched the GNC GCC and > completely rebuilt it. However I am still getting the linker error > regarding the clash between HW and SW floating point. > > This is how I am configuring my GCC and GLIB: > > cd gcc > ../gcc-$GCC_VER/configure --target=$TARGET --with-newlib > --prefix=$PREFIX --with-gnu-as --with-gnu-ld --nfp > make all > make install > cd ..
I have no real idea of your problem, but it occurs to me that if the $TARGET specifies a 486 or higher cpu, floating point is built-in, and there is no reason to link to external fp routines. -- Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net) Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net> USE worldnet address!
Dennis C wrote:
> Thanks for your help. I have successfully patched the GNC GCC and > completely rebuilt it. However I am still getting the linker error > regarding the clash between HW and SW floating point. > > This is how I am configuring my GCC and GLIB: > > cd gcc > ../gcc-$GCC_VER/configure --target=$TARGET --with-newlib > --prefix=$PREFIX --with-gnu-as --with-gnu-ld --nfp
Try adding --with-float=soft to the configure line instead of --nfp, which is only for m68k (according to the gcc manual and http://gcc.gnu.org/ml/gcc-bugs/2004-01/msg01850.html) - Dan
CBFalconer wrote:
> I have no real idea of your problem, but it occurs to me that if > the $TARGET specifies a 486 or higher cpu, floating point is > built-in, and there is no reason to link to external fp routines.
TARGET is an arm, not an x86 - Dan
Dan:

I tried it as you suggested but still I get the same error. I have
worked around the problem by excluding the libgcc.a in the final link.
I was fortunate in that the code that I was building was completely
self contained, including its soft floating point assembly code. So I
was able to exclude the libgcc.a without causing a mess.
Any other ideas? 

By the way, I am using newlib 1.12.0 for GCC:

# extracting newlib - needed for gcc
rm -rf  newlib-$NEWLIB_VER newlib
tar zxvf newlib-$NEWLIB_VER.tar.gz

cd  gcc-$GCC_VER
ln -s ../newlib-$NEWLIB_VER/newlib newlib
ln -s ../newlib-$NEWLIB_VER/libgloss libgloss

I built newlib using the -with-float=soft flag as well.

Could this be a problem?

Thanks
Dennis



Dan Kegel <dank-news@kegel.com> wrote in message news:<4077A23D.8030301@kegel.com>...
> Dennis C wrote: > > Thanks for your help. I have successfully patched the GNC GCC and > > completely rebuilt it. However I am still getting the linker error > > regarding the clash between HW and SW floating point. > > > > This is how I am configuring my GCC and GLIB: > > > > cd gcc > > ../gcc-$GCC_VER/configure --target=$TARGET --with-newlib > > --prefix=$PREFIX --with-gnu-as --with-gnu-ld --nfp > > Try adding > --with-float=soft > to the configure line instead of > --nfp, which is only for m68k (according to the gcc manual > and http://gcc.gnu.org/ml/gcc-bugs/2004-01/msg01850.html) > > - Dan