mirror of
https://github.com/openwrt/openwrt.git
synced 2025-02-20 17:32:57 +00:00
kernel: add support for mtdsplit-fit offset
Support devices that has vendor custom header before FIT image. Some devices has vendor custom header before FIT image. In this case mtd- split can not find FIT image and it results in rootfs mount failure. Please refer iptime,a6004mx device for further examples. Signed-off-by: Yoonji Park <koreapyj@dcmys.kr>
This commit is contained in:
parent
b4d8114770
commit
49763d907b
@ -199,6 +199,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
|
|||||||
struct fdt_header hdr;
|
struct fdt_header hdr;
|
||||||
size_t hdr_len, retlen;
|
size_t hdr_len, retlen;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
|
u32 offset_start = 0;
|
||||||
size_t fit_offset, fit_size;
|
size_t fit_offset, fit_size;
|
||||||
size_t rootfs_offset, rootfs_size;
|
size_t rootfs_offset, rootfs_size;
|
||||||
size_t data_size, img_total, max_size = 0;
|
size_t data_size, img_total, max_size = 0;
|
||||||
@ -211,11 +212,13 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
|
|||||||
if (cmdline_match && !strstr(saved_command_line, cmdline_match))
|
if (cmdline_match && !strstr(saved_command_line, cmdline_match))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
|
of_property_read_u32(np, "openwrt,fit-offset", &offset_start);
|
||||||
|
|
||||||
hdr_len = sizeof(struct fdt_header);
|
hdr_len = sizeof(struct fdt_header);
|
||||||
|
|
||||||
/* Parse the MTD device & search for the FIT image location */
|
/* Parse the MTD device & search for the FIT image location */
|
||||||
for(offset = 0; offset + hdr_len <= mtd->size; offset += mtd->erasesize) {
|
for(offset = 0; offset + hdr_len <= mtd->size; offset += mtd->erasesize) {
|
||||||
ret = mtd_read(mtd, offset, hdr_len, &retlen, (void*) &hdr);
|
ret = mtd_read(mtd, offset + offset_start, hdr_len, &retlen, (void*) &hdr);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_err("read error in \"%s\" at offset 0x%llx\n",
|
pr_err("read error in \"%s\" at offset 0x%llx\n",
|
||||||
mtd->name, (unsigned long long) offset);
|
mtd->name, (unsigned long long) offset);
|
||||||
@ -259,7 +262,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
|
|||||||
enum mtdsplit_part_type type;
|
enum mtdsplit_part_type type;
|
||||||
|
|
||||||
/* Search for the rootfs partition after the FIT image */
|
/* Search for the rootfs partition after the FIT image */
|
||||||
ret = mtd_find_rootfs_from(mtd, fit_offset + fit_size, mtd->size,
|
ret = mtd_find_rootfs_from(mtd, fit_offset + fit_size + offset_start, mtd->size,
|
||||||
&rootfs_offset, &type);
|
&rootfs_offset, &type);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_info("no rootfs found after FIT image in \"%s\"\n",
|
pr_info("no rootfs found after FIT image in \"%s\"\n",
|
||||||
@ -275,7 +278,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
|
|||||||
|
|
||||||
parts[0].name = KERNEL_PART_NAME;
|
parts[0].name = KERNEL_PART_NAME;
|
||||||
parts[0].offset = fit_offset;
|
parts[0].offset = fit_offset;
|
||||||
parts[0].size = mtd_rounddown_to_eb(fit_size, mtd) + mtd->erasesize;
|
parts[0].size = mtd_rounddown_to_eb(fit_size + offset_start, mtd) + mtd->erasesize;
|
||||||
|
|
||||||
if (type == MTDSPLIT_PART_TYPE_UBI)
|
if (type == MTDSPLIT_PART_TYPE_UBI)
|
||||||
parts[1].name = UBI_PART_NAME;
|
parts[1].name = UBI_PART_NAME;
|
||||||
@ -290,7 +293,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
|
|||||||
} else {
|
} else {
|
||||||
/* Search for rootfs_data after FIT external data */
|
/* Search for rootfs_data after FIT external data */
|
||||||
fit = kzalloc(fit_size, GFP_KERNEL);
|
fit = kzalloc(fit_size, GFP_KERNEL);
|
||||||
ret = mtd_read(mtd, offset, fit_size, &retlen, fit);
|
ret = mtd_read(mtd, offset, fit_size + offset_start, &retlen, fit);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_err("read error in \"%s\" at offset 0x%llx\n",
|
pr_err("read error in \"%s\" at offset 0x%llx\n",
|
||||||
mtd->name, (unsigned long long) offset);
|
mtd->name, (unsigned long long) offset);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user