使用生成的 UBI 二进制文件对 NAND 进行编程

使用生成的 UBI 二进制文件对 NAND 进行编程

我们的系统会生成一个 UBI 分区,该分区在首次启动时在 NAND 中创建。系统能够在那里读取和写入文件。我正在尝试创建一个可供 NAND“帮派”程序员使用的二进制文件,以便我们可以使用一些文件对该分区进行预编程。

我创建一个文件夹/火灾结构并使用以下两个命令:

mkfs.ubifs -r ./files -m 2048 -e 126976 -c 2047 -o ubifs.img 
ubinize -o ubi.img -m 2048 -p 128KiB -s 2048 ubinize.cfg

ubinize.cfg: 
[files] 
mode=ubi 
vol_id=0 
vol_type=dynamic 
vol_name=fs 
vol_flags=autoresize 
image=ubifs.img

为了测试我的文件,我使用 uboot 在正确的偏移处编写 ubi.img 并启动系统。系统找到新的UBIFS分区,其中包含有效文件!耶!

问题:当我更改分区中的任何内容,甚至触摸新文件并重新启动时,分区无法挂载,并声称存在大量 ECC 错误:

$ log | grep UBI
05:00:59 PM  [    INFO] [        kernel] UBIFS: background thread "ubifs_bgt1_0" started, PID 306
05:00:59 PM  [ WARNING] [        kernel] UBI warning: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 3:4096,
05:00:59 PM  [ WARNING] [        kernel] UBI warning: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 3:4096,
05:01:00 PM  [ WARNING] [        kernel] UBI warning: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 3:4096,
05:01:00 PM  [   ERROR] [        kernel] UBI error: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 3:4096,
05:01:00 PM  [   ERROR] [        kernel] UBIFS error (pid 304): ubifs_scan: bad node
05:01:00 PM  [ WARNING] [        kernel] UBI warning: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 3:4096,
05:01:00 PM  [ WARNING] [        kernel] UBI warning: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 3:4096,
05:01:01 PM  [ WARNING] [        kernel] UBI warning: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 3:4096,
05:01:01 PM  [   ERROR] [        kernel] UBI error: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 3:4096,
05:01:01 PM  [ WARNING] [        kernel] UBI warning: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 4:4096,
05:01:01 PM  [ WARNING] [        kernel] UBI warning: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 4:4096,
05:01:01 PM  [ WARNING] [        kernel] UBI warning: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 4:4096,
05:01:02 PM  [   ERROR] [        kernel] UBI error: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 4:4096,
05:00:00 PM  [   ERROR] [        kernel] UBIFS error (pid 304): ubifs_recover_master_node: failed to recover master node
05:00:00 PM  [   ERROR] [        kernel] UBIFS error (pid 304): ubifs_recover_master_node: dumping first master node
05:00:00 PM  [    INFO] [        kernel] UBIFS: background thread "ubifs_bgt1_0" stops

  [截屏]

我有什么想法搞砸了创建我的 UBI 图像吗?

答案1

实时调频! -F 参数修复了我上面列出的错误。

http://www.linux-mtd.infradead.org/faq/ubifs.html#L_free_space_fixup

此外,ubi_reader 工具对于理解 mkfs 和 ubinize 中的各种参数也有很大帮助。

https://github.com/jrspruitt/ubi_reader

相关内容