免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2219 | 回复: 4
打印 上一主题 下一主题

mini6410移植全攻略(11)--linux2.6.39 移植之支持nand flash (上) . [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-02-09 14:33 |只看该作者 |倒序浏览
mini6410移植全攻略(11)--linux2.6.39 移植之支持nand flash (上) .









    本文由muge0913编写,希望给嵌入开发者带来一些帮助,并希望能和大家交流技术,若有不对的地方,或有更好的方法请指出。

     转载请注明出处:http://blog.csdn.net/muge0913/article/details/7242620



一、修改arch/arm/mach-s3c64xx/mach-th6410.c文件

1)注册platform设备(nand)。

在static struct platform_device *th6410_devices[]__initdata中加入:







   

[cpp] view plaincopyprint?
  1. 01.&samsung_asoc_dma,  
  2. 02.#if 0   
  3. 03.    &s3c64xx_device_iisv4,  
  4. 04.    &samsung_device_keypad,  
  5. 05.#endif   
  6. 06.//muge0913 add it   
  7. 07.    &s3c_device_nand,  
  8. 08.#ifdef CONFIG_REGULAT   
  9. &samsung_asoc_dma,
  10. #if 0
  11.     &s3c64xx_device_iisv4,
  12.     &samsung_device_keypad,
  13. #endif
  14. //muge0913 add it
  15.     &s3c_device_nand,
  16. #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)添加分区、时序等


[cpp] view plaincopyprint?
  1. 01./*
  2. 02. * Configuring Nandflash on TH6410
  3. 03. */  
  4. 04.vi arch/arm/mach-s3c64xx/mach-th6410.c  
  5. 05.  
  6. 06.第117行  
  7. 07.  
  8. 08.struct mtd_partition mini6410_nand_part[] = {              
  9. 09.  
  10. 10.    {  
  11. 11.  
  12. 12.        .name        = "Bootloader",  
  13. 13.  
  14. 14.        .offset        = 0,  
  15. 15.  
  16. 16.        .size        = (4 * 128 *SZ_1K),  
  17. 17.  
  18. 18.        .mask_flags    = MTD_CAP_NANDFLASH,  
  19. 19.  
  20. 20.    },  
  21. 21.  
  22. 22.    {  
  23. 23.  
  24. 24.        .name        = "Kernel",  
  25. 25.  
  26. 26.        .offset        = (4 * 128 *SZ_1K),  
  27. 27.  
  28. 28.        .size        = (5*SZ_1M) ,  
  29. 29.  
  30. 30.        .mask_flags    = MTD_CAP_NANDFLASH,  
  31. 31.  
  32. 32.    },  
  33. 33.  
  34. 34.    {  
  35. 35.  
  36. 36.        .name        = "File System",  
  37. 37.  
  38. 38.        .offset        = MTDPART_OFS_APPEND,  
  39. 39.  
  40. 40.        .size       = MTDPART_SIZ_FULL,  
  41. 41.  
  42. 42.    }  
  43. 43.  
  44. 44.};         
  45. /*
  46. * Configuring Nandflash on TH6410
  47. */
  48. vi arch/arm/mach-s3c64xx/mach-th6410.c

  49. 第117行

  50. struct mtd_partition mini6410_nand_part[] = {            

  51.     {

  52.         .name        = "Bootloader",

  53.         .offset        = 0,

  54.         .size        = (4 * 128 *SZ_1K),

  55.         .mask_flags    = MTD_CAP_NANDFLASH,

  56.     },

  57.     {

  58.         .name        = "Kernel",

  59.         .offset        = (4 * 128 *SZ_1K),

  60.         .size        = (5*SZ_1M) ,

  61.         .mask_flags    = MTD_CAP_NANDFLASH,

  62.     },

  63.     {

  64.         .name        = "File System",

  65.         .offset        = MTDPART_OFS_APPEND,

  66.         .size       = MTDPART_SIZ_FULL,

  67.     }

  68. };      
复制代码
3)向内核注册信息。

在static void __init th6410_machine_init(void)函数中,添加如下代码:





[cpp] view plaincopyprint?
  1. 01.//muge0913 add codes here   
  2. 02.  
  3. 03.#ifdefCONFIG_MTD_NAND_S3C   
  4. 04.  
  5. 05.s3c_device_nand.name = "s3c6410-nand";  
  6. 06.  
  7. 07.#endif   
  8. 08.  
  9. 09.    s3c_nand_set_platdata(&th6410_nand_info);  
  10. //muge0913 add codes here

  11. #ifdefCONFIG_MTD_NAND_S3C

  12. s3c_device_nand.name = "s3c6410-nand";

  13. #endif

  14.     s3c_nand_set_platdata(&th6410_nand_info);
复制代码
二、修改s3c_nand.c文件




其实该文件开源的百度即有。可以查看已修好的s3c_nand.c文件。

1)修改drivers/mtd/nand/目录下的KconfigKconfig:添加下面部分


[cpp] view plaincopyprint?
  1. 01.configMTD_NAND_S3C2410_HWECC  
  2. 02.    bool "Samsung S3C NAND Hardware ECC"  
  3. 03.    depends on MTD_NAND_S3C2410  
  4. 04.    help  
  5. 05.      Enable the use of the controller's internal ECCgenerator when  
  6. 06.      using NAND. Early versions of the chips have hadproblems with  
  7. 07.      incorrect ECC generation, and if using these, thedefault of  
  8. 08.      software ECC is preferable.  
  9. 09.  
  10. 10.config MTD_NAND_S3C  
  11. 11.    tristate "NAND Flash support for S3C SoC"  
  12. 12.    depends on (ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX)&& MTD_NAND  
  13. 13.    help  
  14. 14.      This enables the NAND flash controller on the S3C.  
  15. 15.      No board specfic support is done by this driver, eachboard  
  16. 16.      must advertise a platform_device for the driver toattach.  
  17. 17.config MTD_NAND_S3C_DEBUG  
  18. 18.    bool "S3C NAND driver debug"  
  19. 19.    depends on MTD_NAND_S3C  
  20. 20.    help  
  21. 21.      Enable debugging of the S3C NAND driver  
  22. 22.config MTD_NAND_S3C_HWECC  
  23. 23.    bool "S3C NAND Hardware ECC"  
  24. 24.    depends on MTD_NAND_S3C  
  25. 25.    help  
  26. 26.      Enable the use of the S3C's internal ECC generatorwhen  
  27. 27.      using NAND. Early versions of the chip have hadproblems with  
  28. 28.      incorrect ECC generation, and if using these, the defaultof  
  29. 29.      software ECC is preferable.  
  30. 30.      If you lay down a device with the hardware ECC, thenyou will  
  31. 31.      currently not be able to switch to software, as thereis no  
  32. 32.      implementation for ECC method used by the S3C  
  33. 33.config MTD_NAND_NDFC  
  34. 34.    tristate "NDFC NanD Flash Controller"  
  35. 35.    depends on 4xx  
  36. 36.    select MTD_NAND_ECC_SMC  
  37. 37.    help  
  38. 38.     NDFC Nand Flash Controllers are integrated in IBM/AMCC's4xx SoCs  
  39. configMTD_NAND_S3C2410_HWECC
  40.     bool "Samsung S3C NAND Hardware ECC"
  41.     depends on MTD_NAND_S3C2410
  42.     help
  43.       Enable the use of the controller's internal ECCgenerator when
  44.       using NAND. Early versions of the chips have hadproblems with
  45.       incorrect ECC generation, and if using these, thedefault of
  46.       software ECC is preferable.

  47. config MTD_NAND_S3C
  48.     tristate "NAND Flash support for S3C SoC"
  49.     depends on (ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX)&& MTD_NAND
  50.     help
  51.       This enables the NAND flash controller on the S3C.
  52.       No board specfic support is done by this driver, eachboard
  53.       must advertise a platform_device for the driver toattach.
  54. config MTD_NAND_S3C_DEBUG
  55.     bool "S3C NAND driver debug"
  56.     depends on MTD_NAND_S3C
  57.     help
  58.       Enable debugging of the S3C NAND driver
  59. config MTD_NAND_S3C_HWECC
  60.     bool "S3C NAND Hardware ECC"
  61.     depends on MTD_NAND_S3C
  62.     help
  63.       Enable the use of the S3C's internal ECC generatorwhen
  64.       using NAND. Early versions of the chip have hadproblems with
  65.       incorrect ECC generation, and if using these, the defaultof
  66.       software ECC is preferable.
  67.       If you lay down a device with the hardware ECC, thenyou will
  68.       currently not be able to switch to software, as thereis no
  69.       implementation for ECC method used by the S3C
  70. config MTD_NAND_NDFC
  71.     tristate "NDFC NanD Flash Controller"
  72.     depends on 4xx
  73.     select MTD_NAND_ECC_SMC
  74.     help
  75.      NDFC Nand Flash Controllers are integrated in IBM/AMCC's4xx SoCs
复制代码
2) 修改Makfile告知内核编译s3c_nand.c

Makefile:添加下面部分

  1. [cpp] view plaincopyprint?
  2. 01.obj-$(CONFIG_MTD_NAND_S3C)       += s3c_nand.o  
  3. 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. 1)make menuconfig

  2.    Device Drivers--->

  3.              <*> Memory Technology Device(MTD) support  --->

  4.                              [*]  MTD partitioning support

  5.                               [*]     Command line partition table parsing

  6.                               <*>  Direct char device access to MTD devices

  7.                              <*>  Caching block device access to MTD devices

  8.                              <*>  NAND Device Support  --->

  9.                                                      < >   NAND Flash support forSamsung S3C SoCs  去掉不要选

  10.                                                       <*>   NAND Flash support for S3C SoC

  11.                                                                  [*]     S3C NAND Hardware ECC

  12.                            
复制代码
2)make zImage



论坛徽章:
0
2 [报告]
发表于 2012-02-09 14:33 |只看该作者
谢谢分享

论坛徽章:
0
3 [报告]
发表于 2012-02-10 14:17 |只看该作者
参观参观



sfp

论坛徽章:
0
4 [报告]
发表于 2012-04-08 23:46 |只看该作者
其实我很想知道它的那个没开源驱动,自己写裸板是在不方便

论坛徽章:
0
5 [报告]
发表于 2012-04-09 05:12 |只看该作者
不要和我比懒,我懒得和你比

顶上去










signature..................................
仙府之缘
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP