我們的系統會產生一個 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 中的各種參數也有很大幫助。