mini6410移植全攻略(11)--linux2.6.39 移植之支持nand flash (上)

本文详细介绍了如何修改TH6410设备驱动,包括注册平台设备、添加分区与时序配置、向内核注册信息等步骤,并指导如何编译内核以实现NAND闪存支持。通过本文,嵌入式开发者能够深入理解设备驱动与内核集成的过程,提升开发效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >




本文由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中加入:



&samsung_asoc_dma, #if 0 &s3c64xx_device_iisv4, &samsung_device_keypad, #endif //muge0913 add it &s3c_device_nand, #ifdef CONFIG_REGULAT



注:关于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)函数中,添加如下代码:


//muge0913 add codes here #ifdefCONFIG_MTD_NAND_S3C s3c_device_nand.name = "s3c6410-nand"; #endif s3c_nand_set_platdata(&th6410_nand_info);

二、修改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 SoCs



2) 修改Makfile告知内核编译s3c_nand.c

Makefile:添加下面部分



obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand.o

改好后保存退出



三、 当然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



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值