20240819解决飞凌的OK3588-C的核心板的适配以太网卡RTL8211F-CG在百兆模式下通过交换机上外网

20240819解决飞凌的OK3588-C的核心板的适配以太网卡RTL8211F-CG在百兆模式下通过交换机上外网
2024/8/19 18:00


缘由:由于自制的飞凌的OK3588-C的核心板的底板对空间要求高/敏感,并且对网速要求不高,百兆即可满足要求。
也就直接使用千兆网卡芯片RTL8211F-CG的百兆模式了,4线,节省一半的面积!
当然,你也可呢过会说,直接使用百兆网卡芯片不就得了?
你是对的,由于网卡芯片MAC/PHY的严重降价,你已经找不到纯粹的百兆网卡芯片了,直接上千兆,降级到百兆使用。

现象:飞凌的OK3588-C的核心板通过底板的RTL8211F-CG和电脑直连,可以让USB转千兆网卡协商成为百兆模式!
链接速度(接受/传输 ):100/100 (Mbps)

root@ok3588:/#
root@ok3588:/# ethtool eth0
Settings for eth0:
        Supported ports: [ TP MII ]
        Supported link modes:   10baseT/Full
                                100baseT/Full
                                1000baseT/Full
        Supported pause frame use: Symmetric Receive-only
        Supports auto-negotiation: Yes
        Supported FEC modes: Not reported
        Advertised link modes:  10baseT/Full
                                100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: Symmetric Receive-only
        Advertised auto-negotiation: Yes
        Advertised FEC modes: Not reported
        Link partner advertised link modes:  10baseT/Half 10baseT/Full
                                             100baseT/Half 100baseT/Full
        Link partner advertised pause frame use: No
        Link partner advertised auto-negotiation: Yes
        Link partner advertised FEC modes: Not reported
        Speed: 100Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 2
        Transceiver: external
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: ug
        Wake-on: d
        Current message level: 0x0000003f (63)
                               drv probe link timer ifdown ifup
        Link detected: yes
root@ok3588:/#

电脑和飞凌的OK3588-C的核心板可以互PING。
核心板:192.168.0.232
电脑:192.168.0.88


root@ok3588:/# 
root@ok3588:/# ifconfig
eth0      Link encap:Ethernet  HWaddr F6:2F:1C:58:C5:DA  
          inet addr:192.168.0.232  Bcast:0.0.0.0  Mask:255.255.255.0

          inet6 addr: fe80::f42f:1cff:fe58:c5da/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3346 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3081 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:287967 (281.2 KiB)  TX bytes:261406 (255.2 KiB)
          Interrupt:79 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:131 errors:0 dropped:0 overruns:0 frame:0
          TX packets:131 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:338490 (330.5 KiB)  TX bytes:338490 (330.5 KiB)

root@ok3588:/# ping 192.168.0.88 
PING 192.168.0.88 (192.168.0.88) 56(84) bytes of data.
64 bytes from 192.168.0.88: icmp_seq=1 ttl=128 time=2.92 ms
64 bytes from 192.168.0.88: icmp_seq=2 ttl=128 time=1.64 ms

64 bytes from 192.168.0.88: icmp_seq=3 ttl=128 time=1.42 ms
64 bytes from 192.168.0.88: icmp_seq=4 ttl=128 time=1.44 ms
64 bytes from 192.168.0.88: icmp_seq=5 ttl=128 time=1.50 ms


Microsoft Windows [版本 10.0.22621.3296]
(c) Microsoft Corporation。保留所有权利。

C:\Users\QQ>adb shell
root@ok3588:/# ping 192.168.0.88
PING 192.168.0.88 (192.168.0.88) 56(84) bytes of data.
64 bytes from 192.168.0.88: icmp_seq=1 ttl=128 time=1.42 ms
64 bytes from 192.168.0.88: icmp_seq=2 ttl=128 time=1.45 ms

64 bytes from 192.168.0.88: icmp_seq=3 ttl=128 time=1.54 ms
64 bytes from 192.168.0.88: icmp_seq=4 ttl=128 time=1.44 ms
64 bytes from 192.168.0.88: icmp_seq=5 ttl=128 time=1.66 ms
^C
--- 192.168.0.88 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4007ms
rtt min/avg/max/mdev = 1.422/1.501/1.656/0.087 ms
root@ok3588:/# exit
logout


飞凌的OK3588-C的核心板通过底板的RTL8211F-CG经交换机中转,确认协商异常:(还是千兆模式)
root@ok3588:/# 
root@ok3588:/# ethtool eth0
Settings for eth0:
    Supported ports: [ TP MII ]
    Supported link modes:   10baseT/Full 
                            100baseT/Full 
                            1000baseT/Full 
    Supported pause frame use: Symmetric Receive-only
    Supports auto-negotiation: Yes
    Supported FEC modes: Not reported
    Advertised link modes:  10baseT/Full 
                            100baseT/Full 
                            1000baseT/Full 
    Advertised pause frame use: Symmetric Receive-only
    Advertised auto-negotiation: Yes
    Advertised FEC modes: Not reported
    Link partner advertised link modes:  10baseT/Half 10baseT/Full 
                                         100baseT/Half 100baseT/Full 
                                         1000baseT/Full 
    Link partner advertised pause frame use: Symmetric Receive-only
    Link partner advertised auto-negotiation: Yes
    Link partner advertised FEC modes: Not reported
    Speed: 1000Mb/s
    Duplex: Full
    Port: Twisted Pair
    PHYAD: 2
    Transceiver: external
    Auto-negotiation: on
    MDI-X: Unknown
    Supports Wake-on: ug
    Wake-on: d
    Current message level: 0x0000003f (63)
                   drv probe link timer ifdown ifup
    Link detected: yes
root@ok3588:/# 
root@ok3588:/# 
root@ok3588:/# 


时间长了就会变成:
root@ok3588:/# 
root@ok3588:/# 
root@ok3588:/# ethtool eth0
Settings for eth0:
    Supported ports: [ TP MII ]
    Supported link modes:   10baseT/Full 
                            100baseT/Full 
                            1000baseT/Full 
    Supported pause frame use: Symmetric Receive-only
    Supports auto-negotiation: Yes
    Supported FEC modes: Not reported
    Advertised link modes:  10baseT/Full 
                            100baseT/Full 
                            1000baseT/Full 
    Advertised pause frame use: Symmetric Receive-only
    Advertised auto-negotiation: Yes
    Advertised FEC modes: Not reported
    Speed: Unknown!
    Duplex: Unknown! (255)
    Port: Twisted Pair
    PHYAD: 2
    Transceiver: external
    Auto-negotiation: on
    MDI-X: Unknown
    Supports Wake-on: ug
    Wake-on: d
    Current message level: 0x0000003f (63)
                   drv probe link timer ifdown ifup
    Link detected: no

root@ok3588:/# 


电话飞凌,得知有人这样干过,出过同样的问题。
解决方法:锁死RTL8211F-CG的最高速度为百兆,这样它就不会再千兆出错了!

Z:\OK3588_Linux_fs\kernel\drivers\net\ethernet\stmicro\stmmac\stmmac_main.c
static void stmmac_validate(struct phylink_config *config,
                unsigned long *supported,
                struct phylink_link_state *state)
{
    struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
    __ETHTOOL_DECLARE_LINK_MODE_MASK(mac_supported) = { 0, };
    __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
    int tx_cnt = priv->plat->tx_queues_to_use;
    int max_speed = priv->plat->max_speed;

    phylink_set(mac_supported, 10baseT_Half);
    phylink_set(mac_supported, 10baseT_Full);
    phylink_set(mac_supported, 100baseT_Half);
    phylink_set(mac_supported, 100baseT_Full);
    phylink_set(mac_supported, 1000baseT_Half);
    phylink_set(mac_supported, 1000baseT_Full);
    phylink_set(mac_supported, 1000baseKX_Full);

    phylink_set(mac_supported, Autoneg);
    phylink_set(mac_supported, Pause);
    phylink_set(mac_supported, Asym_Pause);
    phylink_set_port_modes(mac_supported);

修改为:
static void stmmac_validate(struct phylink_config *config,
                unsigned long *supported,
                struct phylink_link_state *state)
{
    struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
    __ETHTOOL_DECLARE_LINK_MODE_MASK(mac_supported) = { 0, };
    __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
    int tx_cnt = priv->plat->tx_queues_to_use;
    int max_speed = priv->plat->max_speed;

    phylink_set(mac_supported, 10baseT_Half);
    phylink_set(mac_supported, 10baseT_Full);
    phylink_set(mac_supported, 100baseT_Half);
    phylink_set(mac_supported, 100baseT_Full);
    //phylink_set(mac_supported, 1000baseT_Half);
    //phylink_set(mac_supported, 1000baseT_Full);
    //phylink_set(mac_supported, 1000baseKX_Full);

    phylink_set(mac_supported, Autoneg);
    phylink_set(mac_supported, Pause);
    phylink_set(mac_supported, Asym_Pause);
    phylink_set_port_modes(mac_supported);


接交换机 初看 是改过来了。
我 搜索的时候 找到很多1000的地方。确认只需要关闭 这三行?

之前可以,先试下呢


确认可以PING百度了!
(一)静态IP模式:
root@ok3588:/# 
root@ok3588:/# cd /etc/network/
root@ok3588:/etc/network# ls -l
total 24
drwxr-xr-x 2 root root 4096 Mar  9  2023 if-down.d
drwxr-xr-x 2 root root 4096 Mar  9  2023 if-post-down.d
drwxr-xr-x 2 root root 4096 Mar  9  2023 if-pre-up.d
drwxr-xr-x 2 root root 4096 Mar  9  2023 if-up.d
-rw-r--r-- 1 root root  130 Mar  9  2023 interfaces
-rwxr-xr-x 1 root root  846 Mar  9  2023 nfs_check
root@ok3588:/etc/network# 
root@ok3588:/etc/network# cat interfaces 
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.0.232
netmask 255.255.255.0
gateway 192.168.0.1

root@ok3588:/etc/network# 
root@ok3588:/etc/network# cp interfaces interfaces.bak1
root@ok3588:/etc/network# 
root@ok3588:/etc/network# vi interfaces
root@ok3588:/etc/network# 
root@ok3588:/etc/network# cat interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.3.232
netmask 255.255.255.0
gateway 192.168.3.1

root@ok3588:/etc/network# 
root@ok3588:/etc/network# diff interfaces interfaces.bak1 
--- interfaces
+++ interfaces.bak1
@@ -3,7 +3,7 @@
 
 auto eth0
 iface eth0 inet static
-address 192.168.3.232
+address 192.168.0.232
 netmask 255.255.255.0
-gateway 192.168.3.1
+gateway 192.168.0.1
 
root@ok3588:/etc/network# 


内网/局域网测试:
root@ok3588:/# 
root@ok3588:/# ping 192.168.3.85
PING 192.168.3.85 (192.168.3.85) 56(84) bytes of data.
64 bytes from 192.168.3.85: icmp_seq=1 ttl=64 time=0.404 ms
64 bytes from 192.168.3.85: icmp_seq=2 ttl=64 time=0.439 ms

64 bytes from 192.168.3.85: icmp_seq=3 ttl=64 time=0.490 ms
64 bytes from 192.168.3.85: icmp_seq=4 ttl=64 time=0.426 ms
64 bytes from 192.168.3.85: icmp_seq=5 ttl=64 time=0.378 ms
64 bytes from 192.168.3.85: icmp_seq=6 ttl=64 time=0.381 ms
64 bytes from 192.168.3.85: icmp_seq=7 ttl=64 time=0.361 ms
64 bytes from 192.168.3.85: icmp_seq=8 ttl=64 time=0.326 ms
64 bytes from 192.168.3.85: icmp_seq=9 ttl=64 time=0.499 ms
64 bytes from 192.168.3.85: icmp_seq=10 ttl=64 time=0.309 ms
64 bytes from 192.168.3.85: icmp_seq=11 ttl=64 time=0.315 ms
64 bytes from 192.168.3.85: icmp_seq=12 ttl=64 time=0.398 ms


viewpro@viewpro-ThinkBook-16-G5-IRH:~$
viewpro@viewpro-ThinkBook-16-G5-IRH:~$ ping 192.168.3.232
PING 192.168.3.232 (192.168.3.232) 56(84) bytes of data.
64 bytes from 192.168.3.232: icmp_seq=1 ttl=64 time=0.489 ms
64 bytes from 192.168.3.232: icmp_seq=2 ttl=64 time=0.305 ms

64 bytes from 192.168.3.232: icmp_seq=3 ttl=64 time=0.387 ms
64 bytes from 192.168.3.232: icmp_seq=4 ttl=64 time=0.317 ms


外网测试:
root@ok3588:/# 
root@ok3588:/# ping www.baidu.com
ping: www.baidu.com: Temporary failure in name resolution

root@ok3588:/# 


root@ok3588:/# 
root@ok3588:/# cd /etc/
root@ok3588:/etc# 
root@ok3588:/etc# ls -l resolv.conf 
lrwxrwxrwx 1 root root 18 Mar  9  2023 resolv.conf -> ../tmp/resolv.conf
root@ok3588:/etc# 

飞凌的人在保定PING百度之后,得到北方百度的IP地址:110.242.68.66
将名字服务器nameserver 8.8.8.8写入到/etc/resolv.conf中
【神奇的是,典型的DNS:114.114.114.114无效了】

echo nameserver 8.8.8.8 > /etc/resolv.conf


【切记,必须要有空行】

然后通过adb登录飞凌的OK3588-C的核心板,即可PING通百度了!

C:\Users\QQ>adb shell
adb server version (40) doesn't match this client (41); killing...
* daemon started successfully
root@ok3588:/# ping www.baidu.com
PING www.a.shifen.com (183.2.172.42) 56(84) bytes of data.
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=1 ttl=54 time=7.26 ms
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=2 ttl=54 time=7.04 ms

64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=3 ttl=54 time=7.16 ms
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=4 ttl=54 time=7.37 ms
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=37 ttl=54 time=7.45 ms
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=38 ttl=54 time=7.44 ms
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=39 ttl=54 time=6.67 ms
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=40 ttl=54 time=6.41 ms
64 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=41 ttl=54 time=6.81 ms

C:\Users\QQ>


由于/etc/resolv.conf链接到/tmp/resolv.conf上。也就是重启之后失效!
飞凌建议在开机自启动脚本中每次都重新生成这个文件了!


(二)静态IP模式:
配置ETH0的动态IP:
root@ok3588:/etc/network# vi interfaces 
root@ok3588:/etc/network# cat interfaces 
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
#address 192.168.0.232
#netmask 255.255.255.0
#gateway 192.168.0.1

root@ok3588:/etc/network# 


重启,获取动态IP失败:
Starting iptables: OK
Starting bluetoothd: OK
Starting network: udhcpc: started, v1.34.1
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: no lease, failing
FAIL
starting weston... done.


那就再来一遍:
root@ok3588:/# udhcpc 
udhcpc: started, v1.34.1
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover


启动的时候udhcpc获取动态IP成功:
Starting system message bus: done
Starting iptables: OK
Starting bluetoothd: OK
Starting network: udhcpc: started, v1.34.1
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting discover
udhcpc: broadcasting select for 192.168.3.209, server 192.168.3.1
udhcpc: lease of 192.168.3.209 obtained from 192.168.3.1, lease time 86400
deleting routers
adding dns 192.168.3.1
OK
starting weston... done.
Starting dropbear sshd: OK
Starting lighttpd: OK


root@ok3588:/# 
root@ok3588:/# 
root@ok3588:/# ifconfig
eth0      Link encap:Ethernet  HWaddr F6:2F:1C:58:C5:DA  
          inet addr:192.168.3.209  Bcast:192.168.3.255  Mask:255.255.255.0

          inet6 addr: fe80::f42f:1cff:fe58:c5da/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:190 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27233 (26.5 KiB)  TX bytes:1410 (1.3 KiB)
          Interrupt:79 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:125 errors:0 dropped:0 overruns:0 frame:0
          TX packets:125 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:337818 (329.9 KiB)  TX bytes:337818 (329.9 KiB)

root@ok3588:/# 
root@ok3588:/# cat /etc/resolv.conf 
nameserver 192.168.3.1 # eth0
root@ok3588:/# 
root@ok3588:/# ping www.baidu.com
PING www.baidu.com (183.2.172.185) 56(84) bytes of data.
64 bytes from www.baidu.com (183.2.172.185): icmp_seq=1 ttl=54 time=8.29 ms
64 bytes from www.baidu.com (183.2.172.185): icmp_seq=2 ttl=54 time=7.02 ms

64 bytes from www.baidu.com (183.2.172.185): icmp_seq=3 ttl=54 time=6.41 ms
64 bytes from www.baidu.com (183.2.172.185): icmp_seq=4 ttl=54 time=7.19 ms
64 bytes from www.baidu.com (183.2.172.185): icmp_seq=5 ttl=54 time=6.64 ms
64 bytes from www.baidu.com (183.2.172.185): icmp_seq=6 ttl=54 time=6.86 ms
64 bytes from www.a.shifen.com (183.2.172.185): icmp_seq=7 ttl=54 time=6.80 ms
64 bytes from www.a.shifen.com (183.2.172.185): icmp_seq=8 ttl=54 time=6.71 ms
64 bytes from www.a.shifen.com (183.2.172.185): icmp_seq=9 ttl=54 time=6.88 ms
64 bytes from www.a.shifen.com (183.2.172.185): icmp_seq=10 ttl=54 time=6.86 ms
64 bytes from www.a.shifen.com (183.2.172.185): icmp_seq=11 ttl=54 time=6.55 ms
64 bytes from 183.2.172.185: icmp_seq=12 ttl=54 time=6.71 ms
64 bytes from www.baidu.com (183.2.172.185): icmp_seq=13 ttl=54 time=8.96 ms
64 bytes from www.baidu.com (183.2.172.185): icmp_seq=14 ttl=54 time=6.87 ms
64 bytes from www.baidu.com (183.2.172.185): icmp_seq=15 ttl=54 time=15.5 ms
64 bytes from www.baidu.com (183.2.172.185): icmp_seq=16 ttl=54 time=6.20 ms
64 bytes from 183.2.172.185: icmp_seq=17 ttl=54 time=13.8 ms
64 bytes from 183.2.172.185: icmp_seq=18 ttl=54 time=6.91 ms
^C64 bytes from 183.2.172.185: icmp_seq=19 ttl=54 time=6.49 ms

  • 10
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值