如题。
目前正在调试基于BeagleBone AM335X 公司画的板子,利用了RGMII的第二路网口。
使用的PHY芯片是AT8031 两个,分别连接到 AM335X 的 RGMII1 和 RGMII2。
目前 RGMII1 对应的 eth0 是通的,工作正常。RGMII2 对应的eth1始终无法调通。
根据TI官网的 CPSW Ethernet Dual EMac 配置正确的 DeviceTree(pinmux & dual_emac = <1>,见底部),打开了 VLAN 选项。
确定了cpsw.c 中 ALE_Control 寄存器地址的 ale_vlan_aware 位设置了。
详细情况:
现象1 : eth1 和我的电脑直连,从eth1ping通我的电脑,并用wireshark抓到了ping的请求和反馈。可反过来电脑ping eth1不通。PS.电脑百兆网口
现象2:强制使用ethtool设置网口工作模式为 100M ,autoneg off , fule duplex模式,通过eth1 无法ping通外界。
现象3:设置eth1 的IP地址,外界能够ping通eth1的IP,但是从 eth0 进入的!!!看上去eth0模拟了虚拟IP。
原理理解:
CPSW 仅仅只是一个MAC来管理两个 PHY,所以中间引入了一个 ALE(address lookup engine)来做片选哪个PHY的工作。这样来管理两个PHY,并正常工作。不确定我理解的对不,所以查阅了 ALE_Control 和 ale_vlan_aware 寄存器均正确。
参考1 , device tree 节选:
cpsw_default: cpsw_default {
pinctrl-single,pins = <
/* Slave 1 */
/*0x110 (PIN_INPUT_PULLUP | MUX_MODE2)*/ /* rgmii1_rxerr.rgmii1_rxerr */
0x114 (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* rgmii1_txen.rgmii1_txen */
0x118 (PIN_INPUT_PULLUP | MUX_MODE2) /* rgmii1_rxdv.rgmii1_rxdv */
0x11c (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* rgmii1_txd3.rgmii1_txd3 */
0x120 (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* rgmii1_txd2.rgmii1_txd2 */
0x124 (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* rgmii1_txd1.rgmii1_txd1 */
0x128 (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* rgmii1_txd0.rgmii1_txd0 */
0x12c (PIN_INPUT_PULLUP | MUX_MODE2) /* rgmii1_txclk.rgmii1_txclk */
0x130 (PIN_INPUT_PULLUP | MUX_MODE2) /* rgmii1_rxclk.rgmii1_rxclk */
0x134 (PIN_INPUT_PULLUP | MUX_MODE2) /* rgmii1_rxd3.rgmii1_rxd3 */
0x138 (PIN_INPUT_PULLUP | MUX_MODE2) /* rgmii1_rxd2.rgmii1_rxd2 */
0x13c (PIN_INPUT_PULLUP | MUX_MODE2) /* rgmii1_rxd1.rgmii1_rxd1 */
0x140 (PIN_INPUT_PULLUP | MUX_MODE2) /* rgmii1_rxd0.rgmii1_rxd0 */
/* Slave 2 */
0x40 (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a0.rgmii2_tctl */
0x44 (PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a1.rgmii2_rctl */
0x48 (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a2.rgmii2_td3 */
0x4c (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a3.rgmii2_td2 */
0x50 (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a4.rgmii2_td1 */
0x54 (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a5.rgmii2_td0 */
0x58 (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* gpmc_a6.rgmii2_tclk */
0x5c (PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a7.rgmii2_rclk */
0x60 (PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a8.rgmii2_rd3 */
0x64 (PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a9.rgmii2_rd2 */
0x68 (PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a10.rgmii2_rd1 */
0x6c (PIN_INPUT_PULLDOWN | MUX_MODE2) /* gpmc_a11.rgmii2_rd0 */
>;
};
......
......
&cpsw_emac0 {
phy_id = <&davinci_mdio>, <0>;
mac-address = [ 12 23 34 45 56 67 ];
phy-mode = "rgmii";
dual_emac_res_vlan = <0>;
};
&cpsw_emac1 {
phy_id = <&davinci_mdio>, <1>;
phy-mode = "rgmii";
mac-address = [ 22 32 43 54 65 76 ];
dual_emac_res_vlan = <0>;
};
&mac {
pinctrl-names = "default", "sleep";
pinctrl-0 = <&cpsw_default>;
pinctrl-1 = <&cpsw_sleep>;
dual_emac;
};
参考2, Dual Emac 配置方法,节选 AM335X Technical Reference:
14.3.2.10.2 Dual Mac Mode
When operating in dual mac mode the intention is to transfer packets between ports 0 and 1 and ports 0
and 2, but not between ports 1 and 2. Each CPGMAC_SL appears as a single MAC with no bridging
between MAC’s. Each CPGMAC_SL has at least one unique (not the same) mac address.
Dual mac mode is configured as described below:
• Set the ale_vlan_aware bit in the ALE_Control register. This bit configures the ALE to process in vlan
aware mode.The CPSW_3G vlan aware bit (vlan_aware in CPSW_Control) determines how packets
VLAN’s are processed on CPGMAC_SL egress and does not affect how the ALE processes packets or
the packet destination. The CPSW_3G vlan aware bit may be set or not as required (must be set if
VLAN’s are to exit the switch).
• Configure the Port 1 to Port 0 VLAN
Add a VLAN Table Entry with ports 0 and 1 as members (clear the flood masks).
Add a VLAN/Unicast Address Table Entry with the Port1/0 VLAN and a port number of 0. Packets
received on port 1 with this unicast address will be sent only to port 0 (egress). If multiple mac addresses
are desired for this port then multiple entries of this type may be configured.
• Configure the Port 2 to Port 0 VLAN
Add a VLAN Table Entry with ports 0 and 2 as members (clear the flood masks).
Add a VLAN/Unicast Address Table Entry with the Port2/0 VLAN and a port number of 0. Packets
received on port 2 with this unicast address will be sent only to port 0 (egress). If multiple mac addresses
are desired for this port then multiple entries of this type may be configured.
• Packets from the host (port 0) to ports 1 and 2 should be directed. If directed packets are not desired
then VLAN with addresses can be added for both destination ports.
• Select the dual mac mode on the port 0 FIFO by setting tx_in_sel[1:0] = 01 in P0_Tx_In_Ctl. The
intention of this mode is to allow packets from both ethernet ports to be written into the FIFO without
one port starving the other port.
• The priority levels may be configured such that packets received on port 1 egress on one CPDMA RX
channel while packets received on port 2 egress on a different CPDMA RX channel.
PS. 我照做了,也确认过没有问题。
参考3, TI 官网 CPSW Ethernet配置介绍:
http://processors.wiki.ti.com/index.php/AM335x_CPSW_(Ethernet)_Driver%27s_Guide#Dual_Standalone_EMAC_mode
我照做了,其中使用的SDK比较老,基于 kernel v3.2 的,而最新的基于 kernel v3.12 是 sdk7.0,但是发现最后的并没有这个选项: Emac switch 。有其他建议么?
期待回复啊。有人有类似的经验么?AM335X 第二路网口调通过的同仁们。