Hello, We are currently trying to develop an arm-mp3 player. ( http://groups.google.com/group/qamp/, not very interesting really) Problem is, the code size generetad by arm-elf-gcc is about 300k, while all the different object files are about 100k. We already worked around the rq_table.dat using a Taylor approximation. The problem is we only have 128k flash available (we use a real embedded system, not some sort of arm with megs of memory and some weird linux kernel ;)) We started developing under windows (Dev-C++), trying to get to know mad. We were able to decode an mp3 file to pcm without much trouble. The windows executable however, is only 181k, and that includes rq_table.dat. We already tried using -o2 for gcc and strip, but that didn't get us very far. Neither do we include any unnecessary files (layer12.c, sys/*.h, etc). Any help would be appreciated as we pretty much have given up on this ourselves... Tiemen Schut
On Sep 22, 2005, at 7:02 AM, Tiemen Schut wrote:
We are currently trying to develop an arm-mp3 player. (http:// groups.google.com/group/qamp/, not very interesting really)
Problem is, the code size generetad by arm-elf-gcc is about 300k, while all the different object files are about 100k. We already worked around the rq_table.dat using a Taylor approximation. The problem is we only have 128k flash available (we use a real embedded system, not some sort of arm with megs of memory and some weird linux kernel ;))
Is your C library being statically linked into the executable? I don't know anything about your runtime environment. You might be able to get some useful information from nm or objdump (e.g. objdump -x).
If this is the case, and you don't have a dynamic C library otherwise available on the target platform, you'll probably want to look into eliminating decoder.o (which implements the high-level API) and replacing the few remaining C library calls in libmad. There are a couple of {m,c}alloc()/free() calls that can be replaced with static allocation, a sprintf() call that can be eliminated from the timer interface, and some assert() debugging calls that can be avoided. The only other C library calls of concern are memcpy() and memmove() in layer3.c for which you will need to find an alternate implementation, or write one yourself.
On Sep 22, 2005, at 10:02 AM, Tiemen Schut wrote:
We already tried using -o2 for gcc and strip, but that didn't get us very far. Neither do we include any unnecessary files (layer12.c, sys/*.h, etc).
In addition to Rob's suggestions, you're going to want to look into - Os, "Optimize for size", as a compilation option. It won't be night- and-day, but it will make your code smaller. (Be sure to make sure it's still fast enough though! Optimizing for size can go either way - faster because it fits into cache better, slower because it's not unrolling loops, etc.)
Hope this helps!
Joe