Chinaunix首页 | 论坛 | 博客
  • 博客访问: 563780
  • 博文数量: 252
  • 博客积分: 1068
  • 博客等级: 少尉
  • 技术积分: 1775
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-05 21:33
文章分类

全部博文(252)

文章存档

2013年(21)

2012年(231)

分类:

2012-05-31 20:16:51

今日根据《Mini2440_Linux移植开发实战指南》一文进行nandflash驱动
的移植出现了不少问题。不知道是我操作失误还是该文编写出现错漏导致的。
    首先按照步骤修改相关信息之后执行make zImage出现了不少错误:
    其中有代表性的错误如下:

  1. arch/arm/mach-s3c2440/mach-mini2440.c:189: error: array type has incomplete element type
  2. arch/arm/mach-s3c2440/mach-mini2440.c:190: error: array index in non-array initializer
  3. arch/arm/mach-s3c2440/mach-mini2440.c:190: error: (near initialization for 'smdk_default_nand_part')
  4. arch/arm/mach-s3c2440/mach-mini2440.c:191: error: field name not in record or union initializer
  5. arch/arm/mach-s3c2440/mach-mini2440.c:191: error: (near initialization for 'smdk_default_nand_part')
  6. arch/arm/mach-s3c2440/mach-mini2440.c:193: error: unknown field 'tacls' specified in initializer
  7. arch/arm/mach-s3c2440/mach-mini2440.c:193: warning: excess elements in struct initializer
  8. arch/arm/mach-s3c2440/mach-mini2440.c:193: warning: (near initialization for 'mini2440_nand_info')
  9. arch/arm/mach-s3c2440/mach-mini2440.c:194: error: unknown field 'twrph0' specified in initializer
  10. arch/arm/mach-s3c2440/mach-mini2440.c:194: warning: excess elements in struct initializer
  11. arch/arm/mach-s3c2440/mach-mini2440.c:194: warning: (near initialization for 'mini2440_nand_info')
  12. arch/arm/mach-s3c2440/mach-mini2440.c:195: error: unknown field 'twrph1' specified in initializer
  13. arch/arm/mach-s3c2440/mach-mini2440.c:195: warning: excess elements in struct initializer
  14. arch/arm/mach-s3c2440/mach-mini2440.c:195: warning: (near initialization for 'mini2440_nand_info')
  15. arch/arm/mach-s3c2440/mach-mini2440.c:196: error: unknown field 'nr_sets' specified in initializer
  16. arch/arm/mach-s3c2440/mach-mini2440.c:196: warning: type defaults to 'int' in declaration of 'type name'
  17. arch/arm/mach-s3c2440/mach-mini2440.c:196: warning: type defaults to 'int' in declaration of 'type name'
  18. arch/arm/mach-s3c2440/mach-mini2440.c:196: error: negative width in bit-field '<anonymous>'
  19. arch/arm/mach-s3c2440/mach-mini2440.c:196: warning: excess elements in struct initializer
  20. arch/arm/mach-s3c2440/mach-mini2440.c:196: warning: (near initialization for 'mini2440_nand_info')
  21. arch/arm/mach-s3c2440/mach-mini2440.c:197: error: unknown field 'sets' specified in initializer
  22. arch/arm/mach-s3c2440/mach-mini2440.c:197: warning: excess elements in struct initializer
  23. arch/arm/mach-s3c2440/mach-mini2440.c:197: warning: (near initialization for 'mini2440_nand_info')
  24. arch/arm/mach-s3c2440/mach-mini2440.c:198: error: unknown field 'ingnore_unset_ecc' specified in initializer
  25. arch/arm/mach-s3c2440/mach-mini2440.c:198: warning: excess elements in struct initializer

开始以为是输错代码,搞了一个上午都没有搞明白。
到了下午,通过查找网上的资料(还真难找),再对比原来2.6.32内核中外国爱好者编写的mach-mini2440.c
文件,隐约知道是头文件的问题。
于是在自己的mach-mini2440.c中加入

  1. #include <linux/mtd/mtd.h>
  2. #include <linux/mtd/nand.h>
  3. #include <linux/mtd/nand_ecc.h>
  4. #include <linux/mtd/partitions.h>
  5. #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个感受:一是“尽信书不如无书”,
二是不学一些原始的方法,单是站在巨人的肩上去开发是
学不透彻的,虽然移植成功但是还是糊里糊涂。。。。。。 

**********************************************************************************************************************************************/


另:在我自己的移植过程中,又做了如下修改:

        在/opt/FriendlyARM/mini2440/linux-2.6.32.2/arch/arm/mach-s3c2440/mini2440.c中,结构定义语句要放在函数之前,具体内容如下:

       static struct mtd_partition mini2440_default_nand_part[] __initdata = {
       [0] = {
               //这里是bootloader所在的分区,可以放置u-boot,supervivi等内容,对应/dev/mtdblock0
               .name = "supervivi",
               .size = 0x00040000,
               .offset = 0,
             },
       [1] = {
               //这里是supervivi的参数区,其实也属于bootloader的一部分,如果u-boot比较大,
               //可以把此区域覆盖掉,不会影响系统启动,对应/dev/mtdblock1
               .name = "param",
               .offset = 0x00040000,
               .size = 0x00020000,
             },
       [2] = {
               //内核所在的分区,大小为5M,足够放下大部分自己定制的举行内核了,比如内核使用了更大的
               //Linux Logo图片等,对应/dev/mtdblock2
               .name = "Kernel",
               .offset = 0x00060000,
               .size = 0x00500000,
             },
       [3] = {
               //文件系统分区,友善之臂主要用来存放yaffs2文件系统内容,对应/dev/mtdblock3
               .name = "root",
               .offset= 0x00560000,
               .size = 1024 * 1024 *1024,
             },
       [4] = {
               //此区域代表了整片的nand flash,主要是预留使用,比如以后可以通过应用程序访问读取/dev/
               //mtdblock4就能实现备份整片nand flash了。
               .name = "nand",
               .offset = 0x00000000,
               .size = 1024 * 1024 * 1024,
             },
      };
            //下面是开发板的nand flash设置表,因为板子上只有一片,因此也就只有一个表
         static struct s3c2410_nand_set mini2440_nand_sets[] __initdata = {
             [0] = {
                     .name = "NAND",
                     .nr_chips = 1,
                     .nr_partitions = ARRAY_SIZE(mini2440_default_nand_part),
                     .partitions = mini2440_default_nand_part,
                    },
              };
             //下面是nand flash本身的一些特性,一般需要对照datasheet填写,大部分情况下按照以下参数填写即可
         static struct s3c2410_platform_nand mini2440_nand_info __initdata = {
               .tacls = 20,
               .twrph0 = 60,
               .twrph1 = 20,
               .nr_sets = ARRAY_SIZE(mini2440_nand_sets),
               .sets = mini2440_nand_sets,
               .ignore_unset_ecc = 1,
              };
           //此外,还应把nand flash设备注册到系统中,此工作显示在第158行
static void __init mini2440_map_io(void)
 {
         s3c24xx_init_io(mini2440_iodesc, ARRAY_SIZE(mini2440_iodesc));
         s3c24xx_init_clocks(12000000);
         s3c24xx_init_uarts(mini2440_uartcfgs, ARRAY_SIZE(mini2440_uartcfgs));
         s3c_device_nand.dev.platform_data = &mini2440_nand_info;
 }
static void __init mini2440_machine_init(void)
 {
         s3c24xx_fb_set_platdata(&mini2440_fb_info);
         s3c_i2c0_set_platdata(NULL);
         platform_add_devices(mini2440_devices, ARRAY_SIZE(mini2440_devices));
         //smdk_machine_init();
 }
 MACHINE_START(MINI2440, "FriendlyARM Mini2440 development board")
         /* Maintainer: Ben Dooks */
         .phys_io        = S3C2410_PA_UART,
         .io_pg_offst    = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
         .boot_params    = S3C2410_SDRAM_PA + 0x100,
         .init_irq       = s3c24xx_init_irq,
         .map_io         = mini2440_map_io,
         .init_machine   = mini2440_machine_init,
         .timer          = &s3c24xx_timer,
 MACHINE_END


阅读(698) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~