Changeset 24838


Ignore:
Timestamp:
2010-12-26T05:18:13+01:00 (7 years ago)
Author:
cshore
Message:

Added OpenWRT-specific field to imagetag so that we can record the real root length, so that when the CRC fixup is applied and the root length is recorded as zero we can still calculate the rootfs mtd partition size.

Signed-off-by: Daniel Dickinson <daniel@…>

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/mtd/src/imagetag.c

    r24837 r24838  
    125125        } 
    126126 
    127         sprintf(&tag->rootLength[0], "%lu", 0); 
     127        sprintf(&tag->flashRootLength[0], "%lu", 0); 
    128128        strncpy(&tag->totalLength[0], &tag->kernelLength[0], IMAGE_LEN); 
    129129 
     
    259259        } 
    260260 
    261         rootfslen = strntoul(&tag->rootLength[0], NULL, 10, IMAGE_LEN); 
     261        rootfslen = strntoul(&tag->flashRootLength[0], NULL, 10, IMAGE_LEN); 
    262262        if (rootfslen == 0) { 
    263263          if (quiet < 2)  
     
    271271        } 
    272272 
    273         sprintf(&tag->rootLength[0], "%lu", 0); 
     273        sprintf(&tag->flashRootLength[0], "%lu", 0); 
    274274        strncpy(&tag->totalLength[0], &tag->kernelLength[0], IMAGE_LEN); 
    275275 
  • trunk/target/linux/brcm63xx/files/arch/mips/include/asm/mach-bcm63xx/bcm_tag.h

    r20850 r24838  
    4949        char cfeLength[IMAGE_LEN];             // 84-93: Size of CFE 
    5050        char flashImageStart[ADDRESS_LEN];     // 94-105: Address in memory of image start (kernel for OpenWRT, rootfs for stock firmware) 
    51         char rootLength[IMAGE_LEN];            // 106-115: Size of rootfs 
     51        char flashRootLength[IMAGE_LEN];            // 106-115: Size of rootfs for flashing 
    5252        char kernelAddress[ADDRESS_LEN];       // 116-127: Address in memory of kernel 
    5353        char kernelLength[IMAGE_LEN];          // 128-137: Size of kernel 
     
    6262        char rootfsCRC[CRC_LEN];               // 220-223: CRC32 of rootfs partition 
    6363        char kernelCRC[CRC_LEN];               // 224-227: CRC32 of kernel partition 
    64         char reserved1[8];                     // 228-235: Unused at present 
     64     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 
     65        char reserved1[4];                     // 232-235: Unused at present 
    6566        char headerCRC[CRC_LEN];               // 236-239: CRC32 of header excluding tagVersion 
    6667        char reserved2[16];                    // 240-255: Unused at present 
  • trunk/target/linux/brcm63xx/patches-2.6.35/040-bcm963xx_flashmap.patch

    r24834 r24838  
    7474--- /dev/null 
    7575+++ b/drivers/mtd/maps/bcm963xx-flash.c 
    76 @@ -0,0 +1,314 @@ 
     76@@ -0,0 +1,288 @@ 
    7777+/* 
    7878+ * Copyright (C) 2006-2008  Florian Fainelli <florian@openwrt.org> 
     
    159159+       sscanf(buf->kernelLength, "%u", &kernellen); 
    160160+       sscanf(buf->totalLength, "%u", &totallen); 
     161+       sscanf(buf->rootLength, "%u", &rootfslen); 
    161162+       tagversion = &(buf->tagVersion[0]); 
    162163+       boardid = &(buf->boardid[0]); 
     
    174175+                        "from \"%s\"\n", master->name); 
    175176+         return -EINVAL; 
    176 +       } 
    177 + 
    178 +       //      if (SQUASHFS_MAGIC != le32_to_cpu(sb.s_magic) ) { 
    179 +       printk(KERN_DEBUG PFX "Squash magic %08lx: Found: %08lx\n", (long unsigned int)SQUASHFS_MAGIC, (long unsigned int)le32_to_cpu(sb.s_magic)); 
    180 +       if ((uint32_t)SQUASHFS_MAGIC != (uint32_t)le32_to_cpu(sb.s_magic) ) { 
    181 +         /* Not a squashfs image */ 
    182 +               printk(KERN_DEBUG PFX "No squashfs image in \"%s\"\n", master->name); 
    183 +               printk(KERN_DEBUG PFX "Jffs magic %04x: Found: %04x\n", (uint16_t)(JFFS2_MAGIC_BITMASK), *(uint16_t *)(&sb)); 
    184 +               if (*(uint16_t *)(&sb) == JFFS2_MAGIC_BITMASK) { 
    185 +                 printk(KERN_DEBUG PFX "jffs image in \"%s\"\n", master->name); 
    186 +                 /* Is JFFS2 so have rootfslen so that true length gets calculated */ 
    187 +                 rootfslen = master->size - master->erasesize - offset; 
    188 +               } else { 
    189 +                 /* We only recognize squashfs and jffs2.  If it's not either of these, 
    190 +                        don't create a rootfs partition. */ 
    191 +                 printk(KERN_INFO PFX "No known root filesystem in \"%s\"\n", master->name); 
    192 +                 rootfslen = 0; 
    193 +               } 
    194 +       } else { 
    195 +         /* Is a squash image so find where the squash ends */ 
    196 +         if (le64_to_cpu((sb.bytes_used)) <= 0) { 
    197 +               printk(KERN_ALERT PFX "split_squashfs: squashfs is empty in \"%s\"\n", 
    198 +                          master->name); 
    199 +               return 0; 
    200 +         } 
    201 + 
    202 +         rootfslen = (u32) le64_to_cpu(sb.bytes_used); 
    203177+       } 
    204178+ 
  • trunk/tools/firmware-utils/src/imagetag.c

    r24011 r24838  
    339339        if (args->root_first_flag) { 
    340340          sprintf(tag.flashImageStart, "%lu", rootfsoff); 
    341           sprintf(tag.rootLength, "%lu", rootfslen);       
     341          sprintf(tag.flashRootLength, "%lu", rootfslen);          
    342342        } else { 
    343343          sprintf(tag.flashImageStart, "%lu", kerneloff); 
    344           sprintf(tag.rootLength, "%lu", rootfslen + sizeof(deadcode)); 
    345         } 
     344          sprintf(tag.flashRootLength, "%lu", rootfslen + sizeof(deadcode)); 
     345        } 
     346        int2tag(tag.rootLength, rootfslen + sizeof(deadcode)); 
    346347 
    347348        if (args->rsa_signature_given) { 
Note: See TracChangeset for help on using the changeset viewer.