自学内容网 自学内容网

openwrt出现rootfs只读原因

openwrt启动时出现

   0.739626] Creating 4 MTD partitions on "spi0.0":
[    0.744466] 0x000000000000-0x000000200000 : "u-boot"
[    0.750065] 0x000000200000-0x000000210000 : "u-boot-env"
[    0.755939] 0x000000210000-0x000000220000 : "factory"
[    0.761474] 0x000000220000-0x000002000000 : "firmware"
[    0.767204] 2 fit-fw partitions found on MTD device firmware
[    0.772887] Creating 2 MTD partitions on "firmware":
[    0.777865] 0x000000000000-0x000000460000 : "kernel"
[    0.783334] 0x00000045f920-0x000001de0000 : "rootfs"
[    0.788332] mtd: partition "rootfs" doesn't start on an erase/write block boundary -- force read-only
[    0.798081] mtd: setting mtd5 (rootfs) as root device

查看linux代码:

/*
 * Child erasesize might differ from the parent one if the parent
 * exposes several regions with different erasesize. Adjust
 * wr_alignment accordingly.
 */
if (!(child->flags & MTD_NO_ERASE)) {
wr_alignment = child->erasesize;
wr_alignment_minor = child->erasesize_minor;
}

tmp = mtd_get_master_ofs(child, 0);
remainder = do_div(tmp, wr_alignment);
if ((child->flags & MTD_WRITEABLE) && remainder) {
if (wr_alignment_minor) {
/* rely on minor being a factor of major erasesize */
tmp = remainder;
remainder = do_div(tmp, wr_alignment_minor);
}
if (remainder) {
child->flags &= ~MTD_WRITEABLE;
printk(KERN_WARNING"mtd: partition \"%s\" doesn't start on an erase/write block boundary -- force read-only\n",
part->name);
}
}

rootfs未对齐。
查看dts配置。

IMAGE/sysupgrade.bin := append-kernel | append-rootfs | pad-rootfs  | check-size | append-metadata

没有加pad-to $$$$(BLOCKSIZE)
append-rootfs前面加上pad-to $$$$(BLOCKSIZE)。从新编译openwrt软件。
启动:

[    0.739600] Creating 4 MTD partitions on "spi0.0":
[    0.744440] 0x000000000000-0x000000200000 : "u-boot"
[    0.750056] 0x000000200000-0x000000210000 : "u-boot-env"
[    0.755922] 0x000000210000-0x000000220000 : "factory"
[    0.761474] 0x000000220000-0x000002000000 : "firmware"
[    0.767232] 2 fit-fw partitions found on MTD device firmware
[    0.772915] Creating 2 MTD partitions on "firmware":
[    0.777895] 0x000000000000-0x000000460000 : "kernel"
[    0.783373] 0x000000460000-0x000001de0000 : "rootfs"
[    0.788862] mtd: setting mtd5 (rootfs) as root device
[    0.794052] 1 squashfs-split partitions found on MTD device rootfs

正常


原文地址:https://blog.csdn.net/dai_xiangjun/article/details/142495528

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!