Filesystems

使用生成的 UBI 二進製文件對 NAND 進行程式

  • October 4, 2016

我們的系統會生成一個 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 錯誤:

http://i.imgur.com/qoTr4ag.png

$ 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 圖像嗎?

實時調頻!-F 參數修復了我上面列出的錯誤。

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

此外,ubi_reader 工具對理解進入 mkfs 和 ubinize 的各種參數有很大幫助。

https://github.com/jrspruitt/ubi_reader

引用自:https://unix.stackexchange.com/questions/312509