DSPRelated.com
Forums

Loading compressed executable from flash

Started by Laurent June 21, 2004
Hi guys,

I'm programming some stand-alone audio application on the TMS320C6713 DSK.
It has 256 KB of usable flash memory. It's not bad but i'd like to have as
much free space as possible on the flash, to put the maximum amount of my
tiny musics.

My original executable code is about 140 KB big.

My idea is to compress it, for example by using the z library (
http://www.gzip.org/zlib/ ).
Then i would have a tiny piece of code that would basically boot the C zlib
decompressor executable. It will then be my task to decompress my "big"
executable and to place the sections at their correct addresses in
IRAM/SDRAM, being careful with potential overwrite issues. Then i should be
able to call the entry point routine of my program.

Do you think it makes sense ? I think compressing the executable is kinda
neat, it has been done for ages on old 8 & 16/32 bits computers ( like
Commodore 64 & Amiga ).

Did some of you already think about doing something similar, what kind of
compression library did you use, and what kind of issue did you meet ?

Thanks,
Laurent




> Did some of you already think about doing something similar, what
kind of
> compression library did you use, and what kind of issue did you meet ?

Hi Laurent,

Some years ago, I had implemented this kind of solution on a MIPS
platform.
It worked great. If I remember well, I had taken the zLib
compression library (you should find the source code easily).
I had made a small tool that took the .bin, compressed
it, added checksums and some loading info, and converted all this to
a very big byte array in a .c file. Then, this file was compiled
and linked together with a kind of bootloader, that was able to
uncompress the code into RAM and jump to it.

As far as I know, there should be no problem for doing this on
TI DSPs.
You have to take care of some aspects, like cache coherency when
jumping to the new code, and vector table pointer (ISTP on C64x
DSP's).

Regards

J-F



Hello J-F,

Thanks for your answer !

I've found a very interesting compression library to achieve all this.
It's called UCL : http://www.oberhumer.com/opensource/ucl/

As the author says :

UCL is written in ANSI C. Both the source code and the compressed data
format are designed to be portable across platforms.
UCL implements a number of algorithms with the following features:
* Decompression is simple and *very* fast.
* Requires no memory for decompression.
* The decompressors can be squeezed into less than 200 bytes of code.
...
UCL's decompressors should work on any system around - they could even get
ported to 8-bit processors such as the Z-80 or 6502. I don't know if the achieved compression ratio is as good as gzip or bzip2
( i actually don't think so ), but i think the 3 points mentioned above
makes UCL a well adapted tool to address this particular issue :)

Cheers,
Laurent > Hi Laurent,
>
> Some years ago, I had implemented this kind of solution on a MIPS
> platform.
> It worked great. If I remember well, I had taken the zLib
> compression library (you should find the source code easily).
> I had made a small tool that took the .bin, compressed
> it, added checksums and some loading info, and converted all this to
> a very big byte array in a .c file. Then, this file was compiled
> and linked together with a kind of bootloader, that was able to
> uncompress the code into RAM and jump to it.
>
> As far as I know, there should be no problem for doing this on
> TI DSPs.
> You have to take care of some aspects, like cache coherency when
> jumping to the new code, and vector table pointer (ISTP on C64x
> DSP's).
>
> Regards
>
> J-F >
>
> _____________________________________
> Note: If you do a simple "reply" with your email client, only the author
of this message will receive your answer. You need to do a "reply all" if
you want your answer to be distributed to the entire group.
>
> _____________________________________
> About this discussion group:
>
> To Join: Send an email to
>
> To Post: Send an email to
>
> To Leave: Send an email to
>
> Archives: http://www.yahoogroups.com/group/c6x
>
> Other Groups: http://www.dsprelated.com
>
> Yahoo! Groups Links >