Unhandled exception after turning on FPU
Moderators: RoccoMarco, lbednarz, tfAteba
Unhandled exception after turning on FPU
I tried turning on the FPU in the STM32F4DISCOVERY demo (USE_FPU = yes in Makefile, #define CORTEX_USE_FPU true in chconf.h) for the ChibiOS stable_2.4.x branch and it always ends up in unhandled_exception after main. I took a look at the CFSR and it was 0x00008200, which is BFARVALID and PRECISERR, so there's a data fault with the faulting address in BFAR. BFAR contains 0x08100000, so it looks like some data access (or instruction prefetch? I don't know) ran off the bounds of Flash memory.
Has anyone else seen this before? I can replicate the problem with IRQ_STORM_FPU.
I suspect this may be a problem with my setup; I'm using texane/stlink on a Mac with yagarto-4.7.1, and I've tried OpenOCD 0.6.0 too (same thing happens).
Has anyone else seen this before? I can replicate the problem with IRQ_STORM_FPU.
I suspect this may be a problem with my setup; I'm using texane/stlink on a Mac with yagarto-4.7.1, and I've tried OpenOCD 0.6.0 too (same thing happens).
- Giovanni
- Site Admin
- Posts: 14894
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Unhandled exception after turning on FPU
I will be able to test this during the weekend. Could you try to use this toolchain instead?
https://launchpad.net/gcc-arm-embedded
It could be related to how libraries are built.
Giovanni
https://launchpad.net/gcc-arm-embedded
It could be related to how libraries are built.
Giovanni
- Giovanni
- Site Admin
- Posts: 14894
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Unhandled exception after turning on FPU
Hi,
Using YAGARTO 4.6.2 or the toolchain I linked in the previous post the demo works. It is possible this is specific of GCC 4.7.1.
Giovanni
Using YAGARTO 4.6.2 or the toolchain I linked in the previous post the demo works. It is possible this is specific of GCC 4.7.1.
Giovanni
Re: Unhandled exception after turning on FPU
Still have yet to try the ARM toolchain, but yagarto-4.7.1 on Windows seemed to have the same problem. Will be trying the 4.6 toolchain later.
- Giovanni
- Site Admin
- Posts: 14894
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Unhandled exception after turning on FPU
I'll do an analysis regarding GCC 4.7.1 next weekend.
Giovanni
Giovanni
Re: Unhandled exception after turning on FPU
Just tried the ARM release compiler (4.6) on Windows with the Atollic gdb server and haven't been able to the reproduce the problem. Hooray!
However, I did run into exceptions with the summon-arm-toolchain on OS X, which is arm-none-eabi-gcc (Linaro GCC 4.6-2011.10) 4.6.2 20111004 (prerelease), so my options on the Mac are broken as far as FPU support goes. Just in case that this is a problem with my debug setup though, I'm using this as an excuse to buy a Black Magic Probe, which has a gdb server running onboard.
However, I did run into exceptions with the summon-arm-toolchain on OS X, which is arm-none-eabi-gcc (Linaro GCC 4.6-2011.10) 4.6.2 20111004 (prerelease), so my options on the Mac are broken as far as FPU support goes. Just in case that this is a problem with my debug setup though, I'm using this as an excuse to buy a Black Magic Probe, which has a gdb server running onboard.
Re: Unhandled exception after turning on FPU
So I tried yagarto-4.6.2 on Mac with texane/stlink and got IRQ_STORM_FPU working. Then I loaded in my code to find ResetHandler in an infinite loop:
That's right, ResetHandler calls __late_init, but __late_init never returns... instead it falls through to _default_exit:
and then it keeps going:
...all the way to the beginning of ResetHandler. I don't know why it decides to ignore bx lr or b.n _default_exit, but this is an utterly bizarre manifestation of some bug. All the FSRs are clear (except DFSR obviously, since I'm in the debugger).
Code: Select all
(gdb) break __late_init
Breakpoint 2 at 0x80075d0: file ChibiOS/os/ports/GCC/ARMCMx/crt0.c, line 221.
(gdb) jump ResetHandler
Line 262 is not in `fill32'. Jump anyway? (y or n) y
Continuing at 0x80075f0.
Breakpoint 2, __late_init () at ChibiOS/os/ports/GCC/ARMCMx/crt0.c:221
221 void __late_init(void) {}
(gdb) bt
#0 __late_init () at ChibiOS/os/ports/GCC/ARMCMx/crt0.c:221
#1 0x08007686 in ResetHandler () at ChibiOS/os/ports/GCC/ARMCMx/crt0.c:318
#2 0x08007686 in ResetHandler () at ChibiOS/os/ports/GCC/ARMCMx/crt0.c:318
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) si
0x080075d2 in ?? ()
(gdb) si
0x080075d4 in ?? ()
(gdb) si
0x080075d6 in ?? ()
(gdb) disassemble __late_init
Dump of assembler code for function __late_init:
0x080075d0 <+0>: bx lr
End of assembler dump.That's right, ResetHandler calls __late_init, but __late_init never returns... instead it falls through to _default_exit:
Code: Select all
(gdb) si
0x080075d8 in ?? ()
(gdb) si
0x080075da in ?? ()
(gdb) si
0x080075dc in ?? ()
(gdb) si
0x080075de in ?? ()
(gdb) si
_default_exit () at ChibiOS/os/ports/GCC/ARMCMx/crt0.c:232
232 void _default_exit(void) {and then it keeps going:
Code: Select all
(gdb) si
0x080075e2 in ?? ()
(gdb) si
0x080075e4 in ?? ()
(gdb) si
0x080075e6 in ?? ()
(gdb) disassemble _default_exit
Dump of assembler code for function _default_exit:
0x080075e0 <+0>: b.n 0x80075e0 <_default_exit>
End of assembler dump.
(gdb) si
0x080075e8 in ?? ()
(gdb) si
0x080075ea in ?? ()
(gdb) si
0x080075ec in ?? ()
(gdb) si
0x080075ee in ?? ()
(gdb) si
ResetHandler () at ChibiOS/os/ports/GCC/ARMCMx/crt0.c:262
262 asm volatile ("cpsid i");...all the way to the beginning of ResetHandler. I don't know why it decides to ignore bx lr or b.n _default_exit, but this is an utterly bizarre manifestation of some bug. All the FSRs are clear (except DFSR obviously, since I'm in the debugger).
- Giovanni
- Site Admin
- Posts: 14894
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: Unhandled exception after turning on FPU
You could make a flash dump and verify all the code supposed to be in the reset handler is really there.
Giovanni
Giovanni
Re: Unhandled exception after turning on FPU
Will try the flash dump later; these are my compilation options:
I should note that my project is mostly C++, but I link using arm-none-eabi-gcc and link to std math lib with -lm.
Code: Select all
/Users/xw/yagarto-4.6.2/bin/arm-none-eabi-gcc -c -mcpu=cortex-m4 -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant -ffunction-sections -fdata-sections -fno-common -Wall -Wextra -Wstrict-prototypes -Wa,-alms=build/lst/ -DCORTEX_USE_FPU=TRUE -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -MD -MP -MF .dep/build.d -I. -IChibiOS/os/ports/common/ARMCMx/CMSIS/include -IChibiOS/os/ports/common/ARMCMx -IChibiOS/os/ports/GCC/ARMCMx -IChibiOS/os/ports/GCC/ARMCMx/STM32F4xx -IChibiOS/os/kernel/include -IChibiOS/os/hal/include -IChibiOS/os/hal/platforms/STM32F4xx -IChibiOS/os/hal/platforms/STM32 -IChibiOS/os/hal/platforms/STM32/GPIOv2 -Iboard/. -IChibiOS/os/various -Iinclude main.c -o main.oI should note that my project is mostly C++, but I link using arm-none-eabi-gcc and link to std math lib with -lm.