捉虫日记 0002: Can only write 7602176 bytes data to nand flash

来自Jack's Lab
跳转到: 导航, 搜索

1 Phenomenon

Micron NAND 256MiB 3,3V 8-bit (MT29F2G08AACWP, 2048+64 bytes) 64 pages per block, 128K block size (64 * 2048) Driver got from Mindspeed

Using dd to write 20MB data into /dev/mtd0(nand) is always failed. Following is the message:

    root@packet-iad:/root> dd if=jffs2-128k of=/dev/mtd0 bs=128k
    dd: writing `/dev/mtd0': Input/output error
    59+0 records in
    58+0 records out
    7602176 bytes (7.6 MB) copied, 37.587 s, 202 kB/s



2 Analysis

4/24 9:08 The root cause should be the driver's bbt control subsystem has some issue. When I modprobe the driver's module the console output following message:

        root@localhost:/root> modprobe comcerto-nand
        erasesize = 131072; writesize = 2048; oobsize = 64
        Bad eraseblock 58 at 0x00740000
        Bad eraseblock 97 at 0x00c20000
        Bad eraseblock 101 at 0x00ca0000
        Bad eraseblock 620 at 0x04d80000
        Bad eraseblock 971 at 0x07960000
        Bad eraseblock 1481 at 0x0b920000

The first bad block of this nand chip is the 59th block. So when the driver write data into the 58 blocks there is no any error. This size is 58 * 128 * 1024 = 7602176 bytes. But when the driver try to write the 59th block this operation would be failed. Because this is a bad block. Generally nand driver should avoid reading/writing bad blocks. I strange why this driver write bad blocks.



3 Solution

This problem can be solved by using nandwrite tools to write the data into nand flash. dd use the raw data write function which has no bad block checking.

















个人工具
名字空间

变换
操作
导航
工具箱