jz2440 nandflash

Posted oucaijun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jz2440 nandflash相关的知识,希望对你有一定的参考价值。

芯片的型号:K9F2G08U0C
芯片大小:256M Byte记忆单元阵列:(256M + 8,192K)bit x 8bit

2048 blocks * 64 pages/block  * 2048 bytes/page = [256M Bytes]

这个芯片的写操作是以页为单位的,擦除是以块为单位的.
擦出页面的起始地址以及偏移量应该是2048*64的整数倍.

 

问题:
jz2440不能成功地从nandflash读取文件系统, 使用的韦老大给的fs_mini_mdev.yaffs2.

===========================================================
方法一:

0. 查看坏块,重新规划分区

用nfs启动后,使用mount挂载/dev/mtdblock3的时候打印的坏块信息:
nand bad block:
    block 29 is bad
    block 377 is bad
    block 486 is bad
    block 491 is bad
    block 659 is bad
    block 740 is bad
    block 877 is bad
    block 1412 is bad
    block 1444 is bad
    block 1539 is bad
    block 1993 is bad

    
new root area: 我的想法是直接跨过坏块,在好的区域安排mtdblock3.
    block 30 - 360
    0x3C0000 -- 0x2D00000;  size = 0x2940000; (测试用的root大小889bc0, 够用了)

    
    
1. 修改arch/arm/plat-s3c24xx/common-smdk.c    
    /* NAND parititon from 2.4.18-swl5 */
    static struct mtd_partition smdk_default_nand_part[] = {
            [0] = {
            .name   = "bootloader",
            .size   = 0x00040000,
                    .offset = 0,
            },  
            [1] = {
            .name   = "params",
            .offset = MTDPART_OFS_APPEND,
            .size   = 0x00020000,
            },  
            [2] = {
            .name   = "kernel",
            .offset = MTDPART_OFS_APPEND,
            .size   = 0x00200000,
            },  
            [3] = {
            .name   = "root",
            //直接跨过坏块,在好的区域安排mtdblock3.
            .offset = 0x3C0000, //MTDPART_OFS_APPEND,  
            .size   = 0x2940000, //MTDPART_SIZ_FULL,
            }   
    };
    
2. 重新烧写, 设置从nand读取文件系统
    {
        tftp 30000000 fs_mini_mdev.yaffs2 ; nand erase root; //Bytes transferred = 8952768 (889bc0 hex)
        nand write.yaffs2 30000000 0x3C0000 0x2940000;
        
        set bootcmd tftp 0x30007fc0 uImage \;bootm 0x30007fc0;
        set bootargs noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0; save;
    }

NOT GOOD

===========================================================

jz2440不能成功地从nandflash读取文件系统, 使用韦老大给的fs_mini_mdev.yaffs2.
第二次尝试:
我猜想是不是不能跨过某些区域分块,因此考虑把kernel分区往后延伸.

0. 查看坏块, 重新规划
{这里奇怪的是算出来的坏块和mount打印的坏块不同}
NAND erase: device 0 offset 0x260000, size 0xfda0000
Skipping bad block at  0x005e0000       (block:  47   )                                     
Skipping bad block at  0x03160000       (block:  395   )                                     
Skipping bad block at  0x03f00000       (block:  504   )                                     
Skipping bad block at  0x03fa0000       (block:  509   )                                     
Skipping bad block at  0x054a0000       (block:  677   )                                     
Skipping bad block at  0x05ec0000       (block:  758   )                                     
Skipping bad block at  0x06fe0000       (block:  895   )                                     
Skipping bad block at  0x0b2c0000       (block:  1430   )                                     
Skipping bad block at  0x0b6c0000       (block:  1462   )                                     
Skipping bad block at  0x0c2a0000       (block:  1557   )                                     
Skipping bad block at  0x0fb60000       (block:  2011   )                                     
Erasing at 0xffe0000 -- 100% complete.

{
    new new root area:
        block 3 - 47
        0x00060000-0x005e0000 ;  size = 0x580000;
        
    new new root area:
        block 47 - all
        0x005e0000 -- all;  size = all - 0x3C0000;
}

1. 修改arch/arm/plat-s3c24xx/common-smdk.c
    /* NAND parititon from 2.4.18-swl5 */

    static struct mtd_partition smdk_default_nand_part[] = {
            [0] = {
            .name   = "bootloader",
            .size   = 0x00040000,
                    .offset = 0,
            },  
            [1] = {
            .name   = "params",
            .offset = MTDPART_OFS_APPEND,
            .size   = 0x00020000,
            },  
            [2] = {
            .name   = "kernel",
            .offset = MTDPART_OFS_APPEND,
            .size   = 0x580000,
            },  
            [3] = {
            .name   = "root",
            .offset = MTDPART_OFS_APPEND ,
            .size   = MTDPART_SIZ_FULL,
            }   
    };
    
2. 重新烧写, 设置从nand读取文件系统
    {
        tftp 30000000 fs_mini_mdev.yaffs2 ; nand erase root; //Bytes transferred = 8952768 (889bc0 hex)
        nand write.yaffs2 30000000 0x005e0000 0x8A0000;
        
        set bootcmd tftp 0x30007fc0 uImage \;bootm 0x30007fc0;
        set bootargs noinitrd root=/dev/mtdblock3 init=/linuxrc console=ttySAC0; save;
    }

仍然不能正确启动:
{
drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
end_request: I/O error, dev mtdblock3, sector 2
EXT3-fs: unable to read superblock
end_request: I/O error, dev mtdblock3, sector 0
Buffer I/O error on device mtdblock3, logical block 0
end_request: I/O error, dev mtdblock3, sector 0
Buffer I/O error on device mtdblock3, logical block 0
end_request: I/O error, dev mtdblock3, sector 8
Buffer I/O error on device mtdblock3, logical block 1
end_request: I/O error, dev mtdblock3, sector 8
Buffer I/O error on device mtdblock3, logical block 1
end_request: I/O error, dev mtdblock3, sector 16
Buffer I/O error on device mtdblock3, logical block 2
end_request: I/O error, dev mtdblock3, sector 16
Buffer I/O error on device mtdblock3, logical block 2
end_request: I/O error, dev mtdblock3, sector 24
Buffer I/O error on device mtdblock3, logical block 3
end_request: I/O error, dev mtdblock3, sector 24
Buffer I/O error on device mtdblock3, logical block 3
end_request: I/O error, dev mtdblock3, sector 0
FAT: unable to read boot sector
VFS: Cannot open root device "mtdblock3" or unknown-block(31,3)
Please append a correct "root=" boot option; here are the available partitions:
1f00        256 mtdblock0 (driver?)
1f01        128 mtdblock1 (driver?)
1f02       5632 mtdblock2 (driver?)
1f03     256128 mtdblock3 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)
}

===========================================================

以上是关于jz2440 nandflash的主要内容,如果未能解决你的问题,请参考以下文章

Jz2440开发板熟悉

基于JZ2440开发板编写bootloader总结

移植u-boot-2015.10到JZ2440开发板——设置nand分区,环境变量保存地址和其它默认参数

Jz2440 环境安装

9.NandFlash的驱动_读操作2440

s3c2440——Nandflash