jffs2(mtd-utils 版本 1.5.0,
mkfs.jffs2
修订版 1.60)的最小擦除块大小似乎是 8KiB:
Erase size 0x1000 too small. Increasing to 8KiB minimum
但是我正在使用 at25df321a 运行 Linux 3.10,
m25p80 spi32766.0: at25df321a (4096 Kbytes),
且擦除块大小仅为4KiB:
mtd5
Name: spi32766.0
Type: nor
Eraseblock size: 4096 bytes, 4.0 KiB
Amount of eraseblocks: 1024 (4194304 bytes, 4.0 MiB)
Minimum input/output unit size: 1 byte
Sub-page size: 1 byte
Character device major/minor: 90:10
Bad blocks are allowed: false
Device is writable: true
有没有办法让mtd系统将多个擦除块视为一个?也许是一些 ioctl 或模块参数?
如果我刷新具有较大擦除块大小的 jffs2 映像,我会收到大量内核错误消息、丢失文件,有时还会出现恐慌。
解决方法
我发现,尽管擦除块大小为 4KiB,但
flasherase --jffs2
仍能生成工作文件系统。所以我破解了 mkfs.jfss2.c
文件,生成的图像似乎工作正常。我会进行一些测试。
diff -rupN orig/mkfs.jffs2.c new/mkfs.jffs2.c
--- orig/mkfs.jffs2.c 2014-10-20 15:43:31.751696500 +0200
+++ new/mkfs.jffs2.c 2014-10-20 15:43:12.623431400 +0200
@@ -1659,11 +1659,11 @@ int main(int argc, char **argv)
}
erase_block_size *= units;
- /* If it's less than 8KiB, they're not allowed */
- if (erase_block_size < 0x2000) {
- fprintf(stderr, "Erase size 0x%x too small. Increasing to 8KiB minimum\n",
+ /* If it's less than 4KiB, they're not allowed */
+ if (erase_block_size < 0x1000) {
+ fprintf(stderr, "Erase size 0x%x too small. Increasing to 4KiB minimum\n",
erase_block_size);
- erase_block_size = 0x2000;
+ erase_block_size = 0x1000;
}
break;
}
http://lists.infradead.org/pipermail/linux-mtd/2010-September/031876.html
JFFS2 应该能够容纳至少一个节点来擦除块。这 最大节点大小为 4KiB+几个字节。这就是为什么最小 擦除块大小为 8KiB。
但实际上,即使 8KiB 也很糟糕,因为你会浪费一个 擦除块末尾有很多空间。
您应该将多个擦除块加入到一个 64 或 128 KiB 并使用它 - 这将是更优化的。
一些司机已经实施了这一点。我知道
MTD_SPI_NOR_USE_4K_SECTORS
Linux 配置选项。必须将其设置为“n”才能启用大小为 0x00010000 的大擦除扇区。
现在是 2024 年 4 月 26 日,我在 mtd 设备上的 ubifs 分区也遇到了同样的问题。有人(或者也许是我)在“内核菜单配置->设备驱动程序>内存技术设备(MTD)支持>SPI NOR设备支持”中设置了“使用小4096 B擦除扇区”。之后我无法安装ubifs分区,因为.. LEB 太小
# mount -t ubifs -o sync,ro ubi0:images /images
[ T89] UBIFS error (ubi0:0 pid 89): ubifs_mount: too small LEBs (3968 bytes), min. is 15360 bytes
mount: /images: wrong fs type, bad option, bad superblock on ubi0:images, missing codepage or helper program, or other error.
dmesg(1) may have more information after failed mount system call.
UBIFS 至少需要 15360。
注意。如果您想看到如下所示的 mount cmd 输出,您应该使用原始的 mount 包,而不是 busybox 中的 mount