Skip to main content
Noname1937
Associate III
March 16, 2018
Question

Vstr instruction causing hard fault with stm32f407

  • March 16, 2018
  • 7 replies
  • 1912 views
Posted on March 16, 2018 at 16:57

Hello,

I have an olimexe407 board and I am creating an array with floats (-1 to 1) that I'm calculating and then I am converting them to q31 into 3 different buffers.

I initially tried doing this converting it to one buffer and then calling arm_float_to_q31 and it worked, I verified the values manually, by code and by converting them to float from q31 and comparing the initial float buffer and the final one. The problem is that when I added the second and third buffers, I noticed that it was causing a hard fault.

After a while of debugging I noticed that the fault occurred whenever it was doing a vstr instruction (even though it had been doing other float instructions properly until then). At that moment I was doing optimization level 3, which is probably why it was generating the vstr instruction (haven't tried it again after optimization went to none), but still ... the compiler shouldn't be generating an incorrect instruction (IF IT IS and incorrect instruction).

As stated above I am using the olimex board, and I am programming it on eclipse with the arm-none-eabi- tools

PS: At some point I also tried moving a bunch of floats to a struct and in the final float it did the vstr instructon and it failed the same way, that's how I think that it's probably not a library bug (thounsands of people use it ... probably someone else would've found it waaay before me). I turned this around by forcing a memcpy instead of a simple assignment.

#floating-point #stm32f4
This topic has been closed for replies.

7 replies

AvaTar
Senior III
March 16, 2018
Posted on March 16, 2018 at 17:22

To allow floating point instructions, you would also need to enable the FPU.

If you don't want floating point instructions (even if the MCU would support it), build with 'float-abi=soft', and/or select the proper library.

Tesla DeLorean
Guru
March 16, 2018
Posted on March 16, 2018 at 17:53

 ,

 ,

And enabled on the MCU side

/* FPU settings ------------------------------------------------------------*/

 ,

♯ if (__FPU_PRESENT == 1) &,&, (__FPU_USED == 1)

 ,

 , SCB->,CPACR |= ((3UL <,<, 10*2)|(3UL <,<, 11*2)), , /* set CP10 and CP11 Full Access */

 ,

♯ endif

Frequently in SystemInit(), or in assembler in startup.s

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..