Changeset 24834


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

mtd flashmap: Switched to calculating the rootfs size rather than depending on being given the size in the imagetag. This is because solving the problem of second boot CRC errors requires changeing the rootfs size in the image to zero.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/brcm63xx/patches-2.6.35/040-bcm963xx_flashmap.patch

    r22800 r24834  
    7474--- /dev/null 
    7575+++ b/drivers/mtd/maps/bcm963xx-flash.c 
    76 @@ -0,0 +1,267 @@ 
     76@@ -0,0 +1,314 @@ 
    7777+/* 
    7878+ * Copyright (C) 2006-2008  Florian Fainelli <florian@openwrt.org> 
     
    102102+#include <linux/vmalloc.h> 
    103103+#include <linux/platform_device.h> 
     104+#include <linux/magic.h> 
     105+#include <linux/jffs2.h> 
    104106+ 
    105107+#include <bcm_tag.h> 
     
    110112+ 
    111113+#define PFX KBUILD_MODNAME ": " 
     114+ 
     115+struct squashfs_super_block { 
     116+       __le32 s_magic; 
     117+       __le32 pad0[9]; 
     118+       __le64 bytes_used; 
     119+}; 
    112120+ 
    113121+extern int parse_redboot_partitions(struct mtd_info *master, struct mtd_partition **pparts, unsigned long fis_origin); 
     
    120128+       .bankwidth      = BUSWIDTH, 
    121129+}; 
    122 + 
    123130+ 
    124131+static int parse_cfe_partitions( struct mtd_info *master, struct mtd_partition **pparts) 
     
    132139+       unsigned int rootfslen, kernellen, sparelen, totallen; 
    133140+       int namelen = 0; 
    134 +       int i; 
     141+       int i, offset; 
    135142+       char *boardid; 
    136 +        char *tagversion; 
     143+    char *tagversion; 
     144+       struct squashfs_super_block sb; 
    137145+ 
    138146+       /* Allocate memory for buffer */ 
     
    158166+       kerneladdr = kerneladdr - EXTENDED_SIZE; 
    159167+       rootfsaddr = kerneladdr + kernellen; 
     168+ 
     169+       //      offset = master->erasesize + sizeof(struct bcm_tag) + kernellen; 
     170+       offset = rootfsaddr; 
     171+       ret = master->read(master, offset, sizeof(sb), &retlen, (void *) &sb); 
     172+       if (ret || (retlen != sizeof(sb))) { 
     173+         printk(KERN_ALERT PFX "parse_cfe_partitions: error occured while reading " 
     174+                        "from \"%s\"\n", master->name); 
     175+         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); 
     203+       } 
     204+ 
     205+       rootfslen = ( ( rootfslen % master->erasesize ) > 0 ? (((rootfslen / master->erasesize) + 1 ) * master->erasesize) : rootfslen); 
     206+       totallen = rootfslen + kernellen + sizeof(struct bcm_tag); 
     207+ 
    160208+       spareaddr = roundup(totallen, master->erasesize) + master->erasesize; 
    161209+       sparelen = master->size - spareaddr - master->erasesize; 
    162 +       rootfslen = spareaddr - rootfsaddr; 
    163210+ 
    164211+       /* Determine number of partitions */ 
Note: See TracChangeset for help on using the changeset viewer.