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 BCH8 ECC error

Hi,

we have a problem with UBIFS BCH8 error correction.

We have designed a custom board (based on the TI 8148 IPNC platform) that has a DM8147 chip with a 8 bit NAND flash.
We are using kernel of IPNC RDK 3.5.0 (Linux 2.6.37) and UBIFS filesystems on the NAND flash.

We would like to use hardware BCH8 error correction on all MTD partitions. The BCH8 ECC ensures 8 bits correction on every 512 bytes flash area.
This works well on our raw partitions (bootloader and kernel partitions), but the error correction does not work on partitions under UBI/UBIFS.

When we dump all MTD partitions with nanddump, it reports a lot of corrected and uncorrectable bitflips on the UBI partitions, but the bootloader and kernel partitions are totally perfect.

When we generate some bitflips (with nanddump/flash_erase/nandwrite) in an (unmounted and detached) UBI filesystem, that becomes a fatally damaged (unmountable) filesystem.

So the bitflip error correction does not work under UBI.

We tried the new kernel from the IPNC RDK 3.8.0, but the problem still persists.


What can we do?


NAND flash parameters:
  - Type: MT29F1G08ABCH
  - Bus width: 8 bit
  - Size: 128 MiB
  - Page size: 2048 Byte
  - Subpage size: 512 Byte
  - Erase block size: 128 KiB
  - OOB size per page: 64 Byte

MTD partition layout:
  dev:    size   erasesize  name
  mtd0: 00020000 00020000 "U-Boot Stage 1"
  mtd1: 000c0000 00020000 "U-Boot Stage 2"
  mtd2: 00020000 00020000 "U-Boot Env Vars"
  mtd3: 00700000 00020000 "Linux Kernel"
  mtd4: 03c00000 00020000 "Root Filesystem"
  mtd5: 03400000 00020000 "Config Filesystem"
  mtd6: 00800000 00020000 "Log Filesystem"

Create root filesystem: (/dev/mtd4: 60 MiB)
  mkfs.ubifs -o rootfs.ubifs -d rootfs -e 0x1f800 -c 512 -m 0x800 -x zlib
  ubinize -o rootfs.ubi -m 0x800 -p 0x20000 -s 0x200 rootfs.cfg
  ubiformat -y -s 0x200 -f rootfs.ubi /dev/mtd4

rootfs.cfg content:
  [ubifs]
  mode=ubi
  vol_id=0
  vol_type=dynamic
  vol_name=rootfs
  vol_alignment=1
  vol_flags=autoresize
  image=rootfs.ubifs

~# ubiattach /dev/ubi_ctrl -p /dev/mtd6
[  208.360000] UBI: attaching mtd6 to ubi2
[  208.370000] UBI: physical eraseblock size:   131072 bytes (128 KiB)
[  208.370000] UBI: logical eraseblock size:    129024 bytes
[  208.380000] UBI: smallest flash I/O unit:    2048
[  208.380000] UBI: sub-page size:              512
[  208.390000] UBI: VID header offset:          512 (aligned 512)
[  208.390000] UBI: data offset:                2048
[  208.420000] UBI error: check_corruption: PEB 4 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 inspection
[  208.460000] UBI error: check_corruption: PEB 8 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 inspection
[  208.500000] UBI error: check_corruption: PEB 16 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 inspection
[  208.550000] UBI error: check_corruption: PEB 28 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 inspection
[  208.590000] UBI error: check_corruption: PEB 40 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 inspection
[  208.630000] UBI error: check_corruption: PEB 48 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 inspection
[  208.680000] UBI error: check_corruption: PEB 54 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 inspection
[  208.720000] UBI error: check_corruption: PEB 56 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 inspection
[  208.740000] UBI error: check_what_we_have: 8 PEBs are corrupted and preserved
[  208.750000] Corrupted PEBs are: 56 54 48 40 28 16 8 4
[  208.750000] UBI error: check_what_we_have: too many corrupted PEBs, refusing
[  208.760000] =============================================================================
[  208.760000] BUG blkdev_ioc: Objects remaining on kmem_cache_close()
[  208.760000] -----------------------------------------------------------------------------
[  208.760000]
[  208.760000] INFO: Slab 0xc06be620 objects=102 used=3 fp=0xc6f31fc8 flags=0x0080
[  208.760000] Backtrace:
[  208.760000] [<c0047e60>] (dump_backtrace+0x0/0x110) from [<c04320dc>] (dump_stack+0x18/0x1c)
[  208.760000]  r7:c6556b40 r6:c06be620 r5:c6c6cd80 r4:c66ebc78
[  208.760000] [<c04320c4>] (dump_stack+0x0/0x1c) from [<c00cf378>] (slab_err+0x58/0x64)
[  208.760000] [<c00cf320>] (slab_err+0x0/0x64) from [<c00d286c>] (kmem_cache_destroy+0x12c/0x304)
[  208.760000]  r3:c04fb0d0 r2:c04ebbc5
[  208.760000]  r6:c6c6cd80 r5:c06be620 r4:00000000
[  208.760000] [<c00d2740>] (kmem_cache_destroy+0x0/0x304) from [<c02d3a90>] (ubi_scan_destroy_si+0x220/0x234)
[  208.760000] [<c02d3870>] (ubi_scan_destroy_si+0x0/0x234) from [<c02d4f20>] (ubi_scan+0x958/0xa08)
[  208.760000]  r7:ffffffea r6:00000003 r5:00000040 r4:c66f2cec
[  208.760000] [<c02d45c8>] (ubi_scan+0x0/0xa08) from [<c02cc748>] (ubi_attach_mtd_dev+0x46c/0xb2c)
[  208.760000] [<c02cc2dc>] (ubi_attach_mtd_dev+0x0/0xb2c) from [<c02cd034>] (ctrl_cdev_ioctl+0xd8/0x168)
[  208.760000] [<c02ccf5c>] (ctrl_cdev_ioctl+0x0/0x168) from [<c00e2f8c>] (vfs_ioctl+0x28/0x44)
[  208.760000]  r6:00000003 r5:c66f2800 r4:c6e8c830
[  208.760000] [<c00e2f64>] (vfs_ioctl+0x0/0x44) from [<c00e3720>] (do_vfs_ioctl+0x558/0x5a0)
[  208.760000] [<c00e31c8>] (do_vfs_ioctl+0x0/0x5a0) from [<c00e37c0>] (sys_ioctl+0x58/0x7c)
[  208.760000] [<c00e3768>] (sys_ioctl+0x0/0x7c) from [<c0043f40>] (ret_fast_syscall+0x0/0x30)
[  208.760000]  r8:c00440e4 r7:00000036 r6:bedeee8f r5:00000003 r4:bedeeb68
[  208.760000] INFO: Object 0xc6f310c8 @offset=200
[  208.760000] INFO: Object 0xc6f310f0 @offset=240
[  208.760000] INFO: Object 0xc6f31118 @offset=280
[  208.940000] SLUB blkdev_ioc: kmem_cache_destroy called for cache that still has objects.
[  208.950000] Backtrace:
[  208.950000] [<c0047e60>] (dump_backtrace+0x0/0x110) from [<c04320dc>] (dump_stack+0x18/0x1c)
[  208.960000]  r7:00000fc8 r6:c6c6cd80 r5:c6c0144c r4:c6f31ff0
[  208.970000] [<c04320c4>] (dump_stack+0x0/0x1c) from [<c00d29d0>] (kmem_cache_destroy+0x290/0x304)
[  208.980000] [<c00d2740>] (kmem_cache_destroy+0x0/0x304) from [<c02d3a90>] (ubi_scan_destroy_si+0x220/0x234)
[  208.990000] [<c02d3870>] (ubi_scan_destroy_si+0x0/0x234) from [<c02d4f20>] (ubi_scan+0x958/0xa08)
[  209.000000]  r7:ffffffea r6:00000003 r5:00000040 r4:c66f2cec
[  209.000000] [<c02d45c8>] (ubi_scan+0x0/0xa08) from [<c02cc748>] (ubi_attach_mtd_dev+0x46c/0xb2c)
[  209.010000] [<c02cc2dc>] (ubi_attach_mtd_dev+0x0/0xb2c) from [<c02cd034>] (ctrl_cdev_ioctl+0xd8/0x168)
[  209.020000] [<c02ccf5c>] (ctrl_cdev_ioctl+0x0/0x168) from [<c00e2f8c>] (vfs_ioctl+0x28/0x44)
[  209.030000]  r6:00000003 r5:c66f2800 r4:c6e8c830
[  209.030000] [<c00e2f64>] (vfs_ioctl+0x0/0x44) from [<c00e3720>] (do_vfs_ioctl+0x558/0x5a0)
[  209.040000] [<c00e31c8>] (do_vfs_ioctl+0x0/0x5a0) from [<c00e37c0>] (sys_ioctl+0x58/0x7c)
[  209.050000] [<c00e3768>] (sys_ioctl+0x0/0x7c) from [<c0043f40>] (ret_fast_syscall+0x0/0x30)
[  209.060000]  r8:c00440e4 r7:00000036 r6:bedeee8f r5:00000003 r4:bedeeb68
ubiattach: error!: cannot attach "/dev/mtd6"
           error 22 (Invalid argument)
~#

[    4.830000] UBIFS error (pid 121): ubifs_decompress: cannot decompress 2151 bytes, compressor zlib, error -22
[    4.840000] UBIFS error (pid 121): read_block: bad data node (block 10, inode 669)
[    4.850000] UBIFS error (pid 121): do_readpage: cannot read page 10 of inode 669, error -22

[    6.280000] UBIFS error (pid 136): read_block: bad data node (block 166, inode 173)
[    6.300000] UBIFS error (pid 136): do_readpage: cannot read page 166 of inode 173, error -22

Thank you!

Peter

  • If you weren't having any problems before you started using nanddump/nandwrite on UBI pages, my first guess would be that UBIFS uses a different ECC layout.  This makes some sense since the dm814x boot ROM expects a really weird and inconvenient layout.

    Try dumping the raw content (I think nanddump --noecc) and compare the OOB area of an UBI-page with that of a bootloader-page.

  • Thank you for your reply.

    The ECC layout has been already checked by us, and this is the same under UBI and under bootloader.
    OOB layout: (64 bytes)
      - Bad block markers: 2 bytes [0xFF 0xFF]
      - ECC for first subpage: 13 bytes
      - 14th byte of first ECC (compatibility): 1 byte [0x00]
      - ECC for second subpage: 13 bytes
      - 14th byte of second ECC (compatibility): 1 byte [0x00]
      - ECC for third subpage: 13 bytes
      - 14th byte of third ECC (compatibility): 1 byte [0x00]
      - ECC for fourth subpage: 13 bytes
      - 14th byte of fourth ECC (compatibility): 1 byte [0x00]
      - Reserved: 6 bytes [0xFF 0xFF 0xFF 0xFF 0xFF 0xFF]
    We are using nanddump --noecc --oob to dump raw data of MTD partition. Then we are using flash_erase and nandwrite --noecc --oob to write back the bitflipped data.

    Best regards,
    Peter