TI 3358_EVM NAND FLASH启动
[复制链接]
工作环境:ubuntu10.04
SDK:ti-sdk-am335x-evm-05.04.01.00
NANDFLAHS:MT29F2G08A
ubifs制作工具: mtd-utils-1.50,lzo2.06,zlib-1.2.7
mkfs.ubifs -r /home/richard/ti-sdk-am335x-evm-05.04.01.00/rootfs -m 2048 -c 1987-e 126976 -o ubifs.img
ubinize -o ubi.img -m 2048 -p 128KiB -s 2048 ubinize.cfg
从SD卡拷贝到flash中:
U-Boot # mmc rescan
U-Boot # nand erase 0x0 0x280000
U-Boot # saveenv
U-Boot # nandecc hw 2
U-Boot # fatload mmc 0 0x81000000 MLO
U-Boot # nand write 0x81000000 0x0 0x20000
U-Boot # nand write 0x81000000 0x20000 0x20000
U-Boot # nand write 0x81000000 0x40000 0x20000
U-Boot # nand write 0x81000000 0x60000 0x20000
U-Boot # fatload mmc 0 0x81000000 u-boot.img
U-Boot # nand write 0x81000000 0x80000 0x1E0000
U-Boot # fatload mmc 0 0x81000000 uImage
U-Boot# nandecc hw 2
U-Boot# nand erase 0x00280000 0x00500000
U-Boot# nand write 0x82000000 0x00280000 0x500000
u-boot# fatload mmc 0 0x82000000 ubi.img
u-boot# nand erase 0x00780000 0xF880000
u-boot# nandecc hw 2
u-boot# nand write 0x82000000 0x780000 0x7440000
设置成从NANDFLASH启动后,第一次log:
ubifs 初始化:
[ 1.467498] OneNAND driver initializing
[ 1.472320] UBI: attaching mtd7 to ubi0
[ 1.476379] UBI: physical eraseblock size: 131072 bytes (128 KiB)
[ 1.482910] UBI: logical eraseblock size: 126976 bytes
[ 1.488555] UBI: smallest flash I/O unit: 2048
[ 1.493438] UBI: VID header offset: 2048 (aligned 2048)
[ 1.499725] UBI: data offset: 4096
[ 3.081115] UBI: max. sequence number: 0
[ 3.117767] UBI: volume 0 ("rootfs") re-sized from 1652 to 1964 LEBs
[ 3.125579] UBI: attached mtd7 to ubi0
[ 3.129486] UBI: MTD device name: "File System"
[ 3.135223] UBI: MTD device size: 248 MiB
[ 3.140411] UBI: number of good PEBs: 1987
[ 3.145324] UBI: number of bad PEBs: 1
[ 3.149963] UBI: number of corrupted PEBs: 0
[ 3.154571] UBI: max. allowed volumes: 128
[ 3.159393] UBI: wear-leveling threshold: 4096
[ 3.164306] UBI: number of internal volumes: 1
[ 3.168945] UBI: number of user volumes: 1
[ 3.173583] UBI: available PEBs: 0
[ 3.178222] UBI: total number of reserved PEBs: 1987
[ 3.183380] UBI: number of PEBs reserved for bad PEB handling: 19
[ 3.189758] UBI: max/mean erase counter: 1/0
[ 3.194213] UBI: image sequence number: 0
[ 3.198608] UBI: background thread "ubi_bgt0d" started, PID 573
第二部分ubifs文件系统挂载:
[ 4.726135] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[ 4.732421] UBIFS: file system size: 245190656 bytes (239444 KiB, 233 MiB, 1931 LEBs)
[ 4.740814] UBIFS: journal size: 9023488 bytes (8812 KiB, 8 MiB, 72 LEBs)
[ 4.748443] UBIFS: media format: w4/r0 (latest is w4/r0)
[ 4.754516] UBIFS: default compressor: lzo
[ 4.758789] UBIFS: reserved for root: 0 bytes (0 KiB)
[ 4.766876] VFS: Mounted root (ubifs filesystem) on device 0:14.
[ 4.776306] devtmpfs: mounted
[ 4.779785] Freeing init memory: 244K
INIT: version 2.86 booting
Please wait: booting...
Starting udev
WARNING: -e needs -E or -F
[ 6.469848] UBI error: ubi_io_read: error -74 (ECC error) while reading 76 bytes from PEB 139:34576, read 76 bytes
[ 6.507080] UBI error: ubi_io_read: error -74 (ECC error) while reading 81 bytes from PEB 139:36712, read 81 bytes
[ 6.549316] UBI error: ubi_io_read: error -74 (ECC error) while reading 24 bytes from PEB 139:38888, read 24 bytes
[ 6.599090] UBI error: ubi_io_read: error -74 (ECC error) while reading 75 bytes from PEB 139:40320, read 75 bytes
[ 6.631317] UBI error: ubi_io_read: error -74 (ECC error) while reading 77 bytes from PEB 139:42464, read 77 bytes
[ 6.667877] UBI error: ubi_io_read: error -74 (ECC error) while reading 77 bytes from PEB 139:44728, read 77 bytes
[ 6.997009] udevd (711): /proc/711/oom_adj is deprecated, please use /proc/711/oom_score_adj instead.
[ 11.177185] alignment: ignoring faults is unsafe on this CPU. Defaulting to fixup mode.
Root filesystem already rw, not remounting
Caching udev devnodes
ALSA: Restoring mixer settings...
Configuring update-modules.
No state is present for card EVM
Configuring kernel-module-g-mass-storage.
Found hardware: "AM335X_EVM" "" "" "" ""
Hardware is initialized using a generic method
No state is present for card EVM
[ 12.306182] UBI error: ubi_io_read: error -74 (ECC error) while reading 63 bytes from PEB 139:50536, read 63 bytes
[ 12.320709] UBI error: ubi_io_read: error -74 (ECC error) while reading 67 bytes from PEB 139:50920, read 67 bytes
Configuring e2fsprogs.
update-alternatives: Error: cannot register alternative chattr to /usr/bin/chattr since it is already registered to /bin/chattr
update-alternatives: Linking //sbin/uuidd to uuidd.util-linux-ng
Configuring kernel-module-scsi-wait-scan.
[ 12.523284] UBI error: ubi_io_read: error -74 (ECC error) while reading 63 bytes from PEB 139:51312, read 63 bytes
Configuring kernel-module-g-file-storage.
Configuring kernel-module-g-ether.
[ 12.609527] UBI error: ubi_io_read: error -74 (ECC error) while reading 63 bytes from PEB 139:54648, read 63 bytes
[ 12.624023] UBI error: ubi_io_read: error -74 (ECC error) while reading 67 bytes from PEB 139:55104, read 67 bytes
Configuring kernel-module-hid-logitech-dj.
Configuring dbus.
Adding system startup for /etc/init.d/dbus-1.
[ 12.963165] UBI error: ubi_io_read: error -74 (ECC error) while reading 71 bytes from PEB 139:50144, read 71 bytes
[ 12.983245] UBI error: ubi_io_read: error -74 (ECC error) while reading 63 bytes from PEB 139:56344, read 63 bytes
[ 13.058654] UBI error: ubi_io_read: error -74 (ECC error) while reading 74 bytes from PEB 139:58840, read 74 bytes
[ 13.077148] UBI error: ubi_io_read: error -74 (ECC error) while reading 69 bytes from PEB 139:59240, read 69 bytes
[ 13.128448] UBI error: ubi_io_read: error -74 (ECC error) while reading 76 bytes from PEB 139:43584, read 76 bytes
[ 13.142974] UBI error: ubi_io_read: error -74 (ECC error) while reading 71 bytes from PEB 139:36400, read 71 bytes
[ 13.157440] UBI error: ubi_io_read: error -74 (ECC error) while reading 71 bytes from PEB 139:35688, read 71 bytes
[ 13.171905] UBI error: ubi_io_read: error -74 (ECC error) while reading 68 bytes from PEB 139:33552, read 68 bytes
[ 13.186370] UBI error: ubi_io_read: error -74 (ECC error) while reading 74 bytes from PEB 139:37848, read 74 bytes
[ 13.200836] UBI error: ubi_io_read: error -74 (ECC error) while reading 72 bytes from PEB 139:42864, read 72 bytes
[ 13.215301] UBI error: ubi_io_read: error -74 (ECC error) while reading 76 bytes from PEB 139:37120, read 76 bytes
[ 13.229736] UBI error: ubi_io_read: error -74 (ECC error) while reading 72 bytes from PEB 139:34264, read 72 bytes
[ 13.244201] UBI error: ubi_io_read: error -74 (ECC error) while reading 72 bytes from PEB 139:45128, read 72 bytes
[ 13.258636] UBI error: ubi_io_read: error -74 (ECC error) while reading 73 bytes from PEB 139:38568, read 73 bytes
[ 13.273101] UBI error: ubi_io_read: error -74 (ECC error) while reading 73 bytes from PEB 139:40000, read 73 bytes
[ 13.287567] UBI error: ubi_io_read: error -74 (ECC error) while reading 72 bytes from PEB 139:42152, read 72 bytes
[ 13.302001] UBI error: ubi_io_read: error -74 (ECC error) while reading 70 bytes from PEB 139:40720, read 70 bytes
[ 13.316467] UBI error: ubi_io_read: error -74 (ECC error) while reading 71 bytes from PEB 139:34976, read 71 bytes
[ 13.330932] UBI error: ubi_io_read: error -74 (ECC error) while reading 70 bytes from PEB 139:39288, read 70 bytes
[ 13.345367] UBI error: ubi_io_read: error -74 (ECC error) while reading 74 bytes from PEB 139:41432, read 74 bytes
[ 13.364288] UBI error: ubi_io_read: error -74 (ECC error) while reading 77 bytes from PEB 139:61112, read 77 bytes
[ 13.380096] UBI error: ubi_io_read: error -74 (ECC error) while reading 76 bytes from PEB 139:62856, read 76 bytes
[ 13.395935] UBI error: ubi_io_read: error -74 (ECC error) while reading 40 bytes from PEB 139:65496, read 40 bytes
[ 13.411560] UBI error: ubi_io_read: error -74 (ECC error) while reading 75 bytes from PEB 139:67256, read 75 bytes
[ 13.427307] UBI error: ubi_io_read: error -74 (ECC error) while reading 75 bytes from PEB 139:69008, read 75 bytes
[ 13.443450] UBI error: ubi_io_read: error -74 (ECC error) while reading 48 bytes from PEB 139:71632, read 48 bytes
[ 13.459136] UBI error: ubi_io_read: error -74 (ECC error) while reading 81 bytes from PEB 139:73400, read 81 bytes
[ 13.487304] UBI error: ubi_io_read: error -74 (ECC error) while reading 76 bytes from PEB 139:72912, read 76 bytes
[ 13.501831] UBI error: ubi_io_read: error -74 (ECC error) while reading 71 bytes from PEB 139:64128, read 71 bytes
[ 13.516296] UBI error: ubi_io_read: error -74 (ECC error) while reading 71 bytes from PEB 139:63256, read 71 bytes
[ 13.530761] UBI error: ubi_io_read: error -74 (ECC error) while reading 68 bytes from PEB 139:60640, read 68 bytes
[ 13.545196] UBI error: ubi_io_read: error -74 (ECC error) while reading 74 bytes from PEB 139:65896, read 74 bytes
[ 13.559661] UBI error: ubi_io_read: error -74 (ECC error) while reading 72 bytes from PEB 139:72032, read 72 bytes
[ 13.574127] UBI error: ubi_io_read: error -74 (ECC error) while reading 76 bytes from PEB 139:65008, read 76 bytes
[ 13.588592] UBI error: ubi_io_read: error -74 (ECC error) while reading 72 bytes from PEB 139:61512, read 72 bytes
[ 13.603057] UBI error: ubi_io_read: error -74 (ECC error) while reading 73 bytes from PEB 139:66776, read 73 bytes
[ 13.617523] UBI error: ubi_io_read: error -74 (ECC error) while reading 73 bytes from PEB 139:68528, read 73 bytes
[ 13.631958] UBI error: ubi_io_read: error -74 (ECC error) while reading 72 bytes from PEB 139:71160, read 72 bytes
[ 13.646423] UBI error: ubi_io_read: error -74 (ECC error) while reading 70 bytes from PEB 139:69408, read 70 bytes
[ 13.660888] UBI error: ubi_io_read: error -74 (ECC error) while reading 71 bytes from PEB 139:62384, read 71 bytes
[ 13.675323] UBI error: ubi_io_read: error -74 (ECC error) while reading 70 bytes from PEB 139:67656, read 70 bytes
[ 13.689788] UBI error: ubi_io_read: error -74 (ECC error) while reading 74 bytes from PEB 139:70280, read 74 bytes
[ 13.707733] UBI error: ubi_io_read: error -74 (ECC error) while reading 73 bytes from PEB 139:75088, read 73 bytes
[ 13.724182] UBI error: ubi_io_read: error -74 (ECC error) while reading 76 bytes from PEB 139:77704, read 76 bytes
[ 13.739837] UBI error: ubi_io_read: error -74 (ECC error) while reading 81 bytes from PEB 139:79448, read 81 bytes
[ 13.755432] UBI error: ubi_io_read: error -74 (ECC error) while reading 78 bytes from PEB 139:81224, read 78 bytes
[ 13.771392] UBI error: ubi_io_read: error -74 (ECC error) while reading 75 bytes from PEB 139:83856, read 75 bytes
[ 13.787292] UBI error: ubi_io_read: error -74 (ECC error) while reading 77 bytes from PEB 139:85608, read 77 bytes
[ 13.802978] UBI error: ubi_io_read: error -74 (ECC error) while reading 81 bytes from PEB 139:87352, read 81 bytes
[ 13.820343] UBI error: ubi_io_read: error -74 (ECC error) while reading 78 bytes from PEB 139:49744, read 78 bytes
[ 13.841522] UBI error: ubi_io_read: error -74 (ECC error) while reading 68 bytes from PEB 139:49352, read 68 bytes
[ 13.858093] UBI error: ubi_io_read: error -74 (ECC error) while reading 61 bytes from PEB 139:48968, read 61 bytes
Configuring network interfaces... [ 14.114471]
此时已有ecc错误但是文件系统还是挂载成功,可以进入到LINUX系统。
重启后log:
初始化和第一次相同:
挂载后:
[ 4.780731] UBI error: ubi_io_read: error -74 (ECC error) while reading 98304 bytes from PEB 139:32768, read 98304 bytes
[ 4.976715] UBIFS: recovery completed
[ 4.980560] UBIFS: mounted UBI device 0, volume 0, name "rootfs"
[ 4.986877] UBIFS: file system size: 247984128 bytes (242172 KiB, 236 MiB, 1953 LEBs)
[ 4.995239] UBIFS: journal size: 9023488 bytes (8812 KiB, 8 MiB, 72 LEBs)
[ 5.002868] UBIFS: media format: w4/r0 (latest is w4/r0)
[ 5.008941] UBIFS: default compressor: lzo
[ 5.013214] UBIFS: reserved for root: 0 bytes (0 KiB)
[ 5.019256] VFS: Mounted root (ubifs filesystem) on device 0:14.
[ 5.028686] devtmpfs: mounted
[ 5.032165] Freeing init memory: 244K
INIT: version 2.86 booting
Please wait: booting...
Starting udev
[ 5.892333] udevd (708): /proc/708/oom_adj is deprecated, please use /proc/708/oom_score_adj instead.
[ 9.751068] alignment: ignoring faults is unsafe on this CPU. Defaulting to fixup mode.
Root filesystem already rw, not remounting
Caching udev devnodes
ALSA: Restoring mixer settings...
Configuring network interfaces... [ 10.499725]
[ 10.499725] CPSW phy found : id is : 0x4dd074
[ 10.506683] PHY 0:01 not found
No state is present for card EVM
udhcpc (v1.13.2) started
Found hardware: "AM335X_EVM" "" "" "" ""
Hardware is initialized using a generic method
No state is present for card EVM
Sending discover...
Sending discover...
Sending discover...
No lease, forking to background
done.
Setting up IP spoofing protection: rp_filter.
Wed Apr 11 08:27:00 UTC 2012
INIT: Entering runlevel: 5
Starting system message bus: dbus.
Starting telnet daemon.
Starting syslogd/klogd: done
Starting thttpd.
_____ _____ _ _
| _ |___ ___ ___ ___ | _ |___ ___ |_|___ ___| |_
| | _| .'| . | . | | __| _| . | | | -_| _| _|
|__|__|_| |__,|_ |___| |__| |_| |___|_| |___|___|_|
|___| |___|
这次ecc错误的log比较少了,仍然可以进入系统。
再次重启后出现问题。
初始化log:
[ 1.472198] UBI: attaching mtd7 to ubi0
[ 1.476257] UBI: physical eraseblock size: 131072 bytes (128 KiB)
[ 1.482788] UBI: logical eraseblock size: 126976 bytes
[ 1.488433] UBI: smallest flash I/O unit: 2048
[ 1.493347] UBI: VID header offset: 2048 (aligned 2048)
[ 1.499603] UBI: data offset: 4096
[ 3.615936] UBI: max. sequence number: 8
[ 3.636047] UBI: attached mtd7 to ubi0
[ 3.639953] UBI: MTD device name: "File System"
[ 3.645721] UBI: MTD device size: 248 MiB
[ 3.650878] UBI: number of good PEBs: 1987
[ 3.655792] UBI: number of bad PEBs: 1
[ 3.660430] UBI: number of corrupted PEBs: 0
[ 3.665069] UBI: max. allowed volumes: 128
[ 3.669860] UBI: wear-leveling threshold: 4096
[ 3.674774] UBI: number of internal volumes: 1
[ 3.679412] UBI: number of user volumes: 1
[ 3.684051] UBI: available PEBs: 0
[ 3.688690] UBI: total number of reserved PEBs: 1987
[ 3.693847] UBI: number of PEBs reserved for bad PEB handling: 19
[ 3.700225] UBI: max/mean erase counter: 2/0
[ 3.704650] UBI: image sequence number: 0
[ 3.709014] UBI: background thread "ubi_bgt0d" started, PID 573
挂载时出问题:
[ 4.500732] UBI error: ubi_io_read: error -74 (ECC error) while reading 126976 bytes from PEB 4:4096, read 126976 bytes
[ 4.512756] UBIFS: scan_for_master return 0
[ 4.517181] UBIFS: scan_for_master validate_master=0
[ 4.522338] UBIFS: scan_for_master dbg_old_index_check_init=0
[ 4.528350] UBIFS: recovery needed
[ 4.535491] UBI error: ubi_io_read: error -74 (ECC error) while reading 11 bytes from PEB 10:6144, read 11 bytes
[ 4.546142] UBIFS error (pid 1): ubifs_leb_read: reading 11 bytes from LEB 8:2048 failed, error -74
[ 4.556152] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0)
[ 4.563507] Please append a correct "root=" boot option; here are the available partitions:
[ 4.572296] 1f00 128 mtdblock0 (driver?)
[ 4.577575] 1f01 128 mtdblock1 (driver?)
[ 4.582855] 1f02 128 mtdblock2 (driver?)
[ 4.588165] 1f03 128 mtdblock3 (driver?)
[ 4.593414] 1f04 1920 mtdblock4 (driver?)
[ 4.598724] 1f05 128 mtdblock5 (driver?)
[ 4.604003] 1f06 5120 mtdblock6 (driver?)
[ 4.609283] 1f07 254464 mtdblock7 (driver?)
[ 4.614562] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 4.623199] Backtrace:
[ 4.625793] [] (dump_backtrace+0x0/0x110) from [] (dump_stack+0x18/0x1c)
[ 4.634582] r6:cf828000 r5:c05aa1cc r4:c0618f48 r3:c05dbd48
[ 4.640533] [] (dump_stack+0x0/0x1c) from [] (panic+0x6c/0x1a0)
[ 4.648529] [] (panic+0x0/0x1a0) from [] (mount_block_root+0x184/0x228)
[ 4.657257] r3:c05dbd48 r2:00000000 r1:cf81df78 r0:c04e4bf0
[ 4.663177] r7:00008000
[ 4.665832] [] (mount_block_root+0x0/0x228) from [] (prepare_namespace+0xac/0x1e0)
[ 4.675537] [] (prepare_namespace+0x0/0x1e0) from [] (kernel_init+0x124/0x130)
[ 4.684906] r5:c05b83d0 r4:c05b83d0
[ 4.688659] [] (kernel_init+0x0/0x130) from [] (do_exit+0x0/0x67c)
[ 4.696929] r5:c057c7e8 r4:00000000
注意:初始化时的不同我已经标记出来。
之前有在别人帖子看到说是有的内核驱动不支持sub_page,但是ubifs按照sub_page来写,把ecc区写错。按照介绍方法改正,无效果。
另外发现内核中ecc用的是 Hamming code,uboot nand write 时用的是bch8,把内核中nand驱动ecc改为bch8,则把整个flash 的ubi文件系统区域oob区全部写错。把uboot nand write 前用 Hamming code,进入内核,全部ecc error -74.
还有其他人介绍,可能制作的mkfs.ubifs和内核中ecc算法不一致导致。建议linux内核版本和mtd-utils工具时间相近。
我用的mtd-utils-1.5是2012-5月发布的,linux-3.2.0是2011-11月发布的。
也有可能是这方面原因,还是有其他原因呢?