Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 17 Dec 2007 01:39 AM by  info@algotronic.ch
Problem using the floating point unit
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages
info@algotronic.ch
New Member
New Member
Posts:


--
13 Sep 2007 09:24 AM
    I am currently working with the ARM GNU toolchain V 3.-1 provided by logicpd. I have encountered the following problems

    1) The compiler does not accept the option -mfpu=vfp. What option do I need for the compiler to use vfp?

    2)I tried compiling my code with the compiler option --msoft-float but looking at the disassembled code, the floating point functions do not seem to be called. Below are the options passed to gcc and part of the disassembled code. Any ideas on this?

    ---- gcc command ----------------
    arm-elf-cpp -P -D_ASM_ -DBASE_ADDRESS=0x80000000+0x00100000 -DMEMAP_BASE_SDRAM=0x80000000 -DBOOTFLASH_PHYS_BASE=0xA0000000 -DLOGIC_CARDENGINE_IMX31_10 -DCONFIG_IN_FLASH=0 api.lds.S > api.lds
    arm-elf-gcc -mcpu=arm1136jfs -mlittle-endian -fno-omit-frame-pointer -msoft-float -fno-builtin -O3 -Wall -g -ggdb -DBASE_ADDRESS=0x80000000+0x00100000 -DMEMAP_BASE_SDRAM=0x80000000 -DBOOTFLASH_PHYS_BASE=0xA0000000 -DLOGIC_CARDENGINE_IMX31_10 -DCONFIG_IN_FLASH=0 -fno-builtin -nostdlib -N -o speedtest.elf -T api.lds src/main.o src/utilities.o -lm -lc -lgcc
    mv speedtest.elf speedtest_debug.elf
    cp speedtest_debug.elf speedtest_strip.elf
    arm-elf-strip speedtest_strip.elf
    arm-elf-objcopy -O binary speedtest_strip.elf speedtest_strip.raw


    -- dissassemble dump ---------
    8010035c <__ieee754_sqrt>:
    8010035c: e3c02102 bic r2, r0, #-2147483648 ; 0x80000000
    80100360: e1a02a22 mov r2, r2, lsr #20
    80100364: e3a0347f mov r3, #2130706432 ; 0x7f000000
    80100368: e1a0c00d mov ip, sp
    8010036c: e283360f add r3, r3, #15728640 ; 0xf00000
    80100370: e1a02a02 mov r2, r2, lsl #20
    80100374: e92ddff0 stmdb sp!, {r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc}
    ..........
    801003a0: 0a000050 beq 801004e8 <__ieee754_sqrt+0x18c>
    801003a4: e3500000 cmp r0, #0 ; 0x0
    801003a8: da000067 ble 8010054c <__ieee754_sqrt+0x1f0>
    801003ac: e1b04a4c movs r4, ip, asr #20
    801003b0: 0a000038 beq 80100498 <__ieee754_sqrt+0x13c>
    801003b4: e3cc34ff bic r3, ip, #-16777216 ; 0xff000000
    801003b8: e2444fff sub r4, r4, #1020 ; 0x3fc
    801003bc: e3c3360f bic r3, r3, #15728640 ; 0xf00000
    801003c0: e2444003 sub r4, r4, #3 ; 0x3
    801003c4: e3140001 tst r4, #1 ; 0x1
    801003c8: e383c601 orr ip, r3, #1048576 ; 0x100000
    801003cc: 108c3fae addne r3, ip, lr, lsr #31
    ..........
    80100420: 1afffff5 bne 801003fc <__ieee754_sqrt+0xa0>
    80100424: e3a02102 mov r2, #-2147483648 ; 0x80000000
    80100428: ea000007 b 8010044c <__ieee754_sqrt+0xf0>
    .........
    801004e8: e1a03001 mov r3, r1
    801004ec: e1a02000 mov r2, r0
    801004f0: eb000112 bl 80100940 <__muldf3>
    801004f4: e1a03007 mov r3, r7
    801004f8: e1a02006 mov r2, r6
    801004fc: eb00002e bl 801005bc <__adddf3>
    ..........
    80100554: 1a000000 bne 8010055c <__ieee754_sqrt+0x200>
    80100558: e89daff0 ldmia sp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc}
    8010055c: e3500000 cmp r0, #0 ; 0x0
    80100560: aaffff91 bge 801003ac <__ieee754_sqrt+0x50>
    80100564: e1a03001 mov r3, r1
    80100568: e1a02000 mov r2, r0
    8010056c: eb000011 bl 801005b8 <__subdf3>
    80100570: e1a03001 mov r3, r1
    80100574: e1a02000 mov r2, r0
    80100578: eb0001b5 bl 80100c54 <__divdf3>
    8010057c: e89daff0 ldmia sp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, pc}
    spannring
    New Member
    New Member
    Posts:


    --
    13 Sep 2007 12:30 PM
    It appears that LogicPD didn't include VFP support when they built the gcc toolchain. I assume you could pay LogicPD to build you a VFP-enabled toolchain, or you could build one yourself. If you choose the later route you will need to customize the C runtime library (I used newlib) to work on the LogicPD board.

    I have a big old python script to compile binutils, gcc, newlib, and gdb. I can't post it since it has a lot of local dependcies and propriety stuff but I have included the list of commands it runs to generate the tool chain at the bottom
    of this post.

    You'll need to have the source code for gcc 4.2.1, newlib 1.15.0, binuutils 2.17 and gdb 6.6.

    We use Linux and Mac OS X for the development hosts. You can get cross compiler tool chain working on Windows, but it will be more painful.

    Note- Before you can run these command you'll need to setup the appropriate directory structure. For example you should unpack the binutils-2.17 source code into /home/YourHomeDir/TheToolChain/YourBoard/../binutils-2.17

    Do the same for gcc, newlib, and gdb.





    # Building binutils 2.17
    rm -r /home/YourHomeDir/TheToolChain/YourBoard/.yourboard_bare/build-binutils
    cd /home/YourHomeDir/TheToolChain/YourBoard/.yourboard_bare/build-binutils
    /home/YourHomeDir/TheToolChain/YourBoard/../binutils-2.17/configure --target=arm-elf --prefix=/home/YourHomeDir/tmp/yourboard-imx31-cross
    make all install


    # Building gcc 4.2.1 boot
    rm -r /home/YourHomeDir/TheToolChain/YourBoard/.yourboard_bare/build-gcc-boot
    cd /home/YourHomeDir/TheToolChain/YourBoard/.yourboard_bare/build-gcc-boot
    /home/YourHomeDir/TheToolChain/YourBoard/../gcc-4.2.1/configure --target=arm-elf --prefix=/home/YourHomeDir/tmp/yourboard-imx31-cross --disable-multilib --with-mode=arm --with-fpu=vfp --with-float=softfp --with-cpu=arm1136jf-s --with-gnu-as --with-gnu-ld --disable-shared --with-newlib --disable-libssp --without-headers --enable-languages=c
    make all install


    # Building newlib 1.15.0
    rm -r /home/YourHomeDir/TheToolChain/YourBoard/.yourboard_bare/build-newlib
    cd /home/YourHomeDir/TheToolChain/YourBoard/.yourboard_bare/build-newlib
    /home/YourHomeDir/TheToolChain/YourBoard/newlib-1.15.0/configure --disable-multilib --target=arm-elf --prefix=/home/YourHomeDir/tmp/yourboard-imx31-cross
    make CC_FOR_BUILD=gcc CFLAGS_FOR_TARGET=-mcpu=arm1136jf-s GCC_FOR_TARGET=/home/YourHomeDir/tmp/yourboard-imx31-cross/bin/arm-elf-gcc -mcpu=arm1136jf-s all install


    # Building final gcc 4.2.1
    rm -r /home/YourHomeDir/TheToolChain/YourBoard/.yourboard_bare/build-gcc-final
    cd /home/YourHomeDir/TheToolChain/YourBoard/.yourboard_bare/build-gcc-final
    /home/YourHomeDir/TheToolChain/YourBoard/../gcc-4.2.1/configure --target=arm-elf --prefix=/home/YourHomeDir/tmp/yourboard-imx31-cross --disable-multilib --with-mode=arm --with-fpu=vfp --with-float=softfp --with-cpu=arm1136jf-s --with-gnu-as --with-gnu-ld --disable-shared --with-newlib --disable-libssp --with-headers=/home/YourHomeDir/tmp/yourboard-imx31-cross/arm-elf/include --enable-languages=c,c++ --enable-long-long --disable-nls
    make all install


    # Building GDB 6.6
    rm -r /home/YourHomeDir/TheToolChain/YourBoard/.yourboard_bare/build-gdb
    cd /home/YourHomeDir/TheToolChain/YourBoard/.yourboard_bare/build-gdb
    /home/YourHomeDir/TheToolChain/YourBoard/../gdb-6.6/configure --target=arm-elf --prefix=/home/YourHomeDir/tmp/yourboard-imx31-cross
    make all install
    info@algotronic.ch
    New Member
    New Member
    Posts:


    --
    17 Dec 2007 01:39 AM
    Thank you for your answere.
    I finish to build the toolchains. It seams that the use correctely the fpu instructions. I make some basic test with the sqrt(double) functions everything is OK !
    At the moment I try to write a standalone application. I have so problems to configure the stack and interrupt registery. Maybe you now where I can find an example code ?
    You are not authorized to post a reply.