U-boot-200908在FL2440上的移植(三)--移植DM9000
来源:互联网 发布:日志系统数据库设计 编辑:程序博客网 时间:2024/05/12 11:30
hah,经过两天的努力终于把DM9000 给Ping 通了,搞死了,下面介绍一下移植的过程
1.打开/driver/net/dm9000x.c,定位到大概377行在dm9000_init函数中修改如下:
DM9000_iow(DM9000_IMR, IMR_PAR);378 #if 1379 380 i = 0;381 while (!(phy_read(1) & 0x20)) { /* autonegation complete bit */382 udelay(1000);383 i++;384 if (i == 1650) { //3000385 //printf("could not establish link\n");386 break;387 //return 0;388 }389 }390 #endif
2。对于NFS,增加了延时,否则会出现“*** ERROR: Cannot mount”的错误。打开
打开/net/nfs.c,定位到36行,修改如下:
#if defined(CONFIG_CMD_NET) && defined(CONFIG_CMD_NFS)#define HASHES_PER_LINE 65 /* Number of "loading" hashes per line */#define NFS_RETRY_COUNT 30#define NFS_TIMEOUT (CONFIG_SYS_HZ/1000*2000UL) //2000UL
3.添加网卡芯片(DM9000)的初始化函数
int dram_init (void){ gd->bd->bi_dram[0].start = PHYS_SDRAM_1; gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE; return 0;}#include <net.h>#include <netdev.h> extern int dm9000_initialize(bd_t *bis);//implicit declaration of function 'dm9000_initialize'#ifdef CONFIG_DRIVER_DM9000int board_eth_init(bd_t *bis){ return dm9000_initialize(bis);}#endif
4.修改配置文件,在mini2440.h中加入相关定义
打开/include/configs/mini2440.h,
(1)定位到60行附近,修改如下:
/* * Hardware drivers */#if 0#define CONFIG_DRIVER_CS8900 1 /* we have a CS8900 on-board */#define CS8900_BASE 0x19000300#define CS8900_BUS16 1 /* the Linux driver does accesses as shorts */#endif #define CONFIG_NET_MULTI 1#define CONFIG_DRIVER_DM9000 1#define CONFIG_DM9000_BASE 0x20000300 //网卡片选地址#define DM9000_IO CONFIG_DM9000_BASE#define DM9000_DATA (CONFIG_DM9000_BASE+4) //网卡数据地址#define CONFIG_DM9000_NO_SROM 1//#define CONFIG_DM9000_USE_16BIT#undef CONFIG_DM9000_DEBUG
注意:
u-boot-2009.08 可以自动检测DM9000网卡的位数,根据开发板原理图可知网卡的数据位为16位,并且网卡位
于CPU的BANK4上,所以只需在 board/samsung/mini2440/lowlevel_init.S中设置 #define B4_BWSCON (DW16) 即
可,不需要此处的 #define CONFIG_DM9000_USE_16BIT 1
(2)给u-boot加上ping命令,用来测试网络通不通
/* * Command line configuration. */#include <config_cmd_default.h>#define CONFIG_CMD_CACHE#define CONFIG_CMD_DATE#define CONFIG_CMD_ELF#define CONFIG_CMD_NAND#define CONFIG_CMD_JFFS2 /* JFFS2 Support*/#define CONFIG_CMD_PING /*ping command support*/
(3)恢复被注释掉的网卡MAC地址和修改你合适的开发板IP地址以及内核启动参数:
#define CONFIG_BOOTDELAY 3/*#define CONFIG_BOOTARGS "root=ramfs devfs=mount console=ttySA0,9600" */#define CONFIG_ETHADDR 00:12:34:56:80:49 /*08:00:3e:26:0a:5b */#define CONFIG_NETMASK 255.255.255.0#define CONFIG_IPADDR 192.168.80.254//#define CONFIG_SERVERIP #define CONFIG_GATEWAYIP 192.168.80.1//#define CONFIG_OVERWRITE_ETHADDR_ONCE//#define CONFIG_DM9000_DEBUG#undef CONFIG_DM9000_DEBUG
5.打开drivers/net/dm9000x.c ,定位到456行附近,屏蔽掉dm9000_halt函数中的内容:
/* Stop the interface. The interface is stopped when it is brought.*/static void dm9000_halt(struct eth_device *netdev){#if 0 DM9000_DBG("%s\n", __func__); /* RESET devie */ phy_write(0, 0x8000); /* PHY RESET */ DM9000_iow(DM9000_GPR, 0x01); /* Power-Down PHY */ DM9000_iow(DM9000_IMR, 0x80); /* Disable all interrupt */ DM9000_iow(DM9000_RCR, 0x00); /* Disable RX */#endif }
6.打开/drivers/net/dm9000x.c,定位到595行附近,修改如下:
/* Read a word from phyxcer*/static u16phy_read(int reg){ u16 val; /* Fill the phyxcer register into REG_0C */ DM9000_iow(DM9000_EPAR, DM9000_PHY | reg); DM9000_iow(DM9000_EPCR, 0xc); /* Issue phyxcer read command */----------------------------------------------- udelay(1000); //udelay(100); /* Wait read complete */------------------------------------------------------- DM9000_iow(DM9000_EPCR, 0x0); /* Clear phyxcer read command */ val = (DM9000_ior(DM9000_EPDRH) << 8) | DM9000_ior(DM9000_EPDRL); /* The read data keeps on REG_0D & REG_0E */ DM9000_DBG("phy_read(0x%x): 0x%x\n", reg, val); return val;}
这个延时其实很重要的啦,不然会有时出现"operating at unknown: 0 mode"
7.修改drivers/net/dm9000x.c
(1)修改函数:phy_read将 udelay(100); 替换为下面:
int i; …… …… //udelay(100); /* Wait read complete */ i=0; while(DM9000_ior(DM9000_EPCR) & 0x01) /* Wait read complete */ { udelay(100); i++; if (i == 1000) { printf("DM9000 access error/n"); return 0; } }
(2)修改函数phy_write将 udelay(500); 替换为下面:
int i; …… …… //udelay(500); i=0; while(DM9000_ior(DM9000_EPCR) & 0x01) /* Wait read complete */ { udelay(100); i++; if (i == 1000) { printf("DM9000 access error/n"); return 0; } }
(3)注释掉下面函数的调试信息部分,有助于看清调试的信息
static u16phy_read(int reg)//DM9000_DBG("phy_read(0x%x): 0x%x/n", reg, val);
(4)修改函数 dm9000_init
将语句if (i == 10000) { printf("could not establish link/n"); return 0;}替换为/*if (i == 10000) { printf("could not establish link/n"); return 0;}*/if (i == 1650) { break;}
8.修改文件/net/net.c
(1)大概在104行
# define ARP_TIMEOUT 5000UL /* Milliseconds before trying ARP again */替换成# define ARP_TIMEOUT (CONFIG_SYS_HZ/1000*5000UL)
(2)575行
NetSetTimeout (10000UL, startAgainTimeout);替换成NetSetTimeout (10000UL*CONFIG_SYS_HZ/1000, startAgainTimeout);
(3)586行
NetSetTimeout (10000UL, startAgainTimeout);替换成NetSetTimeout (10000UL*CONFIG_SYS_HZ/1000, startAgainTimeout);
(4)757行
NetSetTimeout (10000UL, PingTimeout);替换成NetSetTimeout (10000UL*CONFIG_SYS_HZ/1000, PingTimeout);
(5)781行
#define CDP_TIMEOUT 250UL /* one packet every 250ms */替换成#define CDP_TIMEOUT (250UL*CONFIG_SYS_HZ/1000)
9.很多人建议对UPLL MPLL的设置变换顺序
在 board/samsung/fl2440/fl2440.c 的 board_init 函数
很奇怪,就是开机后,把开发板和主机用网线连起来后,电脑上提示网线未连接,但是我ping 192.168.80.44(我主机上的ip),这样
后,主机上的网络开始搜网了,然后ping的话就可以ping通了,很多网友将这是正常的,我就也没担心了。反正就是好了!!嘎嘎
- U-boot-200908在FL2440上的移植(三)--移植DM9000
- fl2440的U-boot-2010.09移植(三)DM9000网卡及开发板相关配置
- u-boot-2011.03在mini2440/micro2440上的移植(三)——支持DM9000
- U-boot-200908在FL2440上的移植(二)--uboot在norflash上运行
- u-boot-2009.08在飞凌OK2440/FL2440上的移植(三)——让u-boot支持DM9000A
- U-boot-200908在FL2440上的移植(一)--uboot在RAM中运行
- U-boot-200908在FL2440上的移植(四)--用nfs和tftp下载
- U-boot在S3C2440上的移植详解(三)
- U-boot在S3C2440上的移植详解(三)
- fl2440 移植u-boot-2010.09全纪录3----------DM9000网卡支持
- FL2440移植u-boot
- U-BOOT全线移植分析系列之三 U-BOOT在AT91RM9200上的移植
- U-BOOT全线移植分析系列之三 U-BOOT在AT91RM9200上的移植
- u-boot-2009.08在mini2440上的移植 增加DM9000网卡驱动
- fl2440的U-boot-2010.09移植
- FL2440的U-boot-2010.09移植
- fl2440——u-boot的移植
- u-boot-2009.08在mini2440上的移植(四)---增加DM9000驱动和命令自动补全功能
- Python基础09 面向对象的进一步拓展
- UML进行Linux内核调试 --2 网络协议栈测试
- 代码有警告不知道哪里有问题!
- ArcGIS API for Silverlight 之ElementLayer使用及TextSymbol的模板使用
- ubuntu12.04重置root密码
- U-boot-200908在FL2440上的移植(三)--移植DM9000
- Velocity和FreeMarker - Spring Framework reference 2.0.5 使用比较
- Quartz 2D 学习
- 重装vs2005,bug消失!
- 析构函数调用顺序
- oracle rownum的使用
- 在ubuntu上安装 pygame
- mongodb分布式集群架构
- 百度笔试题第一弹