Hi!
I am working on BeagleBone varian board using Ångström distribution. Main difference is that NAND flash is installed on board.
Short story:
UBIFS partition/volume formatted/created in Linux does not work in U-Boot. Ubi part command in U-boot fails and corrupts this UBIFS volume. Later on Linux finds this UBIFS corrupted. I don't have any problems if this UBIFS is accessed pure from Linux. I have made nand flash additions from am335x-evm.dts to BeagleBone device tree. I have tried with ti,nand-ecc-opt = "bch8" (with kernel options CONFIG_MTD_NAND_OMAP_BCH and
OMAP_ECC_BCH8_CODE_HW) and without. In the latter case those kernel options were not active.
Longer store = operations and results:
======================================
BOOT => Linux
root@beaglebone:~# cat /proc/mtd
ddev: size erasesize name
mtd0: 00020000 00020000 "SPL1"
mtd1: 00020000 00020000 "SPL2"
mtd2: 00020000 00020000 "SPL3"
mtd3: 00020000 00020000 "SPL4"
mtd4: 001e0000 00020000 "U-boot"
mtd5: 00020000 00020000 "environment"
mtd6: 00500000 00020000 "Kernel"
mtd7: 0f880000 00020000 "File-System"
root@beaglebone:~# mtdinfo /dev/mtd7
mtd7
Name: File-System
Type: nand
Eraseblock size: 131072 bytes, 128.0 KiB
Amount of eraseblocks: 1988 (260571136 bytes, 248.5 MiB)
Minimum input/output unit size: 2048 bytes
Sub-page size: 512 bytes
OOB size: 64 bytes
Character device major/minor: 90:14
Bad blocks are allowed: true
Device is writable: true
root@beaglebone:~# ubiformat /dev/mtd7
ubiformat: mtd7 (nand), size 260571136 bytes (248.5 MiB), 1988 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 1987 -- 100 % complete
ubiformat: 1980 eraseblocks have valid erase counter, mean value is 2
ubiformat: 8 bad eraseblocks found, numbers: 70, 281, 310, 964, 1590, 1900, 1920, 1977
ubiformat: formatting eraseblock 1987 -- 100 % complete
root@beaglebone:~# ubiattach -m 7
[ 615.304815] UBI: default fastmap pool size: 95
[ 615.309712] UBI: default fastmap WL pool size: 25
[ 615.314727] UBI: attaching mtd7 to ubi0
[ 616.065041] UBI: scanning is finished
[ 616.092241] UBI: attached mtd7 (name "File-System", size 248 MiB) to ubi0
[ 616.099551] UBI: PEB size: 131072 bytes (128 KiB), LEB size: 129024 bytes
[ 616.106760] UBI: min./max. I/O unit sizes: 2048/2048, sub-page size 512
[ 616.113780] UBI: VID header offset: 512 (aligned 512), data offset: 2048
[ 616.120891] UBI: good PEBs: 1980, bad PEBs: 8, corrupted PEBs: 0
[ 616.127267] UBI: user volume: 0, internal volumes: 1, max. volumes count: 128
[ 616.134839] UBI: max/mean erase counter: 4/3, WL threshold: 4096, image sequence number: 1266322069
[ 616.144425] UBI: available PEBs: 1942, total reserved PEBs: 38, PEBs reserved for bad PEB handling: 32
[ 616.154993] UBI: background thread "ubi_bgt0d" started, PID 266
UBI device number 0, total 1980 LEBs (255467520 bytes, 243.6 MiB), available 1942 LEBs (250564608 bytes, 239.0 MiB), LEB size 129024 bytes (126.0 KiB)
root@beaglebone:~# ubimkvol /dev/ubi0 -N rootfs -m
Set volume size to 250564608
Volume ID 0, size 1942 LEBs (250564608 bytes, 239.0 MiB), LEB size 129024 bytes (126.0 KiB), dynamic, name "rootfs", alignment 1
root@beaglebone:~# mkdir /mnt/rootfs
root@beaglebone:~# mount -t ubifs ubi0:rootfs /mnt/rootfs
[ 1246.100061] UBIFS: default file-system created
[ 1246.129559] UBIFS: background thread "ubifs_bgt0_0" started, PID 279
[ 1246.181635] UBIFS: mounted UBI device 0, volume 0, name "rootfs"(null)
[ 1246.188687] UBIFS: LEB size: 129024 bytes (126 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
[ 1246.198379] UBIFS: FS size: 248887296 bytes (237 MiB, 1929 LEBs), journal size 12515328 bytes (11 MiB, 97 LEBs)
[ 1246.209066] UBIFS: reserved for root: 4952683 bytes (4836 KiB)
[ 1246.215270] UBIFS: media format: w4/r0 (latest is w4/r0), UUID BBB7B485-B786-43D4-9EF7-F237AF6C707B, small LPT model
root@beaglebone:~# cd /mnt/rootfs
root@beaglebone:/mnt/rootfs# mkdir testdir
root@beaglebone:/mnt/rootfs# cd testdir
root@beaglebone:/mnt/rootfs/testdir# echo testdata > testfile.txt
root@beaglebone:/mnt/rootfs/testdir# cat testfile.txt
testdata
root@beaglebone:/mnt/rootfs/testdir# sync
root@beaglebone:/mnt/rootfs/testdir# cd
root@beaglebone:~# umount /mnt/rootfs
[ 1774.802970] UBIFS: un-mount UBI device 0, volume 0
[ 1774.812940] UBIFS: background thread "ubifs_bgt0_0" stops
root@beaglebone:~# shutdown -h now
======================================
BOOT => U-Boot
U-Boot# mtdparts
device nand0 <omap2-nand.0>, # parts = 8
#: name size offset mask_flags
0: SPL 0x00020000 0x00000000 0
1: SPL.backup1 0x00020000 0x00020000 0
2: SPL.backup2 0x00020000 0x00040000 0
3: SPL.backup3 0x00020000 0x00060000 0
4: u-boot 0x001e0000 0x00080000 0
5: u-boot-env 0x00020000 0x00260000 0
6: kernel 0x00500000 0x00280000 0
7: rootfs 0x0f880000 0x00780000 0
active partition: nand0,0 - (SPL) 0x00020000 @ 0x00000000
defaults:
mtdids : nand0=omap2-nand.0
mtdparts: mtdparts=omap2-nand.0:128k(SPL),128k(SPL.backup1),128k(SPL.backup2),128k(SPL.backup3),1920k(u-boot),128k(u-boot-env),5m(kernel),-(rootfs)
U-Boot# ubi part rootfs
...... looooong list of following two lines
UBI error: ubi_io_read: error -74 while reading 512 bytes from PEB 1975:512, read 512 bytes
ECC: uncorrectable.
......then quite menay of following lines
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
ECC: uncorrectable.
...... then rest of messages
UBI error: ubi_io_read: error -74 while reading 129024 bytes from PEB 518:2048, read 129024 bytes
UBI warning: ubi_eba_copy_leb: error -74 while reading data from PEB 518
UBI error: wear_leveling_worker: error -74 while moving PEB 518 to PEB 1
UBI warning: ubi_ro_mode: switch to read-only mode
UBI error: do_work: work failed with error code -74
UBI: attached mtd1 to ubi0
UBI: MTD device name: "mtd=7"
UBI: MTD device size: 248 MiB
UBI: number of good PEBs: 1980
UBI: number of bad PEBs: 8
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: 15
UBI: total number of reserved PEBs: 1965
UBI: number of PEBs reserved for bad PEB handling: 19
UBI: max/mean erase counter: 6/3
U-Boot#
======================================
BOOT => Linux
ubiattach -m t
=>
.... exhaustive list of following blocks:
[ 184.135917] UBI warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 268:0, read only 64 bytes, retry
[ 184.148291] uncorrectable error :
[ 184.151767] UBI warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 268:0, read only 64 bytes, retry
[ 184.163943] uncorrectable error :
[ 184.167396] UBI warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 268:0, read only 64 bytes, retry
[ 184.179564] uncorrectable error :
[ 184.183016] UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 268:0, read 64 bytes
[ 184.193837] [<c001051d>] (unwind_backtrace+0x1/0x8c) from [<c022ca67>] (ubi_io_read+0x14f/0x1ec)
[ 184.203171] [<c022ca67>] (ubi_io_read+0x14f/0x1ec) from [<c022cc73>] (ubi_io_read_ec_hdr+0x47/0x12c)
[ 184.212870] [<c022cc73>] (ubi_io_read_ec_hdr+0x47/0x12c) from [<c022fc3b>] (scan_peb.part.4+0x1b/0x408)
[ 184.222843] [<c022fc3b>] (scan_peb.part.4+0x1b/0x408) from [<c0230095>] (scan_all+0x6d/0x73c)
[ 184.231895] [<c0230095>] (scan_all+0x6d/0x73c) from [<c0230a45>] (ubi_attach+0x169/0x244)
[ 184.240591] [<c0230a45>] (ubi_attach+0x169/0x244) from [<c0229373>] (ubi_attach_mtd_dev+0x4ff/0x980)
[ 184.250291] [<c0229373>] (ubi_attach_mtd_dev+0x4ff/0x980) from [<c0229997>] (ctrl_cdev_ioctl+0x7f/0x104)
[ 184.260357] [<c0229997>] (ctrl_cdev_ioctl+0x7f/0x104) from [<c009d6b1>] (vfs_ioctl+0x15/0x20)
[ 184.269412] [<c009d6b1>] (vfs_ioctl+0x15/0x20) from [<c009de57>] (do_vfs_ioctl+0x3ad/0x3e2)
[ 184.278281] [<c009de57>] (do_vfs_ioctl+0x3ad/0x3e2) from [<c009debd>] (sys_ioctl+0x31/0x4c)
[ 184.287157] [<c009debd>] (sys_ioctl+0x31/0x4c) from [<c000c641>] (ret_fast_syscall+0x1/0x46)
[ 184.296279] uncorrectable error :
[ 184.299721] uncorrectable error : [ 184.303366] UBI warning: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 268:512, read only 512 bytes, retry
[ 184.315740] uncorrectable error :
[ 184.319180] uncorrectable error : [ 184.322821] UBI warning: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 268:512, read only 512 bytes, retry
[ 184.335193] uncorrectable error :
[ 184.338631] uncorrectable error : [ 184.342272] UBI warning: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 268:512, read only 512 bytes, retry
[ 184.354643] uncorrectable error :
[ 184.358082] uncorrectable error : [ 184.361723] UBI error: ubi_io_read: error -74 (ECC error) while reading 512 bytes from PEB 268:512, read 512 bytes
[ 184.372704] [<c001051d>] (unwind_backtrace+0x1/0x8c) from [<c022ca67>] (ubi_io_read+0x14f/0x1ec)
[ 184.382032] [<c022ca67>] (ubi_io_read+0x14f/0x1ec) from [<c022cda7>] (ubi_io_read_vid_hdr+0x4f/0x134)
[ 184.391821] [<c022cda7>] (ubi_io_read_vid_hdr+0x4f/0x134) from [<c022fd29>] (scan_peb.part.4+0x109/0x408)
[ 184.401973] [<c022fd29>] (scan_peb.part.4+0x109/0x408) from [<c0230095>] (scan_all+0x6d/0x73c)
[ 184.411116] [<c0230095>] (scan_all+0x6d/0x73c) from [<c0230a45>] (ubi_attach+0x169/0x244)
[ 184.419804] [<c0230a45>] (ubi_attach+0x169/0x244) from [<c0229373>] (ubi_attach_mtd_dev+0x4ff/0x980)
[ 184.429503] [<c0229373>] (ubi_attach_mtd_dev+0x4ff/0x980) from [<c0229997>] (ctrl_cdev_ioctl+0x7f/0x104)
[ 184.439565] [<c0229997>] (ctrl_cdev_ioctl+0x7f/0x104) from [<c009d6b1>] (vfs_ioctl+0x15/0x20)
[ 184.448616] [<c009d6b1>] (vfs_ioctl+0x15/0x20) from [<c009de57>] (do_vfs_ioctl+0x3ad/0x3e2)
[ 184.457487] [<c009de57>] (do_vfs_ioctl+0x3ad/0x3e2) from [<c009debd>] (sys_ioctl+0x31/0x4c)
[ 184.466358] [<c009debd>] (sys_ioctl+0x31/0x4c) from [<c000c641>] (ret_fast_syscall+0x1/0x46)
[ 184.494290] uncorrectable error :
I hope you can find solution for this problem.
Thanks,
Matti