Using float on STM32F1
Posted: Wed Jun 30, 2021 8:50 am
After playing with the F4 a bit I thought it would be pretty neat to be able to use floats on the F1. Yes it will be soft-float but that should be ok for the slower 10 & 100ms tasks. I would like to restrict the fixed-point math to the 8.8 kHz control ISR only.
Problem so far has been that using any sort of float operation would result in a hard fault. That is because gcc by default uses the "wrong" libgcc.a.
I have forced it to use one with floating point implemented by changing LDFLAGS from
to
-Llibopencm3/lib -L/usr/lib/gcc/arm-none-eabi/11.1.0/thumb/v7+fp/softfp -T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections,-Map,linker.map
There is probably a better way to do this, i.e. not having an absolute path in there.
UPDATE: there is. Just specify -march=armv7
I think this is particularly interesting for the ZombieVerter project as that has no fast loops at all.
Problem so far has been that using any sort of float operation would result in a hard fault. That is because gcc by default uses the "wrong" libgcc.a.
I have forced it to use one with floating point implemented by changing LDFLAGS from
Code: Select all
-Llibopencm3/lib -T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections,-Map,linker.map
-Llibopencm3/lib -L/usr/lib/gcc/arm-none-eabi/11.1.0/thumb/v7+fp/softfp -T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections,-Map,linker.map
Code: Select all
-Llibopencm3/lib -march=armv7 -T$(LDSCRIPT) -nostartfiles -Wl,--gc-sections,-Map,linker.map
UPDATE: there is. Just specify -march=armv7
I think this is particularly interesting for the ZombieVerter project as that has no fast loops at all.