码迷,mamicode.com
首页 > 其他好文 > 详细

u-boot-2014.10移植(5)支持nand

时间:2018-11-03 22:04:43      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:address   fine   启动参数   reg   位置   config   res   ESS   fun   

在smdk2440.h里面加上NAND的配置选项 

#define CONFIG_CMD_NAND

编译出错

drivers/mtd/nand/s3c2410_nand.c: In function s3c2410_hwcontrol:
drivers/mtd/nand/s3c2410_nand.c:44: warning: implicit declaration of function s3c2410_get_base_nand
drivers/mtd/nand/s3c2410_nand.c:44: warning: initialization makes pointer from integer without a cast
drivers/mtd/nand/s3c2410_nand.c:59: error: dereferencing pointer to incomplete type
drivers/mtd/nand/s3c2410_nand.c:59: error: dereferencing pointer to incomplete type
drivers/mtd/nand/s3c2410_nand.c:62: error: dereferencing pointer to incomplete type

cp drivers/mtd/nand/s3c2410_nand.c drivers/mtd/nand/s3c2440_nand.c
在drivers/mtd/nand/Makefile添加

COBJS-$(CONFIG_NAND_S3C2410) += s3c2410_nand.o      
COBJS-$(CONFIG_NAND_S3C2440) += s3c2440_nand.o

同时需要修改配置文件smdk2440.h

         /*
         * NAND configuration
         */
        #ifdef CONFIG_CMD_NAND
        #define CONFIG_NAND_S3C2410        == >#define CONFIG_NAND_S3C2440 
        #define CONFIG_SYS_S3C2410_NAND_HWECC   ==>#define CONFIG_SYS_S3C2440_NAND_HWECC            

在drivers/mtd/nand/s3c2440_nand.c

nt board_nand_init(struct nand_chip *nand)
  #if 0
        cfg = S3C2440_NFCONF_EN;
        cfg |= S3C2440_NFCONF_TACLS(tacls - 1);
        cfg |= S3C2440_NFCONF_TWRPH0(twrph0 - 1);
        cfg |= S3C2440_NFCONF_TWRPH1(twrph1 - 1);
  #endif
        cfg = ((tacls-1)<<12)|((twrph0-1)<<8)|((twrph1-1)<<4);
        writel(cfg, &nand_reg->nfconf);
        
        writel((1<<4)|(1<<1)|(1<<0),&nand_reg->nfcont);
        。。。

                nand->select_chip = s3c2440_nand_select;

添加

static void s3c2440_nand_select(struct mtd_info *mtd, int chipnr)
{
        struct s3c2440_nand *nand = s3c2440_get_base_nand();

        switch (chipnr) {
        case -1:
                nand->nfcont |= (1<<1);
                break;
        case 0:
                nand->nfcont &= ~(1<<1);
                break;

        default:
                BUG();
        }
}

重写

static void s3c2440_hwcontrol(struct mtd_info *mtd, int dat, unsigned int ctrl)
{
        struct s3c2440_nand *nand = s3c2440_get_base_nand();

        if (ctrl & NAND_CLE)
        {
                writeb(dat, &nand->nfcmd);
        }
        else if(ctrl & NAND_ALE)
        {
                writeb(dat, &nand->nfaddr);
        }
}

重写编译烧录

U-Boot 2014.10 (Nov 01 2018 - 14:26:34)
        
        CPUID: 32440001
        FCLK:      400 MHz
        HCLK:      100 MHz
        PCLK:       50 MHz
        DRAM:  64 MiB
        WARNING: Caches not enabled
        Flash: 2 MiB
        NAND:  256 MiB
        *** Warning - bad CRC, using default environment
        
        In:    serial
        Out:   serial
        Err:   serial
        Net:   dm9000
        Warning: dm9000 MAC addresses dont match:
        Address in SROM is         ff:ff:ff:ff:ff:ff
        Address in environment is  00:0c:29:45:c4:c3

增加启动参数

在smdk2440.h里面添加宏

#define CONFIG_BOOTCOMMAND    "nand read.jffs2 0x30007FC0 0x60000 0x200000; bootm 0x30007FC0"

如果以前烧写过内核到0x60000的位置,那么现在可以顺利从nor flash启动内核

u-boot-2014.10移植(5)支持nand

标签:address   fine   启动参数   reg   位置   config   res   ESS   fun   

原文地址:https://www.cnblogs.com/hulig7/p/9902129.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!