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.

UBIFS Format and Access Issues

Hi, all,

We are using ubifs as our application file system. The linux kernel is 2.6.37 from DVRRDK-03.00.00.00. The nand flash we used is Samsung 128MB.

And the size of our fs is about 85MB.

The procedure we used  to  build file system is :

(1)  mkfs.ubifs -m 2048 -e 126976 -c 650 -r our-ubifs-dir -F -o rfs-nvr-ubi.img

(2)  ubinize -o rfs-nvr.ubifs -m 2048 -p 128KiB -s 512 -O 2048 ubinize.cfg

And the content of ubiinize.cfg is 

[ubifs]
mode=ubi
image=rfs-nvr-ubi.img
vol_id=0
vol_size=85MiB
vol_type=dynamic
vol_name=appfs
vol_flags=autoresize
Then we have suffered five error cases on flashing UBIFS image into NAND flash as follow:
Case 1
---------------------------------------------------------------------------------------------------------------------------------------
We use the following command to flash the ubifs image to partition 7 successfully and reboot system.
ubiformat -y /dev/mtd7 -s 512 -O 2048 -f rfs-nvr.ubifs
After booting system, we see the following messages (case1-log.txt).  0246.case1-log.log
UBIFS error (pid 585): read_block: bad data node (block 198, inode 142)
UBIFS error (pid 585): do_readpage: cannot read page 198 of inode 142, error -22
UBIFS error (pid 585): read_block: bad data node (block 198, inode 142)
UBIFS error (pid 585): do_readpage: cannot read page 198 of inode 142, error -22
---------------------------------------------------------------------------------------------------------------------------------------
Case 2
---------------------------------------------------------------------------------------------------------------------------------------
We use the following command to flash the ubifs image to partition 7 successfully and reboot system.
ubiformat -y /dev/mtd7 -s 512 -O 2048 -f rfs-nvr.ubifs
After booting system, we see the following messages (case2-log.txt).  0284.case2-log.log
UBI device number 0, total 726 LEBs (92184576 byUBIFS error (pid 479): ubifs_mount: cannot open "/dev/ubi0_0", error -22
tes, 87.9 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
---------------------------------------------------------------------------------------------------------------------------------------
Case 3
---------------------------------------------------------------------------------------------------------------------------------------
We use the following command to flash the ubifs image to partition 7.
ubiformat -y /dev/mtd7 -s 512 -O 2048 -f rfs-nvr.ubifs
But we get the the following messages (case3-log.txt).  3482.case3-log.log
ubiformat: error!: bad UBI magic 0x55424903, should be 0x55424923
---------------------------------------------------------------------------------------------------------------------------------------
Case 4
---------------------------------------------------------------------------------------------------------------------------------------
We use the following command to flash the ubifs image to partition 7.
ubiformat -y /dev/mtd7 -s 512 -O 2048 -f rfs-nvr.ubifs
But we get the the following messages (case4-log.txt). 8623.case4-log.log
UBI device number 0, total 725 LEBs (92057600 bytes, 87.8 MiB), available 0 LEBsUBI error: ubi_io_write: error -5 while writing 512 bytes to PEB 1:0, written 0 bytes
(0 bytes), LEB UBI error: erase_worker: failed to erase PEB 1, error -5
---------------------------------------------------------------------------------------------------------------------------------------
Case 5
---------------------------------------------------------------------------------------------------------------------------------------
We use the following command to flash the ubifs image to partition 7.
ubiformat -y /dev/mtd7 -s 512 -O 2048 -f rfs-nvr.ubifs
But we get the the following messages (case5-log.txt).1348.case5-log.log
[Fri Oct 05 18:51:04.109 2012] libmtd: error!: cannot write 131072 bytes to mtd7 (eraseblock 357, offset 0)
[Fri Oct 05 18:51:04.109 2012]         error 5 (Input/output error)
[Fri Oct 05 18:51:04.109 2012] ubiformat: error!: cannot write eraseblock 357
[Fri Oct 05 18:51:04.125 2012]            error 5 (Input/output error)
[Fri Oct 05 18:51:04.140 2012] libmtd: error!: cannot write 131072 bytes to mtd7 (eraseblock 357, offset 0)
[Fri Oct 05 18:51:04.140 2012]         error 5 (Input/output error)
[Fri Oct 05 18:51:04.140 2012] biformat: flashing eraseblock 343 -- 55 % complete  ubiformat: flashing eraseblock 344 -- 55 % complete  ubiformat: flashing eraseblock 345 -- 55 % complete  ubiformat: flashing eraseblock 346 -- 55 % complete  ubiformat: flashing eraseblock 347 -- 55 % complete  ubiformat: flashing eraseblock 348 -- 56 % complete  ubiformat: flashing eraseblock 349 -- 56 % complete  ubiformat: flashing eraseblock 350 -- 56 % complete  ubiformat: flashing eraseblock 351 -- 56 % complete  ubiformat: flashing eraseblock 352 -- 56 % complete  ubiformat: flashing eraseblock 353 -- 56 % complete  ubiformat: flashing eraseblock 354 -- 56 % complete  ubiformat: flashing eraseblock 355 -- 57 % complete  ubiformat: flashing eraseblock 356 -- 57 % complete  ubiformat: flashing eraseblock 357 -- 57 % complete  libmtd: run torture test for PEB 357
[Fri Oct 05 18:51:04.218 2012] 
[Fri Oct 05 18:51:04.218 2012] ubiformat: marking block 357 bad
[Fri Oct 05 18:51:04.218 2012] 
[Fri Oct 05 18:51:04.218 2012] libmtd: error!: cannot write 131072 bytes to mtd7 (eraseblock 360, offset 0)
[Fri Oct 05 18:51:04.234 2012]         error 5 (Input/output error)
[Fri Oct 05 18:51:04.234 2012] ubiformat: error!: cannot write eraseblock 360
[Fri Oct 05 18:51:04.234 2012]            error 5 (Input/output error)
[Fri Oct 05 18:51:05.140 2012] UPGRADE!! : geo-upgrade-dev-nand-ubifs.c, geo_upgrade_dev_nand_ubifs_write, 249, ubiformat ERROR
[Fri Oct 05 18:51:05.140 2012] UPGRADE!! : geo-upgrade-dev-nand-ubifs.c, geo_upgrade_dev_nand_ubifs_write, 232, retry=1
[Fri Oct 05 18:51:05.156 2012] libmtd: error!: cannot write 131072 bytes to mtd7 (eraseblock 391, offset 0)
[Fri Oct 05 18:51:05.172 2012]         error 5 (Input/output error)
[Fri Oct 05 18:51:05.172 2012] ubiformat: error!: cannot write eraseblock 391
[Fri Oct 05 18:51:05.172 2012]            error 5 (Input/output error)
[Fri Oct 05 18:51:05.187 2012] ubidetach: error!: cannot detach mtd7
[Fri Oct 05 18:51:05.187 2012]            error 19 (No such device)
[Fri Oct 05 18:51:05.218 2012] libmtd: error!: cannot write 131072 bytes to mtd7 (eraseblock 391, offset 0)
[Fri Oct 05 18:51:05.218 2012]         error 5 (Input/output error)
[Fri Oct 05 18:51:05.234 2012] ubiformat: mtd7 (nand), size 103809024 bytes (99.0 MiB), 792 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
---------------------------------------------------------------------------------------------------------------------------------------
Any suggestion will be appreciated , thanks.
  • Jason,

    Can you try these instructions below?

    1. First you should have your rootfs as a tar ball in your SD card or NFS from where you mount the filesystem.
    2. Boot up the device and the filesystem from NFS or SD card according your preference.
    3. Boot it up and login. Hope you have all the required command binaries like "flash_erase" etc in your filesystem. If not take the default arago filesystem image that comes with the EZSDK package.
    4. Follow the steps below

    $ flash_erase /dev/mtd4 0 0
    $ ubiattach /dev/ubi_ctrl -m 4
    $ ubimkvol /dev/ubi0 -N rootfs -m

    $ mkdir /mnt/nand
    $ mount -t ubifs ubi0:rootfs /mnt/nand
    $ tar xvf rootfs.tar.gz -C /mnt/nand

    5. Change the bootargs like below for booting from UBIFS.
    # setenv bootargs 'console=ttyO0,115200n8 mem=160M ubi.mtd=4 rootfstype=ubifs root=ubi0:rootfs rw'

    ==================================================================================

    If you still see any errors, please send the complete logs along with the below mentioned files to renjith.thomas@pathpartnertech.com?

    1. arch/arm/mach-omap2/board-ti8148-evm.c or corresponding board file you are using?
    2. arch/arm/mach-omap2/board-flash.c
    3. arch/arm/mach-omap2/gpmc.c
    4. drivers/mtd/nand/nand_base.c
    5. drivers/mtd/nand/omap2.c
  • Jason,

    Could you also check the size calculations? Looks like you have used your exact file system size (85MB) in your calculations instead of file system partition size (99MB).

    Please follow this link - http://processors.wiki.ti.com/index.php/UBIFS_Support

  • Sivagamy, 

    We have followed that link to do experiments by using system partition size (99MB), and then everything is all right when numbers of  bad blocks on nand flash are fewer.

    The procedure we used  to  build file system is :

    (1)  mkfs.ubifs -m 2048 -e 126976 -c 817 -r our-ubifs-dir -F -o rfs-nvr-ubi.img

    (2)  ubinize -o rfs-nvr.ubifs -m 2048 -p 128KiB -s 512 -O 2048 ubinize.cfg

    And the content of ubiinize.cfg is 

    [ubifs]
    mode=ubi
    image=rfs-nvr-ubi.img
    vol_id=0
    vol_size=94MiB
    vol_type=dynamic
    vol_name=appfs
    vol_flags=autoresize


    But when we do experiments on the board with many bad blocks on nand flash, the ubiattach command will encounter  errors as follow:

    ---------------------------------------------------------------------------------

    root@localhost:~# ubiattach /dev/ubi_ctrl -m 7 -O 2048

    UBI: attaching mtd7 to ubi0
    UBI: physical eraseblock size: 131072 bytes (128 KiB)
    UBI: logical eraseblock size: 126976 bytes
    UBI: smallest flash I/O unit: 2048
    UBI: sub-page size: 512
    UBI: VID header offset: 2048 (aligned 2048)
    UBI: data offset: 4096
    UBI: max. sequence number: 0
    UBI error: vtbl_check: volume table check failed: record 0, error 9
    ubiattach: error!: cannot attach mtd7
                     error 22 (Invalid argument)

    ------------------------------------------------------------------------------------------------------

    The only way to avoid this error is to reduce vol_size.

    And there are 1% or less  bad blocks on nand flash, so that we set the vol_size to 85MB.

    Please refer to log1 that nand flash with fewer bad block.1401.log1.log

    Please refer to log2  that nand flash with more bad block.4863.log2.log

    Any suggestion will be appreciated , thanks.