I'm struggling with writing the Linux root file system to a NAND device (MT29F2G08ABAEAH4-IT:E).
I have a UBI image created by Yocto as follows:
mkfs.ubifs -r /path/to/rootfs -o /path/to/output/rootfs.ubifs -m 2048 -e 129024 -c 1600 -F
ubinize -o /path/to/output/rootfs.ubi -m 2048 -p 128KiB -s 512 ubinize.cfg
ubinize.cfg:
[ubifs]
mode=ubi
image=/path/to/output/rootfs.ubifs
vol_id=0
vol_type=dynamic
vol_name=ddcu-rootfs
vol_flags=autoresize
I'm able to successfully write the filesystem with the following commands from a "manufacturing" Linux:
mount /dev/mmcblk0p3 /mnt/data/
ubiformat /dev/mtd8 -f /mnt/data/rootfs.ubi
ubiattach /dev/ubi_ctrl -m 8
mount -t ubifs ubi0_0 /mnt/rfs
This solution works but is tedious, as I first need to boot the temporary "manufacturing" Linux to prepare RFS for the production Linux. So I want to flash it directly from u-boot. I've read multiple sources (e.g. http://www.linux-mtd.infradead.org/faq/ubifs.html) and notes (e.g. http://lists.denx.de/pipermail/u-boot/2011-September/102740.html), yet I must still do something wrong or there must be a bug somewhere.
1. nand write
I tried to use the nand write
command in u-boot 2011.12 and 2016.01:
nand scrub.part -y mtd_rootfs
fatload mmc 0:3 ${loadaddr} rootfs.ubi
nand write ${loadaddr} mtd_rootfs ${filesize}
Booting Linux now leads to
UBI: attaching mtd8 to ubi0
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 129024 bytes
UBI: smallest flash I/O unit: 2048
UBI: sub-page size: 512
UBI: VID header offset: 512 (aligned 512)
UBI: data offset: 2048
uncorrectable error :
uncorrectable error :
uncorrectable error :
uncorrectable error :
UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read 64 bytes
uncorrectable error :
uncorrectable error :
uncorrectable error :
uncorrectable error :
uncorrectable error :
uncorrectable error :
uncorrectable error :
uncorrectable error :
UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 0:512, read 512 bytes
uncorrectable error :
uncorrectable error :
2. ubi
Another attend was using the ubi u-boot 2016.01 commands:
nand scrub.part -y mtd_rootfs
ext4load mmc 0:2 ${loadaddr} rootfs.ubi
ubi part mtd_rootfs
ubi create ddcu-rootfs
ubi write ${loadaddr} my-rootfs ${filesize}
Trying to mount the volume in u-boot by ubifsmount my-rootfs
fails:
Error reading superblock on volume 'my-rootfs' errno=-22!
Trying to boot Linux leads to:
UBI: attaching mtd8 to ubi0
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 129024 bytes
UBI: smallest flash I/O unit: 2048
UBI: sub-page size: 512
UBI: VID header offset: 512 (aligned 512)
UBI: data offset: 2048
uncorrectable error :
uncorrectable error :
uncorrectable error :
uncorrectable error :
UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read 64 bytes
UBI error: validate_ec_hdr: bad VID header offset 2048, expected 512
UBI error: validate_ec_hdr: bad EC header
UBI error: ubi_io_read_ec_hdr: validation failed for PEB 0
UBI error: ubi_init: cannot attach mtd8
Of course I tried more variants, but it always ends up with the error -74. Can anyone see what I'm doing wrong, or share their working solution, please?