help needed FPU not working on STM32F4 with MIOS32

5 posts in this topic

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!

Share this post

Link to post
Share on other sites

Read somewhere that the FreeRTOS in the repository does not includes the Cortex-M4 floating point support, does not support the saving and restoring the vectored floating point registers during context switches. 

See the #4  tip on this page:



Share this post

Link to post
Share on other sites

Did anyone figure out how to get floats to work with the FPU without crashing? I've tried with -mfloat-abi=softfp and not using the FPU in an ISR but still can't get it to work.


Share this post

Link to post
Share on other sites

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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now