博客首页 注册 建议与交流 排行榜 加入友情链接         宝宝相册的专门空间
推荐 投诉 搜索: 帮助

Tekkaman Ninja

Linux我的梦想,我的未来! 专注linux内核和驱动!本博客的原创文章的内容会不定期更新或修正错误! 转载文章都会注明出处,若有侵权,请即时同我联系,我一定马上删除!! 原创文章版权所有!如需转载,请注明出处: tekkman.cublog.cn ,谢谢合作!!!!!
  tekkman.cublog.cn

关于作者
姓名:Tekkaman  Ninja
职业:ARM9+Linux
年龄:25
位置:福建龙岩
个性介绍:钻研嵌入式Linux技术
E-Mail:tekkamanninja@163.com
|| << >> ||
我的分类


移植U-Boot.1.2.0到友善之臂SBC2440V4(S3C2440AL)(2)

移植UBoot.1.2.0到友善之臂SBC2440V4S3C2440AL)(2)


接上篇:【置顶】移植U-Boot.1.2.0到友善之臂SBC2440V4(S3C2440AL)(1)

 

8、在个文件中添加“CONFIG_S3C2440”,使得原来s3c2410的代码可以编译进来。

1/include/common.h文件的第454行:

#if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) || defined(CONFIG_LH7A40X) || defined(CONFIG_S3C2440)

2/include/s3c24x0.h文件的第859599110148404行:

#if defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)

3/cpu/arm920t/s3c24x0/interrupts.c文件的第33行:

#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) || defined (CONFIG_S3C2440)

38行:#elif defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)

4/cpu/arm920t/s3c24x0/serial.c文件的第22行:

#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) || defined (CONFIG_S3C2440)

26行:#elif defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)

void serial_setbrg (void)

{

         S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);

         int i;

         unsigned int reg = 0;

 

         /* value is calculated so : (int)(PCLK/16./baudrate) -1 */

         reg = get_PCLK() / (16 * gd->baudrate) - 1;

         /* FIFO enable, Tx/Rx FIFO clear */

         uart->UFCON = 0x00;

         uart->UMCON = 0x0;

         /* Normal,No parity,1 stop,8 bit */

         uart->ULCON = 0x3;

......

}

5/cpu/arm920t/s3c24x0/speed.c文件的第33行:

#if defined(CONFIG_S3C2400) || defined (CONFIG_S3C2410) || defined (CONFIG_TRAB) || defined (CONFIG_S3C2440)

37:#elif defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)

顺便修改源代码,以匹配s3c2440

static ulong get_PLLCLK(int pllreg)
{
   ......

    m = ((r & 0xFF000) >> 12) + 8;
    p = ((r & 0x003F0) >> 4) + 2;
    s = r & 0x3;
//tekkaman
#if defined(CONFIG_S3C2440)
   if (pllreg == MPLL)
    return((CONFIG_SYS_CLK_FREQ * m * 2) / (p << s));
    else if (pllreg == UPLL)
#endif
//tekkaman

   
return((CONFIG_SYS_CLK_FREQ * m) / (p << s));
}

......

/* return FCLK frequency */

ulong get_FCLK(void)

{

    return(get_PLLCLK(MPLL));

}

 

/* return HCLK frequency */

ulong get_HCLK(void)

{

    S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();

 

      

              if (clk_power->CLKDIVN & 0x6)   

                            {

                            if ((clk_power->CLKDIVN & 0x6)==2)        return(get_FCLK()/2);

                            if ((clk_power->CLKDIVN & 0x6)==6)        return((clk_power->CAMDIVN & 0x100) ? get_FCLK()/6 : get_FCLK()/3);        

                            if ((clk_power->CLKDIVN & 0x6)==4)        return((clk_power->CAMDIVN & 0x200) ? get_FCLK()/8 : get_FCLK()/4);        

                            return(get_FCLK());

                            }

 

              else       {

                            return(get_FCLK());

                            }

}

......

6/cpu/arm920t/s3c24x0/usb_ohci.c文件的第45行:

#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)

(i2c的文件还没修改,因为没用到)

7/rtc/s3c24x0_rtc.c文件的第35行:

#elif defined(CONFIG_S3C2410) || defined(CONFIG_S3C2440)

 

在个文件中添加“defined(CONFIG_tekkaman2440)”,使得原来SBC2410X的代码可以编译进来。

1/cpu/arm920t/s3c24x0/interrupts.c文件的第181行: 

    defined(CONFIG_VCMA9) || defined(CONFIG_tekkaman2440)

 

9、 include/linux/mtd/nand_ids.h的结构体nand_flash_ids加入

static struct nand_flash_dev nand_flash_ids[] = {

......
    {"Samsung KM29N16000",NAND_MFR_SAMSUNG, 0x64, 21, 1, 2, 0x1000, 0},
   
{"Samsung K9F1208U0B",  NAND_MFR_SAMSUNG, 0x76, 26, 0, 3, 0x4000, 0},
    {"Samsung unknown 4Mb", NAND_MFR_SAMSUNG, 0x6b, 22, 0, 2, 0x2000, 0},
......

};

 

 

10、修改/lib_arm中的board.c。

......

#include <common.h>
#include <command.h>
#include <malloc.h>
#include <devices.h>
#include <version.h>
#include <net.h>
#include <s3c2410.h>

 

......

 

static int display_banner (void)
{      

         S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();

         gpio->GPBDAT = 0x100;  //tekkamanninja

//在串口初始化和console初始化完成,串口输出信息之前,LED1LED2LED3会亮起!

    printf ("\n\n%s\n\n", version_string);
    debug ("U-Boot code: %08lX -> %08lX  BSS: -> %08lX\n",
           _armboot_start, _bss_start, _bss_end);
   
printf ("U-Boot code: %08lX -> %08lX  BSS: -> %08lX\n",    //tekkaman
        _armboot_start, _bss_start, _bss_end);      //tekkaman
#ifdef CONFIG_MODEM_SUPPORT
    debug ("Modem Support enabled\n");
#endif
#ifdef CONFIG_USE_IRQ
    debug ("IRQ Stack: %08lx\n", IRQ_STACK_START);
    debug ("FIQ Stack: %08lx\n", FIQ_STACK_START);
#endif

    return (0);
}

 

......

void start_armboot (void)

{

         init_fnc_t **init_fnc_ptr;

         char *s;

#ifndef CFG_NO_FLASH

         ulong size;

#endif

#if defined(CONFIG_VFD) || defined(CONFIG_LCD)

         unsigned long addr;

#endif

         S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();

......

         gpio->GPBDAT = 0x0;  //tekkamanninja

//在进入命令提示符之前,四个LED会同时亮起!

         /* main_loop() can return to retry autoboot, if so just run it again. */

         for (;;) {

                   main_loop ();

         }

 

         /* NOTREACHED - no way out of command loop except booting */

}


11、 修改common/env_nand.c

......
#ifdef CONFIG_INFERNO
#error CONFIG_INFERNO not supported yet
#endif

int nand_legacy_rw (struct nand_chip* nand, int cmd,
        size_t start, size_t len,
        size_t * retlen, u_char * buf);
extern struct nand_chip nand_dev_desc[CFG_MAX_NAND_DEVICE];
extern int nand_legacy_erase(struct nand_chip *nand, size_t ofs, size_t len, int clean);

/* info for NAND chips, defined in drivers/nand/nand.c */
extern nand_info_t nand_info[CFG_MAX_NAND_DEVICE];

......

#else /* ! CFG_ENV_OFFSET_REDUND */
int saveenv(void)
{
    ulong total;
    int ret = 0;

    puts ("Erasing Nand...");
    //if (nand_erase(&nand_info[0], CFG_ENV_OFFSET, CFG_ENV_SIZE))

if (nand_legacy_erase(nand_dev_desc + 0, CFG_ENV_OFFSET, CFG_ENV_SIZE, 0))
        return 1;


    puts ("Writing to Nand... ");
    total = CFG_ENV_SIZE;
    //ret = nand_write(&nand_info[0], CFG_ENV_OFFSET, &total, (u_char*)env_ptr);

ret = nand_legacy_rw(nand_dev_desc + 0,

0x00 | 0x02, CFG_ENV_OFFSET, CFG_ENV_SIZE,

&total, (u_char*)env_ptr);


    if (ret || total != CFG_ENV_SIZE)
        return 1;

    puts ("done\n");
    return ret;
......
#else /* ! CFG_ENV_OFFSET_REDUND */
/*
 * The legacy NAND code saved the environment in the first NAND device i.e.,
 * nand_dev_desc + 0. This is also the behaviour using the new NAND code.
 */
void env_relocate_spec (void)
{
#if !defined(ENV_IS_EMBEDDED)
    ulong total;
    int ret;

    total = CFG_ENV_SIZE;
    //ret = nand_read(&nand_info[0], CFG_ENV_OFFSET, &total, (u_char*)env_ptr);
    ret = nand_legacy_rw(nand_dev_desc + 0, 0x01 | 0x02, CFG_ENV_OFFSET, CFG_ENV_SIZE, &total, (u_char*)env_ptr);

......



12、 在/board/tekkaman/tekkaman2440/tekkaman2440.c文件的末尾添加对Nand Flash 的初始化函数(在后面Nand Flash的操作都要用到)

u-boot运行至第二阶段进入start_armboot()函数。其中nand_init()函数是对nand flash的最初初始化函数。Nand_init()函数在两个文件中实现。其调用与CFG_NAND_LEGACY宏有关,如果没有定义这个宏,系统调用 drivers/nand/nand.c中的nand_init();否则调用自己在board/tekkaman/tekkaman2440/tekkaman2440.c中的nand_init()函数。这里我选择第二种方式。

 

#if (CONFIG_COMMANDS & CFG_CMD_NAND)
typedef enum {
NFCE_LOW,
NFCE_HIGH
} NFCE_STATE;

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

nand->NFCONF = conf;
}

static inline void NF_Cont(u16 cont)

{

S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

nand->NFCONT = cont;

}

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

nand->NFCMD = cmd;
}

static inline void NF_CmdW(u8 cmd)
{
NF_Cmd(cmd);
udelay(1);
}

static inline void NF_Addr(u8 addr)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

nand->NFADDR = addr;
}

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_WaitRB(void)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

while (!(nand->NFSTAT & (1<<0)));
}

static inline void NF_Write(u8 data)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

nand->NFDATA = data;
}

static inline u8 NF_Read(void)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

return(nand->NFDATA);
}

static inline void NF_Init_ECC(void)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

nand->NFCONT |= (1<<4);
}

static inline u32 NF_Read_ECC(void)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

return(nand->NFECC);
}

#endif


#if (CONFIG_COMMANDS & CFG_CMD_NAND)
extern ulong nand_probe(ulong physadr);


static inline void NF_Reset(void)
{
int i;

NF_SetCE(NFCE_LOW);
NF_Cmd(0xFF); /* reset command */
for(i = 0; i < 10; i++); /* tWB = 100ns. */
NF_WaitRB(); /* wait 200~500us; */
NF_SetCE(NFCE_HIGH);
}


static inline void NF_Init(void)
{
#if 0 /* a little bit too optimistic */
#define TACLS 0
#define TWRPH0 3
#define TWRPH1 0
#else
#define TACLS 0
#define TWRPH0 4
#define TWRPH1 2
#endif

       NF_Conf((TACLS<<12)|(TWRPH0<<8)|(TWRPH1<<4));

       NF_Cont((1<<6)|(1<<4)|(1<<1)|(1<<0));
/*nand->NFCONF = (1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0); */
/* 1 1 1 1, 1 xxx, r xxx, r xxx */
/* En 512B 4step ECCR nFCE=H tACLS tWRPH0 tWRPH1 */

NF_Reset();
}

void
nand_init(void)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

NF_Init();
#ifdef DEBUG
printf("NAND flash probing at 0x%.8lX\n", (ulong)nand);
#endif
printf ("%4lu MB\n", nand_probe((ulong)nand) >> 20);
}
#endif

 

 

12 在/include/s3c24x0.h中加入2440 的NAND FLASH 寄存器定义和CAMDIVN定义:

......

typedef struct {

         S3C24X0_REG32   LOCKTIME;

         S3C24X0_REG32   MPLLCON;

         S3C24X0_REG32   UPLLCON;

         S3C24X0_REG32   CLKCON;

         S3C24X0_REG32   CLKSLOW;

         S3C24X0_REG32   CLKDIVN;

         S3C24X0_REG32   CAMDIVN;

} /*__attribute__((__packed__))*/ S3C24X0_CLOCK_POWER;

......

#if defined(CONFIG_S3C2410)

/* NAND FLASH (see S3C2410 manual chapter 6) */

typedef struct {

         S3C24X0_REG32   NFCONF;

         S3C24X0_REG32   NFCMD;

         S3C24X0_REG32   NFADDR;

         S3C24X0_REG32   NFDATA;

         S3C24X0_REG32   NFSTAT;

         S3C24X0_REG32   NFECC;

} /*__attribute__((__packed__))*/ S3C2410_NAND;

#endif

#if defined (CONFIG_S3C2440)

/* NAND FLASH (see S3C2440 manual chapter 6) */

typedef struct {

         S3C24X0_REG32   NFCONF;

         S3C24X0_REG32   NFCONT;

         S3C24X0_REG32   NFCMD;

         S3C24X0_REG32   NFADDR;

         S3C24X0_REG32   NFDATA;

         S3C24X0_REG32   NFMECC0;

         S3C24X0_REG32   NFMECC1;

         S3C24X0_REG32   NFSECC;

         S3C24X0_REG32   NFSTAT;

         S3C24X0_REG32   NFESTAT0;

         S3C24X0_REG32   NFESTAT1;

         S3C24X0_REG32   NFECC;

} /*__attribute__((__packed__))*/ S3C2410_NAND;

#endif

 

 

三、交叉编译UBoot
UBoot的根目录下
$make
一阵English飘过~~~~~~~~~~~~~~~~~~~~~~~

 

SBC2440V4是双网卡设计,DM9000网卡移植请看: 【置顶】移植U-Boot.1.2.0到友善之臂SBC2440V4(补:DM9000网卡移植),这篇文章的移植使用CS8900网卡。tftp功能是可用的,我测试过!
由于时间关系,我没有复查,可能有遗漏。如果按上面的修改,出现了错误,请及时联系我,我会及时更正!

回目录 移植U-Boot.1.2.0到友善之臂SBC2440V4(S3C2440AL)

发表于: 2007-10-13,修改于: 2007-10-31 08:16,已浏览2488次,有评论1条 推荐 投诉


网友评论
网友: homewood 时间:2007-10-30 19:47:18 IP地址:58.68.132.★
出现笔误:(多了)
static inline void NF_Cont(u16 cont)

{



Blog作者的回复:
非常感谢,已经改过来了


网友: pilgrim_kevin 时间:2007-11-05 22:36:20 IP地址:116.77.162.★
你好,我按照你的这篇文章把u-boot移植到QQ2440上,LED1亮了但是蜂鸣器也响起来,在这里卡住了。可能是什么原因?

Blog作者的回复:
你要依据硬件修改移植过程,你用的是QQ2440,我的是SBC2440V4。你按板子的原理图改改程序。应该很好弄的。


网友: elzo 时间:2007-11-19 11:51:33 IP地址:61.172.36.★
你好,你的u-boot是git上弄下来的吧,好像跟ftp上的有点不一样。
我照你写的做了,启得出但saveenv不行,tftpboot也一直超时,TTTTT

Blog作者的回复:
u-boot的下载地址在博客收藏夹里有!
saveenv不行的问题,可能出在/include/configs/tekkaman2440.h文件上,有可能是:
#define  CFG_ENV_IS_IN_NAND    1
#define CFG_ENV_OFFSET  0X20000
#define CFG_NAND_LEGACY
#define CFG_ENV_SIZE    0x10000   
  ,或是nand 驱动的问题。

tftpboot超时问题,你先看看ping得通吗?在确保驱动没问题的基础上,可能是IP地址配置,要下载的文件名设置问题。你的host的网络配置也要看看,注意:一定要关闭防火墙!!


网友: 本站网友 时间:2008-01-22 00:02:02 IP地址:58.60.63.★
你好,首先很感谢你文章的分享,我现在也出现了这样的问题:

U-Boot 1.1.4 (Jan 21 2008 - 01:28:30)

U-Boot code: 33F80000 -> 33F99A50 BSS: -> 33F9DC30
RAM Configuration:
Bank #0: 30000000 64 MB
Flash: 2 MB
*** Warning - bad CRC, using default environment

In: serial
Out: serial
Err: serial
dm9000 not found at 0x18000300 id: 0x00000000
MAC: 00:00:00:00:00:00
could not establish link
SMDK2410 #
找不到网卡,lowlevel_init.s的bank3默认接网卡,我的实验箱也是接bank3的,所以我没修改,按你文章的做法,屏蔽CS8900的宏定义,并添加改以下宏:
在smdk2410.h中添加版主上面所说的宏:
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE 0x18000300
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE+4)
#define CONFIG_DM9000_USE_16BIT

然后在board.c原来用到CS89000的地方相应添加如下内容:

#ifdef CONFIG_DRIVER_DM9000
extern int eth_init(bd_t * bd);
#endif

#ifdef CONFIG_DRIVER_DM9000
eth_init(gd->bd);
#endif

烧去后,就出现找不到DM9000,是不是还有什么地方没修改,请指导,谢谢!!!

Blog作者的回复:
你好,我觉得可能是的你的硬件连接和我不一样。我没看过你的原理图不好讲,你可以将原理图发给我。我再帮你看看。


网友: 本站网友 时间:2008-01-22 14:05:31 IP地址:122.126.14.★
Tekkaman  兄:
可否提供您的 patch file 測試?
非常感謝~

Blog作者的回复:
以前的移植工作我都没有做 patch ,最近想要做针对2410和2440的u-boot-1.3.1和2.6.24内核的移植,这次做好了会做patch的。


网友: lili1984 时间:2008-02-20 09:35:05 IP地址:221.200.197.★
大哥:
俺的问题是这样的:
drivers/nand_legacy/libnand_legacy.a(nand_legacy.o): In function `NanD_Command':
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:293: undefined reference to `NF_Cmd'

我定义了CFG_NAND_LEGACY宏啊,也在board/tekkaman/tekkaman2440/tekkaman2440.c中定义了nand_init()函数。

这是为什么呢~

Blog作者的回复:
可能是你漏了“12、 在/board/tekkaman/tekkaman2440/tekkaman2440.c文件的末尾添加对Nand Flash 的初始化函数”这一步中的一些函数,你认真看看。在移植U-Boot.1.2.0到友善之臂SBC2440V4(S3C2440AL)(2)


网友: lili1984 时间:2008-02-20 14:19:47 IP地址:221.200.197.★
我是楼上的,我的问题还是没解决啊……
这个是我的tekkaman2440.c,完全复制了您的代码啊~
而且我在tekkaman2440.h里的确定义了CFG_NAND_LEGACY宏啊,为什么U-BOOT还是在/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c中找NF_Read、NF_Write等的定义啊??

/*
 * (C) Copyright 2002
 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
 * Marius Groeger <mgroeger@sysgo.de>
 *
 * (C) Copyright 2002
 * David Mueller, ELSOFT AG, <d.mueller@elsoft.ch>
 *
 * (C) Copyright 2005
 * JinHua Luo, GuangDong Linux Center, <luo.jinhua@gd-linux.com>
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

#include <common.h>
#include <s3c2410.h>

#if (CONFIG_COMMANDS & CFG_CMD_NAND)
#include <linux/mtd/nand.h>
#endif

/* ------------------------------------------------------------------------- */

#define FCLK_SPEED 1

#if FCLK_SPEED==0        /* Fout = 203MHz, Fin = 12MHz for Audio */
#define M_MDIV    0xC3
#define M_PDIV    0x4
#define M_SDIV    0x1
#elif FCLK_SPEED==1        /* Fout = 405MHz */
#define M_MDIV    0x7f
#define M_PDIV    0x2
#define M_SDIV    0x1
#endif

#define USB_CLOCK 1

#if USB_CLOCK==0
#define U_M_MDIV    0xA1
#define U_M_PDIV    0x3
#define U_M_SDIV    0x1
#elif USB_CLOCK==1
#define U_M_MDIV    0x38
#define U_M_PDIV    0x2
#define U_M_SDIV    0x2
#endif

static inline void delay (unsigned long loops)
{
    __asm__ volatile ("1:\n"
              "subs %0, %1, #1\n"
              "bne 1b":"=r" (loops):"0" (loops));
}

/*
 * Miscellaneous platform dependent initialisations
 */

int board_init (void)
{
    DECLARE_GLOBAL_DATA_PTR;
    S3C24X0_CLOCK_POWER * const clk_power = S3C24X0_GetBase_CLOCK_POWER();
    S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();

    /* to reduce PLL lock time, adjust the LOCKTIME register */
    clk_power->LOCKTIME = 0xFFFFFF;

    /* configure MPLL */
    clk_power->MPLLCON = ((M_MDIV << 12) + (M_PDIV << 4) + M_SDIV);

    /* some delay between MPLL and UPLL */
    delay (4000);

    /* configure UPLL */
    clk_power->UPLLCON = ((U_M_MDIV << 12) + (U_M_PDIV << 4) + U_M_SDIV);

    /* some delay between MPLL and UPLL */
    delay (8000);

    /* set up the I/O ports */
    gpio->GPACON = 0x007FFFFF;
    gpio->GPBCON = 0x00055556;
    gpio->GPBUP = 0x000007FF;
    gpio->GPCCON = 0xAAAAAAAA;
    gpio->GPCUP = 0x0000FFFF;
    gpio->GPDCON = 0xAAAAAAAA;
    gpio->GPDUP = 0x0000FFFF;
    gpio->GPECON = 0xAAAAAAAA;
    gpio->GPEUP = 0x0000FFFF;
    gpio->GPFCON = 0x000055AA;
    gpio->GPFUP = 0x000000FF;
    gpio->GPGCON = 0xFF95FF3A;
    gpio->GPGUP = 0x0000FFFF;
    gpio->GPHCON = 0x0016FAAA;
    gpio->GPHUP = 0x000007FF;

    gpio->EXTINT0=0x22222222;
    gpio->EXTINT1=0x22222222;
    gpio->EXTINT2=0x22222222;

    /* arch number of S3C2440-Board */
    gd->bd->bi_arch_number = MACH_TYPE_S3C2440;

    /* adress of boot parameters */
    gd->bd->bi_boot_params = 0x30000100;

    icache_enable();
    dcache_enable();
    gpio->GPBDAT = 0x180;

    return 0;
}

int dram_init (void)
{
    DECLARE_GLOBAL_DATA_PTR;

    gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
    gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;

    return 0;
}

#if (CONFIG_COMMANDS & CFG_CMD_NAND)
typedef enum {
NFCE_LOW,
NFCE_HIGH
} NFCE_STATE;

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

static inline void NF_Cont(u16 cont)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
nand->NFCONT = cont;
}

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

static inline void NF_CmdW(u8 cmd)
{
NF_Cmd(cmd);
udelay(1);
}

static inline void NF_Addr(u8 addr)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
nand->NFADDR = addr;
}

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_WaitRB(void)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
while (!(nand->NFSTAT & (1<<0)));
}

static inline void NF_Write(u8 data)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
nand->NFDATA = data;
}

static inline u8 NF_Read(void)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
return(nand->NFDATA);
}

static inline void NF_Init_ECC(void)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
nand->NFCONT |= (1<<4);
}

static inline u32 NF_Read_ECC(void)
{
S3C2410_NAND * const nand = S3C2410_GetBase_NAND();
return(nand->NFECC);
}

#endif

#if (CONFIG_COMMANDS & CFG_CMD_NAND)
extern ulong nand_probe(ulong physadr);

static inline void NF_Reset(void)
{
    int i;

    NF_SetCE(NFCE_LOW);
    NF_Cmd(0xFF);        /* reset command */
    for(i = 0; i < 10; i++);    /* tWB = 100ns. */
    NF_WaitRB();        /* wait 200~500us; */
    NF_SetCE(NFCE_HIGH);
}

static inline void NF_Init(void)
{
#if 0
#define TACLS   0
#define TWRPH0  3
#define TWRPH1  0
#else
#define TACLS   0
#define TWRPH0  4
#define TWRPH1  2
#endif

    NF_Conf((TACLS<<12)|(TWRPH0<<8)|(TWRPH1<<4));
    NF_Cont((1<<6)|(1<<4)|(1<<1)|(1<<0));
    /*nand->NFCONF = (1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<11)|(TACLS<<8)|(TWRPH0<<4)|(TWRPH1<<0); */
    /* 1  1    1     1,   1      xxx,  r xxx,   r xxx */
    /* En 512B 4step ECCR nFCE=H tACLS   tWRPH0   tWRPH1 */

    NF_Reset();
}

void nand_init(void)
{
    S3C2410_NAND * const nand = S3C2410_GetBase_NAND();

    NF_Init();
#ifdef DEBUG
    printf("NAND flash probing at 0x%.8lX\n", (ulong)nand);
#endif
    printf ("%4lu MB\n", nand_probe((ulong)nand) >> 20);
}
#endif /* CONFIG_COMMANDS & CFG_CMD_NAND */

网友: lili1984 时间:2008-02-20 14:28:52 IP地址:221.200.197.★
报错如下:
drivers/nand_legacy/libnand_legacy.a(nand_legacy.o): In function `NanD_Command':
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:293: undefined reference to `NF_Cmd'
drivers/nand_legacy/libnand_legacy.a(nand_legacy.o): In function `NanD_ReadBuf':
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:541: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:544: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:547: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:550: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:553: undefined reference to `NF_Read'
drivers/nand_legacy/libnand_legacy.a(nand_legacy.o):/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:556: more undefined references to `NF_Read' follow
drivers/nand_legacy/libnand_legacy.a(nand_legacy.o): In function `NanD_Address':
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:335: undefined reference to `NF_Addr'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:341: undefined reference to `NF_Addr'
drivers/nand_legacy/libnand_legacy.a(nand_legacy.o): In function `NanD_IdentChip':
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:392: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:394: undefined reference to `NF_Read'
drivers/nand_legacy/libnand_legacy.a(nand_legacy.o): In function `nand_write_oob':
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:1168: undefined reference to `NF_Write'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:1179: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:1192: undefined reference to `NF_Write'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:1196: undefined reference to `NF_Write'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:1208: undefined reference to `NF_Read'
drivers/nand_legacy/libnand_legacy.a(nand_legacy.o): In function `nand_legacy_erase':
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:1255: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:1263: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:1294: undefined reference to `NF_Read'
drivers/nand_legacy/libnand_legacy.a(nand_legacy.o): In function `nand_write_ecc':
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:1003: undefined reference to `NF_Read'
drivers/nand_legacy/libnand_legacy.a(nand_legacy.o):/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:799: more undefined references to `NF_Read' follow
drivers/nand_legacy/libnand_legacy.a(nand_legacy.o): In function `nand_write_page':
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:857: undefined reference to `NF_Write'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:863: undefined reference to `NF_Write'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:879: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:914: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:923: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:948: undefined reference to `NF_Read'
/root/u-boot-1.2.0/drivers/nand_legacy/nand_legacy.c:954: undefined reference to `NF_Read'
make: *** [u-boot] 错误 1

Blog作者的回复:
你去源代码看看就知道了,问题基本上可以确定是你对的/include/configs/tekkaman2440.h修改时漏了#define WRITE_NAND_ADDRESS(d, adr) {rNFADDR = d;}

#define WRITE_NAND(d, adr) {rNFDATA = d;}

#define READ_NAND(adr) (rNFDATA)

#define NAND_WAIT_READY(nand) {while(!(rNFSTAT&(1<<0)));}

#define NAND_DISABLE_CE(nand) {rNFCONT |= (1<<1);}

#define NAND_ENABLE_CE(nand) {rNFCONT &= ~(1<<1);}

你仔细看看移植U-Boot.1.2.0到友善之臂SBC2440V4(S3C2440AL)(1)

中的

7 为了实现NAND Flash的读写,再次修改/include/configs/tekkaman2440.h


网友: lili1984 时间:2008-02-23 10:52:23 IP地址:221.200.115.★
我的tekkaman2440.h就是按照您的修改方法改的啊……

#ifndef __CONFIG_H
#define __CONFIG_H

/*
 * If we are developing, we might want to start armboot from ram
 * so we MUST NOT initialize critical regs like mem-timing ...
 */
#undef CONFIG_SKIP_LOWLEVEL_INIT    /* undef for developing */

/*
 * High Level Configuration Options
 * (easy to change)
 */
#define CONFIG_ARM920T        1    /* This is an ARM920T Core    */
#define CONFIG_S3C2440        1    /* in a SAMSUNG S3C2440 SoC     */
#define CONFIG_syhf2440        1    /* on a friendly-arm syhf2440X Board  */

/* input clock of PLL */
#define CONFIG_SYS_CLK_FREQ    12000000/* the SBC2410X has 12MHz input clock */


#define USE_920T_MMU        1
#undef CONFIG_USE_IRQ            /* we don't need IRQ/FIQ stuff */

/*
 * Size of malloc() pool
 */
#define CFG_MALLOC_LEN        (CFG_ENV_SIZE + 128*1024)
#define CFG_GBL_DATA_SIZE    128    /* size in bytes reserved for initial data */

/*
 * Hardware drivers
 */
#define CONFIG_DRIVER_CS8900    1    /* we have a CS8900 on-board */
#define CS8900_BASE        0x19000300
#define CS8900_BUS16        1 /* the Linux driver does accesses as shorts */

/*
 * select serial console configuration
 */
#define CONFIG_SERIAL1          1    /* we use SERIAL 1 on SBC2410X */

/************************************************************
 * RTC
 ************************************************************/
#define    CONFIG_RTC_S3C24X0    1

/* allow to overwrite serial and ethaddr */
#define CONFIG_ENV_OVERWRITE

#define CONFIG_BAUDRATE        115200

/***********************************************************
 * Command definition
 ***********************************************************/
#define CONFIG_COMMANDS \
            (CONFIG_CMD_DFL     | \
            CFG_CMD_CACHE     | \
            CFG_CMD_NAND         | \
            CFG_CMD_NET         | \
            /*CFG_CMD_EEPROM     |*/ \
            /*CFG_CMD_I2C     |*/ \
            /*CFG_CMD_USB     |*/ \
            CFG_CMD_REGINFO     | \
            CFG_CMD_DATE         | \
            CFG_CMD_PING         | \
            CFG_CMD_DHCP         | \
            CFG_CMD_ENV         | \
            CFG_CMD_ELF)

/* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */
#include <cmd_confdefs.h>

#define CONFIG_BOOTDELAY    3
#define CONFIG_BOOTARGS        "console=ttySAC0 root=/dev/nfs nfsroot=192.168.0.1:/friendly-arm/rootfs_netserv ip=192.168.0.69:192.168.0.1:192.168.0.1:255.255.255.0:debian:eth0:off"
#define CONFIG_ETHADDR            08:00:3e:26:0a:5b
#define CONFIG_NETMASK          255.255.255.0
#define CONFIG_IPADDR        192.168.0.69
#define CONFIG_SERVERIP        192.168.0.1
/*#define CONFIG_BOOTFILE    "elinos-lart" */
#define CONFIG_BOOTCOMMAND    "dhcp; bootm"

#if (CONFIG_COMMANDS & CFG_CMD_KGDB)
#define CONFIG_KGDB_BAUDRATE    115200        /* speed to run kgdb serial port */
/* what's this ? it's not used anywhere */
#define CONFIG_KGDB_SER_INDEX    1        /* which serial port to use */
#endif

/*
 * Miscellaneous configurable options
 */
#define    CFG_LONGHELP                /* undef to save memory        */
#define    CFG_PROMPT        "[ syhf2440 ]# "    /* Monitor Command Prompt    */
#define    CFG_CBSIZE        256        /* Console I/O Buffer Size    */
#define    CFG_PBSIZE (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */
#define    CFG_MAXARGS        16        /* max number of command args    */
#define CFG_BARGSIZE        CFG_CBSIZE    /* Boot Argument Buffer Size    */

#define CFG_MEMTEST_START    0x30000000    /* memtest works on    */
#define CFG_MEMTEST_END        0x33F00000    /* 63 MB in DRAM    */

#undef  CFG_CLKS_IN_HZ        /* everything, incl board info, in Hz */

#define    CFG_LOAD_ADDR        0x30008000    /* default load address    */

/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need */
/* it to wrap 100 times (total 1562500) to get 1 sec. */
#define    CFG_HZ            1562500

/* valid baudrates */
#define CFG_BAUDRATE_TABLE    { 9600, 19200, 38400, 57600, 115200 }

/*-----------------------------------------------------------------------
 * Stack sizes
 *
 * The stack sizes are set up in start.S using the settings below
 */
#define CONFIG_STACKSIZE    (128*1024)    /* regular stack */
#ifdef CONFIG_USE_IRQ
#define CONFIG_STACKSIZE_IRQ    (4*1024)    /* IRQ stack */
#define CONFIG_STACKSIZE_FIQ    (4*1024)    /* FIQ stack */
#endif

/*-----------------------------------------------------------------------
 * Physical Memory Map
 */
#define CONFIG_NR_DRAM_BANKS    1       /* we have 1 bank of DRAM */
#define PHYS_SDRAM_1        0x30000000 /* SDRAM Bank #1 */
#define PHYS_SDRAM_1_SIZE    0x04000000 /* 64 MB */

#define PHYS_FLASH_1        0x00000000 /* Flash Bank #1 */

#define CFG_FLASH_BASE        PHYS_FLASH_1

/*-----------------------------------------------------------------------
 * FLASH and environment organization
 */
/* #define CONFIG_AMD_LV400    1    /\* uncomment this if you have a LV400 flash *\/ */

#define CONFIG_AMD_LV800    1    /* uncomment this if you have a LV800 flash&n