修改配置文件smdk2410.h(路径:include/configs/smdk2410.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#define CONFIG_DRIVER_DM9000 1 /* we have a DM9000 on-board */#define CONFIG_DM9000_USE_16BIT 1#define CONFIG_DM9000_BASE 0x20000000#define DM9000_DATA 0x20000004#define DM9000_IO 0x20000000 注释掉CS8900的信息,添加DM9000的配置信息。 宏定义CONFIG_DRIVER_DM9000为1表示配置使用DM9000网卡,u-boot编译时会将DM9000相关的驱动编译进去。其中0x20000000是DM9000的基址(BANK4),由于DM9000只有一条地址线CMD(LADDR2,见图3.1)用于区别是数据还是地址(CMD为低时数据总线上传输的是地址信号,CMD为高时传输的是数据信号),所以DM9000_DATA为0x20000004,DM9000_IO为0x20000000。 五、设置IP、serverIP
以上任务完成,在u-boot根目录下编译,编译成功!使用OpenJtag将编译完成的u-boot.bin烧入开发板运行。u-boot启动后,使用print命令查看u-boot的参数:Jz2440 #printbootdelay=3baudrate=115200ethaddr=08:00:3e:26:0a:5bipaddr=192.168.1.6serverip=192.168.1.2netmask=255.255.255.0stdin=serialstdout=serialstderr=serial 看到开发板的IP、serverIP已经修改成功。我们使用ping命令ping一下PC
192.168.1.2。Jz2440 #ping 192.168.1.2dm9000 i/o: 0x20000000, id: 0x90000a46MAC: 50:50:50:50:50:50could not establish linkping failed; host 192.168.1.2 is not alive
host is not alive ,ping不通,看来存在问题! 上网搜索了很久,网上的都是教你屏蔽这一段代码,屏蔽那一段代码,然后就可以了,都没有详细的分析,看不大明白。后来,通过研究高版本的u-boot,发现了问题所在。 打开高版本u-boot,u-boot-1.3.4中的dm9000x.c,可以看到如下更新说明:06/03/2008 Remy Bohmer <linux@bohmer.net>-Fixed the driver to work with DM9000A. 发现DM9000驱动在后续版本中更新了,老版本的(u-boot-1.1.6)对DM9000支持可能存在问题。 发现了问题,马上更新试试看,复制u-boot-1.3.4中的dm9000x.c到u-boot-1.1.6中,覆盖掉原来的dm9000x.c,然后编译。出现了错误!drivers/dm9000x.c:480: undefined reference to `is_zero_ether_addr'/drivers/dm9000x.c:480: undefined reference to `is_multicast_ether_addr'make: *** [u-boot] Error 1 很明显,缺少两个函数定义。网上搜索也没有找到,干脆对u-boot-1.3.4建立SourceInsight工程搜索这两个函数。发现这两个函数都存在于net.h中(路径:include/net.h)。 复制这两个函数,到自己的u-boot(目前为u-boot-1.1.6)的net.h中(路径:include/net.h)/**
* is_zero_ether_addr - Determine if give Ethernet address is all zeros.
* @addr: Pointer to a six-byte array containing the Ethernet address
*
* Return true if the address is all zeroes.
*/static inline int is_zero_ether_addr(const u8 *addr){
return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);}
/**
* is_multicast_ether_addr - Determine if the Ethernet address is a multicast.
* @addr: Pointer to a six-byte array containing the Ethernet address
*
* Return true if the address is a multicast address.
* By definition the broadcast address is also a multicast address.
*/static inline int is_multicast_ether_addr(const u8 *addr){
return (0x01 & addr[0]);} 然后编译,通过! 烧写到开发板,ping主机192.168.1.2:Jz2440 # ping 192.168.1.2ERROR: resetting DM9000 -> not respondingdm9000 i/o: 0x20000000, id: 0x90000a46DM9000: running in 16 bit modeMAC: 08:00:3e:26:0a:5bcould not establish linkhost 192.168.1.2 is alive “host 192.168.1.2 is alive”, ping通了,DM9000移植OK! 七、网络测试
1.测试tftp
通过tftp传输一个程序到内存中运行试试看。在主机上打开tftp软件,将leds.bin(运行地址在0x30000000)放在tftp软件目录中,在u-boot界面,输入命令:Jz2440 #tftp 0x30000000 leds.binERROR: resetting DM9000 -> not respondingdm9000 i/o: 0x20000000, id: 0x90000a46DM9000: running in 16 bit modeMAC: 08:00:3e:26:0a:5bcould not establish linkTFTP from server 192.168.1.2; our IP address is 192.168.1.6Filename 'leds.bin'.Load address: 0x30000000Loading: #doneBytes transferred = 168 (a8 hex) 传输成功,在u-boot界面使用go命令运行程序Jz2440 #go 0x30000000## Starting application at 0x30000000 ... 可以看到Jz2440开发板上led已经在循环闪烁了。 2.测试nfs
由于虚拟机Linux上开启了nfs服务,虚拟机Linux
IP为192.168.1.3,需要先更改serverIP。Jz2440 # setenv serverip 192.168.1.3Jz2440 # saveenv 然后将leds.bin放在nfs目录,/work/nfs_root/,在u-boot界面使用nfs传输文件Jz2440 #nfs 0x30000000 192.168.1.3:/work/nfs_root/leds.binERROR: resetting DM9000 -> not respondingdm9000 i/o: 0x20000000, id: 0x90000a46DM9000: running in 16 bit modeMAC: 08:00:3e:26:0a:5bcould not establish linkFile transfer via NFS from server 192.168.1.3; our IP address is 192.168.1.6Filename '/work/nfs_root/leds.bin'.Load address: 0x30000000Loading: #doneBytes transferred = 168 (a8 hex) 传输成功,在u-boot界面使用go命令运行程序Jz2440 #go 0x30000000## Starting application at 0x30000000 ... 可以看到Jz2440开发板上led已经在循环闪烁了。 至此,DM9000网卡移植成功!