全部博文(92)
分类: 嵌入式
2010-04-07 16:11:20
Linux-2.6.31内核移植(二)支持NAND
U-boot的include/configs/TX2440.h 中会定义各种u-boot参数
bootargs=noinitrd root=/dev/mtdblock2 init=/linuxrc console=ttySAC0
root=/dev/mtdblock2:是指在mtdblock2分区下挂载根文件系统root
既然u-boot这样设置了分区挂载,那么在linux-2.6.31的内核里也要做相应的设置,在nand flash 分区中将block2 设置为yaffs2:
修改:arch/arm/plat-s3c24xx/common-smdk.c文件,在第110行:
这里我们要使nandflash同时支持64M,256M或更高容量。
static struct mtd_partition smdk_default_nand_part[] = {
#if defined(CONFIG_64M_NAND)
[0] = {
.name = "boot",
.offset = 0,
.size = SZ_1M,
},
[1] = {
.name = "kernel",
.offset = SZ_1M + SZ_128K,
.size = SZ_4M,
},
[2] = {
.name = "yaffs2",
.offset = SZ_1M + SZ_128K + SZ_4M,
.size = SZ_64M - SZ_4M - SZ_1M - SZ_128K,
}
#elif defined(CONFIG_256M_NAND)
[0] = {
.name = "boot",
.offset = 0,
.size = SZ_1M,
},
[1] = {
.name = "kernel",
.offset = SZ_1M + SZ_128K,
.size = SZ_4M,
},
[2] = {
.name = "yaffs2",
.offset = SZ_1M + SZ_128K + SZ_4M,
.size = SZ_256M - SZ_4M - SZ_1M - SZ_128K,
}
#endif
};
接下来修改Nand读写匹配时间,这个改不改应该问题都不大,我认为是根据Nand的读写特性相关的,也就是查芯片资料得到的值,每种Nand的值都不一样,还是在这个文件中第140行:
static struct s3c2410_platform_nand smdk_nand_info = {
.tacls = 10,
.twrph0 = 25,
.twrph1 = 10,
.nr_sets = ARRAY_SIZE(smdk_nand_sets),
.sets = smdk_nand_sets,
};
修改Kconfig文件,在配置时选择NAND类型,修改driver/mtd/nand/Kconfig,在172行,添加:
config MTD_NAND_S3C2410_HWECC
bool "Samsung S3C NAND Hardware ECC"
depends on MTD_NAND_S3C2410
help
Enable the use of the controller's internal ECC generator when
using NAND. Early versions of the chips have had problems with
incorrect ECC generation, and if using these, the default of
software ECC is preferable.
choice
prompt "Nand Flash Capacity Select"
depends on MTD
config 64M_NAND
boolean "64M NAND For TX-2440A"
depends on MTD
config 256M_NAND
boolean "256M NAND For TX-2440A"
depends on MTD
endchoice
配置内核,支持NandFlash
Device Drivers --->
<*> Memory Technology Device (MTD) support --->
[*] MTD partitioning support
<*> NAND Device Support --->
<*> NAND Flash support for S3C2410/S3C2440 SoC
[*] S3C2410 NAND Hardware ECC //这个一定要选上
Nand Flash Capacity Select(256M Nand For TX-2440A)--->
重新make zImage 用USB下载到开发板上,看到nand flash 的打印信息:
S3C24XX NAND Driver, (c) 2004 Simtec Electronics
s3c24xx-nand s3c2440-nand: Tacls=1, 10ns Twrph0=3 30ns, Twrph1=1 10ns
s3c24xx-nand s3c2440-nand: NAND hardware ECC
NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 338 at 0x000002a40000
Bad eraseblock 752 at 0x000005e00000
Bad eraseblock 897 at 0x000007020000
Bad eraseblock 1181 at 0x0000093a0000
Bad eraseblock 1192 at 0x000009500000
Bad eraseblock 1490 at 0x00000ba40000
Creating 3 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000100000 : "boot"
0x000000120000-0x000000520000 : "kernel"
0x000000520000-0x000004000000 : "yaffs2"