您的位置:首页 > 其它

移植uboot到fl2440支持DM9000网卡

2016-03-10 21:53 603 查看
之前的博客中移植了uboot到fl2440开发板,并在内存中运行,在实际应用中经常使用nfs或者tftp把内核或文件系统映像下载到内存中,然后再运行或者烧写进Nandflash等存储设备中,而nfs或者tftp都需要网卡驱动的支持,常用的网卡有CS8900和DM9000,fl2440中用的就是DM9000,下面修改uboot源码使之支持DM9000网卡。

修改PLL宏定义

在board/fl2440/fl2440.c添加宏定义:

其中有些原来有的,删掉原来的。

#define FCLK_SPEED 1
#if FCLK_SPEED==0               /* Fout = 203MHz, Fin = 12MHz for Audio */
#define M_MDIV  0xC3
#define M_PDIV  0x4
#define M_SDIV  0x1
#elif FCLK_SPEED==1             /* Fout = 202.8MHz */
#if defined(CONFIG_S3C2410)     /* Fout = 202.8MHz */
#define M_MDIV  0xA1
#define M_PDIV  0x3
#define M_SDIV  0x1
#endif

#if defined(CONFIG_S3C2440)     /* Fout = 405MHZ */
#define M_MDIV 0x7f
#define M_PDIV 0x2
#define M_SDIV 0x1
#endif
#endif

#define USB_CLOCK 1

#if USB_CLOCK==0
#define U_M_MDIV        0xA1
#define U_M_PDIV        0x3
#define U_M_SDIV        0x1
#elif USB_CLOCK==1
#if defined(CONFIG_S3C2410)
#define U_M_MDIV    0x48
#define U_M_PDIV    0x3
#define U_M_SDIV    0x2
#endif

#if defined(CONFIG_S3C2440)
#define U_M_MDIV    0x38
#define U_M_PDIV    0x2
#define U_M_SDIV    0x2
#endif
#endif


增加对DM9000网卡的支持

1.修改board/fl2440/fl2440.c中的int board_eth_init(bd_t *bis)函数为:

int board_eth_init(bd_t *bis)
{
int rc = 0;
#ifdef CONFIG_CS8900
rc = cs8900_initialize(0, CONFIG_CS8900_BASE);
#endif
#ifdef CONFIG_DRIVER_DM9000
rc = dm9000_initialize(bis);
#endif
return rc;
}

2.修改include/configs/fl2440.h文件中关于网卡的宏定义

(1)

将代码:

#define CONFIG_NET_MULTI

#define CONFIG_CS8900 /* we have a CS8900 on-board */

#define CONFIG_CS8900_BASE 0x19000300

#define CONFIG_CS8900_BUS16 /* the Linuxdriver does accesses as shorts */

修改为:

#define CONFIG_NET_MULTI                 1
#define CONFIG_DRIVER_DM9000             1
#define CONFIG_DM9000_USE_16BIT          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 //防止dm9000去从srom中读取物理地址信息

(2)然后在98附近添加宏定义

#define CONFIG_CMD_DHCP  //开发板连接PC后执行dhcp命令,开发板会给PC分配一个ip地址
#define CONFIG_CMD_PING
#define CONFIG_CMD_NET

(3)在104行附近修改

/*#define CONFIG_ETHADDR 08:00:3e:26:0a:5b */

#define CONFIG_NETMASK 255.255.255.0

#define CONFIG_IPADDR 10.0.0.110

#define CONFIG_SERVERIP 10.0.0.1

为:

#define CONFIG_ETHADDR  08:00:3e:26:0a:5b
#define CONFIG_NETMASK      255.255.255.0
#define CONFIG_IPADDR       192.168.1.15 //开发板的IP
#define CONFIG_SERVERIP     192.168.1.16 //PC的IP

(4) 注释掉drivers/net/dm9000x.c的函数static void dm9000_halt(struct eth_device *netdev)中的RESET代码,防止DM9000连接上主机后又断开。



编译测试

完成上面修改之后编译生成u-boot.bin,然后下载到内存中运行,运行起来之后用交叉网线(不宜过长,1m左右即可)连接开发板和PC,再输入dhcp,等PC连接上了之后使用ping命令测试网络是否通畅(只能从开发板ping电脑,电脑ping开发板是不会通的,因为uboot没有回复ping命令的函数)。下面是u-boot.bin的ping命令测试:

ping测试通过,同时可以看到PC收到了开发板的数据。

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: