歡迎您光臨本站 註冊首頁

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

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







   

view plaincopyprint?01.&samsung_asoc_dma,  
02.#if 0   
03.    &s3c64xx_device_iisv4,  
04.    &samsung_device_keypad,  
05.#endif   
06.//muge0913 add it   
07.    &s3c_device_nand,  
08.#ifdef CONFIG_REGULAT   
&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)添加分區、時序等


view plaincopyprint?01./*
02. * Configuring Nandflash on TH6410
03. */  
04.vi arch/arm/mach-s3c64xx/mach-th6410.c  
05.  
06.第117行  
07.  
08.struct mtd_partition mini6410_nand_part[] = {              
09.  
10.    {  
11.  
12.        .name        = "Bootloader",  
13.  
14.        .offset        = 0,  
15.  
16.        .size        = (4 * 128 *SZ_1K),  
17.  
18.        .mask_flags    = MTD_CAP_NANDFLASH,  
19.  
20.    },  
21.  
22.    {  
23.  
24.        .name        = "Kernel",  
25.  
26.        .offset        = (4 * 128 *SZ_1K),  
27.  
28.        .size        = (5*SZ_1M) ,  
29.  
30.        .mask_flags    = MTD_CAP_NANDFLASH,  
31.  
32.    },  
33.  
34.    {  
35.  
36.        .name        = "File System",  
37.  
38.        .offset        = MTDPART_OFS_APPEND,  
39.  
40.        .size       = MTDPART_SIZ_FULL,  
41.  
42.    }  
43.  
44.};         
/*
* 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)函數中,添加如下代碼:





view plaincopyprint?01.//muge0913 add codes here   
02.  
03.#ifdefCONFIG_MTD_NAND_S3C   
04.  
05.s3c_device_nand.name = "s3c6410-nand";  
06.  
07.#endif   
08.  
09.    s3c_nand_set_platdata(&th6410_nand_info);  
//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:添加下面部分


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



《解決方案》

謝謝分享
《解決方案》

參觀參觀



sfp
《解決方案》

其實我很想知道它的那個沒開源驅動,自己寫裸板是在不方便
《解決方案》

不要和我比懶,我懶得和你比

頂上去










signature..................................
仙府之緣

[火星人 ] mini6410移植全攻略(11)--linux2.6.39 移植之支持nand flash (上) .已經有846次圍觀

http://coctec.com/docs/service/show-post-851.html