aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files
diff options
context:
space:
mode:
authorYoonji Park <koreapyj@dcmys.kr>2022-06-05 18:04:18 +0000
committerDaniel Golle <daniel@makrotopia.org>2022-09-12 01:43:49 +0100
commit49763d907b0d87769c3e5885f1c11b5b62ccfa2b (patch)
tree89a43b133ab7a958e06a75a2d29b0f80aca4bf6c /target/linux/generic/files
parentb4d81147708f715b771aee0143c74cd9a7ee8241 (diff)
downloadupstream-49763d907b0d87769c3e5885f1c11b5b62ccfa2b.tar.gz
upstream-49763d907b0d87769c3e5885f1c11b5b62ccfa2b.tar.bz2
upstream-49763d907b0d87769c3e5885f1c11b5b62ccfa2b.zip
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>
Diffstat (limited to 'target/linux/generic/files')
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
index d8fb74ea38..3b71597d23 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c
@@ -199,6 +199,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
struct fdt_header hdr;
size_t hdr_len, retlen;
size_t offset;
+ u32 offset_start = 0;
size_t fit_offset, fit_size;
size_t rootfs_offset, rootfs_size;
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))
return -ENODEV;
+ of_property_read_u32(np, "openwrt,fit-offset", &offset_start);
+
hdr_len = sizeof(struct fdt_header);
/* Parse the MTD device & search for the FIT image location */
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) {
pr_err("read error in \"%s\" at offset 0x%llx\n",
mtd->name, (unsigned long long) offset);
@@ -259,7 +262,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
enum mtdsplit_part_type type;
/* 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);
if (ret) {
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].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)
parts[1].name = UBI_PART_NAME;
@@ -290,7 +293,7 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
} else {
/* Search for rootfs_data after FIT external data */
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) {
pr_err("read error in \"%s\" at offset 0x%llx\n",
mtd->name, (unsigned long long) offset);