1. 代码修改
1.1 修改include/configs/tiny6410.h,屏蔽CS9000的宏定义,增加DM9000的宏定义
/*
* Hardware drivers
*/
#if 0
#define CONFIG_CS8900 /* we have a CS8900 on-board */
#define CONFIG_CS8900_BASE 0x18800300
#define CONFIG_CS8900_BUS16 /* follow the Linux driver */
#endif
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE (0x18000300) /*XM0CSN1*/
#define DM9000_IO (CONFIG_DM9000_BASE)
#define DM9000_DATA (CONFIG_DM9000_BASE+0x4) /*ADDR2*/
//#define CONFIG_DM9000_DEBUG 1
#define CONFIG_DM9000_USE_16BIT 1
#define CONFIG_ETHADDR 08:08:10:12:10:27
#define CONFIG_NETMASK 255.255.255.0
#define CONFIG_IPADDR 192.168.1.253
#define CONFIG_SERVERIP 192.168.1.100
#define CONFIG_GATEWAYIP 192.168.1.1
1.2 修改include/configs/tiny6410.h,在board_eth_init()函数中增加
#if defined(CONFIG_DRIVER_DM9000)
rc = dm9000_initialize(bis);
#endif
2. 编译、烧写、测试
CPU: S3C6400@667MHz
Fclk = 667MHz, Hclk = 133MHz, Pclk = 66MHz (ASYNC Mode)
Board: SMDK6400
DRAM: 256 MiB
WARNING: Caches not enabled
Flash: *** failed ***
Please check codes for flash...
MMC: SAMSUNG SD/MMC: 0
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
Unknown command 'nand' - try 'help'
Wrong Image Format for bootm command
ERROR: can't get kernel image!
TINY6410 # ping 192.168.1.100
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:10:12:10:27
could not establish link
Using dm9000 device
raise: Signal # 8 caught
raise: Signal # 8 caught
raise: Signal # 8 caught
raise: Signal # 8 caught
raise: Signal # 8 caught
host 192.168.1.100 is alive
TINY6410 #
通过ping命令测试网络连接状况,出现“could not establish link”报错,并打印“raise: Signal # 8 caught”。网上搜索解决方案,通过修改arch/arm/cpu/arm1176/s3c64xx/timer.c中的几个变量名可以解决问题:
/*
* (C) Copyright 2003
* Texas Instruments <www.ti.com>
*
* (C) Copyright 2002
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Marius Groeger <mgroeger@sysgo.de>
*
* (C) Copyright 2002
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Alex Zuepke <azu@sysgo.de>
*
* (C) Copyright 2002-2004
* Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
*
* (C) Copyright 2004
* Philippe Robin, ARM Ltd. <philippe.robin@arm.com>
*
* (C) Copyright 2008
* Guennadi Liakhovetki, DENX Software Engineering, <lg@denx.de>
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include <asm/proc-armv/ptrace.h>
#include <asm/arch/s3c6400.h>
#include <div64.h>
//static ulong timer_load_val;
DECLARE_GLOBAL_DATA_PTR;
#define PRESCALER 167
static s3c64xx_timers *s3c64xx_get_base_timers(void)
{
return (s3c64xx_timers *)ELFIN_TIMER_BASE;
}
/* macro to read the 16 bit timer */
static inline ulong read_timer(void)
{
s3c64xx_timers *const timers = s3c64xx_get_base_timers();
return timers->TCNTO4;
}
#if 0
/* Internal tick units */
/* Last decremneter snapshot */
static unsigned long lastdec;
/* Monotonic incrementing timer */
static unsigned long long timestamp;
#endif
int timer_init(void)
{
s3c64xx_timers *const timers = s3c64xx_get_base_timers();
/* use PWM Timer 4 because it has no output */
/*
* We use the following scheme for the timer:
* Prescaler is hard fixed at 167, divider at 1/4.
* This gives at PCLK frequency 66MHz approx. 10us ticks
* The timer is set to wrap after 100s, at 66MHz this obviously
* happens after 10,000,000 ticks. A long variable can thus
* keep values up to 40,000s, i.e., 11 hours. This should be
* enough for most uses:-) Possible optimizations: select a
* binary-friendly frequency, e.g., 1ms / 128. Also calculate
* the prescaler automatically for other PCLK frequencies.
*/
timers->TCFG0 = PRESCALER << 8;
#if 0
if (timer_load_val == 0) {
timer_load_val = get_PCLK() / PRESCALER * (100 / 4); /* 100s */
timers->TCFG1 = (timers->TCFG1 & ~0xf0000) | 0x20000;
}
#endif
gd->timer_rate_hz = get_PCLK() / PRESCALER * (100 / 4); /* 100s */
timers->TCFG1 = (timers->TCFG1 & ~0xf0000) | 0x20000;
/* load value for 10 ms timeout */
//lastdec = timers->TCNTB4 = timer_load_val;
gd->lastinc = timers->TCNTB4 = gd->timer_rate_hz;
/* auto load, manual update of Timer 4 */
timers->TCON = (timers->TCON & ~0x00700000) | TCON_4_AUTO |
TCON_4_UPDATE;
/* auto load, start Timer 4 */
timers->TCON = (timers->TCON & ~0x00700000) | TCON_4_AUTO | COUNT_4_ON;
//timestamp = 0;
gd->timer_reset_value = 0;
return 0;
}
/*
* timer without interrupts
*/
/*
* This function is derived from PowerPC code (read timebase as long long).
* On ARM it just returns the timer value.
*/
unsigned long long get_ticks(void)
{
ulong now = read_timer();
//if (lastdec >= now) {
if (gd->lastinc >= now) {
/* normal mode */
//timestamp += lastdec - now;
gd->timer_reset_value += gd->lastinc - now;
} else {
/* we have an overflow ... */
//timestamp += lastdec + timer_load_val - now;
gd->timer_reset_value += gd->lastinc + gd->timer_rate_hz - now;
}
//lastdec = now;
gd->lastinc = now;
//return timestamp;
return gd->timer_reset_value;
}
/*
* This function is derived from PowerPC code (timebase clock frequency).
* On ARM it returns the number of timer ticks per second.
*/
ulong get_tbclk(void)
{
/* We overrun in 100s */
//return (ulong)(timer_load_val / 100);
return (ulong)(gd->timer_rate_hz / 100);
}
ulong get_timer_masked(void)
{
unsigned long long res = get_ticks();
//do_div (res, (timer_load_val / (100 * CONFIG_SYS_HZ)));
do_div(res, (gd->timer_rate_hz / (100 * CONFIG_SYS_HZ)));
return res;
}
ulong get_timer(ulong base)
{
return get_timer_masked() - base;
}
void __udelay(unsigned long usec)
{
unsigned long long tmp;
ulong tmo;
tmo = (usec + 9) / 10;
tmp = get_ticks() + tmo; /* get current timestamp */
while (get_ticks() < tmp)/* loop till event */
/*NOP*/;
}
重新编译、烧写、测试:
U-Boot 2012.10 (May 01 2020 - 13:06:31) for TINY6410
CPU: S3C6400@667MHz
Fclk = 667MHz, Hclk = 133MHz, Pclk = 66MHz (ASYNC Mode)
Board: SMDK6400
DRAM: 256 MiB
WARNING: Caches not enabled
Flash: *** failed ***
Please check codes for flash...
MMC: SAMSUNG SD/MMC: 0
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
Unknown command 'nand' - try 'help'
Wrong Image Format for bootm command
ERROR: can't get kernel image!
TINY6410 # ping 192.168.1.100
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:10:12:10:27
operating at 100M full duplex mode
Using dm9000 device
host 192.168.1.100 is alive
TINY6410 #
可以ping通我的linux服务器,说明DM9000正常运行。