cancel
Showing results for 
Search instead for 
Did you mean: 

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

davidregan9
Associate III

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

14 REPLIES 14
davidregan9
Associate III

@Dave Nadler​ 

Hello Dave. I implemented your solution with heap_useNewlib.c and it worked.

If I'm understanding it correctly ANY kind of dynamic memory assignment is now coming out of the RAM between end and _estack.

That's all printf family type stuff and all RTOS tasks/objects.

Have you had any experience of running out of heap in a reasonable sized project. On our last project we had an external sdram and directed all RTOS activity to that.

@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??

davidregan9
Associate III

@Dave Nadler​ 

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

davidregan9
Associate III

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

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.