u-boot移植:解决 Retry count exceeded; starting again

搞了一整天的U-boot,现在终于可以使用tftp下载内核镜像了,现在终于成功了,呵呵!先前在移植网卡驱动的时候可以在U-boot中PING通我的主机,没有任何问题,可就是使用tftp服务不能下载,通过在网上搜索,也没有找到一个很好的解决方案。网上说的首先要配置好tftp服务器,我的Ubuntu操作系统,通过安装tftp服务,并经过测试,没有问题了。主机上的防火墙也已经关闭。有时,小点的文件可以成功的下载,而大点的文件就会出现下面的错误。

[U-Boot@mini2440]#tftp 30008000 u-boot.bin 
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode 
MAC: 08:00:3e:26:0a:5b 
operating at 100M full duplex mode 
Using dm9000 device 
TFTP from server 10.27.10.48; our IP address is 10.27.10.23 
Filename 'u-boot.bin'. 
Load address: 0x30008000 
Loading: T T T T #T T T T T T T ##T T T T T T T T T T T ##T T T T T #T T T T ###
done 
Bytes transferred = 154764 (25c8c hex) //文件不到200KB还是出现断断续续的 
[U-Boot@mini2440]#tftp 30008000 zImage  //文件达到2MB就没有出现成功过
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode 
MAC: 08:00:3e:26:0a:5b 
operating at 100M full duplex mode 
Using dm9000 device 
TFTP from server 10.27.10.48; our IP address is 10.27.10.23 
Filename 'zImage'. 
Load address: 0x30008000 
Loading: T T T T T T T T T T T T T T #T T T T T T T T T T T T ##T T T T T T T T#
         ###T T #T T T T T 
Retry count exceeded; starting again 
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode 
MAC: 08:00:3e:26:0a:5b 
operating at 100M full duplex mode 
Using dm9000 device 
TFTP from server 10.27.10.48; our IP address is 10.27.10.23 
Filename 'zImage'. 
Load address: 0x30008000 
Loading: T T T T T T T T T T #T T T T T T T T T #T T T T T T T T #T T T T T T ##
         ####T T T T T T T T ######################T T T #####
         ###T T #T T T T T T ##T T ##T T ##### 
Retry count exceeded; starting again 
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode 
MAC: 08:00:3e:26:0a:5b 
operating at 100M full duplex mode 
Using dm9000 device 
TFTP from server 10.27.10.48; our IP address is 10.27.10.23 
Filename 'zImage'. 
Load address: 0x30008000 
Loading: T T T T T #T T T T T T T T #T T T T T T T T T T T T #T T T T T T T T T#
         ####T T T T #T T T T T T T ##########T T ########T T T ##T T ##
         ##T T #T T T T T T T T T #####T T ######T T #####T T #####T T 
         T T ##
Retry count exceeded; starting again 
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode 
MAC: 08:00:3e:26:0a:5b 
operating at 100M full duplex mode 
Using dm9000 device 
TFTP from server 10.27.10.48; our IP address is 10.27.10.23 
Filename 'zImage'. 
Load address: 0x30008000 
Loading: T T T T T #T T T T T T T T T T T ###T T T T T T T T T ##T T T  T #
   ####T T T T T T ##T T T T #####T T T ##################
  ####T T T T T T #T T T T ##T T #############T T ##T T ##T T ### 
Retry count exceeded; starting again //会一直循环下去,无休无止的


从网上不断的搜索,还有的说是lowlevel_init.S文件中的BANK没有设置对,不过我也检查一下我的BANK的设置,我的DM9000在BANK4上面,下面是我的lowlevel_init.S文件的部分配置,位宽是16Bit的。

#define BWSCON    0x48000000
/* BWSCON */
#define DW8            (0x0)
#define DW16            (0x1)
#define DW32            (0x2)
#define WAIT            (0x1<<2)
#define UBLB            (0x1<<3)

#define B1_BWSCON        (DW32)
#define B2_BWSCON        (DW16)
//#define B3_BWSCON        (DW16 + WAIT + UBLB)
#define B3_BWSCON        (DW16+UBLB)
#define B4_BWSCON        (DW16 + UBLB)
#define B5_BWSCON        (DW16)
#define B6_BWSCON        (DW32)
#define B7_BWSCON        (DW32)

再次修改了修改drivers/net/dm9000x.c文件中phy_read()函数和phy_write函数

phy_write(int reg, u16 value)
{ 
    int i;
    /* Fill the phyxcer register into REG_0C */
    DM9000_iow(DM9000_EPAR, DM9000_PHY | reg);

    /* Fill the written data into REG_0D & REG_0E */
    DM9000_iow(DM9000_EPDRL, (value & 0xff));
    DM9000_iow(DM9000_EPDRH, ((value >> 8) & 0xff));
    DM9000_iow(DM9000_EPCR, 0xa);    /* Issue phyxcer write command */
    //udelay(500);            /* Wait write complete */

    i=0;
    while(DM9000_ior(DM9000_EPCR) & 0x01)
    {
        udelay(100);
        i++;                //替换 udelay(500)
        if(i==1000)
        {
            printf("DM9000 access error\n");
            return 0;
        }
    }
    DM9000_iow(DM9000_EPCR, 0x0);    /* Clear phyxcer write command */
    DM9000_DBG("phy_write(reg:0x%x, value:0x%x)\n", reg, value);
}

static u16
phy_read(int reg)
{
    u16 val;
         int i;
    /* Fill the phyxcer register into REG_0C */
    DM9000_iow(DM9000_EPAR, DM9000_PHY | reg);
    DM9000_iow(DM9000_EPCR, 0xc);    /* Issue phyxcer read command */ i=0;
    //udelay(100);            /* Wait read complete */

    while(DM9000_ior(DM9000_EPCR) & 0x01)
    {
        udelay(100);
        i++;                //替换udelay(100)
        if(i==1000)
            {
                printf("DM9000 access error\n");
                return 0;
            }
    }
    DM9000_iow(DM9000_EPCR, 0x0);    /* Clear phyxcer read command */
    val = (DM9000_ior(DM9000_EPDRH) << 8) | DM9000_ior(DM9000_EPDRL);

    /* The read data keeps on REG_0D & REG_0E */
    DM9000_DBG("phy_read(0x%x): 0x%x\n", reg, val);
    return val;
}

注释掉dm9000_halt 的函数体

static void dm9000_halt(struct eth_device *netdev)
{
    //DM9000_DBG("%s\n", __func__);


    /* RESET devie */
    //phy_write(0, 0x8000);    /* PHY RESET */

    //DM9000_iow(DM9000_GPR, 0x01);    /* Power-Down PHY */

    //DM9000_iow(DM9000_IMR, 0x80);    /* Disable all interrupt */

    //DM9000_iow(DM9000_RCR, 0x00);    /* Disable RX */

}

还要继续修改,修改文件/net/net.c中的内容
在104行附近

//# define ARP_TIMEOUT        5000UL    /* Milliseconds before trying ARP again */
将上面的一句替换成下面这句
# define ARP_TIMEOUT        (CONFIG_SYS_HZ/1000*5000UL) 

在573行附近

#ifndef CONFIG_NET_MULTI
    //NetSetTimeout (10000UL, startAgainTimeout);
将上面的一句替换成下面这句
    NetSetTimeout (10000UL*CONFIG_SYS_HZ/1000, startAgainTimeout);
    NetSetHandler (startAgainHandler);

在585行附近

if (NetDevExists && !once) {
            //NetSetTimeout (10000UL, startAgainTimeout);
将上面的一句替换成下面这句
            NetSetTimeout (10000UL*CONFIG_SYS_HZ/1000, startAgainTimeout);

在757行附近

//NetSetTimeout (10000UL, PingTimeout);
将上面的一句替换成下面这句
    NetSetTimeout (10000UL*CONFIG_SYS_HZ/1000, PingTimeout);

在781行附近

//#define CDP_TIMEOUT            250UL    /* one packet every 250ms */
将上面的一句替换成下面这句
#define CDP_TIMEOUT            (250UL*CONFIG_SYS_HZ/1000)

上面这些都改完以后还是不能使用tftp下载。还是会断断续续的。在网上继续搜索,又找到一个地方需要修改的。看的一个网友是这样分析的

一、问题原因分析:

1、下载与我操作系统版本(fedora 10)一致的tftp server源代码tftp-hpa-0.48.tar.bz2,编译通过后,替换系统的tftpd程序,通过在源代码中添加调试信息,发现是由于 Uboot 端 tftp 程序传过来的Timeout参数不符合服务器端定义引起的:

 Nov 11 10:46:12 HardWare in.tftpd[18275]: client timeout = 7810 , server timeout = 1-255 tftp客户端传过来的timeout是7810,而服务器端定义的范围在1-255秒之间,不是服务器的问题,而是uboot中tftp参数设置的问题。

继续修改/net/tftp.c文件中的下面这句

#define TIMEOUT   60000UL //5000UL   /* Millisecs to timeout for lost pkt */

一开始改变的太小,改成10000UL,直接把后面的UL去掉还是不行,不过改完这里就真的可以了,我都不敢相信这是真的。不过确实是真的,就是这里TIMEOUT的问题,我的板子是通过交换机和主机相连的。
  TIMEOUT 的值是跟据板子配置文件中的 
CONFIG_SYS_HZ 值计算出来的,我的配置文件时从 Uboot目录 include/configs/mini2410.h 复制过来的,值为 1562500,算出来后就等于7810.也就是上面分析的tftp的超时的值。
下面就是成功后的下载界面:

[U-Boot@mini2440]#tftp 30000000 zImage 
dm9000 i/o: 0x20000300, id: 0x90000a46 
DM9000: running in 16 bit mode 
MAC: 08:00:3e:26:0a:5b 
operating at 100M full duplex mode 
Using dm9000 device 
TFTP from server 10.27.10.48; our IP address is 10.27.10.23 
Filename 'zImage'. 
Load address: 0x30000000 
Loading: ################################################################# 
         ################################################################# 
         ################################################################# 
         ################################################################# 
         ################################################################# 
         ################################################################# 
         ################### 
done 
Bytes transferred = 2092932 (1fef84 hex)

转载于:https://my.oschina.net/hanshubo/blog/604597

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值