Jump to content

FPU not working on STM32F4 with MIOS32


Recommended Posts

Hello all!

I've run into a problem while implementing a granular synth on a STM32F4 Discovery using MIOS32. The synth algorithm makes use of floating point operations - I thought it would not be a source of performance issue, since the MCU has a dedicated unit for floating point calculations. Actually, there are performance issues, because the FPU is not enabled for the compiler (I'm using the original toolchain). There's a line commented out in trunk/include/makefile/common.mk:

ifeq ($(FAMILY),STM32F4xx)
# leads to a crash - reason not analysed yet
#CFLAGS += -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mthumb -mfloat-abi=hard -mlittle-endian -ffunction-sections -fdata-sections -fomit-frame-pointer

# works (but FPU not enabled)
CFLAGS += -mcpu=cortex-m4 -mlittle-endian -ffunction-sections -fdata-sections -fomit-frame-pointer

I tried to uncomment that line, it compiled, but crashed for real on the MCU.

Do you know if there's a workaround for that? What can be the source of this problem? Rewriting the synth algorithm is not an option, this is my thesis project, and the deadline is close.

Thanks in advance!

Link to comment
Share on other sites

  • 1 year later...
  • 4 weeks later...

because of using float... i was searching and trying the last day... i figured following out:

when dont use: "-fomit-frame-pointer" in common.mk, t+ deactivate gcc optimize   then floating point is functional, @ least with a "small programm" (see the atached zip file fpu__working.zip)

i was trying to follow the source of the blackscreen and hardfault, thought of frtos and mutexes, off stacksize, mios-switches, and all kind of stuff, deleted all i could in my program, and come to the point - without fomit-frame-pointer and gcc optimize - its only a thing of "size" of the programm not the used functions (i tryed 10 ours till now, all kind off stuff, and thats my conclusio) (i addet much useless stuff, but from all a bit to a file and its still not hardfaulting, but screens are black and the mios-studio debugging is also not functional it fries without hardfault error, you will have to go in bootloader to load a nother code on the machine ( i of course have a switch for that) fpu__still_working.zip

so feel free to add stuff to the attached programs, &  find out what the program let hardfault... we may have to activate fomit frame pointer and gcc optimize...

maybe this 2 settings are enough for a geek -  to easyer find the problem in first place, for me i am tapping in the dark - good morning - good night.


in "common.mk" search for your STM32Board:
# works (but FPU not enabled)
CFLAGS += -mcpu=cortex-m4 -mlittle-endian -ffunction-sections -fdata-sections -fomit-frame-pointer
and replace the whole thing with:
# works (but no "-fomit-frame-pointer" set
CFLAGS +=  -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mlittle-endian -ffunction-sections -fdata-sections
in your Lokal Makefile (the direction where your program is)
search for:
OPTIMIZE  =    -Os
replace with:

i am done, the other things like including float fmath.h which is not functional with dead ends in mios... are too high for me...there is some mess with the library...

i will try now in my code to get a dynamic logaritm without using floats in any kind - thats my conclusio

Edited by Phatline
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...