Floating point instructions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-17 6:16 AM
I am using STM32F303VC with System Workbench IDE.
I can't for the life of me get the hard floating point option to work. The compiler never generates floating point instructions. It' only generating soft code with library calls. Anyone knows what the problem could be?
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-17 1:36 PM
What is your SW4STM32 version ?
Maybe upgrade to latest version should be fix your issue.
Best regards
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-17 8:01 AM
>>Anyone knows what the problem could be?
Settings and defines sent to the compiler? Not hard to get GNU/GCC to compile FPU instructions.
The FPU only supports 32-bit floats, not doubles.
1.23 is a double, 1.23f is a float
printf/scanf use doubles
The FPU only supports simple arithmetic functions, anything complex or transcendental will use mix of software/hardware.
Most stuff tends to use the Soft ABI, though that might be changing now the M7 and M4F are getting more prevalent.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-17 8:12 AM
Hi,
Can you check the configuration of your project this way:
Into
System Workbench Project \ Properties \ C/C++ Build \ Settings \ Tool Settings \ Preprocessor
Check if __FPU_PRESENT and __FPU_USED symbols are defined
And then into MCU Settings Floating Point ABI is hard
Best regards
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-17 12:42 PM
I have both those symbols defined in the preprocessor.
But my problem could be this. I cannot select anything under Float Point Hardware. I have only No unit listed.
Could this be the problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-17 12:46 PM
The FPU only supports 32-bit floats, not doubles.
1.23 is a double, 1.23f is a float
printf/scanf use doubles
The FPU only supports simple arithmetic functions, anything complex or transcendental will use mix of software/hardware.
Most stuff tends to use the Soft ABI, though that might be changing now the M7 and M4F are getting more prevalent.
So i have a simple statement saying:
float x; x = 1.25; x = x*x;
x = 1.25; x = x*x;
x = x*x;
Going through the dissasembly I don't see a single floating point instruction. Even if it were double, the compiler must be making use of 32bit floating point hardware to do double right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-17 1:36 PM
What is your SW4STM32 version ?
Maybe upgrade to latest version should be fix your issue.
Best regards
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-17 2:32 PM
The optimizer should flatten that to constants.
This was one of my test cases, built with GNU/GCC 4.9.3
float test1(float x, float y)
{return(x + y + sqrtf((x * x) + (y * y)));
}
demo.lss listing
...
08002578 <test1>:
//******************************************************************************♯ include <math.h>
float test1(float x, float y)
{ 8002578: b508 push {r3, lr} 800257a: ed2d 8b02 vpush {d8} 800257e: eeb0 8a40 vmov.f32 s16, s0 return(x + y + sqrtf((x * x) + (y * y))); 8002582: ee20 0aa0 vmul.f32 s0, s1, s1//******************************************************************************♯ include <math.h>
float test1(float x, float y)
{ 8002586: eef0 8a60 vmov.f32 s17, s1 return(x + y + sqrtf((x * x) + (y * y))); 800258a: eea8 0a08 vfma.f32 s0, s16, s16 800258e: f001 fcd9 bl 8003f44 <sqrtf> 8002592: ee38 8a28 vadd.f32 s16, s16, s17} 8002596: ee38 0a00 vadd.f32 s0, s16, s0 800259a: ecbd 8b02 vpop {d8} 800259e: bd08 pop {r3, pc}Compiling file: main.c
arm-none-eabi-gcc -c -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16-Os -ffunction-sections -fdata-sections -Wall -Wstrict-prototypes -Wextra -std=gnu89-g -ggdb3 -fverbose-asm -Wa,-ahlms=out/main.lst -DUSE_STDPERIPH_DRIVER
-DSTM32F4XX -DUSE_STM32F4_DISCOVERY -DUSE_USB_OTG_FS -DHSE_VALUE=8000000
-D__FPU_PRESENT=1 -MD -MP -MF out/main.d -I. -Iinc main.c -o out/main.o
Linking target: out/demo.elf
arm-none-eabi-g++ -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16-Tstm32f4xx.ld -g -Wl,-Map=out/demo.map,--cref,--no-warn-mismatch -Wl,--gc-sections
-nostartfiles out/startup_stm32f4xx.o out/diskio.o out/ff.o out/main.o out/misc.oout/newlib_stubs.o out/stm32f4_discovery.o out/stm32f4_discovery_sdio_sd.o
out/stm32f4xx_dma.o out/stm32f4xx_gpio.o out/stm32f4xx_rcc.o out/stm32f4xx_sdio.o
out/stm32fxxx_it.o out/system_stm32f4xx.o -o out/demo.elfUp vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-18 3:15 AM
Oh.. yes.. Finally.. Upgrade did the trick..
I hate it when upgrading fixes a compiler issue. That's so non-intuitive. Wouldn't have figured it out ever!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-18 3:25 AM
Great !!!
Official thread on AC6 forum here.
http://www.openstm32.org/forumthread92
BR
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-08-18 7:01 AM
Not really a compiler issue, that's worked for years, the IDE hiding the options/settings is the problem.
Up vote any posts that you find helpful, it shows what's working..
