cat /sys/kernel/debug/pinctrl/pinctrl-rockchip-pinctrl/pinmux-pins
cat /sys/kernel/debug/gpio


20251225给飞凌OK3588-C开发板适配Rockchip原厂的Android14时将RTL8211F-CG配置为4线百兆模式实测网速94.0 Mbits/sec
2025/12/25 15:26


缘起:给飞凌OK3588-C开发板适配Rockchip原厂的Android14后,需要将以太网卡芯片RTL8211F-CG配置为4线百兆模式。
【丝印ETH,实际eth0】

在Rockchip原厂的
Buildroot【linux-5.10】 拿掉千兆选项。
Buildroot【linux-6.1】直接不动,系统自适应了!
系统上都很容易调通了百兆模式。


步骤:
1、首先解决掉gpio冲突。
2、拿掉gmac0/mdio0也不行!
3、那就只能在DTS中锁定百兆模式!
4、驱动stmmac_main.c中锁定百兆模式!
Y:\new_disk_4t\wyb\RD-RK3588\rk3588u_RK3576_SDK_RELEASE\kernel-6.1\drivers\net\ethernet\stmicro\stmmac\stmmac_main.c


// 2025/12/19 9:16 wenyuanbo add for  GMAC1 RESET
//&pcie2x1l0 {
//    reset-gpios = <&gpio1 RK_PB4 GPIO_ACTIVE_HIGH>;
//    status = "okay";
//};


需要配置ssh。
驱动调试的时候DEBUG口就足够了。最多再打开一个USB接口的adb功能。【有些时候需要多一个口^_】
但是产品给客户暴露的借口就是TF卡的卡槽和以太网接口了!【应用工程师需要的ssh功能】


想实测一下TF卡的读写速度。
4线USB2.0通过adb直接拿到电脑上的速度是:31.3 MB/s
写入TF卡的速度略微低于31.3 MB/s【大概为25.56MB/s】


需要实测开发板丝印ETH1芯片RTL8211F-CG的网速。
通过ifconfig确认为eth0。

需要使用ov5645的驱动框架来适配LVDS接口的105机芯。
按照以前的经验,首先关闭I2C的读写!
结果,肯定会出现某些地方遗漏的,只能通过编译器来检查问题了!


当你把荣品RD-RK3588开发板重新适配一把,就相当于从头做了一个项目:【荣品RD-RK3588开发板】。
当然,开发板的功能都是好的,你免除了调试的过程,也就没有解决相关硬件出错的经验/机会了!

1、
Y:\new_disk_4t\wyb\RD-RK3588\rk3588u_RK3576_SDK_RELEASE\kernel-6.1\arch\arm64\boot\dts\rockchip\rk3588-evb7-v11.dtsi

&gmac1 {
    /* Use rgmii-rxid mode to disable rx delay inside Soc */
    phy-mode = "rgmii-rxid";
    clock_in_out = "output";

    snps,reset-gpio = <&gpio3 RK_PB7 GPIO_ACTIVE_LOW>;
    snps,reset-active-low;
    /* Reset time is 20ms, 100ms for rtl8211f */
    snps,reset-delays-us = <0 20000 100000>;

    pinctrl-names = "default";
    pinctrl-0 = <&gmac1_miim
             &gmac1_tx_bus2
             &gmac1_rx_bus2
             &gmac1_rgmii_clk
             &gmac1_rgmii_bus>;

    tx_delay = <0x43>;
    /* rx_delay = <0x3f>; */

    phy-handle = <&rgmii_phy>;
    status = "okay";
};

修改为:

&gmac1 {
    /* Use rgmii-rxid mode to disable rx delay inside Soc */
    phy-mode = "rgmii-rxid";
    clock_in_out = "output";

    snps,reset-gpio = <&gpio1 RK_PB4 GPIO_ACTIVE_LOW>;
    snps,reset-active-low;
    /* Reset time is 20ms, 100ms for rtl8211f */
    snps,reset-delays-us = <0 20000 100000>;

    pinctrl-names = "default";
    pinctrl-0 = <&gmac1_miim
             &gmac1_tx_bus2
             &gmac1_rx_bus2
             &gmac1_rgmii_clk
             &gmac1_rgmii_bus>;

    tx_delay = <0x44>;
    /* rx_delay = <0x4f>; */

    phy-handle = <&rgmii_phy1>;
    status = "okay";
};


&i2s7_8ch {
    status = "okay";
};

&mdio1 {
    rgmii_phy: phy@1 {
        compatible = "ethernet-phy-ieee802.3-c22";
        reg = <0x1>;
    };
};

&mipi_dcphy0 {
    status = "okay";
};

修改为:

&i2s7_8ch {
    status = "okay";
};

//&mdio0 {
//    rgmii_phy0: phy@1 {
//        compatible = "ethernet-phy-ieee802.3-c22";
//        reg = <0x1>;
//    };
//};

&mdio1 {
    rgmii_phy1: phy@2 {
        compatible = "ethernet-phy-ieee802.3-c22";
        reg = <0x2>;
        
        /* 强制PHY工作在100Mbps全双工模式 */
        max-speed = <100>;

        
        /* 如果需要强制特定的速度和双工模式,可以添加以下属性 */
        /*
        speed = <100>;
        full-duplex;
        */
        
        /* 如果需要关闭自协商,强制100Mbps全双工 */
        /*
        managed = "in-band-status";  // 或者 "manual"
        autoneg = <0>;  // 关闭自协商
        */
    };
};

&mipi_dcphy0 {
    status = "okay";
};


3、实测网速:
rootroot@rootroot-X99-Turbo:~$ 
rootroot@rootroot-X99-Turbo:~$ iperf3 -c 192.168.3.242 -i 1 -t 1800
Connecting to host 192.168.3.242, port 5201
[  5] local 192.168.3.116 port 41158 connected to 192.168.3.242 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  12.0 MBytes   101 Mbits/sec   11    181 KBytes  
    
[  5]   1.00-2.00   sec  11.5 MBytes  96.4 Mbits/sec   10    168 KBytes       
[  5]   2.00-3.00   sec  11.3 MBytes  94.9 Mbits/sec    8    156 KBytes       
[  5]   3.00-4.00   sec  10.9 MBytes  91.2 Mbits/sec   10    163 KBytes       
[  5]   4.00-5.00   sec  11.3 MBytes  94.9 Mbits/sec    0    192 KBytes       
[  5]   5.00-6.00   sec  11.4 MBytes  95.9 Mbits/sec   10    178 KBytes       
[  5]   6.00-7.00   sec  10.9 MBytes  91.2 Mbits/sec    9    164 KBytes       
[  5]   7.00-8.00   sec  11.3 MBytes  94.9 Mbits/sec    8    151 KBytes       
[  5]   8.00-9.00   sec  11.3 MBytes  94.9 Mbits/sec    0    199 KBytes       
[  5]   9.00-10.00  sec  11.3 MBytes  94.9 Mbits/sec    9    189 KBytes       
[  5]  10.00-11.00  sec  10.9 MBytes  91.2 Mbits/sec   10    177 KBytes       

[  5] 1790.00-1791.00 sec  10.9 MBytes  91.7 Mbits/sec    9    188 KBytes       
[  5] 1791.00-1792.00 sec  11.3 MBytes  94.9 Mbits/sec   10    175 KBytes       
[  5] 1792.00-1793.00 sec  11.3 MBytes  94.9 Mbits/sec   10    163 KBytes       
[  5] 1793.00-1794.00 sec  11.3 MBytes  94.9 Mbits/sec   10    150 KBytes       
[  5] 1794.00-1795.00 sec  11.3 MBytes  94.9 Mbits/sec    0    199 KBytes       
[  5] 1795.00-1796.00 sec  10.9 MBytes  91.2 Mbits/sec   10    188 KBytes       
[  5] 1796.00-1797.00 sec  11.3 MBytes  94.9 Mbits/sec   10    177 KBytes       
[  5] 1797.00-1798.00 sec  11.4 MBytes  95.9 Mbits/sec    9    164 KBytes       
[  5] 1798.00-1799.00 sec  10.9 MBytes  91.2 Mbits/sec    9    150 KBytes       
[  5] 1799.00-1800.00 sec  11.3 MBytes  94.9 Mbits/sec    0    199 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-1800.00 sec  19.7 GBytes  94.0 Mbits/sec  13213             sender
[  5]   0.00-1800.09 sec  19.7 GBytes  94.0 Mbits/sec                  receiver

iperf Done.
rootroot@rootroot-X99-Turbo:~$ ll


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

C:\Users\QQ>adb shell
rk3588_u:/ $ su
rk3588_u:/ #
rk3588_u:/ # ll
total 92
drwxr-xr-x   2 root   root       4096 2025-12-25 06:25 acct
drwxr-xr-x  67 root   root       1400 1970-01-01 00:00 apex
lrw-r--r--   1 root   root         11 2025-12-25 06:25 bin -> /system/bin
lrw-r--r--   1 root   root         50 2025-12-25 06:25 bugreports -> /data/user_de/0/com.android.shell/files/bugreports
drwxrwx---   6 system cache      4096 1970-01-01 00:00 cache
drwxr-xr-x   3 root   root          0 1970-01-01 00:00 config
lrw-r--r--   1 root   root         17 2025-12-25 06:25 d -> /sys/kernel/debug
drwxrwx--x  50 system system     4096 2025-12-25 06:25 data
drwx------   8 root   system      160 1970-01-01 00:00 data_mirror
drwxr-xr-x   2 root   root       4096 2025-12-25 06:25 debug_ramdisk
drwxr-xr-x  25 root   root       2340 2025-12-25 06:25 dev
lrw-r--r--   1 root   root         11 2025-12-25 06:25 etc -> /system/etc
lrwxr-x---   1 root   shell        16 2025-12-25 06:25 init -> /system/bin/init
-rwxr-x---   1 root   shell       463 2025-12-25 06:25 init.environ.rc
drwxr-xr-x  13 root   root        300 1970-01-01 00:00 linkerconfig
drwx------   2 root   root      16384 2025-12-25 06:25 lost+found
drwxr-xr-x  12 root   root       4096 1970-01-01 00:00 metadata
drwxr-xr-x  16 root   system      340 1970-01-01 00:00 mnt
drwxr-xr-x   5 root   root       4096 2025-12-25 06:25 odm
drwxr-xr-x   4 root   root       4096 2025-12-25 06:25 odm_dlkm
drwxr-xr-x   2 root   root       4096 2025-12-25 06:25 oem
drwxr-xr-x   2 root   root       4096 2025-12-25 06:25 postinstall
dr-xr-xr-x 468 root   root          0 1970-01-01 00:00 proc
drwxr-xr-x   9 root   root       4096 2025-12-25 06:25 product
lrw-r--r--   1 root   root         21 2025-12-25 06:25 sdcard -> /storage/self/primary
drwxr-xr-x   2 root   root       4096 2025-12-25 06:25 second_stage_resources
drwx--x---   4 shell  everybody    80 1970-01-01 00:00 storage
dr-xr-xr-x  14 root   root          0 1970-01-01 00:00 sys
drwxr-xr-x  13 root   root       4096 2025-12-25 06:25 system
drwxr-xr-x   4 root   root       4096 2025-12-25 06:25 system_dlkm
drwxr-xr-x   8 root   root       4096 2025-12-25 06:25 system_ext
drwxr-xr-x  11 root   root       4096 2025-12-25 06:25 vendor
drwxr-xr-x   5 root   root       4096 2025-12-25 06:25 vendor_dlkm
rk3588_u:/ #
rk3588_u:/ # ifconfig
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:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 TX bytes:0

dummy0    Link encap:Ethernet  HWaddr 4e:4d:a9:a0:06:ff
          inet6 addr: fe80::4c4d:a9ff:fea0:6ff/64 Scope: Link
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 TX bytes:350

eth0      Link encap:Ethernet  HWaddr 3e:a3:45:31:f4:12  Driver rk_gmac-dwmac
          inet addr:192.168.3.242  Bcast:192.168.3.255  Mask:255.255.255.0
          inet6 addr: fe80::d7f:9472:b05:cd6a/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:849 errors:0 dropped:0 overruns:0 frame:0
          TX packets:82 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:154535 TX bytes:8477
          Interrupt:68

rk3588_u:/ #
rk3588_u:/ # iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 192.168.3.116, port 41146
[  5] local 192.168.3.242 port 5201 connected to 192.168.3.116 port 41158
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  10.7 MBytes  90.1 Mbits/sec

[  5]   1.00-2.00   sec  11.2 MBytes  94.1 Mbits/sec
[  5]   2.00-3.00   sec  11.2 MBytes  94.1 Mbits/sec
[  5]   3.00-4.00   sec  11.2 MBytes  94.0 Mbits/sec
[  5]   4.00-5.00   sec  11.2 MBytes  94.0 Mbits/sec
[  5]   5.00-6.00   sec  11.2 MBytes  94.1 Mbits/sec
[  5]   6.00-7.00   sec  11.2 MBytes  94.1 Mbits/sec
[  5]   7.00-8.00   sec  11.2 MBytes  94.0 Mbits/sec
[  5]   8.00-9.00   sec  11.2 MBytes  94.0 Mbits/sec
[  5]   9.00-10.00  sec  11.2 MBytes  94.0 Mbits/sec
[  5]  10.00-11.00  sec  11.2 MBytes  94.0 Mbits/sec

[  5] 1790.00-1791.00 sec  11.2 MBytes  94.1 Mbits/sec
[  5] 1791.00-1792.00 sec  11.2 MBytes  94.1 Mbits/sec
[  5] 1792.00-1793.00 sec  11.2 MBytes  94.1 Mbits/sec
[  5] 1793.00-1794.00 sec  11.2 MBytes  94.0 Mbits/sec
[  5] 1794.00-1795.00 sec  11.2 MBytes  94.0 Mbits/sec
[  5] 1795.00-1796.00 sec  11.2 MBytes  94.0 Mbits/sec
[  5] 1796.00-1797.00 sec  11.2 MBytes  94.0 Mbits/sec
[  5] 1797.00-1798.00 sec  11.2 MBytes  94.1 Mbits/sec
[  5] 1798.00-1799.00 sec  11.2 MBytes  94.1 Mbits/sec
[  5] 1799.00-1800.00 sec  11.2 MBytes  94.1 Mbits/sec
[  5] 1800.00-1800.09 sec  1005 KBytes  93.9 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1800.09 sec  19.7 GBytes  94.0 Mbits/sec                  receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

C:\Users\QQ>

参考资料:

RK3588网卡无法获取IP地址排查
RK3588的Android14 
以太网卡使用RTL8211F-CG芯片,4线,千兆网卡 当 百兆网卡用。
不能获取IP地址


console:/ $ 
console:/ $ su
console:/ # ifconfig
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:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:0 TX bytes:0 

dummy0    Link encap:Ethernet  HWaddr d2:2e:e7:08:32:af
          inet6 addr: fe80::d02e:e7ff:fe08:32af/64 Scope: Link
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:0 TX bytes:280 

eth0      Link encap:Ethernet  HWaddr 3e:a3:45:31:f4:12  Driver rk_gmac-dwmac
          inet6 addr: fe80::fbb1:f197:f76a:1e8a/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:488 TX bytes:2522 
          Interrupt:68 

console:/ # ifconfig -a
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:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:0 TX bytes:0 

dummy0    Link encap:Ethernet  HWaddr d2:2e:e7:08:32:af
          inet6 addr: fe80::d02e:e7ff:fe08:32af/64 Scope: Link
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:0 TX bytes:280 

ifb0      Link encap:Ethernet  HWaddr 4e:41:c4:14:20:b0
          BROADCAST NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:32 
          RX bytes:0 TX bytes:0 

ifb1      Link encap:Ethernet  HWaddr 1a:02:a6:76:39:00
          BROADCAST NOARP  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:32 
          RX bytes:0 TX bytes:0 

eth0      Link encap:Ethernet  HWaddr 3e:a3:45:31:f4:12  Driver rk_gmac-dwmac
          inet6 addr: fe80::fbb1:f197:f76a:1e8a/64 Scope: Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:488 TX bytes:2592 
          Interrupt:68 

ip_vti0   Link encap:UNSPEC  
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:0 TX bytes:0 

ip6_vti0  Link encap:UNSPEC  
          NOARP  MTU:1364  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:0 TX bytes:0 

sit0      Link encap:IPv6-in-IPv4  
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:0 TX bytes:0 

ip6tnl0   Link encap:UNSPEC  
          NOARP  MTU:1452  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:0 TX bytes:0 

console:/ # 
console:/ # 
console:/ # [   55.007086][  T278] type=1400 audit(1766642445.504:309): avc:  denied  { read } for  comm="bluetooth@1.0-s" name="u:object_r:default_prop:s0" dev="tmpfs" ino=139 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:object_r:default_prop:s0 tclass=file permissive=0
[   55.007300][  T278] type=1400 audit(1766642445.504:310): avc:  denied  { read } for  comm="bluetooth@1.0-s" name="u:object_r:default_prop:s0" dev="tmpfs" ino=139 scontext=u:r:hal_bluetooth_default:s0 tcontext=u:object_r:default_prop:s0 tclass=file permissive=0

console:/ # 
console:/ # dmesg | grep gmac
[    1.873194] rk_gmac-dwmac fe1c0000.ethernet: IRQ eth_lpi not found
[    1.873318] rk_gmac-dwmac fe1c0000.ethernet: supply phy not found, using dummy regulator
[    1.873367] rk_gmac-dwmac fe1c0000.ethernet: clock input or output? (output).
[    1.873375] rk_gmac-dwmac fe1c0000.ethernet: TX delay(0x44).
[    1.873381] rk_gmac-dwmac fe1c0000.ethernet: Can not read property: rx_delay.
[    1.873386] rk_gmac-dwmac fe1c0000.ethernet: set rx_delay to 0xffffffff
[    1.873402] rk_gmac-dwmac fe1c0000.ethernet: integrated PHY? (no).
[    1.873410] rk_gmac-dwmac fe1c0000.ethernet: cannot get clock mac_clk_rx
[    1.873416] rk_gmac-dwmac fe1c0000.ethernet: cannot get clock mac_clk_tx
[    1.873427] rk_gmac-dwmac fe1c0000.ethernet: cannot get clock clk_mac_speed
[    1.873645] rk_gmac-dwmac fe1c0000.ethernet: init for RGMII_RXID
[    1.873758] rk_gmac-dwmac fe1c0000.ethernet: User ID: 0x30, Synopsys ID: 0x51
[    1.873766] rk_gmac-dwmac fe1c0000.ethernet:     DWMAC4/5
[    1.873772] rk_gmac-dwmac fe1c0000.ethernet: DMA HW capability register supported
[    1.873778] rk_gmac-dwmac fe1c0000.ethernet: RX Checksum Offload Engine supported
[    1.873783] rk_gmac-dwmac fe1c0000.ethernet: TX Checksum insertion supported
[    1.873789] rk_gmac-dwmac fe1c0000.ethernet: Wake-Up On Lan supported
[    1.873818] rk_gmac-dwmac fe1c0000.ethernet: TSO supported
[    1.873824] rk_gmac-dwmac fe1c0000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[    1.873830] rk_gmac-dwmac fe1c0000.ethernet: Enabled L3L4 Flow TC (entries=2)
[    1.873836] rk_gmac-dwmac fe1c0000.ethernet: Enabled RFS Flow TC (entries=10)
[    1.873842] rk_gmac-dwmac fe1c0000.ethernet: TSO feature enabled
[    1.873847] rk_gmac-dwmac fe1c0000.ethernet: Using 32/32 bits DMA host/device width
[   20.313460] rk_gmac-dwmac fe1c0000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
[   20.314875] rk_gmac-dwmac fe1c0000.ethernet eth0: PHY [stmmac-1:02] driver [Generic PHY] (irq=POLL)
[   20.315330] rk_gmac-dwmac fe1c0000.ethernet eth0: No Safety Features support found
[   20.315349] rk_gmac-dwmac fe1c0000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
[   20.315632] rk_gmac-dwmac fe1c0000.ethernet eth0: registered PTP clock
[   20.318732] rk_gmac-dwmac fe1c0000.ethernet eth0: FPE workqueue start
[   20.318739] rk_gmac-dwmac fe1c0000.ethernet eth0: configuring for phy/rgmii-rxid link mode
[   26.448416] rk_gmac-dwmac fe1c0000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
console:/ # 
console:/ #
从你的描述和日志来看,以太网接口eth0已经启动,并且链接速度为1Gbps,但是只获取到了IPv6的本地链路地址(fe80::...),而没有获取到IPv4地址。
这可能是因为没有启用DHCP或者静态配置IP地址。在Android上,以太网配置通常通过以太网服务完成,但也可以手动配置。

首先,我们可以尝试手动运行dhcpcd来获取IP地址,或者使用静态IP地址配置。

但是,请注意,Android系统通常使用netd来管理网络,所以也可以尝试通过设置以太网配置来启用DHCP。

根据你提供的日志,网卡已经启动并连接,所以物理连接应该没有问题。

我们可以尝试以下步骤:

检查是否启用了DHCP客户端。在Android中,以太网配置可以通过设置菜单中的以太网设置来配置DHCP或静态IP。
但是,如果你是在调试模式下,也可以使用命令行。

使用命令行工具dhcpcd或udhcpc来获取IP地址。

检查是否有什么服务或配置阻止了DHCP请求。

检查路由器或DHCP服务器端是否有问题。

但是,从你提供的日志中,我们还看到了一些avc: denied的SELinux权限拒绝,这可能导致某些网络配置失败。

我们可以先尝试手动获取IP地址,看看是否能够成功。

由于你已经有了root权限,我们可以尝试以下命令:

首先,停止以太网服务(如果正在运行),然后手动启动DHCP客户端。

但是,在Android 14中,以太网服务可能是通过“EthernetService”来管理的。我们可以尝试通过设置来配置。

由于是命令行环境,我们可以尝试使用dhcpcd命令(如果存在的话)或者udhcpc。

先检查一下这两个命令是否存在:

如果不存在,可以尝试使用busybox中的udhcpc。

另外,也可以尝试使用netcfg命令来查看网络配置。

但是,从你的ifconfig输出中,我们看到eth0只有IPv6地址,没有IPv4地址。

我们可以尝试手动运行dhcpcd:

步骤:

停止以太网服务(如果可能的话)

释放当前接口的IP地址(如果有)

尝试获取IP地址

但是,在Android中,更常见的是使用netd来管理。我们可以通过设置属性来控制。

另一种方法是,通过ifconfig手动设置静态IP地址,然后测试网络连接。

但是,你的问题是不能获取IP地址,所以我们先尝试DHCP。

由于你的系统是Android 14,可能有一些变化。我们可以尝试使用dhcpcd命令。

先检查dhcpcd是否存在:

console:/ # which dhcpcd

如果不存在,可以尝试使用udhcpc:

console:/ # which udhcpc

如果都不存在,可以尝试使用busybox的udhcpc。

假设我们有udhcpc,那么可以尝试:

console:/ # udhcpc -i eth0

如果成功,应该会获取到IP地址。

如果失败,可能是DHCP请求没有发出,或者被拒绝。我们可以使用tcpdump来查看网络包。

但是,我们也可以先检查路由和防火墙规则。

另外,从dmesg中看到,网卡驱动是rk_gmac-dwmac,并且已经识别为千兆网卡,但实际连接速度为1Gbps,所以物理连接是千兆,但你想让它工作在百兆?你描述中写的是“当百兆网卡用”,可能是指连接到了百兆网络?但日志显示是1Gbps,所以可能自动协商成千兆了。

如果你希望强制成百兆,可能需要调整网卡配置,但这可能不是不能获取IP地址的原因。

我们先尝试获取IP地址。

另外,从SELinux的拒绝日志来看,可能有一些网络相关的服务被拒绝,这可能导致DHCP客户端无法正常运行。你可以尝试暂时关闭SELinux,然后测试DHCP,但这在生产环境中不推荐。

临时关闭SELinux:setenforce 0

然后再次尝试DHCP。

如果关闭SELinux后可以获取IP地址,那么就需要调整SELinux策略。

但是,从你提供的avc拒绝日志来看,是蓝牙服务访问属性被拒绝,可能和网络无关。

我们可以先尝试手动获取IP地址。

如果手动可以获取,那么可能是Android的以太网服务没有正确配置。

在Android中,以太网配置通常通过设置数据库配置,你可以尝试通过settings命令来设置以太网DHCP。

例如:

查看当前以太网配置:

console:/ # settings get ethernet

设置以太网为DHCP:

console:/ # settings put ethernet ip_mode dhcp

然后重启以太网服务。

但是,不同的Android版本可能有所不同。

另外,也可以尝试通过ifconfig设置静态IP,然后ping网关测试。

例如:

console:/ # ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up
console:/ # route add default gw 192.168.1.1 dev eth0
console:/ # setprop net.dns1 8.8.8.8

然后测试网络连接。

如果静态IP可以工作,那么问题可能出在DHCP客户端或服务上。

根据你的描述,我们首先尝试手动运行DHCP客户端。

请先尝试:

console:/ # udhcpc -i eth0

如果udhcpc不存在,可以尝试使用dhcpcd:

console:/ # dhcpcd eth0

如果都不存在,可以尝试使用busybox的udhcpc。

如果手动运行DHCP客户端可以获取IP地址,那么可能是Android的以太网服务没有正确启动DHCP客户端。

另外,检查一下系统属性:

console:/ # getprop | grep dhcp

可能会看到一些关于以太网DHCP的属性。

希望这些步骤能帮助你解决问题。


修改这个驱动文件,锁死网速最高100Mbps
Y:\new_disk_4t\wyb\RD-RK3588\rk3588u_RK3576_SDK_RELEASE\kernel-6.1\drivers\net\ethernet\stmicro\stmmac\stmmac_main.c

针对RTL8211F网卡在RK3588 Android14上无法获取IP地址的问题,我建议修改驱动文件来强制锁定网速为100Mbps。以下是要在 stmmac_main.c 文件中进行的修改:

修改方案
方案1:强制设置PHY速度为100Mbps
在PHY初始化时强制设置RTL8211F为100M全双工模式:

c
// 在 stmmac_main.c 文件中找到 stmmac_hw_setup 函数
// 在函数开头添加以下代码:

static int stmmac_hw_setup(struct net_device *dev, bool ptp_register)
{
    struct stmmac_priv *priv = netdev_priv(dev);
    // ... 现有代码 ...
    
    // +++ 新增:强制设置PHY为100M全双工 +++
    // 对于RTL8211F,我们需要强制设置速度和双工模式
    {
        struct phy_device *phydev = priv->dev->phydev;
        if (phydev) {
            netdev_info(priv->dev, "Forcing RTL8211F to 100Mbps Full Duplex\n");
            // 设置PHY为100M全双工,关闭自协商
            phy_write(phydev, MII_BMCR, BMCR_ANENABLE | BMCR_SPEED100 | BMCR_FULLDPLX);
            // 强制重启自协商
            phy_write(phydev, MII_BMCR, BMCR_ANENABLE | BMCR_ANRESTART | BMCR_SPEED100 | BMCR_FULLDPLX);
            
            // 也可以直接设置PHY寄存器来强制100M
            // RTL8211F特定寄存器配置
            phy_write(phydev, 0x1f, 0x0007);  // 页选择7
            phy_write(phydev, 0x1e, 0x00ec);  // 设置100M模式
            phy_write(phydev, 0x1f, 0x0000);  // 返回页0
        }
    }
    // +++ 结束新增 +++
    
    // ... 原有代码 ...
}
方案2:修改PHY配置函数
找到PHY配置相关的地方,强制设置100M:

c
// 在 stmmac_main.c 中找到 phylink配置相关函数
// 添加以下代码来覆盖速度设置:

static void stmmac_mac_link_up(struct phylink_config *config,
                   struct phy_device *phy,
                   unsigned int mode, phy_interface_t interface,
                   int speed, int duplex,
                   bool tx_pause, bool rx_pause)
{
    struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
    u32 old_ctrl, ctrl;
    
    old_ctrl = readl(priv->ioaddr + MAC_CTRL_REG);
    ctrl = old_ctrl & ~priv->hw->link.speed_mask;
    
    // +++ 修改:强制设置为100Mbps +++
    netdev_info(priv->dev, "Overriding speed from %d to 100Mbps\n", speed);
    speed = SPEED_100;  // 强制100M
    duplex = 1;         // 强制全双工
    // +++ 结束修改 +++
    
    if (interface == PHY_INTERFACE_MODE_USXGMII) {
        // ... 原有代码 ...
    } else if (interface == PHY_INTERFACE_MODE_XLGMII) {
        // ... 原有代码 ...
    } else {
        switch (speed) {
        case SPEED_2500:
            ctrl |= priv->hw->link.speed2500;
            break;
        case SPEED_1000:
            ctrl |= priv->hw->link.speed1000;
            break;
        case SPEED_100:
            ctrl |= priv->hw->link.speed100;
            break;
        case SPEED_10:
            ctrl |= priv->hw->link.speed10;
            break;
        default:
            return;
        }
    }
    
    // ... 后续代码不变 ...
}

方案3:在DMA初始化时添加PHY强制配置
c
// 在 stmmac_init_dma_engine 函数中添加:

static int stmmac_init_dma_engine(struct stmmac_priv *priv)
{
    // ... 原有代码 ...
    
    // +++ 新增:强制PHY配置 +++
    {
        struct mii_bus *mii = priv->mii;
        int phy_addr = priv->plat->phy_addr;
        
        if (mii && phy_addr >= 0) {
            netdev_info(priv->dev, "Configuring RTL8211F PHY at addr %d\n", phy_addr);
            
            // 设置PHY为100M全双工,关闭自协商
            mii->write(mii, phy_addr, MII_BMCR, 
                      BMCR_SPEED100 | BMCR_FULLDPLX | BMCR_ANENABLE);
            mdelay(10);
            
            // RTL8211F特定配置
            mii->write(mii, phy_addr, 0x1f, 0x0007);  // 选择页7
            mii->write(mii, phy_addr, 0x1e, 0x00ec);  // 100M模式配置
            mii->write(mii, phy_addr, 0x1f, 0x0000);  // 返回页0
            
            // 重启自协商
            mii->write(mii, phy_addr, MII_BMCR, 
                      BMCR_SPEED100 | BMCR_FULLDPLX | BMCR_ANENABLE | BMCR_ANRESTART);
        }
    }
    // +++ 结束新增 +++
    
    // ... 原有代码 ...
}
建议的完整修改(在驱动初始化时添加)
在 stmmac_dvr_probe 函数末尾,注册网络设备之前添加:

c
int stmmac_dvr_probe(struct device *device,
             struct plat_stmmacenet_data *plat_dat,
             struct stmmac_resources *res)
{
    // ... 原有代码 ...
    
    // +++ 新增:配置RTL8211F为100Mbps +++
    {
        struct mii_bus *mii_bus = priv->mii;
        int phy_addr = plat_dat->phy_addr;
        
        if (mii_bus && phy_addr >= 0) {
            dev_info(device, "Configuring RTL8211F PHY for 100Mbps operation\n");
            
            // 方法1:通过标准MII寄存器
            mii_bus->write(mii_bus, phy_addr, MII_BMCR, 
                          BMCR_SPEED100 | BMCR_FULLDPLX);
            
            // 方法2:通过RTL8211F扩展寄存器
            // 页选择
            mii_bus->write(mii_bus, phy_addr, 0x1f, 0x0007);  // 选择页7
            // 配置100M模式
            mii_bus->write(mii_bus, phy_addr, 0x1e, 0x00ec);  // 100M配置
            mii_bus->write(mii_bus, phy_addr, 0x1f, 0x0000);  // 返回页0
            
            // 可选:关闭节能模式
            mii_bus->write(mii_bus, phy_addr, 0x1f, 0x000a);  // 选择页10
            mii_bus->write(mii_bus, phy_addr, 0x11, 0x0000);  // 关闭EEE
            mii_bus->write(mii_bus, phy_addr, 0x1f, 0x0000);  // 返回页0
        }
    }
    // +++ 结束新增 +++
    
    ret = register_netdev(ndev);
    // ... 后续代码 ...
}
替代方案:通过设备树配置
如果可能,更好的方法是通过设备树配置PHY:

dts
&gmac {
    phy-mode = "rgmii";
    phy-handle = <&phy>;
    
    // 强制PHY设置
    phy-connection-type = "rgmii-id";
    snps,reset-gpio = <&gpio0 RK_PA0 GPIO_ACTIVE_LOW>;
    snps,reset-active-low;
    snps,reset-delays-us = <0 10000 50000>;
    
    // 强制100M
    max-speed = <100>;
    // 或者
    assigned-clock-rates = <50000000>; // 50MHz for 100M
};

&mdio {
    phy: ethernet-phy@0 {
        reg = <0>;
        // RTL8211F特定配置
        realtek,led-0-mode = <0>;  // 禁用LED闪烁
        realtek,led-1-mode = <0>;
        // 强制100M全双工
        max-speed = <100>;
    };
};
重要注意事项
编译和测试:修改后需要重新编译内核模块并加载

日志检查:修改后查看dmesg输出,确认PHY配置是否生效

硬件检查:确保4线连接正确(TX+, TX-, RX+, RX-)

PHY复位:可能需要添加PHY复位时序

如果上述修改仍不能解决问题,可能需要:

检查RK3588 GMAC的时钟配置

检查设备树中PHY的引脚配置

检查电源管理配置

考虑硬件连接问题(4线连接可能需要特定匹配电阻)

请先尝试方案2(修改stmmac_mac_link_up函数),因为这是最直接的方法。修改后重新编译内核并测试。

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐