u-boot-2009.08已经对DM9000x网卡有很好的支持了,只是默认的是CS8900网卡,所以我们只需在yy2440.h中添加相应的宏定义就可以了,修改如下:[参考黄刚大侠的博客修改]
/* * Hardware drivers */ #if 0 #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 */ #endif //添加u-boot对DM9000X网卡的支持 #define CONFIG_DRIVER_DM9000 1 #define CONFIG_NET_MULTI 1 #define CONFIG_DM9000_NO_SROM 1 #define CONFIG_DM9000_BASE 0x20000300 //网卡片选地址 #define DM9000_IO CONFIG_DM9000_BASE #define DM9000_DATA (CONFIG_DM9000_BASE + 4) //网卡数据地址 #define CONFIG_DM9000_USE_16BIT 1
#define CONFIG_CMD_PING
//恢复被注释掉的网卡MAC地址和修改你合适的开发板IP地址
#define CONFIG_ETHADDR 08:00:3e:26:0a:5b //开发板MAC地址 #define CONFIG_NETMASK 255.255.255.0 #define CONFIG_IPADDR 192.168.1.105 //开发板IP地址
#define CONFIG_SERVERIP 192.168.1.103 //Linux主机IP地址 |
在yy2440.c中添加如下函数和头文件
#include <net.h> #include <netdev.h>
#ifdef CONFIG_DRIVER_DM9000 int board_eth_init(bd_t *bis) { return dm9000_initialize(bis); } #endif
|
修改MD9000网卡驱动代码,如下:
#gedit drivers/net/dm9000x.c
|
#if 0 //屏蔽掉dm9000_init函数中的这一部分,不然使用网卡的时候会报“could not establish link”的错误 i = 0; while (!(phy_read(1) & 0x20)) { /* autonegation complete bit */ udelay(1000); i++; if (i == 10000) { printf("could not establish link "); return 0; } } #endif
|
这是修改的还ping不通,出现
DM9000: running in 16 bit mode
MAC: 08:00:3e:26:0a:5b
operating at unknown: 0 mode
Using dm9000 device
需修改dm9000x.c里面的函数
/* Stop the interface. The interface is stopped when it is brought. */ static void dm9000_halt(struct eth_device *netdev) { //DM9000_DBG("%sn", __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 */ }
|
此时出现tftp下载断断续续的情况
Loading: 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 unknown: 0 mode
Using dm9000 device
TFTP from server 192.168.0.111; our IP address is 192.168.0.123
Filename 'zImage'.
Load address: 0x30008000
Loading: T T #T T #T T ##############T ##T ##############T ###########T ##
和黄刚大侠遇到的情况一样,把板子和电脑用网线直接连起来,照黄大侠的说法把板子和电脑直接相连也不行!奇怪,出厂烧进去的u-boot用路由器也可以的呀。不急,好好找找原因
到现在,网卡是移植好了!
看着错误的原因貌似是因为超时而导致网卡重启,grep了Retry count exceeded; starting 发现在tftp.c里面puts了一次,既然是tftp,就先看他吧,试着修改了下面这个函数,在TftpTimeoutCountMax乘以10,断续还是会,只是没刚才那么严重,可以将内核下载完成,说明方向对了,但是没找到点上。
TftpTimeout (void) { if (++TftpTimeoutCount > TftpTimeoutCountMax) { puts ("\nRetry count exceeded; starting again\n"); #ifdef CONFIG_MCAST_TFTP mcast_cleanup(); #endif NetStartAgain (); } else { puts ("T "); NetSetTimeout (TftpTimeoutMSecs, TftpTimeout); TftpSend (); } }
|
继续在网上游荡,也自己试着修改代码,看到一个网友遇到TFTP error: 'Unsupported option(s) requested (8)这样的情况,我也遇到了,当
TftpTimeoutCountMax乘以一个太大的数的时候就会出现这样的情况,顺便也看了他的调试方法,找到了断续传输的原因所在,他是这样说的
一、问题原因分析:
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参数设置的问题。
原文链接地址:http://blog.chinaunix.net/u3/105764/showart.php?id=2091464 |
按照这个思路修改了tftp.c中的
#define TIMEOUT 50000 /* Millisecs to timeout for lost pkt */
|
编译后烧进去却出现这样的问题:
TFTP from server 192.168.0.111; our IP address is 192.168.0.123 Filename 'zImage'. Load address: 0x33008000 Loading: * ARP 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 unknown: 0 mode Using dm9000 device
|
同样是还没传输开始就被打断了,继续grep
ARP Retry count exceeded; starting again 在net.c里面发现了,打开看,同样有这样的定义
#ifndef CONFIG_ARP_TIMEOUT # define ARP_TIMEOUT 5000UL /* Milliseconds before trying ARP again */ #else # define ARP_TIMEOUT CONFIG_ARP_TIMEOUT #endif
|
好,也把你改为,也就是去掉毫秒的单位
#ifndef CONFIG_ARP_TIMEOUT # define ARP_TIMEOUT 5000 /* Milliseconds before trying ARP again */ #else # define ARP_TIMEOUT CONFIG_ARP_TIMEOUT #endif
|
编译烧写,发现第一次都会有断续,但是第二次就没有了,行了,将就着用吧
YY2440 # tftp 30008000 zImage dm9000 i/o: 0x20000300, id: 0x90000a46 DM9000: running in 16 bit mode MAC: 08:00:3e:26:0a:5b operating at unknown: 0 mode Using dm9000 device TFTP from server 192.168.0.111; our IP address is 192.168.0.123 Filename 'zImage'. Load address: 0x30008000 Loading: * ARP 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 unknown: 0 mode Using dm9000 device TFTP from server 192.168.0.111; our IP address is 192.168.0.123 Filename 'zImage'. Load address: 0x30008000 Loading: * ARP 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 unknown: 0 mode Using dm9000 device TFTP from server 192.168.0.111; our IP address is 192.168.0.123 Filename 'zImage'. Load address: 0x30008000 Loading: * ARP 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 unknown: 0 mode Using dm9000 device TFTP from server 192.168.0.111; our IP address is 192.168.0.123 Filename 'zImage'. Load address: 0x30008000 Loading: * ARP 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 unknown: 0 mode Using dm9000 device TFTP from server 192.168.0.111; our IP address is 192.168.0.123 Filename 'zImage'. Load address: 0x30008000 Loading: * ARP 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 unknown: 0 mode Using dm9000 device TFTP from server 192.168.0.111; our IP address is 192.168.0.123 Filename 'zImage'. Load address: 0x30008000 Loading: * ARP 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 unknown: 0 mode Using dm9000 device TFTP from server 192.168.0.111; our IP address is 192.168.0.123 Filename 'zImage'. Load address: 0x30008000 Loading: ################################################################# ################################################################# ########## done Bytes transferred = 2052152 (1f5038 hex) YY2440 # tftp 30008000 zImage dm9000 i/o: 0x20000300, id: 0x90000a46 DM9000: running in 16 bit mode MAC: 08:00:3e:26:0a:5b operating at unknown: 0 mode Using dm9000 device TFTP from server 192.168.0.111; our IP address is 192.168.0.123 Filename 'zImage'. Load address: 0x30008000 Loading: ################################################################# ################################################################# ########## done Bytes transferred = 2052152 (1f5038 hex) YY2440 #
|
2010.7.31
今日有新发现,tftp断断续续的原因是电脑网卡的反应时间和uboot里面每次重启时间搭配不好,以前一直重新连接,不能下载,是没等电脑网卡反应过来,并且还要经过虚拟机的虚拟网卡,tftp连接就重启了,故不能下载:
解决办法之一是:修改net/tftp.c里面# define TIMEOUT_COUNT这个宏定义,代表重启前的重试次数,把次数加大,比如夸张点1000次才重启,那么电脑网卡就有充足的时间来完成初始化,只要连接上了,就可以下载了。
方法二是:修改每次重试的等待时间,修改net/tftp.c里面的#define TIMEOUT5 0000UL 和net/net.c里面的# define ARP_TIMEOUT 50000UL,比原来多加个0,大点无所谓,只要是使网卡有足够的反应时间。
阅读(305) | 评论(0) | 转发(0) |