X-Git-Url: http://git.ozo.com/?p=openwrt-10.03%2F.git;a=blobdiff_plain;f=package%2Fmtd%2Fsrc%2Ffis.c;fp=package%2Fmtd%2Fsrc%2Ffis.c;h=f825f590c96a50141849d24c63b9d652ab146808;hp=559ca95069a510cd6f76e66ca0d5cfafe3cb4a6f;hb=30b136923fe6a874a4bbd430c83b7d656607931b;hpb=0b111996782aa58aef2891eeccdb8bd9875c27ae diff --git a/package/mtd/src/fis.c b/package/mtd/src/fis.c index 559ca9506..f825f590c 100644 --- a/package/mtd/src/fis.c +++ b/package/mtd/src/fis.c @@ -143,6 +143,8 @@ fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new) struct fis_image_desc *redboot = NULL; struct fis_image_desc *first = NULL; struct fis_image_desc *last = NULL; + struct fis_image_desc *first_fb = NULL; + struct fis_image_desc *last_fb = NULL; struct fis_image_desc *desc; struct fis_part *part; uint32_t offset = 0, size = 0; @@ -184,13 +186,21 @@ fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new) } desc--; + first_fb = first; + last_fb = last; + + if (first_fb->hdr.flash_base > last_fb->hdr.flash_base) { + first_fb = last; + last_fb = first; + } + /* determine size of available space */ desc = (struct fis_image_desc *) start; while ((char *) desc < end) { if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff)) break; - if (desc->hdr.flash_base > last->hdr.flash_base && + if (desc->hdr.flash_base > last_fb->hdr.flash_base && desc->hdr.flash_base < offset) offset = desc->hdr.flash_base; @@ -198,7 +208,7 @@ fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new) } desc--; - size = offset - first->hdr.flash_base; + size = offset - first_fb->hdr.flash_base; #ifdef notyet desc = first - 1; @@ -214,7 +224,7 @@ fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new) last++; desc = first + n_new; - offset = first->hdr.flash_base; + offset = first_fb->hdr.flash_base; if (desc != last) { if (desc > last)