Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


sprinf conversion of float is not working for STM32F7

I’m tryint to use sprintf to convert a float to a string, but the returned string is empty (just the ‘\0’ is returned).
Do any of you know of a trick that can make it work?

I’m using the latest versions of AC6 and the “Hello World” example from cube.

/Breinholm

Tunisia

Hello Breinholm,

Check your linker flags (project properties > C/C++ Build > Setings > Tool Settings (TAB) > MCU GCC Linker > Miscellaneous > Linker flags),
if you are using nanolib “-specs=nano.specs” you need to add “-u _printf_float” to enable float printf.

Best Regards,
TarekB

Hi Tarek,

I treid adding “-u _printf_float” to enable float printf. as you suggest but after build i get the following errors?


Building target: EM34.elf
Invoking: MCU GCC Linker
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -specs=nosys.specs -specs=nano.specs -Xlinker -u _printf_float -T”../STM32F103CBTx_FLASH.ld” -Wl,-Map=output.map -Wl,--gc-sections -lm -o “EM34.elf” @”objects.list”
arm-none-eabi-gcc.exe: error: _printf_float: No such file or directory
make: *** EM34.elf Error 1

I am using latest updates for STM32 CubeMX, and STM32 Workbench..... I recall this solution used to work on previuos version but not now?
Any suggestions?

Hi,

I think you put the “-u _printf_float” on the wrong place, it should be in the linker flags and not the -Xlinker area.

Regards
Kevin.

Hi Tang,

I am sure I put the options under the Linker Flags, as I said this option was working under previous versions (unsure which version it was) but I recently clicked “update” on both the STM32 CubeMX and the System32 Workbench programs and now for some unlknown reason The Linker throws the following errors:

Building target: EM34.elf
Invoking: MCU GCC Linker
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -specs=nosys.specs -specs=nano.specs -Xlinker -u _sprintf_float -Xlinker -u _printf_float -T”../STM32F103CBTx_FLASH.ld” -Wl,-Map=output.map -Wl,--gc-sections -lm -o “EM34.elf” @”objects.list”
arm-none-eabi-gcc.exe: error: _sprintf_float: No such file or directory
arm-none-eabi-gcc.exe: error: _printf_float: No such file or directory
make: *** EM34.elf Error 1

(see attached image)


Tunisia

Kevin is right :
“-u _printf_float” should be after “-specs=nano.specs”

Notes :
arm-none-eabi-gcc -mcpu=cortex-m3 -mthumb -mfloat-abi=soft -specs=nosys.specs -specs=nano.specs -Xlinker -u _sprintf_float -Xlinker -u _printf_float -T”../STM32F103CBTx_FLASH.ld” ....

  1. There is no “_sprintf_float”
  2. You do not need Xlinker options
  3. You should have only one -u _printf_float
  4. In (project properties > C/C++ Build > Setings > Tool Settings (TAB) > MCU GCC Linker > Miscellaneous > Linker flags),you should have ” -specs=nosys.specs -specs=nano.specs -u _printf_float”

Many thanks tarek,

My problem issue was that was adding the “-u_printf_float” option using the “ADD ICON” which put the required string into the TEXT BOX below ? ..
This was working ok on previous versions of Sytem32 Workbench ...but ... The Latest version doesn’t work like that anymore ... so what I did was to edit/replace the main string at the top ( -specs=nosys.specs -specs=nano.specs ) to what you have shown above .(-specs=nosys.specs -specs=nano.specs -u _printf_float). this worked OK ..
Thanks again for your help.biggrin



 

Newest Forum Posts

  1. reservation car service Seattle by Jamesprede, 2025-05-01 10:06
  2. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  10. Build a project in "release" mode by tang, 2025-02-20 10:36

Last-Modified Blogs