Skip to main content
davidregan9
Associate III
August 12, 2019
Question

Cannot use printf with floats on a Cube generated System Workbench project for STM32F429i discovery board.

  • August 12, 2019
  • 14 replies
  • 4907 views

Used cube to generate a project with default settings for STM32F429I disco board plus CMSIS V2 RTOS and USART 2 half duplex transmit only . Generated the code for System Workbench.

I retargeted _write() and provided __io_putchar(). I added -u _printf_float to the linker flags.

In the StartDefaultTask I added

 float fVal = 345.678;

 printf("Hello World\r\n");

 printf("fVal %f\r\n",fVal);

Output

Hello World

fVal . !

Issues

With -specs = nosys.specs -specs= nano.specs -u _printf_float - printf causes a hard fault.

With specs = nosys.specs -specs -u _printf_float - 1st printf OK 2nd printf produces incorrect output

This topic has been closed for replies.

14 replies

Dave Nadler
Senior III
August 20, 2019

@davidregan9​ - Yes you understand correctly; all malloc'd memory is consolidated. In next few days I'll post an update (on web page linked above) with better control of and diagnostics for the separate stack used for ISRs. I haven't had too much trouble with running out of space and I always put detailed diagnostics into the application (checking task stacks, heap, and shortly the ISR MSP stack).

Glad my solution helped you,

Best Regards, Dave

PS: @Markus GIRDLAND​ - Any progress getting these fixes integrated into CubeMX??

Markus GIRDLAND
ST Employee
August 27, 2019

Sorry for the late reply, I've been out-of-office.

I haven't heard any status update regarding this from the CubeMX team as of yet.

As soon as it is implemented they'll share it with the IDE team.

davidregan9
Associate III
August 20, 2019

@Dave Nadler​ 

Excellent piece of work. Never had occasion to use --wrap switch so that took a couple of go's

davidregan9
Associate III
August 20, 2019

@Dave Nadler​ Thank you for replying. I was starting to think nobody was out there.