u-boot-1.1.6 移植到sbc2410

1. 由于u-boot-1.1.6中本身就支持sbc2410开发板,但生成的u-boot.bin不支持nandflash操作,我们的工作就是扩展这一部分的功能。因此,第一步先配置:make sbc2410x_config。

2. 修改sbc2410x.h,激活CFG_CMD_NAND命令。   

make后出现:warning: "NAND_CTL_SETCLE" redefined 等警告,只需取消在文件sbc2410x.h中下面的定义。

#define NAND_CTL_CLRALE(nandptr)
#define NAND_CTL_SETALE(nandptr)
#define NAND_CTL_CLRCLE(nandptr)
#define NAND_CTL_SETCLE(nandptr)

3. 再make,发现:

sbc2410x.c:146:  warning: implicit declaration of function `NF_SetCE'
sbc2410x.c:146: error: `NFCE_LOW' undeclared (first use in this function)
sbc2410x.c:147: warning: implicit declaration of function `NF_Cmd'
sbc2410x.c:149: warning: implicit declaration of function `NF_WaitRB'
sbc2410x.c:150: error: `NFCE_HIGH' undeclared (first use in this function)
sbc2410x.c:165: warning: implicit declaration of function `NF_Conf'

在sbc2410x.c中增加下面函数:

typedef enum {
    NFCE_LOW,
    NFCE_HIGH
} NFCE_STATE;

static inline void NF_SetCE(NFCE_STATE s)
{
    S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
    switch (s) {
    case NFCE_LOW:
        nand->NFCONT &= ~(1<<1);
        break;
    case NFCE_HIGH:
        nand->NFCONT |= (1<<1);
        break;
    }
}

static inline void NF_Cmd(u8 cmd)
{
    S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
    nand->NFCMD = cmd;
}

static inline void NF_WaitRB(void)
{
    S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
    while (!(nand->NFSTAT & (1<<0)));
}

static inline void NF_Conf(u16 conf)
{
    S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
    nand->NFCONF = conf;
}

4. make后又出现:

sbc2410x.c: In function `NF_SetCE':
sbc2410x.c:152: error: structure has no member named `NFCONT'
sbc2410x.c:155: error: structure has no member named `NFCONT'

在S3c2410.h中在S3C2410_NAND结构体中增加

S3C24X0_REG32    NFCONT;

5. 重新make出现:

nand.c:38: error: `CFG_NAND_BASE' undeclared here (not in a function)
在sbc2410x.h中增加

#define CFG_NAND_BASE 0

6. make后发现:

arm-linux-ld: Warning: size of symbol `nand_init' changed from 148 in drivers/nand/libnand.a(nand.o) to 128 in drivers/nand/libnand.a(nand.o)

将sbc2410x.c中的函数nand_init,NF_Reset,NF_Init注释掉。

7. 再make:

/home/book/u-boot-1.1.6/drivers/nand/nand.c:50: undefined reference to `board_nand_init'

增加cpu/arm920t/s3c241x0/nand_flash.c,该文件完成board_nand_init函数的定义。

同时修改同文件夹下的Makefile,在COBJS最后加上nand_flash.o。

附nand_flash.c源文件如下:

#include

#if (CONFIG_COMMANDS & CFG_CMD_NAND) && !defined(CFG_NAND_LEGACY)
#include
#include

DECLARE_GLOBAL_DATA_PTR;

#define S3C2410_NFSTAT_READY      (1<<0)
#define S3C2410_NFCONF_nFCE    (1<<11)

#define S3C2440_NFSTAT_READY    (1<<0)
#define S3C2440_NFCONT_nFCE    (1<<1)

static void s3c2410_nand_select_chip(struct mtd_info *mtd, int chip)
{
S3C2410_NAND * const s3c2410nand = S3C2410_GetBase_NAND();

if (chip == -1) {
s3c2410nand->NFCONF |= S3C2410_NFCONF_nFCE;
} else {
s3c2410nand->NFCONF &= ~S3C2410_NFCONF_nFCE;
}
}


static void s3c2410_nand_hwcontrol(struct mtd_info *mtd, int cmd)
{
S3C2410_NAND * const s3c2410nand = S3C2410_GetBase_NAND();
struct nand_chip *chip = mtd->priv;

switch (cmd) {
case NAND_CTL_SETNCE:
case NAND_CTL_CLRNCE:
printf("%s: called for NCE/n", __FUNCTION__);
break;

case NAND_CTL_SETCLE:
chip->IO_ADDR_W = (void *)&s3c2410nand->NFCMD;
break;

case NAND_CTL_SETALE:
chip->IO_ADDR_W = (void *)&s3c2410nand->NFADDR;
break;

default:
chip->IO_ADDR_W = (void *)&s3c2410nand->NFDATA;
break;
}
}


static int s3c2410_nand_devready(struct mtd_info *mtd)
{
S3C2410_NAND * const s3c2410nand = S3C2410_GetBase_NAND();

return (s3c2410nand->NFSTAT & S3C2410_NFSTAT_READY);
}

static void s3c24x0_nand_inithw(void)
{
S3C2410_NAND * const s3c2410nand = S3C2410_GetBase_NAND();
#define TACLS  0
#define TWRPH0 4
#define TWRPH1 2
s3c2410nand->NFCONF = (1<<15)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0);
}


void board_nand_init(struct nand_chip *chip)
{
S3C2410_NAND * const s3c2410nand = S3C2410_GetBase_NAND();

s3c24x0_nand_inithw();

chip->IO_ADDR_R= (void *)&s3c2410nand->NFDATA;
chip->IO_ADDR_W= (void *)&s3c2410nand->NFDATA;
chip->hwcontrol= s3c2410_nand_hwcontrol;
chip->dev_ready= s3c2410_nand_devready;
chip->select_chip = s3c2410_nand_select_chip;
chip->options= 0;
chip->eccmode= NAND_ECC_SOFT;
}

#endif
8. make成功生成u-boot.bin。

 

备注:第3步、4步可以省略,因为在做第6步后,第3、4步的问题就不存在了。最后经上机检测,该u-boot已可以进nand操作,只是在使用nand read命令时,时好时坏,不稳定。我认为,可能是nandflash时序上一些重要的时间参数设置上的问题,下一次再继续调试,找出原因。

你可能感兴趣的:(u-boot-1.1.6 移植到sbc2410)