This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

rootfs on a ubifs on nand flash

hi TI,

I have a board with omap 3530 and 512MB flash NAND device: Manufacturer ID: 0x2c, Chip ID: 0xbc (Micron NAND 512MiB 1,8V 16-bit)
we have been running the system with sd card however, recently we started getting RMAs from the field because of SD card failures, the system is supposed to work in heavy industry conditions and random power failures is expected.

Anyway, the plan is to move formward with using the internal nand flash and put rootfs on a UBIFS, so I have the following mtd partitions:
[ 1.050262] Creating 5 MTD partitions on "omap2-nand.0":
[ 1.055877] 0x000000000000-0x000000080000 : "X-Loader"
[ 1.063751] 0x000000080000-0x000000260000 : "U-Boot"
[ 1.071777] 0x000000260000-0x000000280000 : "Environment"
[ 1.079528] 0x000000280000-0x000000680000 : "Kernel"
[ 1.088592] 0x000000680000-0x000020000000 : "File System"

I succeeded to get the kernel and uboot, x loader flahed from both u-boot commands and from up & running linux from sd card.
also changed u-boot env. to load kernel from flash and still load rootfs from sd card.

on host, I created the ubi image using the command:
sudo mkfs.ubifs -r Packages/rootfs/media/mmcblk0p2/ -m 2048 -e 126KiB -c 3000 -o ubifs.img

then on target I do:
ubiformat /dev/mtd4
ubiattach /dev/ubi_ctrl -m 4
ubimkvol /dev/ubi0 -N rootfs -s 390MiB
ubiupdatevol /dev/ubi0_0 ubifs.img
then I mount the partition and check it, it looks okay and I can touch, edit, save a file there then umount and after remounting it I can see the file with the changes
mkdir /mnt/try
mount -t ubifs ubi0:rootfs /mnt/try
sync

then, now I reboot the unit, interrupt u-boot and change rootfs settings to be:
ubi.mtd=4 root=ubi0:rootfs rw rootfstype=ubifs

then boot, the unit does not boot and ends with a kernel panic after many many ubi related errors:
[ 1.308776] UBI: attaching mtd4 to ubi0
[ 1.312835] UBI: physical eraseblock size: 131072 bytes (128 KiB)
[ 1.319519] UBI: logical eraseblock size: 129024 bytes
[ 1.325225] UBI: smallest flash I/O unit: 2048
[ 1.330230] UBI: sub-page size: 512
[ 1.335083] UBI: VID header offset: 512 (aligned 512)
[ 1.341278] UBI: data offset: 2048
[ 1.346832] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read 64 bytes
[ 1.357543] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 0:512, read 512 bytes
[ 1.384796] UBI error: check_corruption: PEB 0 contains corrupted VID header, and the data does not contain all 0xFF, this may be a non-UBI PEB or a severe VID header corruption which requires manual in
[ 1.404907] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1:0, read 64 bytes
[ 1.415557] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1:512, read 512 bytes
[ 1.426696] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 2:0, read 64 bytes
[ 1.437347] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 2:512, read 512 bytes
[ 1.448120] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 2
[ 1.774169] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1026:0, read 64 bytes
[ 1.785125] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1026:512, read 512 bytes
[ 1.796173] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1026
[ 1.805145] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1027:0, read 64 bytes
[ 1.816101] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1027:512, read 512 bytes
[ 1.827148] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1027
[ 1.837371] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1032:0, read 64 bytes
[ 1.848327] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1032:512, read 512 bytes
[ 1.859375] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1032
[ 1.868347] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1033:0, read 64 bytes
[ 1.879272] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1033:512, read 512 bytes
[ 1.890319] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1033
[ 1.899932] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1036:0, read 64 bytes
[ 1.910858] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1036:512, read 512 bytes
[ 1.921905] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1036
[ 1.931854] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1040:0, read 64 bytes
[ 1.942810] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1040:512, read 512 bytes
[ 1.953826] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1040
[ 1.962829] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1041:0, read 64 bytes
[ 1.973754] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1041:512, read 512 bytes
[ 1.984802] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1041
[ 1.994079] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1043:0, read 64 bytes
[ 2.005065] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1043:512, read 512 bytes
[ 2.016113] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1043
[ 2.025238] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1044:0, read 64 bytes
[ 2.036224] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1044:512, read 512 bytes
[ 2.047271] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1044
[ 2.057220] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1048:0, read 64 bytes
[ 2.068145] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1048:512, read 512 bytes
[ 2.079193] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1048
[ 2.088195] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1049:0, read 64 bytes
[ 2.099121] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1049:512, read 512 bytes
[ 2.110168] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1049
[ 2.119476] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1051:0, read 64 bytes
[ 2.130432] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1051:512, read 512 bytes
[ 2.141479] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1051
[ 2.151092] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1054:0, read 64 bytes
[ 2.162048] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1054:512, read 512 bytes
[ 2.173095] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1054
[ 2.183013] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1058:0, read 64 bytes
[ 2.193939] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1058:512, read 512 bytes
[ 2.204986] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1058
[ 2.215209] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1063:0, read 64 bytes
[ 2.226165] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1063:512, read 512 bytes
[ 2.237213] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1063
[ 2.246826] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1066:0, read 64 bytes
[ 2.257751] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1066:512, read 512 bytes
[ 2.268798] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1066
[ 2.279022] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1071:0, read 64 bytes
[ 2.289978] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1071:512, read 512 bytes
[ 2.301025] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1071
[ 2.310638] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1074:0, read 64 bytes
[ 2.321563] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1074:512, read 512 bytes
[ 2.332611] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1074
[ 2.342834] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1079:0, read 64 bytes
[ 2.353790] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1079:512, read 512 bytes
[ 2.364837] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1079
[ 2.374450] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1082:0, read 64 bytes
[ 2.385375] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1082:512, read 512 bytes
[ 2.396423] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1082
[ 2.405426] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1083:0, read 64 bytes
[ 2.416351] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1083:512, read 512 bytes
[ 2.427398] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1083
[ 2.436676] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1085:0, read 64 bytes
[ 2.447631] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1085:512, read 512 bytes
[ 2.458679] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1085
[ 2.468261] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1088:0, read 64 bytes
[ 2.479217] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1088:512, read 512 bytes
[ 2.490264] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1088
[ 2.499237] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1089:0, read 64 bytes
[ 2.510192] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1089:512, read 512 bytes
[ 2.521240] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1089
[ 2.530517] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1091:0, read 64 bytes
[ 2.541473] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1091:512, read 512 bytes
[ 2.552520] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1091
[ 2.561492] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1092:0, read 64 bytes
[ 2.572448] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1092:512, read 512 bytes
[ 2.583496] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1092
[ 2.593414] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1096:0, read 64 bytes
[ 2.604370] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1096:512, read 512 bytes
[ 2.615417] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1096
[ 2.624389] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1097:0, read 64 bytes
[ 2.635314] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1097:512, read 512 bytes
[ 2.646362] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1097
[ 2.656280] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1101:0, read 64 bytes
[ 2.667205] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1101:512, read 512 bytes
[ 2.678253] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1101
[ 2.687866] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1104:0, read 64 bytes
[ 2.698822] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1104:512, read 512 bytes
[ 2.709869] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1104
[ 2.718841] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1105:0, read 64 bytes
[ 2.729766] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1105:512, read 512 bytes
[ 2.740814] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1105
[ 2.750122] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1107:0, read 64 bytes
[ 2.761047] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1107:512, read 512 bytes
[ 2.772094] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1107
[ 2.781402] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1109:0, read 64 bytes
[ 2.792327] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1109:512, read 512 bytes
[ 2.803375] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1109
[ 2.812988] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1112:0, read 64 bytes
[ 2.823944] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1112:512, read 512 bytes
[ 2.834991] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1112
[ 2.843963] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1113:0, read 64 bytes
[ 2.854888] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1113:512, read 512 bytes
[ 2.865936] UBI warning: process_eb: valid VID header but corrupted EC header at PEB 1113
[ 2.875213] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 1115:0, read 64 bytes
[ 2.886169] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 1115:512, read 512 bytes


So, I thought maybe the image is not correct!, maybe ubinize is needed, I tried that but doesn't seem to help.

so I thought, maybe the steps on the mtd4 partition is the problem, I tried to just create the ubi without flashing the image, as follows:
ubiformat /dev/mtd4
ubiattach /dev/ubi_ctrl -m 4
ubimkvol /dev/ubi0 -N rootfs -s 390MiB

mounting works and I see empty partition.

now, reboot the unit and try to attach and mount without formatting:
ubiattach /dev/ubi_ctrl -m 4, this commands gives the same ubi ECC errors I got while booting.
so a reboot cycle does something causing the nand flash partition to get altered somehow and show these ECC errors.

I tried running nandtest, I get weird results, the number of ECC failures changes everytime I run the test.
root@i5IS-:~# nandtest /dev/mtd0
ECC corrections: 0
ECC failures : 0
Bad blocks : 0
BBT blocks : 0
00060000: checking...
Finished pass 1 successfully
root@i5IS-:~# nandtest /dev/mtd1
ECC corrections: 0
ECC failures : 222
Bad blocks : 0
BBT blocks : 0
001c0000: checking...
Finished pass 1 successfully
root@i5IS-:~# nandtest /dev/mtd2
ECC corrections: 0
ECC failures : 42
Bad blocks : 0
BBT blocks : 0
00000000: checking...
Finished pass 1 successfully
root@i5IS-:~# nandtest /dev/mtd3
ECC corrections: 0
ECC failures : 258
Bad blocks : 0
BBT blocks : 0
003e0000: checking...
Finished pass 1 successfully

and for mtd4, I got sometimes compare failed:

16440000: reading...
ECC failed at 16440000
16440000: checking...
compare failed. seed 286155573
Byte 0x1a800 is 30 should be 24
Byte 0x1a801 is ff should be 23
...................
................
...........


I think we have kernel 2.6.38 and u-boot 2010.06, I see that from serial console:

U-Boot 2010.06-1-dirty (Nov 22 2012 - 08:06:57)

OMAP3530-GP ES3.1.2, CPU-OPP2, L3-165MHz
G6IDU board + LPDDR/NAND
I2C: ready
DRAM: 512 MiB
NAND: 512 MiB
In: serial
Out: serial
Err: serial
Die ID #41bc0007000000000155d96f0601401d
Net: No ethernet found.
Hit any key to stop autoboot: 0
U-Boot #
U-Boot # run ubi-boot
mmc0 is available
reading uImage

2474016 bytes read
## Booting kernel from Legacy Image at 80000000 ...
Image Name: Linux-2.6.38
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2473952 Bytes = 2.4 MiB
Load Address: 80008000
Entry Point: 80008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK

Starting kernel ...


I'm NOT an expert linux and u-boot programmer, so any help on this issue is appreciated


Regards,
Ahmed

  • For this UBIFS mount failures may due to wrong format/created of UBIFS image.

    Checkout the following links.


    http://processors.wiki.ti.com/index.php/UBIFS_Support
    http://www.linux-mtd.infradead.org/faq/ubifs.html#L_mkfubifs
    http://www.linux-mtd.infradead.org/faq/ubi.html#L_ubi_mkimg
  • Thanks for your reply, the provided links helped me to find the following 2 issues:

    1 - I found that my u-boot was not built with UBI support, so access from uboot was not successful.

    2 - The ubiformat command, I didn't specify the 2048 subpage size (using -s option)

    I have the board up & running with UBI FS,

    Thanks,
  • Sounds really good.
    I was glad that you were able to solve the problem.
    Thanks for your update.
  • now I have another issue, still related to the ubifs.

    the unit boots properly and file system seems to work properly only in first boot cycle, however once I reboot the unit  within few minutes, I get the following error on the serial console:

    [ 70.543243] UBIFS error (pid 763): make_reservation: cannot reserve 1169 bytes in jhead 2, error -30
    [ 70.552947] UBIFS error (pid 763): do_writepage: cannot write page 1 of inode 5916, error -30

    Then the rootfs becomes read-only, so I can't touch a new file or edit an existing one!

    what is error -30? is this still related to the way I have my rootfs ubi image created?

    Thanks,

    Ahmed

  • Hi Ahmed,

    The error 30 is for read only filesystem.
    Provide your u-boot bootargs and make sure that you have "rw" in u-boot bootargs.

    #define EROFS 30 /* Read-only file system */
  • Hi Titus,

    the uboot bootargs is rw, I can create and edit files in some boot cycles if I do it fast enough before the problem occurs!

    here is the bootarg to boot from nand n case you can spot something wrong in it!

    nand-boot=run nand-bootargs;nand read 80000000 280000 260000 ; bootm 80000000
    nand-bootargs=setenv bootargs ${bootargs-base} ubi.mtd=4,2048 rootfstype=ubifs root=ubi0:rootfs1 rw init=/init rootwait
    bootcmd=run nand-boot

    and here is the errors that just came in my last boot cycle after about 30 seconds:

    [ 35.449279] UBIFS error (pid 795): make_reservation: cannot reserve 160 bytes in jhead 1, error -30
    [ 35.458892] UBIFS error (pid 795): ubifs_write_inode: can't write inode 5486, error -30
    [ 40.464935] UBIFS error (pid 795): make_reservation: cannot reserve 160 bytes in jhead 1, error -30
    [ 40.474517] UBIFS error (pid 795): ubifs_write_inode: can't write inode 5926, error -30
    [ 40.483459] UBIFS error (pid 795): make_reservation: cannot reserve 160 bytes in jhead 1, error -30
    [ 40.493041] UBIFS error (pid 795): ubifs_write_inode: can't write inode 5927, error -30
    [ 40.502227] UBIFS error (pid 795): make_reservation: cannot reserve 160 bytes in jhead 1, error -30
    [ 40.511840] UBIFS error (pid 795): ubifs_write_inode: can't write inode 5916, error -30
  • I'm stuck at this point, any suggestion on how to proceed?
    could this be the unstable bits issue mentioned here: http://elinux.org/Start_working_on_the_%22unstable_bits%22_issue_to_make_UBIFS_more_robust

    should I switch do something specific before shutting down the unit?
    my only choice if I can't get this to work is to switch to jffs2, which I tried to escape from in the first place :(