Print float values RAK Wistrio 5205

(DA SILVA) #1

Hi all,

I’m looking for a way to display float values on serial port. It seems there is a new function “e_printf” in the latest firmware (2.x.x.x) but I can’t test it because if I compile the FW with the Ac6 OpenSTM32 IDE, the board reboots permanently, displaying stranges characters on Serial port.

So I’m using an old firmware (1.1.3), that uses a simplified “printf.c” file to reduce memory footprint, but seems to have limited options and the %f is not present :

switch (*pFormat) {
case ‘d’:
case ‘i’: num = PutSignedInt(pStr, fill, width, va_arg(ap, signed int)); break;
case ‘u’: num = PutUnsignedInt(pStr, fill, width, va_arg(ap, unsigned int)); break;
case ‘x’: num = PutHexa(pStr, fill, width, 0, va_arg(ap, unsigned int)); break;
case ‘X’: num = PutHexa(pStr, fill, width, 1, va_arg(ap, unsigned int)); break;
case ‘s’: num = PutString(pStr, va_arg(ap, char *)); break;
case ‘c’: num = PutChar(pStr, va_arg(ap, unsigned int)); break;

Thanks for your help?

regards

(Todor Velev) #2

Hi @JCDS
I am not so familiar with OpenSTM32. Do you turn on the floating point output? Which compiler version are you using c11 or c99? What gcc are you using?
Sorry for too many questions :smiley: Try to help :slight_smile:

Regards
Todor

(DA SILVA) #3

Hello Velev,

OpenSTM32 Ac6 uses arm-none-eabi-gcc compiler, I don’t know if it’s C99 or C11, even the version seems to be :

arm-none-eabi-gcc-7.3.1.exe (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907]

Here is an extract of the compile with all the options :

arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -DUSE_DEBUGGER -DUSE_HAL_DRIVER -DSTM32L151xB -DSTM32L151CBU6 -DREGION_EU868 -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/boards/mcu/stm32/STM32L1xx_HAL_Driver" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Inc" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/boards/RAK811BreakBoard" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/boards/RAK811BreakBoard/cmsis" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/boards/mcu/stm32" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/boards/mcu/stm32/cmsis" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/mac" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/mac/region" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/peripherals" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/radio" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/system" -I"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/system/crypto" -Os -g3 -Wall -fmessage-length=0 -ffunction-sections -c -MMD -MP -MF"src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dma.d" -MT"src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dma.o" -o “src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dma.o” “…/src/boards/mcu/stm32/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dma.c”

I know that floating point is not supported on all MCU and I’ve seen some specific options for the linker like “-specs=nosys.specs -specs=nano.specs -u _printf_float -u _scanf_float” :

Invoking: MCU G++ Linker
arm-none-eabi-g++ -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -specs=nosys.specs -specs=nano.specs -u _printf_float -u _scanf_float -T"D:/Synchro_Project/Synchro/RAK811/WisTrio_5205_07-12/src/boards/RAK811BreakBoard/cmsis/arm-gcc/STM32L151XB_FLASH.ld" -Wl,-Map=output.map -Wl,–gc-sections -fno-exceptions -fno-rtti -o “WisTrio_5205_07-12.elf” @“objects.list” -lm

Thanks for your help