summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--package/mtd/src/imagetag.c6
-rw-r--r--target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h5
-rw-r--r--target/linux/brcm63xx/patches-2.6.35/040-bcm963xx_flashmap.patch30
-rw-r--r--tools/firmware-utils/src/imagetag.c5
4 files changed, 11 insertions, 35 deletions
diff --git a/package/mtd/src/imagetag.c b/package/mtd/src/imagetag.c
index 2080128c1..f6095be44 100644
--- a/package/mtd/src/imagetag.c
+++ b/package/mtd/src/imagetag.c
@@ -124,7 +124,7 @@ trx_fixup(int fd, const char *name)
exit(1);
}
- sprintf(&tag->rootLength[0], "%lu", 0);
+ sprintf(&tag->flashRootLength[0], "%lu", 0);
strncpy(&tag->totalLength[0], &tag->kernelLength[0], IMAGE_LEN);
imagestart = sizeof(tag);
@@ -258,7 +258,7 @@ mtd_fixtrx(const char *mtd, size_t offset)
fprintf(stderr, "Checking current fixed status.\n");
}
- rootfslen = strntoul(&tag->rootLength[0], NULL, 10, IMAGE_LEN);
+ rootfslen = strntoul(&tag->flashRootLength[0], NULL, 10, IMAGE_LEN);
if (rootfslen == 0) {
if (quiet < 2)
fprintf(stderr, "Header already fixed, exiting\n");
@@ -270,7 +270,7 @@ mtd_fixtrx(const char *mtd, size_t offset)
fprintf(stderr, "Setting root length to 0.\n");
}
- sprintf(&tag->rootLength[0], "%lu", 0);
+ sprintf(&tag->flashRootLength[0], "%lu", 0);
strncpy(&tag->totalLength[0], &tag->kernelLength[0], IMAGE_LEN);
if (quiet < 2) {
diff --git a/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h b/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h
index d6a5ee811..89650d1ea 100644
--- a/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h
+++ b/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h
@@ -48,7 +48,7 @@ struct bcm_tag {
char cfeAddress[ADDRESS_LEN]; // 72-83: Address in memory of CFE
char cfeLength[IMAGE_LEN]; // 84-93: Size of CFE
char flashImageStart[ADDRESS_LEN]; // 94-105: Address in memory of image start (kernel for OpenWRT, rootfs for stock firmware)
- char rootLength[IMAGE_LEN]; // 106-115: Size of rootfs
+ char flashRootLength[IMAGE_LEN]; // 106-115: Size of rootfs for flashing
char kernelAddress[ADDRESS_LEN]; // 116-127: Address in memory of kernel
char kernelLength[IMAGE_LEN]; // 128-137: Size of kernel
char dualImage[DUALFLAG_LEN]; // 138-139: Unused at present
@@ -61,7 +61,8 @@ struct bcm_tag {
char imageCRC[CRC_LEN]; // 216-219: CRC32 of image less imagetag (kernel for Alice Gate)
char rootfsCRC[CRC_LEN]; // 220-223: CRC32 of rootfs partition
char kernelCRC[CRC_LEN]; // 224-227: CRC32 of kernel partition
- char reserved1[8]; // 228-235: Unused at present
+ char rootLength[4]; // 228-231: steal from reserved1 to keep the real root length so we can use in the flash map even after we have change the rootLength to 0 to satisfy devices that check CRC on every boot
+ char reserved1[4]; // 232-235: Unused at present
char headerCRC[CRC_LEN]; // 236-239: CRC32 of header excluding tagVersion
char reserved2[16]; // 240-255: Unused at present
};
diff --git a/target/linux/brcm63xx/patches-2.6.35/040-bcm963xx_flashmap.patch b/target/linux/brcm63xx/patches-2.6.35/040-bcm963xx_flashmap.patch
index c1b424d5d..4835a159a 100644
--- a/target/linux/brcm63xx/patches-2.6.35/040-bcm963xx_flashmap.patch
+++ b/target/linux/brcm63xx/patches-2.6.35/040-bcm963xx_flashmap.patch
@@ -73,7 +73,7 @@ Signed-off-by: Axel Gembe <ago@bastart.eu.org>
+obj-$(CONFIG_MTD_BCM963XX) += bcm963xx-flash.o
--- /dev/null
+++ b/drivers/mtd/maps/bcm963xx-flash.c
-@@ -0,0 +1,314 @@
+@@ -0,0 +1,288 @@
+/*
+ * Copyright (C) 2006-2008 Florian Fainelli <florian@openwrt.org>
+ * Mike Albon <malbon@openwrt.org>
@@ -158,6 +158,7 @@ Signed-off-by: Axel Gembe <ago@bastart.eu.org>
+ sscanf(buf->kernelAddress, "%u", &kerneladdr);
+ sscanf(buf->kernelLength, "%u", &kernellen);
+ sscanf(buf->totalLength, "%u", &totallen);
++ sscanf(buf->rootLength, "%u", &rootfslen);
+ tagversion = &(buf->tagVersion[0]);
+ boardid = &(buf->boardid[0]);
+
@@ -175,33 +176,6 @@ Signed-off-by: Axel Gembe <ago@bastart.eu.org>
+ return -EINVAL;
+ }
+
-+ // if (SQUASHFS_MAGIC != le32_to_cpu(sb.s_magic) ) {
-+ printk(KERN_DEBUG PFX "Squash magic %08lx: Found: %08lx\n", (long unsigned int)SQUASHFS_MAGIC, (long unsigned int)le32_to_cpu(sb.s_magic));
-+ if ((uint32_t)SQUASHFS_MAGIC != (uint32_t)le32_to_cpu(sb.s_magic) ) {
-+ /* Not a squashfs image */
-+ printk(KERN_DEBUG PFX "No squashfs image in \"%s\"\n", master->name);
-+ printk(KERN_DEBUG PFX "Jffs magic %04x: Found: %04x\n", (uint16_t)(JFFS2_MAGIC_BITMASK), *(uint16_t *)(&sb));
-+ if (*(uint16_t *)(&sb) == JFFS2_MAGIC_BITMASK) {
-+ printk(KERN_DEBUG PFX "jffs image in \"%s\"\n", master->name);
-+ /* Is JFFS2 so have rootfslen so that true length gets calculated */
-+ rootfslen = master->size - master->erasesize - offset;
-+ } else {
-+ /* We only recognize squashfs and jffs2. If it's not either of these,
-+ don't create a rootfs partition. */
-+ printk(KERN_INFO PFX "No known root filesystem in \"%s\"\n", master->name);
-+ rootfslen = 0;
-+ }
-+ } else {
-+ /* Is a squash image so find where the squash ends */
-+ if (le64_to_cpu((sb.bytes_used)) <= 0) {
-+ printk(KERN_ALERT PFX "split_squashfs: squashfs is empty in \"%s\"\n",
-+ master->name);
-+ return 0;
-+ }
-+
-+ rootfslen = (u32) le64_to_cpu(sb.bytes_used);
-+ }
-+
+ rootfslen = ( ( rootfslen % master->erasesize ) > 0 ? (((rootfslen / master->erasesize) + 1 ) * master->erasesize) : rootfslen);
+ totallen = rootfslen + kernellen + sizeof(struct bcm_tag);
+
diff --git a/tools/firmware-utils/src/imagetag.c b/tools/firmware-utils/src/imagetag.c
index 1818daaca..a7b9babd3 100644
--- a/tools/firmware-utils/src/imagetag.c
+++ b/tools/firmware-utils/src/imagetag.c
@@ -338,11 +338,12 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
if (args->root_first_flag) {
sprintf(tag.flashImageStart, "%lu", rootfsoff);
- sprintf(tag.rootLength, "%lu", rootfslen);
+ sprintf(tag.flashRootLength, "%lu", rootfslen);
} else {
sprintf(tag.flashImageStart, "%lu", kerneloff);
- sprintf(tag.rootLength, "%lu", rootfslen + sizeof(deadcode));
+ sprintf(tag.flashRootLength, "%lu", rootfslen + sizeof(deadcode));
}
+ int2tag(tag.rootLength, rootfslen + sizeof(deadcode));
if (args->rsa_signature_given) {
strncpy(tag.rsa_signature, args->rsa_signature_arg, RSASIG_LEN);