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.

why can't mount ubifs image

Other Parts Discussed in Thread: AM3517

I want to flash the android ubifs images by fastboot,

my NAND flash is Samsung K9F4G08U0A, 512MiB 3,3V 8-bit, page size is 2k, each block contains 64 pages.

I create the ubi.img as follows,

$ sudo mkfs.ubifs -r temp/ -m 2048 -e 131072 -c 4096 -o ubifs.img

$ ubinize -o ubi.img -m 2048 -p 128KiB -s 512 ubinize.cfg

ubinize.cfg

 [ubifs]

   mode=ubi

   image=ubifs.img

   vol_id=0

   vol_size=200MiB

   vol_type=dynamic

   vol_name=rootfs

   vol_flags=autoresize

 

then,

$ sudo ./fastboot flash system <rootfs_image_path>/ubi.img

 

in u-boot,

# setenv nandboot 'echo Booting from nand ...; nand read ${loadaddr} ${boot_nand_offset} ${boot_nand_size}; bootm ${loadaddr}'

# setenv bootcmd 'run nandboot'

# setenv bootargs 'init=/init console=ttyS0,115200n8 noinitrd ip=off androidboot.console=ttyS0 rootwait mem=256M \

     omap_vout.vid1_static_vrfb_alloc=y rw ubi.mtd=4 rootfstype=ubifs root=ubi0:rootfs bootdelay=2'

but the kernel can't mount the android ubifs system.

when I boot from MMC, I find just a /dev/ubi_ctrl, but no /dev/ubi0.

I am confused, but don't know what is the problem.

 

Regards,

Kevin

 

  • Hi Kevin,

    Please follow following procedure to create ubifs image.

    Creating ubifs image:
    $ sudo mkfs.ubifs -r nfs_rootfs/ -m 2048 -e 126976
    -c 3991 -o ubifs.img

    Create/Edit ubinize.cfg:
    $ cat ubinize.cfg
    [ubifs]
    mode=ubi
    image=ubifs.img
    vol_id=0
    vol_size=450MiB
    vol_type=dynamic
    vol_name=rootfs
    vol_flags=autoresize

    Creating ubi.img to be flashed:
    $ sudo ubinize -o ubi.img  -m 2048 -p 128KiB -s 512 ubinize.cfg

    Kindly provide kernel boot log in case of failure.

    Thanks and Regards,

    Pankaj Bharadiya

  • Hi Pankaj Bharadiya,

    I create the ubifs image as your procedures, and it doesn't succeed.

    Console logs is like this,

    UBIFS error (pid 1): ubifs_check_node: bad CRC: calculated 0xfa4550ed, read 0x5ef3df6b
    UBIFS error (pid 1): ubifs_check_node: bad node at LEB 0:0
    UBIFS error (pid 1): ubifs_read_node: expected node type 6
    VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0)
    Please append a correct "root=" boot option; here are the available partitions:
    1f00             512 mtdblock0 (driver?)
    1f01            1792 mtdblock1 (driver?)
    1f02             256 mtdblock2 (driver?)
    1f03            5120 mtdblock3 (driver?)
    1f04          516608 mtdblock4 (driver?)
    Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)


    and kernel boot log is attached.

    1524.kernel_boot_log.txt

     

    Another post related to this question is at http://e2e.ti.com/support/embedded/f/509/p/111434/394467.aspx#394467


    Regards,

    Kevin


  • Hi Kevin,

              Can you try with the procedure mentioned in the below attached document.

    3286.ubifs.doc

     

    Regards,

    N.S.SriHarsha

  • Hi,

    It seems mkfs.ubifs's bug, when I update mkfs.ubifs from 1.3 to 1.4, the kernel can boot the ubi.img image now.

    I mkfs.ubifs as follows,

    $ sudo mkfs.ubifs -r temp/ -m 2048 -e 129024 -c 3991 -o ubifs.img

    In ubinize.cfg I set vol_size=450MiB

    $ sudo ubinize -o ubi.img -m 2048 -p 128KiB -s 512 ubinize.cfg

     

    then,

    the system starts up, but not completely, some java processes can't be found in the process list.

    and lots of errors show up on the console such as

    UBIFS error (pid 802): make_reservation: cannot reserve 424 bytes in jhead 1, error -30
    UBIFS error (pid 802): ubifs_create: cannot create regular file, error -30

     

    I attached some log files,

    Processlist :7217.ProcessList.txt

    Kernel log:5023.KernelLog.txt

     

    Thanks,

    Kevin

  • Hi,

    I also find my ubifs is mounted read-only, but I indeed changed the boot args in u-boot command as follows,

    #setenv nandargs 'setenv bootargs console=${console} ubi.mtd=4 rootfstype=ubifs root=ubi0:rootfs rw init=/init'

    as the file system is read only,  so I can't mkdir in root directory, and I can't copy file to system through adb push.

     

    What is the problem? Have I typed wrong arguments in bootargs?

    Maybe this have something to do with the error,

    UBIFS error (pid 802): make_reservation: cannot reserve 424 bytes in jhead 1, error -30
    UBIFS error (pid 802): ubifs_create: cannot create regular file, error -30

     

    Thanks,

    Kevin


  • Hi SriHarsha,

    I did as your doc's instructions, and I copy the log below, hope it can help to analyse.

    1. Build UBIFS image,

    $ sudo mkfs.ubifs -v -r temp/ -m 2048 -e 129024 -c 2047 -o ubifs.img
    mkfs.ubifs
        root:         temp/
        min_io_size:  2048
        leb_size:     129024
        max_leb_cnt:  2047
        output:       ubifs.img
        jrn_size:     8388608
        reserved:     0
        compr:        lzo
        keyhash:      r5
        fanout:       8
        orph_lebs:    1
    WARNING: setting root UBIFS inode UID=GID=0 (root) and permissions to u+rwx,go+rx; use --squash-rino-perm or --nosquash-rino-perm to suppress this warning
        super lebs:   1
        master lebs:  2
        log_lebs:     5
        lpt_lebs:     2
        orph_lebs:    1
        main_lebs:    465
        gc lebs:      1
        index lebs:   5
        leb_cnt:      476
        UUID:         1B515EF4-DFD0-49C0-ACBC-04E9C16FF74A
    Success!

    2. Edit ubinize.cfg

    [ubifs]
       mode=ubi
       image=ubifs.img
       vol_id=0
       vol_size=200MiB
       vol_type=dynamic
       vol_name=rootfs
       vol_flags=autoresize

    3. Create UBI img

    $ sudo ubinize -v -o ubi.img -m 2048 -p 128KiB -s 512 ubinize.cfg
    ubinize: LEB size:                  129024
    ubinize: PEB size:                  131072
    ubinize: min. I/O size:             2048
    ubinize: sub-page size:             512
    ubinize: VID offset:                512
    ubinize: data offset:               2048
    ubinize: UBI image sequence number: 957562613
    ubinize: loaded the ini-file "ubinize.cfg"
    ubinize: count of sections: 1

    ubinize: parsing section "ubifs"
    ubinize: mode=ubi, keep parsing
    ubinize: volume type: dynamic
    ubinize: volume ID: 0
    ubinize: volume size: 209715200 bytes
    ubinize: volume name: rootfs
    ubinize: volume alignment: 1
    ubinize: autoresize flags found
    ubinize: adding volume 0
    ubinize: writing volume 0
    ubinize: image file: ubifs.img

    ubinize: writing layout volume
    ubinize: done

    4. Push the ubi.img to the MMC

    adb push ubi.img /shared

    5. Ubiformat

    # ubiformat /dev/mtd/mtd4 -s 512 -f /shared/ubi.img
    ubiformat: mtd4 (nand), size 529006592 bytes (504.5 MiB), 4036 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
    libscan: scanning eraseblock 4035 -- 100 % complete
    ubiformat: 4033 eraseblocks are supposedly empty
    ubiformat: bad eraseblocks: 1480, 2560, 2711
    ubiformat: flashing eraseblock 383 -- 80 % complete  libmtd: error!: cannot write 131072 bytes to mtd4 (eraseblock 383, offset 0)
            error 5 (Input/output error)

    ubiformat: error!: cannot write eraseblock 383
               error 5 (Input/output error)
    ubiformat: mark it as bad? Continue (yes/no) yes
    ubiformat: marking block 383 bad
    ubiformat: flashing eraseblock 478 -- 100 % complete  ubiformat: error!: eof reached; 131072 bytes remaining
    ubiformat: error!: failed to read eraseblock 477 from "/shared/ubi.img"
               error 5 (Input/output error)

    6.  Ubiattach

    # ubiattach /dev/ubi_ctrl -m 4
    UBI: attaching mtd4 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: volume 0 ("rootfs") re-sized from 1626 to 3988 LEBs
    UBI: attached mtd4 to ubi0
    UBI: MTD device name:            "jffs2-nand"
    UBI: MTD device size:            504 MiB
    UBI: number of good PEBs:        4032
    UBI: number of bad PEBs:         4
    UBI: max. allowed volumes:       128
    UBI: wear-leveling threshold:    4096
    UBI: number of internal volumes: 1
    UBI: number of user volumes:     1
    UBI: available PEBs:             0
    UBI: total number of reserved PEBs: 4032
    UBI: number of PEBs reserved for bad PEB handling: 40
    UBI: max/mean erase counter: 1/0
    UBI: image sequence number: 957562613
    UBI: background thread "ubi_bgt0d" started, PID 1528
    UBI device number 0, total 4032 LEBs (520224768 bytes, 496.1 MiB), available 0 LEBs (0 bytes), LEB size 129024 bytes (126.0 KiB)

    7. mount

    # mount -t ubifs ubi0:rootfs /mnt/ubi
    UBIFS: mounted UBI device 0, volume 0, name "rootfs"
    UBIFS: file system size:   262692864 bytes (256536 KiB, 250 MiB, 2036 LEBs)
    UBIFS: journal size:       9033728 bytes (8822 KiB, 8 MiB, 71 LEBs)
    UBIFS: media format:       w4/r0 (latest is w4/r0)
    UBIFS: default compressor: lzo
    UBIFS: reserved for root:  0 bytes (0 KiB)

     

    In the above procedure, there seems something wrong happened in step 5. Is the ubi.img not good.

     

    Thanks,

    Kevin

     

  • Hi Kevin,

                The same procedure has worked for me, hope UBIFS image was created with sudo permissions and nand was erased before UBIFormat.

     

    Regards,

    N.S.SriHarsha

  • Hi SriHarsha,

        I am sure, that the UBIFS image was created with sudo permissions, and nand was erased in u-boot with 'nand erase' or 'nand scrub' command.

        BTW,

        my mkfs.ubifs is of version 1.4, and ubinize is of version 1.2.

    Regards,

    Kevin

     

     

  • Hi,

    I found the following bold errors are printed in ubi driver in kernel, kernel/drivers/mtd/ubi/io.c, could be the ubi driver's problem?

    UBI error: ubi_io_write: error -5 while writing 512 bytes to PEB 2326:0, written 0 bytes
    UBI error: erase_worker: failed to erase PEB 2326, error -5
    UBI: mark PEB 2326 as bad
    UBI: 38 PEBs left in the reserve
    UBI error: ubi_io_write: error -5 while writing 512 bytes to PEB 2599:0, written 0 bytes
    UBI error: erase_worker: failed to erase PEB 2599, error -5
    UBI: mark PEB 2599 as bad
    UBI error: ubi_io_mark_bad: cannot mark PEB 2599 bad, error -5
    UBI warning: ubi_ro_mode: switch to read-only mode
    UBI error: do_work: work failed with error code -5
    UBI error: ubi_thread: ubi_bgt0d: work failed with error code -5
    UBIFS error (pid 870): ubifs_wbuf_write_nolock: cannot write 3778 bytes to LEB 477:0, error -30
    UBIFS warning (pid 870): ubifs_ro_mode: switched to read-only mode, error -30
    UBIFS error (pid 870): do_writepage: cannot write page 0 of inode 769, error -30
    UBIFS error (pid 802): make_reservation: cannot reserve 424 bytes in jhead 1, error -30
    UBIFS error (pid 802): ubifs_create: cannot create regular file, error -30
    UBIFS error (pid 802): make_reservation: cannot reserve 416 bytes in jhead 1, error -30
    UBIFS error (pid 802): ubifs_create: cannot create regular file, error -30
    UBIFS error (pid 802): make_reservation: cannot reserve 424 bytes in jhead 1, error -30
    UBIFS error (pid 802): ubifs_create: cannot create regular file, error -30


    I haven't found a better way to solve it. any suggestions?

    Thanks,

  • Hi Kevin,

    Replied on a similar thread of yours http://e2e.ti.com/support/embedded/f/509/p/111434/410995.aspx#410995

    Requesting you stick to one E2E thread, that will help us in tracking this  issue.

    Regards,
    Amit Pundir

  • Found a solution to the problem.

    The AM3517 processor supports NAND prefetch and prefetch DMA, so I enabled MTD_NAND_OMAP_PREFETCH and MTD_NAND_OMAP_PREFETCH_DMA in kernel config, then the errors didn't come up any more, the android system can start up from NAND successfully now.

     

    Regards,

    Kevin