一、移植网卡DM9000
在配置文件include\configs\tq2440.h中添加DM9000的配置信息
#if 0
#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 */
#endif
#defineCONFIG_DRIVER_DM9000
#defineCONFIG_DM9000_NO_SROM 1
#defineCONFIG_DM9000_BASE0x20000000
#defineDM9000_IOCONFIG_DM9000_BASE
#defineDM9000_DATA(CONFIG_DM9000_BASE + 4)
修改IP地址,添加MAC地址(也可在u-boot启动后通过setenv命令设置)
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR 192.168.2.100
#define CONFIG_SERVERIP 192.168.2.209
#define CONFIG_ETHADDR 00:0c:29:4d:e4:f4
修改board\tq2440\tq2440.c
int board_eth_init(bd_t*bis)
{
int rc = 0;
#ifdef CONFIG_CS8900
rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
#endif
#ifdefCONFIG_DRIVER_DM9000
rc = dm9000_initialize(bis);
#endif
return rc;
}
重新编译烧到NOR FLASH执行
U-Boot 2012.04.01 (Dec 292012 - 15:58:53)
CPUID: 32440001
FCLK: 400 MHz
HCLK: 100 MHz
PCLK: 50 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
*** Warning - bad CRC, usingdefault environment
In: serial
Out: serial
Err: serial
Net: dm9000
TQ2440 #
现在可以用tftpboot命令通过网络下载文件了,前提是确保服务器IP和开发板u-boot的IP在同一个网段。
TQ2440 # pri
baudrate=115200
bootdelay=5
ethact=dm9000
ethaddr=00:0c:29:4d:e4:f4
ipaddr=172.28.12.10
netmask=255.255.255.0
serverip=172.28.12.60
stderr=serial
stdin=serial
stdout=serial
Environment size: 194/65532bytes
TQ2440 # tftp 32000000 u-boot.bin
dm9000 i/o: 0x20000000, id:0x90000a46
DM9000: running in 16 bitmode
MAC: 00:0c:29:4d:e4:f4
could notestablish link
Using dm9000 device
TFTP from server172.28.12.60; our IP address is 172.28.12.10
Filename 'u-boot.bin'.
Load address: 0x32000000
Loading: #############
done
Bytes transferred = 183576(2cd18 hex)
出现一个错误could not establish link
解决错误并加快速度
修改drivers\net\dm9000x.c
#if 0
i = 0;
while (!(dm9000_phy_read(1) & 0x20)) { /* autonegation complete bit */
udelay(1000);
i++;
if (i == 10000) {
printf("could not establish link\n");
return 0;
}
}
/* see what we've got */
lnk = dm9000_phy_read(17) >> 12;
printf("operating at ");
switch (lnk) {
case 1:
printf("10M half duplex ");
break;
case 2:
printf("10M full duplex ");
break;
case 4:
printf("100M half duplex ");
break;
case 8:
printf("100M full duplex ");
break;
default:
printf("unknown: %d ", lnk);
break;
}
printf("mode\n");
#endif
重新编译烧到NOR FLASH运行
U-Boot 2012.04.01 (Dec 292012 - 17:14:04)
CPUID: 32440001
FCLK: 400 MHz
HCLK: 100 MHz
PCLK: 50 MHz
DRAM: 64 MiB
WARNING: Caches not enabled
Flash: 2 MiB
*** Warning - bad CRC, usingdefault environment
In: serial
Out: serial
Err: serial
Net: dm9000
TQ2440 # tftp 32000000u-boot.bin
dm9000 i/o: 0x20000000, id:0x90000a46
DM9000: running in 16 bitmode
MAC: 00:0c:29:4d:e4:f4
Using dm9000 device
TFTP from server172.28.12.60; our IP address is 172.28.12.10
Filename 'u-boot.bin'.
Load address: 0x32000000
Loading: T #############
done
Bytes transferred = 182996(2cad4 hex)
TQ2440 #