u-boot-2014.10移植支持nand

Posted hulig7

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了u-boot-2014.10移植支持nand相关的知识,希望对你有一定的参考价值。

在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移植支持nand的主要内容,如果未能解决你的问题,请参考以下文章

u-boot-2014.10移植修改环境变量的存储位置

u-boot-2014.10移植

u-boot-2014.10移植识别dm9000

u-boot-2014.10移植设置时钟/SDRAM

u-boot-2014.10移植添加mtdparts命令和分区

移植kernel-3.10.79