Editing those findings did not help. In fact I was referring a wrong file in my last message. File README.omap3 refers to is: arch/arm/include/asm/arch-omap3/omap_gpmc.h Whereas in my last message I was referring: arch/arm/include/asm/arch-am33x/omap_gpmc.h
However, there was one mistake also in that correct file. Definition found in that file has wrong .eccbytes value. #define GPMC_NAND_HW_BCH8_ECC_LAYOUT {\ .eccbytes = 56,\ .eccpos = {12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,\ 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,\ 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,\ 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63},\ .oobfree = {\ {.offset = 2,\ .length = 10 } } \ } Unfortunately fixing that to correct value 52 did not help either. So, I'm running out out ideas. I'll enclose steps I executed both on Linux and u-boot side and their outcome. These are from the initial state before trying to fix that omap_gpmc.h. ====================================== 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 : [ Best Regards, Matti 2013/10/25 matti kaasinen <matti.kaasi...@gmail.com> > Hi Gary, > I think I have found something that could explain this behaviour. They > happen to be on u-boot side. In fact I just wrote to u-boot mailin list > about this. I'll copy it below: > > Linux 3.8.13 seems to use 52 ecc bytes mapping them to positions 12..64. > > Default u-boot set-up found from include/asm/arch-am33x/omap_ > gpmc.h define: > #define GPMC_NAND_HW_BCH8_ECC_LAYOUT {\ > .eccbytes = 56,\ > .eccpos = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,\ > 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,\ > 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,\ > 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,\ > 52, 53, 54, 55, 56, 57},\ > .oobfree = {\ > {.offset = 58,\ > .length = 6 } } \ > } > that seems using 56 ecc bytes, mapping them to positions 2..57. > This 56 bytes seems fighting with the fact found from u-boot > README.omap3/BCH8 set-up that points, that > * CONFIG_SYS_NAND_ECCBYTES must be 13 for this BCH8 set-up > On the other hand, am335x_evm.h use CONFIG_SYS_NAND_ECCBYTES to calculate > CONFIG_SYS_NAND_ECCTOTAL that is same as .eccbytes in > GPMC_NAND_HW_BCH8_ECC_LAYOUT definition. Value 13 gives 52 bytes that is > compatible with Linux whereas 14 gives that 56 found from > GPMC_NAND_HW_BCH8_ECC_LAYOUT definition above. > > Also text in README.omap3 states: > "The NAND OOB layout is the same as in linux kernel, if the linux kernel > BCH8 > implementation for OMAP3 works for you so the u-boot version should also. > When you require the SPL to read with BCH8 there are two more configs to > change: > > * CONFIG_SYS_NAND_ECCPOS (must be the same as .eccpos in > GPMC_NAND_HW_BCH8_ECC_LAYOUT defined in > arch/arm/include/asm/arch- > omap3/omap_gpmc.h) > * CONFIG_SYS_NAND_ECCSIZE must be 512 > * CONFIG_SYS_NAND_ECCBYTES must be 13 for this BCH8 setup" > > I would interpret this so that no modifications are needed > GPMC_NAND_HW_BCH8_ECC_LAYOUT structure. > That can't be true even if the mapping was the same as .eccbytes field > have wrong value considering what the last line states for BCH8 set-up. > If above assumption is correct, isn't this really a bug in omap_gpmc.h, > not just a Linux version related problem? > > Regards, > Matti > > > 2013/10/25 Gary Thomas <g...@mlbassoc.com> > >> On 2013-10-25 00:01, matti kaasinen wrote: >> >>> Hi! >>> >>> Do anyone happen to know how u-boot should be set to access Linux created >>> ubifs partition correctly? I'm working on beaglebone variant board with >>> nand flash addition. Linux side (3.8.13) seems working fine provided >>> that I >>> don't mount it in u-boot side. However, if i do, it gets corrupted. For >>> instance, if I attach Linux created ubifs partition (ubi part >>> <partition>), >>> i will get tons of "ECC: uncorrectable" errors. After re-boot also Linux >>> side will get these errors. >>> >>> I'm using Angstrom distribution with following details. >>> BB_VERSION = "1.17.0" >>> TARGET_ARCH = "arm" >>> TARGET_OS = "linux-gnueabi" >>> MACHINE = "beaglebone" >>> DISTRO = "angstrom" >>> DISTRO_VERSION = "v2012.12" >>> TUNE_FEATURES = "armv7a vfp neon cortexa8" >>> TARGET_FPU = "vfp-neon" >>> >>> Any hints warmly appreciated. >>> >> >> Details about your NAND device will probably be necessary as well as the >> actual errors and operations you tried. >> >> I suspect that the problem may have to do with NAND sub-page writes. I've >> experienced this on other platforms and was able to work around it by not >> letting UBI use them. For example on my 2K Micron NAND device, I use this >> command to attach: >> # ubiattach /dev/ubi_ctrl -m 3 -O 2048 >> The -O option forces the UBI system to only use 2048 byte writes, as >> opposed >> to the 512 byte sub-pages that it would like to use. >> >> If you want to boot with this as your file system, use these kernel >> command >> line options: >> root=ubi0:root ubi.mtd=3,2048 rootfstype=ubifs >> >> See if this helps. If not, send as many details as you can. >> >> -- >> ------------------------------**------------------------------ >> Gary Thomas | Consulting for the >> MLB Associates | Embedded world >> ------------------------------**------------------------------ >> >> ______________________________**_________________ >> Angstrom-distro-devel mailing list >> Angstrom-distro-devel@**linuxtogo.org<Angstrom-distro-devel@linuxtogo.org> >> http://lists.linuxtogo.org/**cgi-bin/mailman/listinfo/** >> angstrom-distro-devel<http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/angstrom-distro-devel> >> > > _______________________________________________ Angstrom-distro-devel mailing list Angstrom-distro-devel@linuxtogo.org http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/angstrom-distro-devel