Any size reduction for printf()

Hi All,

I am using Yagarto (use newlib) to compile a hello world with printf() for atmel AT91SAM9261. The output needs about 4k flash and 2k ram. I have also tried hello world without printf(). The required size is about 80% less.

Is there any method to reduce memory needed in newlib? Actually, I just need prinf() and getc().

Thank you for any comment.

Sorry. The flash size is about 35K!

This can be done easily.

Simple do not use newlib but roll your own or get one of the many super small printf’s out there on the web.

If you cannot find a small printf, post back here and I will try and find it for you.

It would b useful to me sometimes.

Good Luck with your project.

Same problem, but when using sprintf. Also 2K of ram is really a lot, and when you call printf the actual memory use grows because it uses malloc to allocate other ram…

two choices really.

  1. get a smaller version from a web search

  2. use integer version of newlib stdio functions. printf would be iprintf etc

cheers

spen

Thank you all.

Actually, my most concern is in RAM size. I know both printf() and iprintf() in newlib will use about 2K RAM coz it is used malloc.

It seems uClibc is a small footprint c lib. Does anyone try uClibc with Yagarto for AT91SAM9261? I would like to try but I am new guy and never build own c lib. Don’t have idea how to start to build own c Lib!

Please give me some gulidline.

Thank you.

I would not recommend using uclibc as a statically linked application - it uses a different license to newlib.

Just search the internet, there are a lot of small printf’s available.

Cheers

Spen

This one works for me:

http://www.menie.org/georges/embedded/index.html#printf

Thank you.

Currently, I am trying to use bertrik’s advice. I have own sprintf(), getchar() and putchar() functions. When compiling, errors coz of conflict with newlib functions. So I changed my functions name.

Is there any method to keep these function names, so can use them instead of newlib functions?

Thanks,

Keep them with a different name and use a #define to rename all the references.

Something like:

#define sprintf mysprintf