mtd: mtd_blk: map the part address if dev is mtd_blk
The blk_dread will occor error if the image is packed with multiple firmwares, for example boot.img, when nand or spi nand have bad block. So call mtd_blk_map_table_init to remap part address to make sure reading correct data. Signed-off-by: Jason Zhu <jason.zhu@rock-chips.com> Change-Id: Icebc6b1c5a10758efa615424d0706b9ed6ec23ad
This commit is contained in:
parent
2b7be5df0e
commit
a07b97f223
|
|
@ -103,6 +103,30 @@ static bool get_mtd_blk_map_address(struct mtd_info *mtd, loff_t *off)
|
||||||
return mapped;
|
return mapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mtd_blk_map_partitions(struct blk_desc *desc)
|
||||||
|
{
|
||||||
|
disk_partition_t info;
|
||||||
|
int i, ret;
|
||||||
|
|
||||||
|
if (!desc)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (desc->if_type != IF_TYPE_MTD)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (i = 1; i < MAX_SEARCH_PARTITIONS; i++) {
|
||||||
|
ret = part_get_info(desc, i, &info);
|
||||||
|
if (ret != 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (mtd_blk_map_table_init(desc,
|
||||||
|
info.start << 9,
|
||||||
|
info.size << 9)) {
|
||||||
|
printf("mtd block map table fail\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static __maybe_unused int mtd_map_read(struct mtd_info *mtd, loff_t offset,
|
static __maybe_unused int mtd_map_read(struct mtd_info *mtd, loff_t offset,
|
||||||
size_t *length, size_t *actual,
|
size_t *length, size_t *actual,
|
||||||
loff_t lim, u_char *buffer)
|
loff_t lim, u_char *buffer)
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,6 @@ char *mtd_part_parse(void);
|
||||||
int mtd_blk_map_table_init(struct blk_desc *desc,
|
int mtd_blk_map_table_init(struct blk_desc *desc,
|
||||||
loff_t offset,
|
loff_t offset,
|
||||||
size_t length);
|
size_t length);
|
||||||
|
void mtd_blk_map_partitions(struct blk_desc *desc);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue