开始我以为DM9000是个PHY,查了一下是个含有MAC和PHY的网卡,还包含一个4KDWORD值的SRAM
一、网卡的正常化配置
1、修改头文件调用关系
在原配的smdk6400.h中(因为是复制过来的),网卡配置为CS8900,而手头开发板上的网卡为DM9000,所以第一步来修改网卡驱动程序。
修改/include/configs/smdk6410.h
找到如下字段,更改如下
/* * Hardware drivers */ #define CONFIG_NET_MULTI //#define CONFIG_CS8900 /* we have a CS8900 on-board */ //#define CONFIG_CS8900_BASE 0x18800300 //#define CONFIG_CS8900_BUS16 /* follow the Linux driver */ #define CONFIG_DRIVER_DM9000 1 /* we have a DM9000 on-board */ #define CONFIG_DM9000_BASE 0x18000000 #define DM9000_IO CONFIG_DM9000_BASE #define DM9000_DATA (CONFIG_DM9000_BASE+4) #define CONFIG_DM9000_USE_16BIT #define CONFIG_ETHADDR 00:40:5c:26:0a:5b #define CONFIG_NETMASK 255.255.255.0 #define CONFIG_IPADDR 192.168.0.22 #define CONFIG_SERVERIP 192.168.0.88 #define CONFIG_GATEWAYIP 192.168.0.1
2、修改dm9000x.c文件
文件为drivers/net/dm9000x.c
在for(;;)之前加入两句
DM9000_ior(DM9000_MRRH);
DM9000_ior(DM9000_MRRL);
修改函数为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 */ }
3、修改net配置文件
文件一 /net/eth.c
增加启动属性,在int eth_initialize(bd_t *bis)函数中,
#if defined(CONFIG_DB64360) || defined(CONFIG_CPCI750)
mv6436x_eth_initialize(bis);
#endif
#if defined(CONFIG_DB64460) || defined(CONFIG_P3Mx)
mv6446x_eth_initialize(bis);
#endif
之后添加
增加一段/* for DM9000 init */ #if defined(CONFIG_DRIVER_DM9000) dm9000_initialize(bis); #endif /*------------------------------*/
文件二 /net/net.c
修改ARP_TIMEOUT
#ifndef CONFIG_ARP_TIMEOUT //# define ARP_TIMEOUT 5000UL /* Milliseconds before trying ARP again */ # define ARP_TIMEOUT 5 /* Milliseconds before trying ARP again */ #else # define ARP_TIMEOUT CONFIG_ARP_TIMEOUT #endif
修改NetArpWaitTimerStart
// if ((t - NetArpWaitTimerStart) > ARP_TIMEOUT) { if ((t - NetArpWaitTimerStart) > ARP_TIMEOUT*CONFIG_SYS_HZ) {
修改NetSetTimeout
// NetSetTimeout (10000UL, PingTimeout); NetSetTimeout (10*CONFIG_SYS_HZ, PingTimeout);
文件三/net/tftp.c
修改 TftpStart (void)
注释如下函数段
/* * Allow the user to choose TFTP blocksize and timeout. * TFTP protocol has a minimal timeout of 1 second. */ /* if ((ep = getenv("tftpblocksize")) != NULL) * TftpBlkSizeOption = simple_strtol(ep, NULL, 10); * * if ((ep = getenv("tftptimeout")) != NULL) * TftpTimeoutMSecs = simple_strtol(ep, NULL, 10); * * if (TftpTimeoutMSecs < 1000) { * printf("TFTP timeout (%ld ms) too low, " * "set minimum = 1000 ms\n", * TftpTimeoutMSecs); * TftpTimeoutMSecs = 1000; * } * * debug("TFTP blocksize = %i, timeout = %ld ms\n", * TftpBlkSizeOption, TftpTimeoutMSecs); */
至此,网卡驱动修改完成,可以编译试一试了。
如果在局域网中,可以尝试ping一下其他主机的ip,