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 | ||
---|---|---|
222 | 222 | } |
223 | 223 | |
224 | 224 | |
225 | static int __init | |
226 | find_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 | } | |
225 | 256 | |
226 | 257 | |
227 | 258 | static int __init |
... | ... | |
232 | 263 | int off, blocksize; |
233 | 264 | u32 i, crc = ~0; |
234 | 265 | size_t len; |
235 | struct squashfs_super_block *sb = (struct squashfs_super_block *) buf; | |
236 | 266 | |
237 | 267 | blocksize = mtd->erasesize; |
238 | 268 | if (blocksize < 0x10000) |
... | ... | |
318 | 348 | init_mtd_partitions(struct mtd_info *mtd, size_t size) |
319 | 349 | { |
320 | 350 | int cfe_size; |
351 | int dual_image_offset = 0; | |
321 | 352 | |
322 | 353 | if ((cfe_size = find_cfe_size(mtd,size)) < 0) |
323 | 354 | return NULL; |
... | ... | |
336 | 367 | bcm47xx_parts[3].size = ROUNDUP(NVRAM_SPACE, mtd->erasesize); |
337 | 368 | } |
338 | 369 | |
370 | /* dual image offset*/ | |
371 | printk("Looking for dual image\n"); | |
372 | dual_image_offset=find_dual_image_off(mtd,size); | |
339 | 373 | /* linux (kernel and rootfs) */ |
340 | 374 | if (cfe_size != 384 * 1024) { |
341 | 375 | 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 - | |
343 | 377 | bcm47xx_parts[1].offset; |
344 | 378 | } else { |
345 | 379 | /* do not count the elf loader, which is on one block */ |
... | ... | |
353 | 387 | |
354 | 388 | /* find and size rootfs */ |
355 | 389 | 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; | |
357 | 391 | |
358 | 392 | return bcm47xx_parts; |
359 | 393 | } |