本文由muge0913编写,希望给嵌入开发者带来一些帮助,并希望能和大家交流技术,若有不对的地方,或有更好的方法请指出。
转载请注明出处:http://blog.youkuaiyun.com/muge0913/article/details/7242620
一、修改arch/arm/mach-s3c64xx/mach-th6410.c文件
1)注册platform设备(nand)。
在static struct platform_device *th6410_devices[]__initdata中加入:
注:关于nandflash平台设备更多知识在arch/arm/plat-samsung/dev-nand.c和arch/arm/plat-samsung/include/plat/nand.h以及arch/arm/plat-samsung/include/plat/regs-nand.hdev-nand.c:定义了nand平台设备、nand平台设备所需资源、平台的一些数据信息等。nand.h:定义了芯片本身相关的信息、bsp对nandflash的一些时序设置信息等。regs-nand.h:CPU中NANDFLASH各种寄存器的定义。
2)添加分区、时序等
/* * Configuring Nandflash on TH6410 */ vi arch/arm/mach-s3c64xx/mach-th6410.c 第117行 struct mtd_partition mini6410_nand_part[] = { { .name = "Bootloader", .offset = 0, .size = (4 * 128 *SZ_1K), .mask_flags = MTD_CAP_NANDFLASH, }, { .name = "Kernel", .offset = (4 * 128 *SZ_1K), .size = (5*SZ_1M) , .mask_flags = MTD_CAP_NANDFLASH, }, { .name = "File System", .offset = MTDPART_OFS_APPEND, .size = MTDPART_SIZ_FULL, } };3)向内核注册信息。
在static void __init th6410_machine_init(void)函数中,添加如下代码:
二、修改s3c_nand.c文件
其实该文件开源的百度即有。可以查看已修好的s3c_nand.c文件。
1)修改drivers/mtd/nand/目录下的KconfigKconfig:添加下面部分
configMTD_NAND_S3C2410_HWECC bool "Samsung S3C NAND Hardware ECC" depends on MTD_NAND_S3C2410 help Enable the use of the controller's internal ECCgenerator when using NAND. Early versions of the chips have hadproblems with incorrect ECC generation, and if using these, thedefault of software ECC is preferable. config MTD_NAND_S3C tristate "NAND Flash support for S3C SoC" depends on (ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX)&& MTD_NAND help This enables the NAND flash controller on the S3C. No board specfic support is done by this driver, eachboard must advertise a platform_device for the driver toattach. config MTD_NAND_S3C_DEBUG bool "S3C NAND driver debug" depends on MTD_NAND_S3C help Enable debugging of the S3C NAND driver config MTD_NAND_S3C_HWECC bool "S3C NAND Hardware ECC" depends on MTD_NAND_S3C help Enable the use of the S3C's internal ECC generatorwhen using NAND. Early versions of the chip have hadproblems with incorrect ECC generation, and if using these, the defaultof software ECC is preferable. If you lay down a device with the hardware ECC, thenyou will currently not be able to switch to software, as thereis no implementation for ECC method used by the S3C config MTD_NAND_NDFC tristate "NDFC NanD Flash Controller" depends on 4xx select MTD_NAND_ECC_SMC help NDFC Nand Flash Controllers are integrated in IBM/AMCC's4xx SoCs2) 修改Makfile告知内核编译s3c_nand.c
Makefile:添加下面部分
改好后保存退出
三、 当然drivers/mtd/nand/s3c_nand_mlc.fo
也要拷贝过来,这是友善没有开源的一个驱动之一,所以不用研究了,拷过来就是了。
四、修改drivers/mtd/nand/nand_base.c文件
直接将drivers/mtd/nand/nand_base.c拷过来覆盖就可以了。
五、编译内核
然后再
1)make menuconfig
Device Drivers--->
<*> Memory Technology Device(MTD) support --->
[*]MTD partitioning support
[*] Command line partition table parsing
<*>Direct char device access to MTD devices
<*>Caching block device access to MTD devices
<*>NAND Device Support --->
< > NAND Flash support forSamsung S3C SoCs 去掉不要选
<*> NAND Flash support for S3C SoC
[*] S3C NAND Hardware ECC
2)make zImage
编译信息说明nand分区成功。
Creating 3 MTD partitions on "NAND 2GiB 3,3V 8-bit":
0x000000000000-0x000000400000 : "Bootloader"
0x000000400000-0x000000c00000 : "Kernel"
0x000000c00000-0x000080000000 : "File System"
编译信息见下文!!
本文由muge0913编写,希望给嵌入开发者带来一些帮助,并希望能和大家交流技术,若有不对的地方,或有更好的方法请指出。
转载请注明出处:http://blog.youkuaiyun.com/muge0913/article/details/7242620