http://blog.ednchina.com/singlechip/2154280/message.aspx
估计此方法不仅针对2011.03版本有用,对其他版本应该也有用,具体自己没测试过。
针对DM9000A 的移植,网上一般都将DM9000X.C以下代码给屏蔽了。
i = 0;
while (!(phy_read(1) & 0x20)) { /* autonegation complete bit */
udelay(1000);
i++;
if (i == 10000) {
printf("could not establish link/n");
return 0;
}
}
这样就不会提示" could not establish link" ping的时候失败,但会出现第一次ping,或tftp时失败,每次都要终止,再次ping才能通,这对直接下载内核运行有所不变。
后来自己通过增加延时,彻底解决了此问题,每次上电都能一次性ping成功,tftp也能一次成功。
具体如下:
i = 0;
while (!(phy_read(1) & 0x20)) { /* autonegation complete bit */
udelay(1000);
i++;
if (i == 500000) {
printf("could not establish link/n");
return 0;
}
}
问题就解决了!
U-Boot 2011.03-dirty (Oct 24 2011 - 22:44:00)
DRAM: 64 MiB
Flash: 512 KiB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: dm9000
YY2440 # tftp 33000000 u-boot.bin
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:0c:20:02:0a:5b
operating at unknown: 7 mode
Using dm9000 device
TFTP from server 192.168.1.51; our IP address is 192.168.1.3
Filename 'u-boot.bin'.
Load address: 0x33000000
Loading: ##########
done
Bytes transferred = 134128 (20bf0 hex)
U-Boot 2011.03-dirty (Oct 24 2011 - 22:44:00)
DRAM: 64 MiB
Flash: 512 KiB
*** Warning - bad CRC, using default environment
In: serial
Out: serial
Err: serial
Net: dm9000
YY2440 # ping 192.168.1.51
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:0c:20:02:0a:5b
operating at unknown: 7 mode
Using dm9000 device
host 192.168.1.51 is alive
YY2440 #
每次出现 operating at unknown: 7 mode 对使用没有任何影响,所以我没屏蔽掉它。
/* see what we've got */
lnk = phy_read(17) >> 12;
printf("operating at ");
switch (lnk) {
case 1:
printf("10M half duplex ");
break;
case 2:
printf("10M full duplex ");
break;
case 4:
printf("100M half duplex ");
break;
case 8:
printf("100M full duplex ");
break;
default:
printf("unknown: %d ", lnk);
break;
}
printf("mode\n");
////////////////////////////////////////
修正 2011.10.25 20:15
以上是针对用旧的u-boot 烧写新的 u-boot 到内存 运行的情况
如果 u-boot 是烧写到 nandflash 运行时,把
i = 0;
while (!(phy_read(1) & 0x20)) { /* autonegation complete bit */
udelay(1000);
i++;
if (i == 10000) {
printf("could not establish link/n");
return 0;
}
}
屏蔽掉,ping tftp 的响应速度非常快。。。。。而且第一次也能成功。
////////////////////////////////////////
U-Boot 2011.03-dirty (Oct 25 2011 - 20:08:54)
DRAM: 64 MiB
NAND: NAND_ECC_NONE selected by board driver. This is not recommended !!
64 MiB
In: serial
Out: serial
Err: serial
Net: dm9000
Hit any key to stop autoboot: 0
YY2440 # ping 192.168.1.51
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:0c:20:02:0a:5b
operating at unknown: 0 mode
Using dm9000 device
host 192.168.1.51 is alive
YY2440 # tftp 30000000 u-boot.bin
dm9000 i/o: 0x18000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 00:0c:20:02:0a:5b
operating at unknown: 0 mode
Using dm9000 device
TFTP from server 192.168.1.51; our IP address is 192.168.1.3
Filename 'u-boot.bin'.
Load address: 0x30000000
Loading: ############
done
Bytes transferred = 170572 (29a4c hex)
YY2440 # nand erase 0 30000
NAND erase: device 0 offset 0x0, size 0x30000
Erasing at 0x2c000 -- 100% complete.
OK
YY2440 # nand write 30000000 0 30000
NAND write: device 0 offset 0x0, size 0x30000
196608 bytes written: OK
用户434599 2012-10-25 13:04