注册 登录
电子工程世界-论坛 返回首页 EEWORLD首页 频道 EE大学堂 下载中心 Datasheet 专题
gongping11的个人空间 https://home.eeworld.com.cn/space-uid-67414.html [收藏] [复制] [分享] [RSS]
日志

u-boot-2010.06移植到TQ2440过程4-网络DM9000

已有 3333 次阅读2011-10-10 21:32 |个人分类:嵌入式学习-uboot移植|

网络的移植,由于TQ2440的网卡是DM9000,而SMDK2410的网卡是CS8900,因此需要移植,
DM9000的一些代码在net文件夹中已经存在,只需要对照CS8900进行移植。
首先板级屏蔽掉CS8900的宏,添加DM9000相关的宏
57 /*
58 * Hardware drivers
59 */
60 /*屏蔽CS8900的宏定义*/
61 #if 0
62 #define CONFIG_NET_MULTI
63 #define CONFIG_CS8900 /* we have a CS8900 on-board */
64 #define CONFIG_CS8900_BASE 0x19000300
65 #define CONFIG_CS8900_BUS16 /* the Linux driver does accesses as sho rts */
66 #endif
68 /*添加DM9000的宏定义*/
69 #define CONFIG_DRIVER_DM9000 1
70 #define CONFIG_NET_MULTI 1
71 #define CONFIG_DM9000_NO_SROM 1
72 #define CONFIG_DM9000_BASE 0x20000300 /*网卡片选地址*/
73 #define DM9000_IO CONFIG_DM9000_BASE
74 #define DM9000_DATA (CONFIG_DM9000_BASE + 4) /*网卡数据地址*/
102 /*添加ping命令*/
103 #define CONFIG_CMD_PING
104 /*添加网卡支持命令*/
105 #define CONFIG_CMD_NET
106 /*添加NFS命令*/
107 #define CONFIG_CMD_NFS
121 /*恢复被注销的网卡MAC地址*/
122 #define CONFIG_ETHADDR 08:00:3e:26:0a:5b
123
124 /*子网掩码*/
125 #define CONFIG_NETMASK 255.255.255.0
126 /*添加TQ2440的IP地址*/
127 #define CONFIG_IPADDR 192.168.10.122
128 /*添加主机IP地址*/
129 #define CONFIG_SERVERIP 192.168.10.154
 
对了还需要添加初始化代码
/*添加DM9000的初始化代码*/
vi board/samsung/smdk2440/smdk2440.c中,查找CS8900相关的即可实现
编译下载测试:
##### Boot for Nor Flash Main Menu #####
##### EmbedSky TFTP download mode #####
[1] Download u-boot.bin to Nand Flash
[2] Download Eboot (eboot.nb0) to Nand Flash
[3] Download Linux Kernel (zImage.bin) to Nand Flash
[4] Download stepldr.nb1 to Nand Flash
[5] Set TFTP parameters(PC IP,TQ2440 IP,Mask IP...)
[6] Download YAFFS image (root.bin) to Nand Flash
[7] Download Program (uCOS-II or TQ2440_Test) to SDRAM and Run it
[8] Boot the system
[9] Format the Nand Flash
[0] Set the boot parameters
[a] Download User Program (eg: uCOS-II or TQ2440_Test)
[b] Download LOGO Picture (.bin) to Nand Flash
 
[o] Download u-boot to Nor Flash
[p] Test network (TQ2440 Ping PC's IP)
[r] Reboot u-boot
[t] Test Linux Image (zImage)
[q] Return main Menu
Enter your selection: 1
dm9000 i/o: 0x20000300, id: 0x90000a46
MAC: 0a:1b:2c:3d:4e:5f
TFTP from server 192.168.10.154; our IP address is 192.168.10.122
Filename 'u-boot.bin'.
Load address: 0x30000000
Loading: T ##########
done
Bytes transferred = 142244 (22ba4 hex)
NAND erase: device 0 offset 0x0, size 0x40000
Erasing at 0x20000 -- 100% complete.
OK
NAND write: device 0 offset 0x0, size 0x22ba4
Writing data at 0x22800 -- 100% complete.
142244 bytes written: OK
Enter your selection:
U-Boot 2010.06 (Oct 08 2011 - 19:17:17)
DRAM: 64 MiB
Flash: 2 MiB
NAND: 256 MiB
In: serial
Out: serial
Err: serial
Net: dm9000 /*DM9000移植成功*/
Hit any key to stop autoboot: 0
Unknown command 'boot_zImage' - try 'help'
u-boot@SMDK2440 # tftpboot 0x30000000 u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 0a:1b:2c:3d:4e:5f
could not establish link
Using dm9000 device
TFTP from server 192.168.10.154; our IP address is 192.168.10.122 /*TFTP成功*/
Filename 'u-boot.bin'.
Load address: 0x30000000
Loading: ##########
done
Bytes transferred = 142244 (22ba4 hex)
u-boot@SMDK2440 # go 0x30000000
## Starting application at 0x30000000 ...
u-boot@SMDK2440 # nfs 0x30000000 192.168.10.154:/opt/filesystem/zImage.bin /*NFS支持*/
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 0a:1b:2c:3d:4e:5f
could not establish link
Using dm9000 device
File transfer via NFS from server 192.168.10.154; our IP address is 192.168.10.2
Filename '/opt/filesystem/zImage.bin'.
Load address: 0x30000000
Loading: *
done
u-boot@SMDK2440 # go 0x30000000
## Starting application at 0x30000000 ...
U-Boot 2010.06 (Oct 08 2011 - 19:17:17)
DRAM: 64 MiB
Flash: 2 MiB
NAND: 256 MiB
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
u-boot@SMDK2440 #
结合网上的论述,建议将一些代码屏蔽掉,避免出更多的问题,主要是一些错误标示和延迟时间相关
的东西。首先,现在虽然成功了,但是还存在一些问题就是启动网络的服务非常的慢,需要等较长的
时间,同时结合别人的经验,我也照着做了修改。
1、修改网卡的DM9000的驱动bug
/*屏蔽掉网卡报coudle not estable link 的错误*/
[root@Gong-Computer u-boot-2010.06]# vi drivers/net/dm9000x.c
static int dm9000_init(struct eth_device *dev, bd_t *bd)
......
#if 0
i = 0;
while (!(phy_read(1) & 0x20)) { /* autonegation complete bit */
udelay(1000);
i++;
if (i == 10000) {
printf("could not establish link\n");
return 0;
}
}
#endif
2屏蔽掉dm9000_halt 函数中的内容
[root@Gong-Computer u-boot-2010.06]# vi drivers/net/dm9000x.c
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
}
编译下载,下载可以采用之前移植的nand flash和网络进行烧写了,而不用再使用TQ2440提供的uboot
命令了。具体操作如下:
U-Boot 2010.06 (Oct 09 2011 - 14:42:27)
DRAM: 64 MiB
Flash: 2 MiB
NAND: 256 MiB
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
Unknown command 'boot_zImage' - try 'help'
u-boot@SMDK2440 # tftp 0x30000000 u-boot_netbug.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 0a:1b:2c:3d:4e:5f
could not establish link
Using dm9000 device
TFTP from server 192.168.10.154; our IP address is 192.168.10.122
Filename 'u-boot_netbug.bin'.
Load address: 0x30000000
Loading: ##########
done
Bytes transferred = 144512 (23480 hex)
u-boot@SMDK2440 # nand erase 0x0 0x40000
NAND erase: device 0 offset 0x0, size 0x40000
Erasing at 0x20000 -- 100% complete.
OK
u-boot@SMDK2440 # nand write 0x30000000 0x0 0x40000
NAND write: device 0 offset 0x0, size 0x40000
262144 bytes written: OK
u-boot@SMDK2440 #
Nand Flash的写入一定是先擦除再写入,这是Flash的特点。
重启以后得到如下的效果:
U-Boot 2010.06 (Oct 09 2011 - 19:45:11)
DRAM: 64 MiB
Flash: 2 MiB
NAND: 256 MiB
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
Unknown command 'boot_zImage' - try 'help'
u-boot@SMDK2440 #
测试网络命令:
u-boot@SMDK2440 # ping 192.168.10.154
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 0a:1b:2c:3d:4e:5f
operating at unknown: 0 mode
Using dm9000 device
host 192.168.10.154 is alive
u-boot@SMDK2440 # tftp 0x30000000 uImage.img
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 0a:1b:2c:3d:4e:5f
operating at unknown: 0 mode
Using dm9000 device
TFTP from server 192.168.10.154; our IP address is 192.168.10.122
Filename 'uImage.img'.
Load address: 0x30000000
Loading: #################################################################
#################################################################
##################################
done
Bytes transferred = 2400432 (24a0b0 hex)
这个时候的速度相比之前要快很多。
但是出现了新的问题,NFS不能实现了,具体参看下面的问题。
u-boot@SMDK2440 # nfs 0x30000000 192.168.10.154:/opt/filesystem
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 0a:1b:2c:3d:4e:5f
operating at unknown: 0 mode
Using dm9000 device
File transfer via NFS from server 192.168.10.154; our IP address is 192.168.10.122
Filename '/opt/filesystem'.
Load address: 0x30000000
Loading: T *** ERROR: Cannot mount
T T T T T T T T T T T T T T T T T T T T T T T T T T T T T
Retry count exceeded; starting again
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 0a:1b:2c:3d:4e:5f
operating at unknown: 0 mode
Using dm9000 device
File transfer via NFS from server 192.168.10.154; our IP address is 192.168.10.122
Filename '/opt/filesystem'.
Load address: 0x30000000
Loading: *** ERROR: Cannot mount
T T T T T T T T T T T T T T T T T T T T T T T T T T T T T
根据网上的说法我又修改了net/nfs.c
[root@Gong-Computer u-boot-2010.06]# vi net/nfs.c
nfs_umountall_reply (uchar *pkt, unsigned len)
{
struct rpc_t rpc_pkt;
debug("%s\n", __func__);
memcpy ((unsigned char *)&rpc_pkt, pkt, len);
/*我修改过*/
// if (ntohl(rpc_pkt.u.reply.id) != rpc_id)
if ((ntohl(rpc_pkt.u.reply.id)+1) != rpc_id)
return -1;
if (rpc_pkt.u.reply.rstatus ||
rpc_pkt.u.reply.verifier ||
rpc_pkt.u.reply.astatus) {
return -1;
}
fs_mounted = 0;
memset (dirfh, 0, sizeof(dirfh));
return 0;
}
u-boot@SMDK2440 # tftp 0x30000000 u-boot_nfs.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 0a:1b:2c:3d:4e:5f
operating at unknown: 0 mode
Using dm9000 device
TFTP from server 192.168.10.154; our IP address is 192.168.10.122
Filename 'u-boot_nfs.bin'.
Load address: 0x30000000
Loading: ##########
done
Bytes transferred = 144520 (23488 hex)
u-boot@SMDK2440 # nand erase 0x0 0x40000
NAND erase: device 0 offset 0x0, size 0x40000
Erasing at 0x20000 -- 100% complete.
OK
u-boot@SMDK2440 # nand write 0x30000000 0x0 0x40000
NAND write: device 0 offset 0x0, size 0x40000
262144 bytes written: OK
u-boot@SMDK2440 #
U-Boot 2010.06 (Oct 09 2011 - 20:10:13)
DRAM: 64 MiB
Flash: 2 MiB
NAND: 256 MiB
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
Unknown command 'boot_zImage' - try 'help'
u-boot@SMDK2440 # nfs 0x30000000 192.168.10.154:/opt/filesystem/u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 0a:1b:2c:3d:4e:5f
operating at unknown: 0 mode
Using dm9000 device
File transfer via NFS from server 192.168.10.154; our IP address is 192.168.10.122
Filename '/opt/filesystem/u-boot.bin'.
Load address: 0x30000000
Loading: T #############################*** ERROR: Cannot umount
我将刚才改过的地方再改了回来,竟然发现能够加载了,可能是因为我的文件数据太大(>64M),
导致RAM区不能正常的接受,因此不能加载成功,但是小的数据能够实现文件的加载,如下图所示。
u-boot@SMDK2440 # nfs 0x30000000 192.168.10.154:/opt/filesystem/u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 0a:1b:2c:3d:4e:5f
operating at unknown: 0 mode
Using dm9000 device
File transfer via NFS from server 192.168.10.154; our IP address is 192.168.10.122
Filename '/opt/filesystem/u-boot.bin'.
Load address: 0x30000000
Loading: #############################
done
Bytes transferred = 144520 (23488 hex)
实质上此时已经可以用于linux操作系统的移植,接下来我们进行移植。
评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

热门文章