Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


printf implementation causes problems.

Posted by Angel Eyes on October 19, 2008
Hi ,

I am working on a FreeRTOS port on Samsung 4510 processor . I have ported the RTOS successfully, however when I try to do a printf application port on it , I see some annomalies.

I have ported the standard printf implementation ( named my_printf ) where I have used the UART . And have created some .c files which handle the my_printf function , I have also used the stdarg.h for this implementation . When I run the image , the printing happens once for the respective task ( say I have put a my_printf statement for task no x ) however from the next time the printing does not happen for that task . Hence I have no idea if that task works anymore .

However for those taske in which I have directly output characters through the UART like below , the output is visible consistently .

int i ;
for (;;) {
char * hellostr="Task 2 running \n ";
long* paddr=(long*)0x3ffd00c;

* paddr=hellostr;


This works faithfully .

But the printf implementation fails after one time print .

What might be the problem ?


RE: printf implementation causes problems.

Posted by Dave on October 20, 2008
I'm not sure which parts of printf you wrote yourself and which come from the C library. If you are using the GCC C library then you will probably find that the printf family of functions uses lots of stack, is not reentrant, and may even attempt to use malloc. The most likely cause of your problem is a stack overflow.

The FreeRTOS download includes some cut down versions of sprintf that use much less stack and are reentrant. Try using one of those. Look for a file called printf-stdarg.c

RE: printf implementation causes problems.

Posted by Angel Eyes on October 20, 2008

Hi ,

Sorry for the false alarm :) . I got the problem I mistakenly deleted the endless for loop in the task I put the printf statement in so after printing once it was exiting that function .

My printf implementation uses no GCC libraries and I have named it as my_printf which does not make any calls to the GCC library , it is a cut down version as you stated , it only uses stdarg.h header which is external , apart from that there is a my_printf.c function and uart.c function which I created with their respective header files .

It works fine now , so far so good :). Thanks a lot .

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

Version 10.1.0 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner