Date:2010-07-01 18:26:24 (13 years 8 months ago)
Author:markus
Commit:4fd65eaf7bbb4eeddd9068eeb4c74d384a130dc7
Message:brcm47xx: added dual image support to flashmap driver

some CFE versions (i.e. WRT54G3Gv2-VF) expect two separate firmware
images which each consume half of the available flash space.
these changes check for the TRX header version and set the partition
size correctly.
Tested on G3Gv2-VF and Asus WL-500GP



git-svn-id: svn://svn.openwrt.org/openwrt/trunk@22019 3c298f89-4303-0410-b956-a3cf2f4a3e73
Files: target/linux/brcm47xx/files/drivers/mtd/maps/bcm47xx-flash.c (5 diffs)

Change Details

target/linux/brcm47xx/files/drivers/mtd/maps/bcm47xx-flash.c
222222}
223223
224224
225static int __init
226find_dual_image_off (struct mtd_info *mtd, size_t size)
227{
228    struct trx_header trx;
229    int off, blocksize;
230    size_t len;
231
232    blocksize = mtd->erasesize;
233    if (blocksize < 0x10000)
234        blocksize = 0x10000;
235
236    for (off = (128*1024); off < size; off += blocksize) {
237        memset(&trx, 0xe5, sizeof(trx));
238        /*
239        * Read into buffer
240        */
241        if (mtd->read(mtd, off, sizeof(trx), &len, (char *) &trx) ||
242            len != sizeof(trx))
243            continue;
244        /* found last TRX header */
245        if (le32_to_cpu(trx.magic) == TRX_MAGIC){
246            if (le32_to_cpu(trx.flag_version >> 16)==2){
247                printk("dual image TRX header found\n");
248                return size/2;
249            } else {
250                return 0;
251            }
252        }
253    }
254    return 0;
255}
225256
226257
227258static int __init
...... 
232263    int off, blocksize;
233264    u32 i, crc = ~0;
234265    size_t len;
235    struct squashfs_super_block *sb = (struct squashfs_super_block *) buf;
236266
237267    blocksize = mtd->erasesize;
238268    if (blocksize < 0x10000)
...... 
318348init_mtd_partitions(struct mtd_info *mtd, size_t size)
319349{
320350    int cfe_size;
351    int dual_image_offset = 0;
321352
322353    if ((cfe_size = find_cfe_size(mtd,size)) < 0)
323354        return NULL;
...... 
336367        bcm47xx_parts[3].size = ROUNDUP(NVRAM_SPACE, mtd->erasesize);
337368    }
338369
370    /* dual image offset*/
371    printk("Looking for dual image\n");
372    dual_image_offset=find_dual_image_off(mtd,size);
339373    /* linux (kernel and rootfs) */
340374    if (cfe_size != 384 * 1024) {
341375        bcm47xx_parts[1].offset = bcm47xx_parts[0].size;
342        bcm47xx_parts[1].size = bcm47xx_parts[3].offset -
376        bcm47xx_parts[1].size = bcm47xx_parts[3].offset - dual_image_offset -
343377            bcm47xx_parts[1].offset;
344378    } else {
345379        /* do not count the elf loader, which is on one block */
...... 
353387
354388    /* find and size rootfs */
355389    find_root(mtd,size,&bcm47xx_parts[2]);
356    bcm47xx_parts[2].size = size - bcm47xx_parts[2].offset - bcm47xx_parts[3].size;
390    bcm47xx_parts[2].size = size - dual_image_offset - bcm47xx_parts[2].offset - bcm47xx_parts[3].size;
357391
358392    return bcm47xx_parts;
359393}

Archive Download the corresponding diff file



interactive