Unhandled exception after vpush instruction

Discussions and support about ChibiOS/RT, the free embedded RTOS.
meatball
Posts: 32
Joined: Thu May 19, 2016 4:39 pm
Has thanked: 9 times
Been thanked: 2 times

Unhandled exception after vpush instruction

Postby meatball » Mon Dec 19, 2016 6:05 pm

Just as the title says.

You can see the STM32F4's CPU registers and the disassembly just before the exception, and after it.

The vpush instruction attempts to move the FPU registers (s16 - s31) to the stack, but the next instruction branches over to the unhanded exception handler instead.

For some reason, R7 contains something at this point. Does anyone know what could cause this to happen?

vpush.PNG


next...

vpush2.PNG


The only things I had to define in the IDE were the following linker symbols..

__main_stack_size__=__STACK_SIZE
__process_stack_size__=__STACK_SIZE

Compilation, linking all goes well. Stack size is set to 0x0400.

Any other run-time clues I can use to figure out what is going on?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Unhandled exception after vpush instruction

Postby Giovanni » Mon Dec 19, 2016 7:01 pm

Hi,

Probably the FPU is not enabled (compiler options), so the first float instruction triggers the exception.

Giovanni

meatball
Posts: 32
Joined: Thu May 19, 2016 4:39 pm
Has thanked: 9 times
Been thanked: 2 times

Re: Unhandled exception after vpush instruction

Postby meatball » Mon Dec 19, 2016 8:46 pm

Hi Giovanni,

I have the following compiler definitions enabled:

__FPU_ENABLED
__FPU_USED

Assembler Flags:
-x assembler-with-cpp
-DCORTEX_USE_FPU=TRUE

Other flags:
ARM_MATH_CM4
STM32F407VG
STM32F4XX

all appear to be defined in ChibiOS itself, and adding them to the compiler flags raises redundancy errors.

Are there any other flags I should be raising?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Unhandled exception after vpush instruction

Postby Giovanni » Mon Dec 19, 2016 9:37 pm

See in crt0_v7m.S if the FPU initialization is really executed.

Giovanni

meatball
Posts: 32
Joined: Thu May 19, 2016 4:39 pm
Has thanked: 9 times
Been thanked: 2 times

Re: Unhandled exception after vpush instruction

Postby meatball » Mon Dec 19, 2016 10:12 pm

It was not.

I was missing the 'CORTEX_USE_FPU' flag. I didn't think I would've needed to add it since '__FPU_USED' is defined.

Does ChibiStudio define CORTEX_USE_FPU by default?

I don't understand the difference between these flags. FPU_USED is an ARM specific flag, but CORTEX_USE_FPU seems to be a ChibiOS thing. Why use both of these?

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Unhandled exception after vpush instruction

Postby Giovanni » Mon Dec 19, 2016 10:38 pm

Hi,

ChibiOS uses its own macros that are not dependent on specific compilers, __FPU_USED is not used anywhere in ChibiOS.

Giovanni


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 11 guests