Chinaunix首页 | 论坛 | 博客
  • 博客访问: 79044
  • 博文数量: 26
  • 博客积分: 46
  • 博客等级: 民兵
  • 技术积分: 170
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-19 23:01
文章分类
文章存档

2012年(26)

我的朋友

分类:

2012-05-28 11:02:37

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开发板的DM9000 10/100M网卡调试通过之后;上面的输出信息是通过网卡下载内核到mobile sdram的log。

板卡是飞凌设计的OK6410,默认带的u-boot居然不支持tftp,ping这些基本的东西。下载个内核吭哧吭哧几十分钟,当然也可以用USB会快很多,但是作者爱瞎折腾,要把这个烂东西调通,DM9000AE,嗬,不知道这世界上还有没有人用这玩意。

修改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

一般的网卡甚至USB,蓝牙芯片都会外接预留的EEPROM,用来存储地址等配置信息;DM9000也不例外,默认驱动就是使用EEPROM存地址的,飞凌为了省钱,直接悬空,因此MAC地址需要从Nand Flash上面读出来,再写到DM9000寄存器里。

从Linux2.6.28内核中拷贝如下2个函数,后面判断空地址要用:
/**
* 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]);
}

无数的先贤采用了以下代码来设置MAC地址,外加空判断,算是很排场了:
/* 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


另外参考内核代码rx之前一定要读两次MRR,估计是芯片设计缺陷,没什么理由:
#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函数,一切OK;设置好网关,服务器,就能下载内核了。

默认的是CS8900,有这个CS8900的好处是,他把XM0CSN1所在的BANK1初始化了,省的我再去配时序,下面是飞凌默认设置时的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 #


阅读(1175) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~