0

我用的是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

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

4

1 回答 1

0

我检查了我的 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;
}

现在,一切正常。但我仍然对为什么 DM9000_ISR 的第二位出错感到困惑。难道是DM9000的硬件BUG?

于 2014-11-24T05:28:04.997 回答