aboutsummaryrefslogtreecommitdiffstats
path: root/package/mtd/src
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-07-04 11:56:25 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-07-04 11:56:25 +0000
commit38cb1da868fc8ee3fd35a2260862dd0e20babdd0 (patch)
tree722737aba317f3258a928c34584060f7b452fc1f /package/mtd/src
parent0b837752020c98e26d6f66004b5c73855864d06f (diff)
downloadupstream-38cb1da868fc8ee3fd35a2260862dd0e20babdd0.tar.gz
upstream-38cb1da868fc8ee3fd35a2260862dd0e20babdd0.tar.bz2
upstream-38cb1da868fc8ee3fd35a2260862dd0e20babdd0.zip
mtd - remove partition table assumption when writing fis table
When mtd alters the fis partition table it assumes that the first partition table entry also is the first logical parition table entry. For instance our table could look like this (irrelevant partitions put aside): * vmlinux.bin.l7 0xA8710000 * rootfs 0xA8030000 Here mtd would assume vmlinux.bin.l7 being the first partition and use its address to calculate the size and offset which ultimately leads to a broken partition table. This patch alters the behavior by checking what partition has the smaller address to do the calculations based on that address. Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> SVN-Revision: 32601
Diffstat (limited to 'package/mtd/src')
-rw-r--r--package/mtd/src/fis.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/package/mtd/src/fis.c b/package/mtd/src/fis.c
index 559ca95069..f825f590c9 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)