EmbeddedRelated.com
Forums

Standard Lib function with FreeRTOS Increases code size

Started by prab...@yahoo.co.in July 1, 2009
Hi all,
Thanks for all shared with ur knowledge,and suggestionsregrding this issue.

1. I have used printf-stdarg.c.Code memory didnt decrease.then I have tried " #define printfkprintf " in Global header fileand change thedefinition of this printf function name to kprintf in printf-stdarg.c.But still code size didnt decrease.I am checking that .map file for whether the " standard libs are still included"?.How to stop compiler to use stdlib instead of user defined printf function(printf-stdarg.c)?.

2. In printf-stdarg.c %f is not supported .for my app i need%f also.Is any other
lib supported this also?Is latest printf-stdarg.c supported this?.

3.My last project i used keil.that supported full printf functionality(.including %f).
code memory also not incresed much.Anyone explain how keil lib used less memory??
I am looking similar lib in GCC.

Thanks,
Prabu


--- On Thu, 2/7/09, Pete Vidler wrote:
From: Pete Vidler
Subject: Re: [lpc2000] Standard Lib function with FreeRTOS Increases code size
To: l...
Date: Thursday, 2 July, 2009, 1:52 PM

Bruce Paterson wrote:
> Agree with Foltos here. There must be a printf (or variant) left behind
> in your code. Ensure all files that include the global #define have
> re-compiled (check your dependencies) . The map file shows you what is
> going on.

Depending on his library, printf may still be included in the final
output. He may also need the -ffunction-sections and -fdata-sections
compiler options (preferably on the libraries themselves as well) and
link with the --gc-sections option (often passed as '-Wl,--gc-sections'
if GCC is used to start the linker).

Those are only valid for GCC.

Also, I would recommend against the '#define printf' as anything other
than a test to see what difference it makes... I certainly wouldn't use
that in production code. In fact, I think I'd prefer a global search
and replace in either situation.

Pete

Love Cricket? Check out live scores, photos, video highlights and more. Click here http://cricket.yahoo.com



An Engineer's Guide to the LPC2100 Series

pra bu wrote:
> I am checking that .map file for whether the " standard libs are
> still included"?.

How exactly are you measuring your code size? Hopefully not just by
looking at the size of the elf file...

Have you tried other methods to reduce code size -- such as the options
I mentioned previously and optimising for space over speed (-Os)?

> How to stop compiler to use stdlib instead of user
> defined printf function(printf-stdarg.c)?.

If you're #include-ing the header for this library and not stdio.h, then
it should work. It's possible that GCC is hardwired to use printf from
the standard library, but changing the name should have avoided that
possibility.

(Provided you changed the name *everywhere*).

> 2. In printf-stdarg.c %f is not supported .for my app i need %f
> also.Is any other lib supported this also?Is latest printf-stdarg.c
> supported this?.

You can fake it using %d. Check out the answer here:

http://stackoverflow.com/questions/905928/using-floats-with-sprintf-in-embedded-c

Here's a cut-down version of the code presented there:

float value = 678.0123;
int intVal = value;
float decVal = value - intVal;
int intDecVal = (int)(decVal * 10000);
printf("value = %d.%04d\n", intVal, intDecVal);

> 3.My last project i used keil.that supported full printf
> functionality(.including %f). code memory also not incresed
> much.

Maybe that's why people pay for it...?

Pete