修改include/configs/...6410.h
注释掉:
//#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 #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_NET_MULTI 1 #define CONFIG_ETHADDR 01:23:45:67:89:ab #define CONFIG_NETMASK 255.255.255.0 #define CONFIG_IPADDR 192.168.1.4 #define CONFIG_SERVERIP 192.168.1.101 #define CONFIG_GATEWAYIP 192.168.1.1 #define CONFIG_DM9000_DEBUG
0x18000000由数据手册得出
查看driver/net下面的dm9000x已经对dm9000ae支持很好
现在修改net/eth.c
int eth_write_hwaddr(struct eth_device *dev, const char *base_name, int eth_number) { unsigned char env_enetaddr[6]; int ret = 0; // if (!eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr)) // return -1; eth_getenv_enetaddr_by_index(base_name, eth_number, env_enetaddr); //用于获得网卡的MAC地址 if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) { if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) && memcmp(dev->enetaddr, env_enetaddr, 6)) { printf("\nWarning: %s MAC addresses don't match:\n", dev->name); printf("Address in SROM is %pM\n", dev->enetaddr); printf("Address in environment is %pM\n", env_enetaddr); } memcpy(dev->enetaddr, env_enetaddr, 6); } if (dev->write_hwaddr && !eth_mac_skip(eth_number) && is_valid_ether_addr(dev->enetaddr)) { ret = dev->write_hwaddr(dev); } return ret; }
/* * If board-specific initialization exists, call it. * If not, call a CPU-specific one */ #if 0 if (board_eth_init != __def_eth_init) { if (board_eth_init(bis) < 0) printf("Board Net Initialization Failed\n"); } else if (cpu_eth_init != __def_eth_init) { if (cpu_eth_init(bis) < 0) printf("CPU Net Initialization Failed\n"); } else printf("Net Initialization Skipped\n"); #endif if (board_eth_init(bis) < 0) cpu_eth_init(bis);
网卡成功识别:
接下来了的问题是ping命令的错误:
着手解决下,总是出现dm9000_phy_read(0x1):0x7800的问题
将dm9000x.c下面字段注释掉
LINE:604 DM9000_DBG("dm9000_phy_read(0x%x): 0x%x\n",reg,val);
查看到DM9000_DBG的宏定义
LINE:71 #define DM9000_DBG(fmt,args...) printf(fmt,##args)
可见仅仅是打印信息,注释掉无影响
然后为了防止断网,注释掉:
dm9000_halt里面的内容
DM9000_DBG("%s\n",__func__); /*RESET devie*/ dm9000_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*/
然后延时加长
LINE:599 udelay(100); 修改成 udelay(1000);
LINE:369 if(i == 3000){ 修改为: if(i == 10000){
生成uboot后下载运行ping结果为:
屏蔽了多余信息之后:
下面是TFTP下载实验了