linux - uboot tftpboot总是超时(使用DM9000A网卡)

标签 linux networking ethernet u-boot tftp

我使用uboot,并在其中添加了tftpboot命令。但是效果不太好,虽然可以传输数据,但在整个传输过程中总是出现超时。控制台显示如下

我的以太网拓扑是:带有uboot的板连接到我的路由器,我的PC连接到路由器。我的tftp服务器位于我PC的VM linux上,并且VM使用桥接模式连接到以太网

当然,我尝试将我的板直接连接到 PC,但问题仍然存在

我修改了dm9000x.c第433行,更改

tmo = get_timer(0) + 5 * CONFIG_SYS_HZ; //

进入

tmo = get_timer(0) + 200; //timeout 200 miliiseconds

翻译时间现在可以忍受了。但仍然出现多次传输超时,日志如下

dm9000 i/o: 0x88000000, id: 0x90000a46 
DM9000: running in 16 bit mode
MAC: 1a:2a:3a:4a:5a:6a
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.0.15; our IP address is 192.168.0.12
Filename '/linux-3.14.24/fs/yaffs2/ubifs.img'.
Load address: 0x20000000
Loading: ################################################################transmission timeout
#
         ####transmission timeout
#############################################################
         ####################transmission timeout
##########transmission timeout
################transmission timeout
##################transmission timeout
#
         #################################################################
         #################################################################
         #############################################################transmission timeout
####
         #####################transmission timeout
######################transmission timeout
######################
         #################################################################
         ###############################################################transmission timeout
##
         ##################################transmission timeout
#######transmission timeout
########################
         #################################################################
         #################################################################
         #################################################################
         ###################transmission timeout
###################
         61.5 KiB/s
done
Bytes transferred = 4515840 (44e800 hex)
4515840 bytes written to volume rootfs

我还是不知道为什么,因为它实际上可以传输数据。那么对此有什么想法吗?

最佳答案

我检查了我的 u-boot dm9000 驱动程序并发现了这个

static int dm9000_send(struct eth_device *netdev, void *packet, int length)
{
    int tmo;
    struct board_info *db = &dm9000_info;

    DM9000_DMP_PACKET(__func__ , packet, length);

    DM9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */

    /* Move data to DM9000 TX RAM */
    DM9000_outb(DM9000_MWCMD, DM9000_IO); /* Prepare for TX-data */

    /* push the data to the TX-fifo */
    (db->outblk)(packet, length);

    /* Set TX length to DM9000 */
    DM9000_iow(DM9000_TXPLL, length & 0xff);
    DM9000_iow(DM9000_TXPLH, (length >> 8) & 0xff);

    /* Issue TX polling command */
    DM9000_iow(DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */

    /* wait for end of transmission */
    tmo = get_timer(0) + 10 * CONFIG_SYS_HZ;
    while ( !(DM9000_ior(DM9000_NSR) & (NSR_TX1END | NSR_TX2END)) ||
        !(DM9000_ior(DM9000_ISR) & IMR_PTM) ) {
        if (get_timer(0) >= tmo) {
            printf("NSR is 0x%x, ISR is 0x%x\n",DM9000_ior(DM9000_NSR),DM9000_ior(DM9000_ISR)); // this line is for debug use
            printf("transmission timeout\n");
            break;
        }
    }

    DM9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */

    DM9000_DBG("transmit done\n\n");
    return 0;
}

当发生超时时,

printf("NSR is 0x%x, ISR is 0x%x\n",DM9000_ior(DM9000_NSR),DM9000_ior(DM9000_ISR)); // this line is for debug use

这一行表明DM9000_ISR的第二位永远不会设置为1。我不知道为什么所以我改变了这样的代码

static int dm9000_send(struct eth_device *netdev, void *packet, int length)
{
    int tmo;
    struct board_info *db = &dm9000_info;

    DM9000_DMP_PACKET(__func__ , packet, length);

    DM9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */

    /* Move data to DM9000 TX RAM */
    DM9000_outb(DM9000_MWCMD, DM9000_IO); /* Prepare for TX-data */

    /* push the data to the TX-fifo */
    (db->outblk)(packet, length);

    /* Set TX length to DM9000 */
    DM9000_iow(DM9000_TXPLL, length & 0xff);
    DM9000_iow(DM9000_TXPLH, (length >> 8) & 0xff);

    /* Issue TX polling command */
    DM9000_iow(DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */

    /* wait for end of transmission */
    tmo = get_timer(0) + 10 * CONFIG_SYS_HZ;

    while (DM9000_ior(DM9000_TCR) &TCR_TXREQ) {
        if (get_timer(0) >= tmo) {
            printf("transmission timeout\n");
            break;
        }
    }

    DM9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */

    DM9000_DBG("transmit done\n\n");
    return 0;
}

现在,一切都OK了。但我仍然对为什么 DM9000_ISR 的第二位出错感到困惑。是DM9000硬件BUG吗?

关于linux - uboot tftpboot总是超时(使用DM9000A网卡),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27086432/

相关文章:

linux - 使用 Raspbian JESSIE 启动 Pi3 时自动启动 "Chromium"

linux - bash -错误 : Syntax error: operand expected (error token is "testdir/.hidd1/")

android - 无法弄清楚在 OkHttp 的 onResponse 方法中要检查什么

javascript - Arduino 上的以太网 Web 服务器,具有动态数据

networking - 以太网驱动程序 - 不使用 DMA?

boost - 如何从 streambuf 中获取一个或多个特定字节?

c - 从另一个应用程序访问(读/写)虚拟内存进程

c - 在Linux上加载C运行时

c++ - 发送给单个接收者的多个 UDP 消息

delphi - Indy 在 Windows 上支持原始 TCP 套接字吗?