[mbed] Change from hard to softfp for FRDM-K64F (Cortex-M4F) (#1217)

36 views
Skip to first unread message

Jags27

unread,
Jun 30, 2015, 1:49:29 AM6/30/15
to mbedmicro/mbed

Hi,

I have a posted a question in mbed forum about the change of fpu flag for FRDM-K64F from hard to softfp. This processor is having FPU by default, so It would be good to provide the mbed library with the hard enabled instead of soft.

https://developer.mbed.org/questions/54230/Mbed-library-for-K64F-is-built-with-soft/#answer7952

I have been redirected to raise an issue in this forum.

It seems, the flag is changed from hard to soft based on the following request.
https://github.com/mbedmicro/mbed/pull/224/files

My request is to change this flag to hard for the better performance.


Reply to this email directly or view it on GitHub.

Adam Green

unread,
Jul 1, 2015, 5:07:28 AM7/1/15
to mbedmicro/mbed

I will point out that -mfloat-abi=softfp does use the FPU for single precision floating point operations. That flag just tells the compiler to pass floating point function parameters in the integer registers instead of the floating point registers. When it comes time to do something like adding two floating point registers, it will use the FPU to do it.

Jags27

unread,
Jul 1, 2015, 5:38:29 AM7/1/15
to mbedmicro/mbed

Hi,

I agree with your explanation on the usage of flag. I did some search in the web and found below link.
From the below link, it looks like softfp takes more cycles though as it uses the integer registers.
https://wiki.debian.org/ArmHardFloatPort/VfpComparison

I am actually linking the mbed library (which is by default built with softfp) with CMSIS RTX library (which is built with hardfp) using gcc compiler. During the linking, the compiler throws an error as the libraries are built with different fpu flags.

My request is that it would be good if your provide the two versions of libraries. One is with softfp and other is with hardfp.

Jags27

unread,
Jul 6, 2015, 5:08:04 AM7/6/15
to mbedmicro/mbed

I am new to github and do not know how to assign this pull request to particular owner.

Can someone assign this issue to dinau who has changed the hardfp tp soft.

Martin Kojtal

unread,
Jul 6, 2015, 5:14:36 AM7/6/15
to mbedmicro/mbed

I was not aware rtx is built with hardfp command argument.

If you mention a nickname, they should be notified.
cc @dinau

Jags27

unread,
Jul 6, 2015, 5:19:29 AM7/6/15
to mbedmicro/mbed

Can you respond to my request @dinau

dinau

unread,
Jul 9, 2015, 9:08:10 AM7/9/15
to mbedmicro/mbed

Hi,
I'm going to make the pull request to enable hardfp option in a few days.

Jags27

unread,
Jul 14, 2015, 1:59:19 AM7/14/15
to mbedmicro/mbed

Hi,
Thanks for creating the pull request. How do i get the update on this pull request ? I mean how do i know that library is available with hardfp ?

dinau

unread,
Jul 14, 2015, 10:27:11 AM7/14/15
to mbedmicro/mbed

Hi Jags27,

I've yet to make pull request
because I've investigated this issue
but I've encountered serious problem at this moment.
If you use gcc optimization option "O0", it seems works well.
But all other options e.g. "O2, O3, Os" dose not works.
(The default option is O2)
I don't know why the reason that it dose not work well so far.

The modification is as follows:
workspace_tools/toolchains/gcc.py :
line 49 :
change from

            self.cpu.append("-mfloat-abi=softfp")

to

            self.cpu.append("-mfloat-abi=hard")

Can anynone help to resolve this issue ?

dinau

Jags27

unread,
Jul 20, 2015, 7:10:25 AM7/20/15
to mbedmicro/mbed

Hi,

Can you describe about the error that you are facing @dinau

Jagadeesh K

dinau

unread,
Jul 23, 2015, 8:10:55 AM7/23/15
to mbedmicro/mbed

Hi Jags27,

mbed sdk tools reference to :

https://developer.mbed.org/handbook/mbed-tools

After above change I mentioned, I executed as follows:

 python workspace_tools/build.py -m NUCLEO_F411RE -t GCC_ARM -r -c -v  
 python workspace_tools/make.py  -m NUCLEO_F411RE -t GCC_ARM -n RTOS_7 -d . -v

You can change the board name 'NUCLEO_F411RE' to 'K64F'.

I changed tentatively RTOS_7 sample (libraries/tests/rtos/comsis/timer/main.cpp) to

#include "mbed.h"
#include "cmsis_os.h"

DigitalOut LEDs[4] = {
    DigitalOut(LED1)
};

void blink(void const *n) {
    LEDs[(int)n] = !LEDs[(int)n];
}

osTimerDef(blink_0, blink);

int main(void) {
    osTimerId timer_0 = osTimerCreate(osTimer(blink_0), osTimerPeriodic, (void *)0);

    osTimerStart(timer_0, 200);

    osDelay(osWaitForever);
}

You can also change GCC optimization option to any value by modifying

workspace_tools/toolchains/gcc.py : line 77.

Resulting:

(1) LED blinking OK
-mfloat-abi=softfp
Optimization: -O2
(2) LED blinking OK
-mfloat-abi=hard
Optimization: -O0
(3)LED blinking NG
-mfloat-abi=hard
Optimiztion: -O1,-O2,-O3,-Os

dinau

Reply all
Reply to author
Forward
0 new messages