1、u-boot-2010.06默认的网卡是CS8900,所以要先把它屏蔽掉
gedit include/configs/apple2440.h
/*
#define CONFIG_NET_MULTI
#define CONFIG_CS8900 /* we have a CS8900 on-board */
#define CONFIG_CS8900_BASE 0x19000300
#define CONFIG_CS8900_BUS16 /* the Linux driver does accesses as shorts */
*/
//添加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) //网卡数据地址
//在102行处添加命令,下面红色部分
#define CONFIG_CMD_CACHE
#define CONFIG_CMD_DATE
#define CONFIG_CMD_ELF
//给uboot加上ping命令,用来测试网络通不通
#define CONFIG_CMD_PING
//添加网卡支持命令
#define CONFIG_CMD_NET
//恢复被注释掉的网卡MAC地址
#define CONFIG_ETHADDR 08:00:3e:26:0a:5b//TQ2440dm9000xmac地址
(注:我在apple2440.h中遗漏了如下定义,所以要在uboot中通过setenv及saveenv来设置。)
#define CONFIG_NETMASK 255.255.255.0//子网掩码
#define CONFIG_IPADDR 192.168.0.106//TQ2440IP地址
#define CONFIG_SERVERIP 192.168.0.107//主机(PC)IP地址
2、修改板载DM9000网卡初始化代码
gedit board/sumsung/apple2440/apple2440.c
#ifdef CONFIG_CMD_NET
int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_DRIVER_DM9000
rc = dm9000_initialize(bis);
#endif
return rc;
}
3、修改网卡驱动bug
gedit drivers/net/dm9000x.c
<1>//屏蔽掉dm9000_init函数中的这一部分,不然使用网卡的时候会报“could not establish link”的错误
#if 0
i = 0;
while (!(phy_read(1) & 0x20))
{ /* autonegation complete bit */
udelay(1000);
i++;
if (i == 10000)
{
printf("could not establish link\n");
return 0;
}
}
#endif
<2>//屏蔽掉dm9000_halt函数中的内容
static void dm9000_halt(struct eth_device *netdev)
{
#if 0
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 */
#endif
}