diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2010-03-28 07:16:27 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2010-03-28 07:16:27 +0000 |
commit | ebab30b7c71564a015eed10323878fd8244422b9 (patch) | |
tree | 31a57bb9e768d994174f4b6734255a6efa9a4c06 /package/mtd | |
parent | d14e0a0b9393c582f7df6d5bb7be9341020e5270 (diff) | |
download | mtk-20170518-ebab30b7c71564a015eed10323878fd8244422b9.zip mtk-20170518-ebab30b7c71564a015eed10323878fd8244422b9.tar.gz mtk-20170518-ebab30b7c71564a015eed10323878fd8244422b9.tar.bz2 |
package/mtd: fix automatic partition size detection in fis_remap
SVN-Revision: 20537
Diffstat (limited to 'package/mtd')
-rw-r--r-- | package/mtd/Makefile | 2 | ||||
-rw-r--r-- | package/mtd/src/fis.c | 26 |
2 files changed, 20 insertions, 8 deletions
diff --git a/package/mtd/Makefile b/package/mtd/Makefile index ced26d5..9438b96 100644 --- a/package/mtd/Makefile +++ b/package/mtd/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk include $(INCLUDE_DIR)/kernel.mk PKG_NAME:=mtd -PKG_RELEASE:=11 +PKG_RELEASE:=12 PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME) STAMP_PREPARED := $(STAMP_PREPARED)_$(call confvar,CONFIG_MTD_REDBOOT_PARTS) diff --git a/package/mtd/src/fis.c b/package/mtd/src/fis.c index 3108c5a..b285d24 100644 --- a/package/mtd/src/fis.c +++ b/package/mtd/src/fis.c @@ -146,7 +146,7 @@ fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new) struct fis_image_desc *desc; struct fis_part *part; uint32_t offset = 0, size = 0; - char *end, *tmp; + char *start, *end, *tmp; int i; desc = fis_open(); @@ -156,6 +156,7 @@ fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new) if (!quiet) fprintf(stderr, "Updating FIS table... \n"); + start = (char *) desc; end = (char *) desc + fis_erasesize; while ((char *) desc < end) { if (!desc->hdr.name[0] || (desc->hdr.name[0] == 0xff)) @@ -167,9 +168,12 @@ fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new) if (!strcmp((char *) desc->hdr.name, "RedBoot")) redboot = desc; + /* update max offset */ + if (offset < desc->hdr.flash_base) + offset = desc->hdr.flash_base; + for (i = 0; i < n_old; i++) { if (!strncmp((char *) desc->hdr.name, (char *) old[i].name, sizeof(desc->hdr.name))) { - size += desc->hdr.size; last = desc; if (!first) first = desc; @@ -180,13 +184,21 @@ fis_remap(struct fis_part *old, int n_old, struct fis_part *new, int n_new) } desc--; - if (desc == last) { - desc = fisdir; + /* 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 && + desc->hdr.flash_base < offset) + offset = desc->hdr.flash_base; + + desc++; } + desc--; - /* size fixup */ - if (desc && (last->hdr.flash_base < desc->hdr.flash_base - last->hdr.size)) - size += (desc->hdr.flash_base - last->hdr.flash_base) - last->hdr.size; + size = offset - first->hdr.flash_base; #ifdef notyet desc = first - 1; |