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.

DM385: Bug somewhere in ubifs code

Part Number: DM385


I am using the IPNC RDK 3.9.1 and trying to run from NAND, but every now and then after I flash the filesystem, it fails to mount on startup.  For example, currently the filesystem is 189 MiB on my Ubuntu host, when I ubinize it, the resulting file is 101248 KiB, which suggests that the filesystem is being compressed somehow.  After I write it to a 208 MiB NAND partition, when it tries to mount, it fails write at PEB 791, which at a PEB size of 128 KiB, just happens to match the size of the ubinized file. 

[    1.207155] 8 ofpart partitions found on MTD device 8000000.nand
[    1.213190] Creating 8 MTD partitions on "8000000.nand":
[    1.218558] 0x000000000000-0x000000020000 : "NAND.SPL"
[    1.226324] 0x000000020000-0x000000420000 : "NAND.u-boot"
[    1.234410] 0x000000420000-0x000000440000 : "NAND.u-boot-env"
[    1.241474] 0x000000440000-0x000000a40000 : "NAND.kernel"
[    1.250268] 0x000000a40000-0x00000d240000 : "NAND.file-system"
[    1.327504] 0x00000d240000-0x00000d280000 : "NAND.u-boot-spl-os"
[    1.334902] 0x00000d280000-0x00000de80000 : "NAND.data"
[    1.345724] 0x00000de80000-0x000010000000 : "NAND.reserved"
[    1.364721] ubi0: attaching mtd4
[    1.646141] ubi0 warning: scan_peb: valid VID header but corrupted EC header at PEB 791

To me that suggests a bug either in ubinize, when the filesystem gets compressed, or when it is supposed to get uncompressed.  Is that when it is written to flash (I'm using nandwrite from uboot) or by the driver when it gets mounted?  Any ideas?

  • Never mind.  I now realize it was user error; I was not thinking carefully enough about the flashing process: when programming other partitions, the commands to u-boot look like this:

    fatload mmc 0 0x82000000 dm38x-csk.dtb
    nand erase 0x0DA40000 0x40000
    nand write 0x82000000 0x0DA40000 0x40000

    where the size of the erase and the size of the write are equal, since the file is sized to fit the partition exactly, up to PEB boundary.  However, when programming the filesystem partition, I need to take care to look at the size of the ubinized file in bytes (which is automatically rounded up to a multiple of PEB size) and while I should erase the entire partition, I should only write the actual file size, e.g.:

    ## We write ubifs_csk.bin to the 208 MiB file-system partition,
    ## first erasing the entire partition, then populating it.
    fatload mmc 0 0x82000000 ubifs_csk.bin
    nand erase 0x00A40000 0x0D000000

    ## Note: When we write, we need to calculate the size of ubifs_csk.bin,
    ## in bytes in hex; it will already be a multiple of the PEB size, so no need to round up.
    nand write 0x82000000 0x00A40000 0x061C0000

    I would have been nice if any of the TI documentation for the IPNC RDK explained the process in more detail, so that it could be revised to reflect changes in the resulting software.  I bothered to answer my own question here to help anyone else who might have this problem.

    BTW, since it is not well-documented elsewhere:

    • 0x82000000 refers to an used address in RAM for temporary storage, so fatload mmc 0 0x82000000 <filename> means we are reading the given file from the 0th MMC unit (i.e., SD card) into RAM at this address
    • 0x00A40000 is the starting address of the NAND partition
    • 0x0D000000 is the physical size of the partition
    • 0x061C0000 is the actual size of the ubinized filesystem in bytes.  Note: This size is reported by the fatload command, so you just need to convert to hex.

  • Thank you for this information.
    Cesar