2023-02-26 09:20 AM
I am using the NUCLEO-C031C6 dev board and I seem to be having many difficulties. I am trying to do a printf() or use a sprintf() method to print a float number to the serial port. I noticed that this controller device(STM32C031C6T6) does not have an FPU and when I try to enable the linker flag -u_printf_float I automatically get a compilation error: "Nucleo_C031_FirstTest.elf section `.text' will not fit in region `FLASH'
\tools\arm-none-eabi\bin\ld.exe: region `FLASH' overflowed by 8676 bytes
collect2.exe: error: ld returned 1 exit status" I am not sure how to circumvent this? Is there a way to increase the allocation for FLASH? I tried changing the HEAP and STACK sizes but that has no effect. I am sure this device should be able to handle the extra code to do a printf of a float value? Once again any help or suggestions are greatly appreciated. I have attached my project file here
2023-02-26 09:45 AM
It should have 32KB of FLASH, and that should be described in the Linker Script
Floating Point libraries take up space, but I have them in some 16KB parts.
Perhaps it's your other code that is the issue?
Perhaps try the Keil compiler. It has a free license for STM32 CM0(+) parts
2023-02-26 10:09 AM
and set optimizer to -Os or -O2 .
2023-02-26 10:33 AM
i just tried on F030 : opt. -Os :
(old) prog 7.2kB ;
with float + printf(..float) 11kB overflow.
with float (but no printf float lib) 11.4 kB ;
so you can use float , but for print must put the float in some int by subtract+multiply and put the print chars for float together yourself.
2023-02-26 09:10 PM
There are alternative to float for saving code size and core bandwidth.
Here are some example for STM32C03 on STM32C0316-DK just using for example int32_t Temperature_degC_x10 with corresponding custom printf to show like "27.5". There is a printf for the 16x2 LCD and the reporting on Bluetooth Electronics Android app using USART to SPP HC-06 dongle.
Otherwise there is the Q31 fractional bit representation in 32 bit variables elements that was used in the past in mobile phone drivers.