EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

ARM Cortex-M3 (Stellaris LM3S811) soft float problem (GCC/QEMU)

Started by frikkiethirion December 14, 2009
Good day,
I'm running GCC 4.4.2 (newlib 1.17) cross compiled for target:
arm-none-eabi under Linux.
I'm testing my small application under QEMU: qemu-system-arm -M lm3s811evb
and
use Eclipse/GDB to debug the application.

I've run into a problem where floating point arithmetic causes the chip to
crash. GCC was compiled with the "soft-float" option. My application is
also compiled with the "soft float" option and linked against the math
library (-lm).

The piece of offending code is:
     fTmp += 3.0;
The disassembly is:
     d24:       6b38            ldr     r0, [r7, #48] 
     d26:       492a            ldr     r1, [pc, #168]
     d28:       f000 ec32       blx     1590 <__addsf3>
     d2c:       4603            mov     r3, r0
     d2e:       633b            str     r3, [r7, #48]
Eclipse opens the file: ieee754-sf.S and focus on Line 68:
     ARM_FUNC_START addsf3

Will there be any specific reason why this helper function may cause the
chip to crash? 
Could it be a case of QEMU not simulating the ARM behavior properly?

Any help will be much appreciated
Regards,
Frikkie Thirion	   
					
---------------------------------------		
This message was sent using the comp.arch.embedded web interface on
http://www.EmbeddedRelated.com
frikkiethirion <frixmail@gmail.com> wrote:
> Eclipse opens the file: ieee754-sf.S and focus on Line 68: > ARM_FUNC_START addsf3 > Will there be any specific reason why this helper function may cause the > chip to crash?
The Cortex-M3 supports only the Thumb-2 instruction set, calling an ARM function will cause an Usage Fault. I'm guessing there's a compiler/linker flag missing in your setup, or some bug in newlib's build process. -a
>frikkiethirion <frixmail@gmail.com> wrote: >> Eclipse opens the file: ieee754-sf.S and focus on Line 68: >> ARM_FUNC_START addsf3 >> Will there be any specific reason why this helper function may cause
the
>> chip to crash? > >The Cortex-M3 supports only the Thumb-2 instruction set, calling an ARM >function will cause an Usage Fault. I'm guessing there's a
compiler/linker
>flag missing in your setup, or some bug in newlib's build process. > >-a > >
I'm having a similar problem on LM3S9B92-EK. I'm using GNU Arm toolkit configured with the '--with-float=soft' option. The project is compiled with -mthumb (Thumb-2), -msoft-float (Software floating point emulation), -mcpu=cortex-m3 (Cortex-M3 architecture) and a few other flags. I'm linking it against libdriver and libgcc (the one that's installed into the thumb subdirectory). Mine crashes (HardFault) on a simple comparison of 2 floats: float a = 1.2f; float b = 1.1f; UARTprintf ("\nLess %d..\n", (a < b)); And I'm pretty sure that the UART printout is working correctly.. Well, I doubt it's newlib - I could be wrong, but I guess that libgcc should contain software floating point emulation code. I'm a bit doubtful in the linker script that I wrote, because none of the supplied scripts linked without errors. Another suspicion would be the startup_gcc.c file, which I haven't modified much (due to the lack of working float sample code). Or, it could actually be a bug in the libgcc.. . Tried to keep a long post short =P. All suggestions are welcome, Thank You --------------------------------------- Posted through http://www.EmbeddedRelated.com
>>frikkiethirion <frixmail@gmail.com> wrote: >>> Eclipse opens the file: ieee754-sf.S and focus on Line 68: >>> ARM_FUNC_START addsf3 >>> Will there be any specific reason why this helper function may cause >the >>> chip to crash? >> >>The Cortex-M3 supports only the Thumb-2 instruction set, calling an ARM >>function will cause an Usage Fault. I'm guessing there's a >compiler/linker >>flag missing in your setup, or some bug in newlib's build process. >> >>-a >> >> > >I'm having a similar problem on LM3S9B92-EK. I'm using GNU Arm toolkit >configured with the '--with-float=soft' option. The project is compiled >with -mthumb (Thumb-2), -msoft-float (Software floating point emulation), >-mcpu=cortex-m3 (Cortex-M3 architecture) and a few other flags. I'm
linking
>it against libdriver and libgcc (the one that's installed into the thumb >subdirectory). > >Mine crashes (HardFault) on a simple comparison of 2 floats: >float a = 1.2f; >float b = 1.1f; > >UARTprintf ("\nLess %d..\n", (a < b)); > >And I'm pretty sure that the UART printout is working correctly.. > >Well, I doubt it's newlib - I could be wrong, but I guess that libgcc >should contain software floating point emulation code. > >I'm a bit doubtful in the linker script that I wrote, because none of the >supplied scripts linked without errors. Another suspicion would be the >startup_gcc.c file, which I haven't modified much (due to the lack of >working float sample code). Or, it could actually be a bug in the
libgcc..
> >. Tried to keep a long post short =P. > >All suggestions are welcome, >Thank You > > > >--------------------------------------- >Posted through http://www.EmbeddedRelated.com >
Well, as it turned out, libgcc had been configured wrong (for ARM7TDMI). I had to configure gcc with this: --target=${GCC_TARGET} --prefix=${ARMTOOLS} --enable-interwork --enable-multilib --enable-languages="c,c++" --with-newlib --with-headers=../../src/newlib-${NEWLIB_VERSION}/newlib/libc/include --with-float=soft --with-cpu=cortex-m3 --with-tune=cortex-m3 --with-mode=thumb --disable-libssp where NEWLIB_VERSION=1.18.0 GCC_TARGET=arm-none-eabi and ARMTOOLS=/usr/local/arm Hope this helps.. --------------------------------------- Posted through http://www.EmbeddedRelated.com

The 2024 Embedded Online Conference