[U-Boot] Problems with creating an UBIFS partition with uboot

Hello all,
I ve googled a lot and read many mailing list entries, but got stuck now with the following problem:
=> ubifsmount rootfs UBIFS error (pid 0): ubifs_read_node: bad node type (0 but expected 6) UBIFS error (pid 0): ubifs_read_node: bad node at LEB 0:0 Error reading superblock on volume 'ubi:rootfs'!
1) I ve erased my nand-partition with 'nand erase' 2) I ve created a UBI partition with 'ubi part' 3) I ve uploaded my UBI image with 'tftp' 4) I ve created an volume with 'ubi create' 5) I ve written the image to the volume with 'ubi write' 6) I wanted to mount the volume --> and failed
INFO: I was able to mount a UBI image, which I ve created on the device, when booting from NFS. So I guess that the UBI image is OK.
Was did I wrong?
Thanks a lot, Charly
Here is the complete history:
I ve created an UBI image from an UBIFS file with the following cmd:
ubinize -orootfs.ubi.img -m2048 -O512 -p128KiB ubinize.cfg
and this ubinize.cfg
[ubifs] mode=ubi image=rootfs.ubifs vol_id=0 vol_size=512MiB vol_type=dynamic vol_name=rootfs vol_flags=autoresize
=> setenv mtdids nor0=fc000000.flash,nand0=mpc5121.nand
=> setenv mtdparts 'mtdparts=fc000000.flash:256k(protected),60m(filesystem),2560k(kernel),256k(device-tree),1024k(u-boot);mpc5121.nand:-(ubi-data)'
=> mtdparts
device nor0<fc000000.flash>, # parts = 5 #: name size offset mask_flags 0: protected 0x00040000 0x00000000 0 1: filesystem 0x03c00000 0x00040000 0 2: kernel 0x00280000 0x03c40000 0 3: device-tree 0x00040000 0x03ec0000 0 4: u-boot 0x00100000 0x03f00000 0
device nand0<mpc5121.nand>, # parts = 1 #: name size offset mask_flags 0: ubi-data 0x20000000 0x00000000 0
active partition: nor0,0 - (protected) 0x00040000 @ 0x00000000
defaults: mtdids : nor0=fc000000.flash,nand0=mpc5121.nand mtdparts: mtdparts=fc000000.flash:43776k(user),16m(rootfs),4m(kernel),256k(dtb),1m(u-boot);mpc5121.nand:-(data)
=> nand erase ${start of ubi-data} ${size of ubi-data} Skipping bad block at 0x1ffc0000 Skipping bad block at 0x1ffe0000
OK
=> ubi part ubi-data Creating 1 MTD partitions on "nand0": 0x000000000000-0x000020000000 : "mtd=0" UBI: attaching mtd3 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 UBI: empty MTD device detected UBI: create volume table (copy #1) UBI: create volume table (copy #2) UBI: attached mtd3 to ubi0 UBI: MTD device name: "mtd=0" UBI: MTD device size: 512 MiB UBI: number of good PEBs: 4064 UBI: number of bad PEBs: 32 UBI: max. allowed volumes: 128 UBI: wear-leveling threshold: 4096 UBI: number of internal volumes: 1 UBI: number of user volumes: 0 UBI: available PEBs: 4020 UBI: total number of reserved PEBs: 44 UBI: number of PEBs reserved for bad PEB handling: 40 UBI: max/mean erase counter: 0/0
=> ubifsmount ubi-data UBIFS error (pid 0): ubifs_get_sb: cannot open "ubi:ubi-data", error -19 Error reading superblock on volume 'ubi:ubi-data'!
=> ubifsmount rootfs UBIFS error (pid 0): mount_ubifs: can't format empty UBI volume: read-only mount Error reading superblock on volume 'ubi:rootfs'!
=> tftp rootfs.ubi.img Using FEC ETHERNET device TFTP from server 10.1.1.83; our IP address is 10.1.1.84 Filename 'rootfs.ubi.img'. Load address: 0x400000 Loading: ##################################################### ##################################################### ##################################################### ##################################################### done Bytes transferred = 18219008 (1160000 hex)
=> printenv [...] filesize=1160000 fileaddr=400000 [...]
=> ubi create rootfs Creating dynamic volume rootfs of size 518676480
=> ubi write ${fileaddr} rootfs ${filesize} Volume "rootfs" found at volume id 0
=> ubifsmount rootfs UBIFS error (pid 0): ubifs_read_node: bad node type (0 but expected 6) UBIFS error (pid 0): ubifs_read_node: bad node at LEB 0:0 Error reading superblock on volume 'ubi:rootfs'!
=> nand write ${fileaddr} ubi-data ${filesize}
NAND write: device 0 offset 0x0, size 0x1160000 Skip bad block 0x00040000 Skip bad block 0x00580000 Skip bad block 0x005a0000 Skip bad block 0x00640000 Skip bad block 0x00740000 18219008 bytes written: OK
=> ubifsmount rootfs UBIFS error (pid 0): ubifs_read_node: bad node type (0 but expected 6) UBIFS error (pid 0): ubifs_read_node: bad node at LEB 0:0 Error reading superblock on volume 'ubi:rootfs'!

At a glance, one problem is the use of ubinize, which is intended to work when doing "bare NAND" flashing with no awareness of UBI. I.e. if you tried these steps with "rootfs.ubifs" rather than "rootfs.ubi.img", they'd probably work. However, that doesn't explain why the last attempt (doing a straight "nand write") also fails, since that should work with the ubinized image.
To get it working piece by piece, you should try first without ubinize, using "ubi write". Once that's working, then add in the ubinize step and try flashing it in "raw" mode.
Anyway, here's what I do, in case having another reference helps. My U-Boot config has the following:
#define MTDIDS_DEFAULT "nand0=flash" #define MTDPARTS_DEFAULT "mtdparts=flash:5M(uboot),-(root)"
Simple layout, everything aside from U-Boot is UBI[FS]. (This device only has a single NAND chip.) In U-Boot, I do:
- nand erase 200000 - mtdparts default - ubi part root - ubi create container - tftp ubifs.img - ubi write ${fileaddr} container ${filesize}
After that, I can use the filesystem with no problems:
- ubifsmount container - ubifsload [address] [...]
ubifs.img was created with:
mkfs.ubifs -m 2048 -e 129024 -c 8152 -x lzo -U -v -r /path/to/root/ -o ubifs.img
Most of this looks similar to what you're doing, but here it is anyway just in case.

Hello Matthew,
thanks a lot, I will try this approach on Monday, when I'm back at work.
At a glance, one problem is the use of ubinize, which is intended to work when doing "bare NAND" flashing with no awareness of UBI. I.e. if you tried these steps with "rootfs.ubifs" rather than "rootfs.ubi.img", they'd probably work. However, that doesn't explain why the last attempt (doing a straight "nand write") also fails, since that should work with the ubinized image.
I like this apprach, since buildroot creates an ubifs file for me, so I don't need the extra step to create the image with ubinize.
Best regards,
Charly
participants (2)
-
Karl Krach
-
Matthew L. Creech