This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: downloading compressed program images


>>>>> "Joel" == Joel Sherrill <joel@OARcorp.com> writes:

    Joel> I am looking for information on downloading compressed
    Joel> images of executables to target hardware.  What I have in
    Joel> mind is a program resident on the target which allows
    Joel> maintenance personnel to downloaded via RS-232 a new program
    Joel> image.  The two things I am looking for are:

    Joel>   + compression/decompression software
    Joel>   + serial protocol ([XYZ]modem])

    Joel> To minimize download time (executable is ~ 1 Mbyte), I would
    Joel> like to compress the image on the host, download it via some
    Joel> reliable serial protocol, decompress it on the target, and
    Joel> then burn it into flash.

    Joel> I know this has been done before and was looking for
    Joel> suggestions on freely available software to help with the
    Joel> compression/decompression and serial protocol parts.

Check out http://www.gzip.org/ and http://www.cdrom.com/pub/infozip/zlib/.

I used inflate.c (with a few changes) from the gzip-1.2.4 distribution
and created my own header file (included below) to work around the
GPL'ed gzip.h.  I used "gzip --no-name --best" on the host to compress
the file and then used a utility I wrote to remove the gzip header and
crc32.  I also moved the uncompressed input size to the beginning of
the file to make things a bit easier for the target SW.  FWIW, the
inflate code was around 7 kbytes on a 68HC16.

I got the raw inflate.c approach working before I found out about
zlib.  If I had to do it over again, I'd probably give zlib a good
look.

--- cut here ---
/*
 *      gzip.h - Surrogate gzip.h file.
 *
 * Exists solely so as to not fall under the GNU General Public License.
 *
 * See the real gzip.h for more useful information.
 */

typedef unsigned char  uch;
typedef unsigned short ush;
typedef unsigned long  ulg;

extern uch inbuf[];             /* input buffer */
extern uch far *window;         /* sliding output buffer */

extern unsigned insize;         /* # of bytes in input buffer */
extern unsigned inptr;          /* index in input buffer */

int inflate(void);
--- cut here ---

--
David