西西軟件園多重安全檢測(cè)下載網(wǎng)站、值得信賴的軟件下載站!
軟件
軟件
文章
搜索

首頁(yè)編程開(kāi)發(fā)其它知識(shí) → OK6410開(kāi)發(fā)板上的DM9000網(wǎng)卡可以用啦

OK6410開(kāi)發(fā)板上的DM9000網(wǎng)卡可以用啦

相關(guān)文章發(fā)表評(píng)論 來(lái)源:本站整理時(shí)間:2010/11/28 16:23:18字體大小:A-A+

作者:佚名點(diǎn)擊:1125次評(píng)論:0次標(biāo)簽: OK6410 DM9000網(wǎng)卡

  • 類型:休閑益智大小:113M語(yǔ)言:中文 評(píng)分:10.0
  • 標(biāo)簽:
立即下載

OKe

U-Boot 1.1.6 (Nov 5 2010 - 09:50:08) for SMDK6410


CPU: S3C6410@532MHz
Fclk = 532MHz, Hclk = 133MHz, Pclk = 66MHz, Serial = CLKUART (SYNC Mode)
Board: SMDK6410
DRAM: 128 MB
Flash: 0 kB
NAND: 1024 MB
*** Warning - bad CRC or NAND, using default environment

In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
SMDK6410 # tftp c0008000 /Image_Nand
dm9000 i/o: 0x18000000, id: 0x90000a46
MAC: 00:40:5c:26:0a:5b
operating at 100M full duplex mode
TFTP from server 192.168.1.12; our IP address is 192.168.1.20
Filename '/Image_Nand'.
Load address: 0xc0008000
Loading: T T T
Abort
SMDK6410 # ping 192.168.1.12
dm9000 i/o: 0x18000000, id: 0x90000a46
MAC: 00:40:5c:26:0a:5b
operating at 100M full duplex mode
host 192.168.1.12 is alive
SMDK6410 # tftp c0008000 /Image_Nand
dm9000 i/o: 0x18000000, id: 0x90000a46
MAC: 00:40:5c:26:0a:5b
operating at 100M full duplex mode
TFTP from server 192.168.1.12; our IP address is 192.168.1.20
Filename '/Image_Nand'.
Load address: 0xc0008000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
##########
done
Bytes transferred = 4040704 (3da800 hex)
SMDK6410 #


這篇帖子是寫在OK6410開(kāi)發(fā)板的DM9000 10/100M網(wǎng)卡調(diào)試通過(guò)之后;上面的輸出信息是通過(guò)網(wǎng)卡下載內(nèi)核到mobile sdram的log。

板卡是飛凌設(shè)計(jì)的OK6410,默認(rèn)帶的u-boot居然不支持tftp,ping這些基本的東西。下載個(gè)內(nèi)核吭哧吭哧幾十分鐘,當(dāng)然也可以用USB會(huì)快很多,但是作者愛(ài)瞎折騰,要把這個(gè)爛東西調(diào)通,DM9000AE,嗬,不知道這世界上還有沒(méi)有人用這玩意。

修改smdk6410.h的以下代碼:
#ifdef CONFIG_DRIVER_SMC911X
#undef CONFIG_DRIVER_CS8900
#define CONFIG_DRIVER_SMC911X_BASE 0x18800300
#else
#define CONFIG_DRIVER_CS8900 0 /* we have a CS8900 on-board */
#define CS8900_BASE 0x18800300
#define CS8900_BUS16 1 /* the Linux driver does accesses as shorts */
#endif
改為:
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE 0x18000000/*XM0CSN1*/
#define DM9000_DATA 0x18000004/*ADDR2*/
#define DM9000_IO CONFIG_DM9000_BASE
//#define CONFIG_DM9000_DEBUG 1
#define CONFIG_DM9000_USE_16BIT 1

一般的網(wǎng)卡甚至USB,藍(lán)牙芯片都會(huì)外接預(yù)留的EEPROM,用來(lái)存儲(chǔ)地址等配置信息;DM9000也不例外,默認(rèn)驅(qū)動(dòng)就是使用EEPROM存地址的,飛凌為了省錢,直接懸空,因此MAC地址需要從Nand Flash上面讀出來(lái),再寫到DM9000寄存器里。

從Linux2.6.28內(nèi)核中拷貝如下2個(gè)函數(shù),后面判斷空地址要用:
/**
* is_zero_ether_addr - Determine if give Ethernet address is all zeros.
* @addr: Pointer to a six-byte array containing the Ethernet address
*
* Return true if the address is all zeroes.
*/
static inline int is_zero_ether_addr(const u8 *addr)
{
return !(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5]);
}

/**
* is_multicast_ether_addr - Determine if the Ethernet address is a multicast.
* @addr: Pointer to a six-byte array containing the Ethernet address
*
* Return true if the address is a multicast address.
* By definition the broadcast address is also a multicast address.
*/
static inline int is_multicast_ether_addr(const u8 *addr)
{
return (0x01 & addr[0]);
}

無(wú)數(shù)的先賢采用了以下代碼來(lái)設(shè)置MAC地址,外加空判斷,算是很排場(chǎng)了:
/* Set Node address */
#ifdef DM9000AE_ZENGJUN_SHARE
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 = s ?
simple_strtoul (s, &e, 16) : 0;
if (s)
s = (*e) ? e + 1 : e;
}
}
#else
for (i = 0; i < 6; i++)
((u16 *) bd->bi_enetaddr) = read_srom_word(i);
#endif


另外參考內(nèi)核代碼rx之前一定要讀兩次MRR,估計(jì)是芯片設(shè)計(jì)缺陷,沒(méi)什么理由:
#ifndef DM9000AE_ZENGJUN_SHARE
DM9000_ior(DM9000_MRRH);
DM9000_ior(DM9000_MRRL);
#endif
/* Check packet ready or not */
DM9000_ior(DM9000_MRCMDX); /* Dummy read */

最后,注空eth_halt函數(shù),一切OK;設(shè)置好網(wǎng)關(guān),服務(wù)器,就能下載內(nèi)核了。

默認(rèn)的是CS8900,有這個(gè)CS8900的好處是,他把XM0CSN1所在的BANK1初始化了,省的我再去配時(shí)序,下面是飛凌默認(rèn)設(shè)置時(shí)的u-boot輸出:

OKs

U-Boot 1.1.6 (Nov 5 2010 - 10:29:09) for SMDK6410

CPU: S3C6410@532MHz
Fclk = 532MHz, Hclk = 133MHz, Pclk = 66MHz, Serial = CLKUART (SYNC Mode)
Board: SMDK6410
DRAM: 128 MB
Flash: 0 kB
NAND: 1024 MB
*** Warning - bad CRC or NAND, using default environment

In: serial
Out: serial
Err: serial
Hit any key to stop autoboot: 0
SMDK6410 # ping 192.168.1.10
CS8900 Ethernet chip not found?!
ping failed; host 192.168.1.10 is not alive
SMDK6410 # ping 192.168.1.10
CS8900 Ethernet chip not found?!
ping failed; host 192.168.1.10 is not alive
SMDK6410 #

    相關(guān)評(píng)論

    閱讀本文后您有什么感想? 已有人給出評(píng)價(jià)!

    • 8 喜歡喜歡
    • 3 頂
    • 1 難過(guò)難過(guò)
    • 5 囧
    • 3 圍觀圍觀
    • 2 無(wú)聊無(wú)聊

    熱門評(píng)論

    最新評(píng)論

    第 2 樓 福建聯(lián)通3G統(tǒng)一出口 網(wǎng)友 客人 發(fā)表于: 2011/10/23 20:47:25
    寫得真的很不錯(cuò),按樓主步驟做了一遍,果然u-boot就可以使用tftp下載了。太感謝樓主啦! 希望樓主以后還能寫出更好的文章,方便我們這些初學(xué)者。

    支持( 0 ) 蓋樓(回復(fù))

    第 1 樓 廣東深圳電信 網(wǎng)友 客人 發(fā)表于: 2010/12/29 10:40:27
    很好很強(qiáng)大

    支持( 0 ) 蓋樓(回復(fù))

    發(fā)表評(píng)論 查看所有評(píng)論(0)

    昵稱:
    表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
    字?jǐn)?shù): 0/500 (您的評(píng)論需要經(jīng)過(guò)審核才能顯示)