uboot1.1.6——DM9000移植问题,求点击
帖子有些屁长,希望大家能耐心看完~~
最近在学习uboot,所以选用了较低版本的u-boot-1.1.6,移植到mini2440,现在在dm9000网卡驱动这卡住了。
过程是这样的:
1、在board/mini2440/mini24440.h中添加dm9000的需要的一些宏定义
#if 0
#define CONFIG_DRIVER_CS89001/* we have a CS8900 on-board */
#define CS8900_BASE0x19000300
#define CS8900_BUS161 /* the Linux driver does accesses as shorts */
#endif
#define CONFIG_DRIVER_DM90001
#define CONFIG_NET_MULTI 1
#define CONFIG_DM9000_NO_SROM 1
#define CONFIG_DM9000_BASE0x20000300 //网卡片选地址
#define DM9000_IOCONFIG_DM9000_BASE
#define DM9000_DATA(CONFIG_DM9000_BASE + 4) //网卡数据地址
#define CONFIG_BOOTDELAY3
/*#define CONFIG_BOOTARGS "root=ramfs devfs=mount console=ttySA0,9600" */
#define CONFIG_ETHADDR 08:00:3e:26:0a:5b
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR172.31.108.211//开发板IP地址
#define CONFIG_SERVERIP172.31.108.66//Linux主机IP地址
#ifdef CONFIG_DRIVER_DM9000
dm9000_initialize(bis);
#endif
static void dm9000_get_enetaddr(struct eth_device *dev)
{
#if !defined(CONFIG_DM9000_NO_SROM)
int i;
for (i = 0; i < 3; i++)
phy_read(i, dev->enetaddr + (2 * i));
#endif
}
int dm9000_initialize(bd_t *bis)
{
struct eth_device *dev = &(dmfe_info.netdev);
// Load MAC address from EEPROM
dm9000_get_enetaddr(dev);
dev->init = eth_init;
dev->halt = eth_halt;
dev->send = eth_send;
dev->recv = eth_rx;
sprintf(dev->name, "dm9000");
eth_register(dev);
return 0;
}
/* Structure/enum declaration ------------------------------- */
typedef struct board_info {
u32 runt_length_counter;/* counter: RX length < 64byte */
u32 long_length_counter;/* counter: RX length > 1514byte */
u32 reset_counter;/* counter: RESET */
u32 reset_tx_timeout;/* RESET caused by TX Timeout */
u32 reset_rx_status;/* RESET caused by RX Statsus wrong */
u16 tx_pkt_cnt;
u16 queue_start_addr;
u16 dbug_cnt;
u8 phy_addr;
u8 device_wait_reset;/* device state */
u8 nic_type;/* NIC type */
unsigned char srom[128];
struct eth_device netdev;
} board_info_t;
board_info_t dmfe_info;
...
/* Set Node address */
#ifndef CONFIG_AT91SAM9261EK
for (i = 0; i < 6; i++)
((u16 *) bd->bi_enetaddr)[i] = read_srom_word(i);
#endif
if (is_zero_ether_addr(bd->bi_enetaddr) ||
is_multicast_ether_addr(bd->bi_enetaddr)) {
/* try reading from environment */
u8 i;
char *s, *e;
s = getenv ("ethaddr");
for (i = 0; i < 6; ++i) {
bd->bi_enetaddr[i] = s ?
simple_strtoul (s, &e, 16) : 0;
if (s)
s = (*e) ? e + 1 : e;
}
}
...
...
#if 0 //屏蔽掉dm9000_init函数中的这一部分,不然使用网卡的时候会报“could not establish link”的错误
i = 0;
while (!(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 = 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
...
...
static uchar default_environment[] = {
#if defined(CONFIG_BOOTARGS)
"bootargs=" CONFIG_BOOTARGS "\0"
#endif
#if defined(CONFIG_BOOTCOMMAND)
"bootcmd=" CONFIG_BOOTCOMMAND "\0"
#endif
#if defined(CONFIG_RAMBOOTCOMMAND)
"ramboot=" CONFIG_RAMBOOTCOMMAND "\0"
#endif
#if defined(CONFIG_NFSBOOTCOMMAND)
"nfsboot=" CONFIG_NFSBOOTCOMMAND "\0"
#endif
#if defined(CONFIG_BOOTDELAY) && (CONFIG_BOOTDELAY >= 0)
"bootdelay=" MK_STR (CONFIG_BOOTDELAY) "\0"
#endif
#if defined(CONFIG_BAUDRATE) && (CONFIG_BAUDRATE >= 0)
"baudrate=" MK_STR (CONFIG_BAUDRATE) "\0"
#endif
#ifdefCONFIG_LOADS_ECHO
"loads_echo=" MK_STR (CONFIG_LOADS_ECHO) "\0"
#endif
#ifdefCONFIG_ETHADDR
"ethaddr=" MK_STR (CONFIG_ETHADDR) "\0"
#endif
#ifdefCONFIG_ETH1ADDR
"eth1addr=" MK_STR (CONFIG_ETH1ADDR) "\0"
#endif
#ifdefCONFIG_ETH2ADDR
"eth2addr=" MK_STR (CONFIG_ETH2ADDR) "\0"
#endif
#ifdefCONFIG_ETH3ADDR
"eth3addr=" MK_STR (CONFIG_ETH3ADDR) "\0"
#endif
#ifdefCONFIG_ETHPRIME
"ethprime=" CONFIG_ETHPRIME "\0"
#endif
#ifdefCONFIG_IPADDR
"ipaddr=" MK_STR (CONFIG_IPADDR) "\0"
#endif
#ifdefCONFIG_SERVERIP
"serverip=" MK_STR (CONFIG_SERVERIP) "\0"
#endif
#ifdefCFG_AUTOLOAD
"autoload=" CFG_AUTOLOAD "\0"
#endif
#ifdefCONFIG_ROOTPATH
"rootpath=" MK_STR (CONFIG_ROOTPATH) "\0"
#endif
#ifdefCONFIG_GATEWAYIP
"gatewayip=" MK_STR (CONFIG_GATEWAYIP) "\0"
#endif
#ifdefCONFIG_NETMASK
"netmask=" MK_STR (CONFIG_NETMASK) "\0"
#endif
#ifdefCONFIG_HOSTNAME
"hostname=" MK_STR (CONFIG_HOSTNAME) "\0"
#endif
#ifdefCONFIG_BOOTFILE
"bootfile=" MK_STR (CONFIG_BOOTFILE) "\0"
#endif
#ifdefCONFIG_LOADADDR
"loadaddr=" MK_STR (CONFIG_LOADADDR) "\0"
#endif
#ifdefCONFIG_PREBOOT
"preboot=" CONFIG_PREBOOT "\0"
#endif
#ifdefCONFIG_CLOCKS_IN_MHZ
"clocks_in_mhz=" "1" "\0"
#endif
#if defined(CONFIG_PCI_BOOTDELAY) && (CONFIG_PCI_BOOTDELAY > 0)
"pcidelay=" MK_STR (CONFIG_PCI_BOOTDELAY) "\0"
#endif
#ifdef CONFIG_EXTRA_ENV_SETTINGS
CONFIG_EXTRA_ENV_SETTINGS
#endif
"\0"/* Termimate env_t data with 2 NULs */
};