u-boot默認的網絡芯片是CS8900,但開發板上的網絡芯片是DM9000,所以為了使用網絡功能,就必須進行移植。好在u-boot有DM9000的驅動程序,我們只需要把關於CS8900的部分換成DM9000的部分即可。
首先在include/configs/zhaocj2440.h文件內注釋掉下列語句:
#define CONFIG_CS8900 /* we have a CS8900 on-board */
#define CONFIG_CS8900_BASE 0x19000300
#define CONFIG_CS8900_BUS16 /* the Linux driver does accesses asshorts */
再添加下列語句:
#define CONFIG_DRIVER_DM9000
#define CONFIG_DM9000_NO_SROM
#define CONFIG_DM9000_BASE 0x20000300
#define DM9000_IO CONFIG_DM9000_BASE
#define DM9000_DATA (CONFIG_DM9000_BASE + 4)
然後定義缺省的環境變量,先添加MAC地址,再修改開發板以及宿主機的IP地址:
#define CONFIG_ETHADDR 00:01:02:03:04:05
#define CONFIG_IPADDR 192.168.1.126
#define CONFIG_SERVERIP 192.168.1.125
環境變量的設置也可以通過u-boot的setenv命令來完成。
最後修改board/sumsung/zhaocj/zhaocj2440.c文件中的board_eth_init函數:
int board_eth_init(bd_t *bis)
{
intrc = 0;
#ifdef CONFIG_DRIVER_DM9000
rc= dm8900_initialize(bis);
#endif
returnrc;
}
完成上述步驟,開發板就能正常的使用網絡功能了。
開機顯示下面內容:
U-Boot 2011.06 (Dec 18 2011 - 20:23:37)
DRAM: 64 MiB
Flash: 2 MiB
NAND: 256 MiB
*** Warning - bad CRC, using defaultenvironment
In: serial
Out: serial
Err: serial
Net: dm9000
系統已經識別出DM9000,我們再來ping主機:
ZHAOCJ2440 # ping 192.168.1.125
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:01:02:03:04:05
could not establish link
Using dm9000 device
host 192.168.1.125 is alive
當看到最後一行“host192.168.1.125 is alive”時,說明網絡功能已能正常使用。如果為了去掉“could not establish link”字樣,並加快運行速度,可以注釋掉drivers/net/dm9000x.c文件中的dm9000_init函數內的下面語句:
i= 0;
while(!(dm9000_phy_read(1) & 0x20)) { /*autonegation complete bit */
udelay(1000);
i++;
if(i == 10000) {
printf("couldnot establish link\n");
return0;
}
}
/*see what we've got */
lnk= dm9000_phy_read(17) >> 12;
printf("operatingat ");
switch(lnk) {
case1:
printf("10M half duplex ");
break;
case2:
printf("10M full duplex ");
break;
case4:
printf("100M half duplex ");
break;
case8:
printf("100M full duplex ");
break;
default:
printf("unknown:%d ", lnk);
break;
}
相關閱讀:
U-Boot源代碼下載地址 http://www.linuxidc.com/Linux/2011-07/38897.htm
U-Boot-2011.06啟動流程分析 http://www.linuxidc.com/Linux/2011-07/39310.htm
u-boot-2011.06在基於s3c2440開發板的移植之編譯配置 http://www.linuxidc.com/Linux/2011-10/45455.htm
u-boot-2011.06在基於s3c2440開發板的移植之NorFlash啟動 http://www.linuxidc.com/Linux/2011-10/45456.htm
u-boot-2011.06在基於S3C2440開發板的移植之解決raise: Signal # 8 caught http://www.linuxidc.com/Linux/2011-10/454554.htm
u-boot-2011.06在基於s3c2440開發板的移植之支持NandFlash讀寫 http://www.linuxidc.com/Linux/2011-10/45457.htm
u-boot-2011.06在基於s3c2440開發板的移植之硬件ECC http://www.linuxidc.com/Linux/2011-10/454558.htm
u-boot-2011.06在基於s3c2440開發板的移植之DM9000 http://www.linuxidc.com/Linux/2012-09/70507.htm
u-boot-2011.06在基於s3c2440開發板的移植之nandflash啟動 http://www.linuxidc.com/Linux/2012-09/70508.htm
u-boot-2011.06在基於s3c2440開發板的移植之支持YAFFS2 http://www.linuxidc.com/Linux/2012-09/70509.htm
u-boot-2011.06在基於s3c2440開發板的移植之引導內核與加載根文件系統 http://www.linuxidc.com/Linux/2012-09/70510.htm
u-boot-2011.06在基於s3c2440開發板的移植之結束篇 http://www.linuxidc.com/Linux/2012-09/70511.htm