Quality RTOS & Embedded Software

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


Loading

printf using printf-stdarg.c

Posted by roujesky on August 1, 2014

I had this working on an old mplab8 project running FreeRTOS. But I have a brand new project running the latest version of FreeRTOS on a PIC32MX795. Now, tho, when i call printf, it goes straight to this function in printf-stdarg.c

/* To keep linker happy. / int write( int i, char c, int n) { return 0; }

what am I doing wrong? Like I said, this worked for me years ago. I should see it stepping thru all the functions in printf-stdarg.c....

thanks!


printf using printf-stdarg.c

Posted by rtel on August 2, 2014

printf-stdarg.c contains an extremely light weight version of some of the stdio functions. It is a useful way of keeping the code size of GCC built programs (XC32 is GCC by another name) down as bringing in a lot of GCC libraries can really bloat code and massively increase your stack usage. In printf-stdarg.c you can direct the output of printf() wherever you like (UART, console, USB CDC etc.) or just provide a dummy write() function if you are not actually going to use printf() at all.

If the libraries that come with your compiler (presumably XC32) come with an implementation of write() that does what you want then you can simply remove printf-stdarg.c from the project all together - if you do that I would strongly suggest you have stack overflow checking turned on in FreeRTOSConfig.h.

Regards.


printf using printf-stdarg.c

Posted by bowerymarc on August 2, 2014

You need to implement the actual output function yourself, or use sprintf and deal with the resultant char array. So overload write(). Your old project probably did that somewhere.

Attachments

alternate (1722 bytes)

printf using printf-stdarg.c

Posted by roujesky on August 3, 2014

thanks! I will implement the necessary code in write().


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


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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 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.


Careers

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

Renesas

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