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.

PROCESSOR-SDK-AM62X: Access UBIFS (NOR flash) from U-Boot

Part Number: PROCESSOR-SDK-AM62X
Other Parts Discussed in Thread: SK-AM62

My Linux root filesystem is stored on NOR flash, formatted as UBIFS. I need to access this via U-Boot.

I configured U-Boot to enable the appropriate commands. I also configured CONFIG_MTDIDS_DEFAULT="nor0:spi0.0", and set CONFIG_MTDPARTS_DEFAULT to "mtdparts=spi0.0:<flash layout>".

I rebuilt U-Boot, and flashed my device (the SK-AM62 evaluation kit, configured to boot from OSPI). I entered the following commands:

=> sf probe          
SF: Detected s28hs512t with page size 256 Bytes, erase size 256 KiB, total 64 MiB

=> mtd list
List of MTD devices:
* nor0
  - type: NOR flash
  - block size: 0x40000 bytes
  - min I/O: 0x1 bytes
  - 0x000000000000-0x000004000000 : "nor0"
          - 0x000000000000-0x000000080000 : "tiboot3"
          - 0x000000080000-0x000000280000 : "tispl"
          - <...>
          - 0x000000800000-0x000002800000 : "rootfs"
          - <...>

=> ubi part rootfs 
ubi0: attaching mtd7
ubi0: scanning is finished
ubi0: attached mtd7 (name "rootfs", size 32 MiB)
...

However, the ubifsmount command failed:

=> ubifsmount ubi0:rootfs
UBIFS error (ubi0:0 pid 0): validate_sb: min. I/O unit mismatch; 16 in superblock, 8 real
UBIFS error (ubi0:0 pid 0): validate_sb: bad superblock, error 1
...
Error reading superblock on volume 'ubi0:rootfs' errno=-22!

When I created the filesystem image, I passed "-m 16" to both mkfs.ubifs and ubinize. (I don't recall how I came to use this value. However, it could be that this is based on the fact that the device uses an ECC on 16-byte data units.)

I rebuilt the root filesystem using "-m 8" for both mkfs.ubifs and ubinize. However, this led to a (worse) problem: Now Linux gets a fatal error when trying to mount the filesystem:

UBIFS error (ubi0:0 pid 1): ubifs_read_superblock: min. I/O unit mismatch; 8 in superblock, 16 real

I've looked at the various U-Boot configuration options, as well as the various options for mkfs.ubifs and ubinize, but haven't found anything that seems relevant.

How do I resolve this problem?

  • Hello James,
    This is an early e2e on flashing/booting u-boot, Linux, root_fs(ubifs) from 64MB OSPI-NOR on AM64x EVM for your reference.
    e2e.ti.com/.../3769546
    Best,
    -Hong

  • In the case you referenced:

    The case you referenced has just one reference to "superblock":

    I went to SD Linux and mout my ubifs and shown wrong fs type, bad option, bad superblock on ubi0:thinh_ubi, missing codepage or helper program, or other error.

    I also looked in that case for uses of the "-m" flag (minimum I/O unit size). There were only a couple; and they both specified "-m 16".

    I didn't find any other information that seems pertinent to my issue. So this case doesn't seem to help with my problem.

  • Hello James,
    Have you looked at the UBIFS online guide for any hint?
    www.linux-mtd.infradead.org/.../ubifs.html
    Best,
    -Hong

  • Have you looked at the UBIFS online guide for any hint?

    Yes, I have looked at this guide, as well as the one on UBI. There doesn't seem to be anything related to my issue.

    I did look at the U-Boot source generating the error, and tracking down ubisfsinfo::min_io_size. I found the following section of code in fs/ubifs/super.c:

    /*
    * UBIFS aligns all node to 8-byte boundary, so to make function in
    * io.c simpler, assume minimum I/O unit size to be 8 bytes if it is
    * less than 8.
    */
    if (c->min_io_size < 8) {
        c->min_io_size = 8;
        c->min_io_shift = 3;
        if (c->max_write_size < c->min_io_size) {
            c->max_write_size = c->min_io_size;
            c->max_write_shift = c->min_io_shift;
        }
    }

    My guess is that this is the code that is setting min_io_size to 8.

    min_io_size should be set to 16, but I couldn't find where or how it should be set up.

  • Hello James,
    In the previous referenced e2e
    e2e.ti.com/.../3769546
    "3. Flash the generated UBI rootfs file "am6-sdk-tiny-fs.ubi" to OSPI in kernel from SD card boot as an example:
    I used "ubiformat /dev/mtd7 -f am6-sdk-tiny-fs.ubi" at kernel to flash/format the UBI rootfs file to MTD7 (ospi.rootfs).
    Refer to the attached log file "am6_ubiformat_ospi.txt" for more details.
    I also attached another log file "am6_ubiattach_ospi.txt" to show attaching MDT7 (ospi.rootfs) for testing."

    As alternative checkpoint, can we try something similar to the steps as listed in ""am6_ubiformat_ospi.txt" and "am6_ubiattach_ospi.txt" to see ubifs works @kernel on your setup?
    Best,
    -Hong