linux-2.6.31.1支持Nand Flash
目的:使NandFlash驱动同时支持64M, 256M或更高容量的NandFlash
将linux内核解压在/opt目录下,修改内核源码文件,添加对Nand Flash的支持
1. 修改arch/arm/plat-s3c24xx/common-smdk.c文件110行:
将static struct mtd_partition smdk_default_nand_part[]结构体的内容替换成下面的
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
};
2. 修改Nand读写匹配时间,查芯片资料得到值,改成如下:
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,
};
3. 修改Kconfig文件,增加NAND类型选择项。修改driver/mtd/nand/Kconfig文件,在172行增加下面
choice
prompt "Nand Flash Capacity Select"
depends on MTD
config 64M_NAND
boolean "64M NAND For TQ-2440"
depends on MTD
config 256M_NAND
boolean "256M NAND For TQ-2440"
depends on MTD
endchoice
4. 配置内核支持NandFlash
终端运行make menuconfig打开图形配置界面
Device Drivers --->
Memory Technology Device (MTD) support --->
[*] MTD partitioning support
NAND Device Support --->
NAND Flash support for Samsung S3C SoCs
[*] Samsung S3C NAND Hardware ECC
Nand Flash Capacity Select(256M NAND For TQ-2440) --->
(X) 256M NAND For TQ-2440
5. 重新编译内核
#make zImage
重新烧写内核
启动时如输出:
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 1283 at 0x00000a060000
Bad eraseblock 1539 at 0x00000c060000
Bad eraseblock 1618 at 0x00000ca40000
Bad eraseblock 1744 at 0x00000da00000
Creating 3 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000100000 : "boot"
0x000000120000-0x000000520000 : "kernel"
0x000000520000-0x000010000000 : "yaffs2"
说明驱动配置成功了。
6. 参考资料
天祥电子《linux-2.6.31移植v1.5》
目的:使NandFlash驱动同时支持64M, 256M或更高容量的NandFlash
将linux内核解压在/opt目录下,修改内核源码文件,添加对Nand Flash的支持
1. 修改arch/arm/plat-s3c24xx/common-smdk.c文件110行:
将static struct mtd_partition smdk_default_nand_part[]结构体的内容替换成下面的
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
};
2. 修改Nand读写匹配时间,查芯片资料得到值,改成如下:
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,
};
3. 修改Kconfig文件,增加NAND类型选择项。修改driver/mtd/nand/Kconfig文件,在172行增加下面
choice
prompt "Nand Flash Capacity Select"
depends on MTD
config 64M_NAND
boolean "64M NAND For TQ-2440"
depends on MTD
config 256M_NAND
boolean "256M NAND For TQ-2440"
depends on MTD
endchoice
4. 配置内核支持NandFlash
终端运行make menuconfig打开图形配置界面
Device Drivers --->
Memory Technology Device (MTD) support --->
[*] MTD partitioning support
NAND Device Support --->
NAND Flash support for Samsung S3C SoCs
[*] Samsung S3C NAND Hardware ECC
Nand Flash Capacity Select(256M NAND For TQ-2440) --->
(X) 256M NAND For TQ-2440
5. 重新编译内核
#make zImage
重新烧写内核
启动时如输出:
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 1283 at 0x00000a060000
Bad eraseblock 1539 at 0x00000c060000
Bad eraseblock 1618 at 0x00000ca40000
Bad eraseblock 1744 at 0x00000da00000
Creating 3 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x000000000000-0x000000100000 : "boot"
0x000000120000-0x000000520000 : "kernel"
0x000000520000-0x000010000000 : "yaffs2"
说明驱动配置成功了。
6. 参考资料
天祥电子《linux-2.6.31移植v1.5》