全部博文(39)
分类: 嵌入式
2010-12-02 13:18:20
移植过程基本同http://blog.chinaunix.net/u3/101649/showart_2126764.html,稍作修改
1、u-boot-2010.06默认的网卡是CS8900,所以要先把它屏蔽掉
vi include/configs/smdk2440.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地址
#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网卡初始化代码
vi board/sumsung/smdk2440/smdk2440.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
vi 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
}
3、make
插上网线,电脑上的ip netmask getway都要设置好,还要关闭防火墙
烧写进板子,启动uboot进入控制台
setenv getwayip 192.168.0.1
saveenv
ping 192.168.0.107即可
[SMDK2440]# ping 192.168.0.107
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
host 192.168.0.108 is alive