PHY使用MII和RMII与SAM9260链接时需要注意的事项

问题1:

采用newmsg-9260的开发板,开发板上的PHY使用RMII方式链接SAM9260,而实际的目标板上,为了将4层板改为2层板,将连接方式由RMII改为了MII,由此带来的问题如下:

1. 不管使用newmsg更改过的源码还是从kernel.org下载的源码,不管如何更改内核选项,编译生成的内核uImage通过NFS方式挂载根文件系统时,总是不能成功挂载根文件系统,出现错误提示:

IP-Config: Complete:
     device=eth0, addr=192.168.1.244, mask=255.255.255.0, gw=255.255.255.255,
     host=192.168.1.244, domain=, nis-domain=(none),
     bootserver=255.255.255.255, rootserver=192.168.1.200, rootpath=
Looking up port of RPC 100003/2 on 192.168.1.200
eth0: link up (10/Half)
eth0: link down
eth0: link up (10/Half)
rpcbind: server 192.168.1.200 not responding, timed out
Root-NFS: Unable to get nfsd port number from server, using default
Looking up port of RPC 100005/1 on 192.168.1.200
rpcbind: server 192.168.1.200 not responding, timed out
Root-NFS: Unable to get mountd port number from server, using default
Root-NFS: Server returned error -5 while mounting /nfsroot/root422
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "<NULL>" or unknown-block(2,0)
Please append a correct "root=" boot option; here are the available partitions:
1f00          258048 mtdblock0 (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

解决:

修改了./arch/arm/mach-at91/board-sam9260ek.c中一行,is_rmii由1改为0,编译后通过NFS可以成功加载根文件系统了;

[1]. 修改的地方ek_macb_data = {
    .phy_irq_pin    = AT91_PIN_PA7,
    .is_rmii    = 0,
    // .is_rmii    = 1,
};
[2]. MII和RMII的时钟频率不一样,今天查了下,MII的时钟频率是100Mbps时25MHz,10Mbp时2.5Mhz;而RMII省了一半信号线,所以频率提高一倍到50MHz;

既然时钟不一样,程序中必然需要用到条件语句分别进行配置。
[3]. 网上看到对函数lpc32xx_mii_probe()的分析:lpc32xx_mii_probe()完成了这样一个事情:找到第一个phy设备,然后根据内核配置,选用MII接口或RMII接口,之后再进行简单的配置。

这部分说明了,起关键作用的是,内核源码中有一个参数设定了使用MII还是RMII;
[4]. 确实在配置网络时有很多地方用到了is_rmii作为条件,查找is_rmii的赋值的地方,最终确认是./arch/arm/mach-at91/board-sam9260ek.c中的ek_macb_data;


问题2:

使用newmsg提供的U-Boot源码u-boot-2009.11-rc2.tar.gz编译,在U-Boot命令行模式下,始终不能ping通主机上的服务器,从而不能使用tftp方式加载内核镜像等;

解决:

在用户自定义的头文件newmsg9260.h中,对宏CONFIG_RMII的定义是#define CONFIG_RMII     1
原来以为,要禁止使用RMII方式,只需要将CONFIG_RMII宏的数值改为0;

[1]. 实际用到此宏定义作为判别条件的文件macb.c中对宏CONFIG_RMII的引用是这样的,#ifdef CONFIG_RMII;

[2]. 要使得判别条件#ifdef CONFIG_RMII为假,不能使用#define CONFIG_RMII 0的方式进行声明,而应该使用#undef CONFIG_RMII的方式来声明;

[3]. 换用#undef CONFIG_RMII的方式声明后,编译生成的二进制文件下载到开发板的flash中,在U-Boot的命令行模式,发现不能ping通服务器了,这是我们期望的;

开发板原来能ping通服务器,现在不能ping通了,说明用#undef CONFIG_RMII的方式做的声明起作用了;

[4]. 编译生成的二进制文件下载到目标板的flash中,在U-Boot的命令行模式,发现能够ping通服务器了,这是我们期望的;

[5]. 目标板上使用tftp命令加载各种镜像文件,网络很通畅,又解决了一个拦路虎;


原文地址:https://www.cnblogs.com/java20130726/p/3218567.html