初试mini2440 nandflash驱动移植

今日根据《Mini2440_Linux移植开发实战指南》一文进行nandflash驱动
的移植出现了不少问题。不知道是我操作失误还是该文编写出现错漏导致的。
    首先按照步骤修改相关信息之后执行make zImage出现了不少错误:
    其中有代表性的错误如下:
arch/arm/mach-s3c2440/mach-mini2440.c:189: error: array type has incomplete element type
arch/arm/mach-s3c2440/mach-mini2440.c:190: error: array index in non-array initializer
arch/arm/mach-s3c2440/mach-mini2440.c:190: error: (near initialization for 'smdk_default_nand_part')
arch/arm/mach-s3c2440/mach-mini2440.c:191: error: field name not in record or union initializer
arch/arm/mach-s3c2440/mach-mini2440.c:191: error: (near initialization for 'smdk_default_nand_part')

arch/arm/mach-s3c2440/mach-mini2440.c:193: error: unknown field 'tacls' specified in initializer
arch/arm/mach-s3c2440/mach-mini2440.c:193: warning: excess elements in struct initializer
arch/arm/mach-s3c2440/mach-mini2440.c:193: warning: (near initialization for 'mini2440_nand_info')
arch/arm/mach-s3c2440/mach-mini2440.c:194: error: unknown field 'twrph0' specified in initializer
arch/arm/mach-s3c2440/mach-mini2440.c:194: warning: excess elements in struct initializer
arch/arm/mach-s3c2440/mach-mini2440.c:194: warning: (near initialization for 'mini2440_nand_info')
arch/arm/mach-s3c2440/mach-mini2440.c:195: error: unknown field 'twrph1' specified in initializer
arch/arm/mach-s3c2440/mach-mini2440.c:195: warning: excess elements in struct initializer
arch/arm/mach-s3c2440/mach-mini2440.c:195: warning: (near initialization for 'mini2440_nand_info')
arch/arm/mach-s3c2440/mach-mini2440.c:196: error: unknown field 'nr_sets' specified in initializer
arch/arm/mach-s3c2440/mach-mini2440.c:196: warning: type defaults to 'int' in declaration of 'type name'
arch/arm/mach-s3c2440/mach-mini2440.c:196: warning: type defaults to 'int' in declaration of 'type name'
arch/arm/mach-s3c2440/mach-mini2440.c:196: error: negative width in bit-field '<anonymous>'
arch/arm/mach-s3c2440/mach-mini2440.c:196: warning: excess elements in struct initializer
arch/arm/mach-s3c2440/mach-mini2440.c:196: warning: (near initialization for 'mini2440_nand_info')
arch/arm/mach-s3c2440/mach-mini2440.c:197: error: unknown field 'sets' specified in initializer
arch/arm/mach-s3c2440/mach-mini2440.c:197: warning: excess elements in struct initializer
arch/arm/mach-s3c2440/mach-mini2440.c:197: warning: (near initialization for 'mini2440_nand_info')
arch/arm/mach-s3c2440/mach-mini2440.c:198: error: unknown field 'ingnore_unset_ecc' specified in initializer
arch/arm/mach-s3c2440/mach-mini2440.c:198: warning: excess elements in struct initializer

开始以为是输错代码,搞了一个上午都没有搞明白。
到了下午,通过查找网上的资料(还真难找),再对比原来2.6.32内核中外国爱好者编写的mach-mini2440.c
文件,隐约知道是头文件的问题。
于是在自己的mach-mini2440.c中加入
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/nand_ecc.h>
#include <linux/mtd/partitions.h>
#include <plat/nand.h>
果然make过了,不过仍然有一行warning:
arch/arm/mach-s3c2440/mach-mini2440.c:233: warning: 'mini2440_nand_info' defined but not used
把生成的zImage下载到板子上运行,也没有出现该文中所描述的情形,初步估计还是移植失败
看来该文漏洞不少,这次不得不依靠网上的高手了。



   昨天的问题
    warning: 'mini2440_nand_info' defined but not used
    今日终于还是解决了,原来除了昨天说
的之外还得添加别的东西,在这个函数:
static void __init mini2440_map_io(void)
{
}
中加入以下代码:
s3c_device_nand.dev.platform_data = &mini2440_nand_info;
    再次make zImage,没有再出现warning,下载到板子,
成功出现了nand flash的分区信息。
    当然网上还有所谓的“石器时代”的移植方法,迟下再
试,毕竟这里头很多内在原理还是没搞明白的。当下先对文
件系统的移植作个了解,过一阵子再回过头来详细分析。
    我对这两天的移植有2个感受:一是“尽信书不如无书”,
二是不学一些原始的方法,单是站在巨人的肩上去开发是
学不透彻的,虽然移植成功但是还是糊里糊涂。。。。。。

你可能感兴趣的:(C++,c,linux,C#,Flash)