
Quick Question: It looks to me that the max uncompressed image size is hard coded to 4Meg (0x400000 bytes). Any thoughts why?
Long question: We were having some problems booting large uImages (reported here ~ month ago). It seemed as if the were not being decompressed properly. When we had someone (Aubrey Li) dig into it he found/pointed out that in the latest cvs, u-boot/common/cmd_bootm.c the function do_bootm defines what looks to be a uncompressed max length as:
uint unc_len = 0x400000;
This is passed to gunzip if the image needs to be uncompressed.
--snip-- case IH_COMP_GZIP: printf (" Uncompressing %s ... ", name); if (gunzip ((void *)ntohl(hdr->ih_load), unc_len, (uchar *)data, &len) != 0) { puts ("GUNZIP ERROR - must RESET board to recover\n"); SHOW_BOOT_PROGRESS (-6); do_reset (cmdtp, flag, argc, argv); } break; --snip--
gunzip takes this as the second parameter and sets it to dstlen.
int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp)
This is passed to the inflation routine as
s.avail_out = dstlen;
where inflate from u-boot/lib_generic/zlib.c uses this to halt decompression if the image size can not fit.
-- snip -- from int inflate(z, f) -- if (f == Z_PACKET_FLUSH && z->avail_in == 0 && z->avail_out != 0) r = inflate_packet_flush(z->state->blocks);
--snip -- from local int inflate_flush(s, z, r)-- /* compute number of bytes to copy as far as end of window */ n = (uInt)((q <= s->write ? s->write : s->end) - q); if (n > z->avail_out) n = z->avail_out; if (n && r == Z_BUF_ERROR) r = Z_OK;
/* update counters */ z->avail_out -= n; z->total_out += n;
--
When unc_len is increased - our problem goes away...
So: two questions: - what is the best way to manage the size of unc_len? in include/configs/platform.h? Or just make it really_really big?
- do you want a patch in u-boot/common/cmd_bootm.c/gunzip to check to see if the image was completely decompressed? OR - do you want a patch in u-boot/lib_generic/zlib.c to return an error if it runs out of room?
Thanks -Robin