[ROC-RK3568-PC] [Firefly-Android] 10min带你了解Ethernet的使用
Posted Neutionwei
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[ROC-RK3568-PC] [Firefly-Android] 10min带你了解Ethernet的使用相关的知识,希望对你有一定的参考价值。
- 🍇 博主主页: 【Systemcall小酒屋】
- 🍇 博主追寻:热衷于用简单的案例讲述复杂的技术,“假传万卷书,真传一案例”,这是林群院士说过的一句话,另外“成就是最好的老师”,技术既要沉淀,也得分享,成就感的正反馈是支持我持续耕耘的动力!
- 🍇 专栏目录: 【Firefly-RK356x板卡】
- 🍇 专栏说明:基于Firefly旗下的RK356x板卡进行入门篇讲述,欢迎订阅,博主会持续更新!
文章目录
一、设备树配置
1.1 公共配置
kernel/arch/arm64/boot/dts/rockchip/rk3568-firefly-port.dtsi
:
&gmac0
phy-mode = "rgmii";
clock_in_out = "input";
snps,reset-gpio = <&gpio2 RK_PD3 GPIO_ACTIVE_LOW>;
snps,reset-active-low;
/* Reset time is 20ms, 100ms for rtl8211f */
snps,reset-delays-us = <0 20000 100000>;
assigned-clocks = <&cru SCLK_GMAC0_RX_TX>, <&cru SCLK_GMAC0>;
assigned-clock-parents = <&cru SCLK_GMAC0_RGMII_SPEED>, <&cru CLK_MAC0_2TOP>;
pinctrl-names = "default";
pinctrl-0 = <&gmac0_miim
&gmac0_tx_bus2
&gmac0_rx_bus2
&gmac0_rgmii_clk
&gmac0_rgmii_bus>;
tx_delay = <0x3c>;
rx_delay = <0x2f>;
phy-handle = <&rgmii_phy0>;
status = "disabled";
;
&gmac1
phy-mode = "rgmii";
clock_in_out = "input";
snps,reset-gpio = <&gpio2 RK_PD1 GPIO_ACTIVE_LOW>;
snps,reset-active-low;
/* Reset time is 20ms, 100ms for rtl8211f */
snps,reset-delays-us = <0 20000 100000>;
assigned-clocks = <&cru SCLK_GMAC1_RX_TX>, <&cru SCLK_GMAC1>;
assigned-clock-parents = <&cru SCLK_GMAC1_RGMII_SPEED>, <&cru CLK_MAC1_2TOP>;
pinctrl-names = "default";
pinctrl-0 = <&gmac1m1_miim
&gmac1m1_tx_bus2
&gmac1m1_rx_bus2
&gmac1m1_rgmii_clk
&gmac1m1_rgmii_bus>;
tx_delay = <0x4f>;
rx_delay = <0x26>;
phy-handle = <&rgmii_phy1>;
status = "disabled";
;
1.2 板级配置
kernel/arch/arm64/boot/dts/rockchip/rk3568-firefly-roc-pc.dtsi
:
&gmac0
status = "okay";
tx_delay = <0x4a>;
rx_delay = <0x2e>;
;
&gmac1
status = "okay";
tx_delay = <0x3e>;
rx_delay = <0x32>;
;
二、双以太网的使用
此设备的双以太网口分内网和外网。 内网又称局域网(Local Area Network,LAN,是指在某一区域内由多台计算机以及网络设备构成的网络,无法连通外部网络;外网为广域网,又称公网,是连接不同地区局域网或城域网计算机通信的远程网,可以连通外部网络,如访问百度,搜狗。
- eth0 : 副网口,用于内网
- eth1 : 主网口,用于外网
android 系统Settings
-> Network & internet
-> Ethernet/Ethernet2
, 可以查看主副网口的 IP 地址。
2.1 查看IP地址
双以太网口接入网络,可以通过调试串口或者adb
来查看IP地址:
- eth0(内网):
ifconfig eth0
eth0 Link encap:Ethernet HWaddr b2:d1:83:54:0e:62 Driver rk_gmac-dwmac
inet addr:192.168.1.102 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::721f:ee30:f2a3:7bac/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:189 errors:0 dropped:0 overruns:0 frame:0
TX packets:135 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:18349 TX bytes:7022
Interrupt:41
- eth1(外网):
ifconfig eth1
eth1 Link encap:Ethernet HWaddr ae:d1:83:54:0e:62 Driver rk_gmac-dwmac
inet addr:168.168.108.98 Bcast:168.168.255.255 Mask:255.255.0.0
inet6 addr: fe80::641:354:8888:73fe/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2016 errors:0 dropped:0 overruns:0 frame:0
TX packets:41 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:128098 TX bytes:4374
Interrupt:51
2.2 网络测试
- eth0(内网):
ping -I eth0 -c 10 192.168.1.1
PING 192.168.1.1 (192.168.1.1) from 192.168.1.102 eth0: 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.936 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.10 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.962 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=64 time=0.959 ms
64 bytes from 192.168.1.1: icmp_seq=5 ttl=64 time=1.14 ms
64 bytes from 192.168.1.1: icmp_seq=6 ttl=64 time=0.966 ms
64 bytes from 192.168.1.1: icmp_seq=7 ttl=64 time=1.02 ms
64 bytes from 192.168.1.1: icmp_seq=8 ttl=64 time=1.03 ms
64 bytes from 192.168.1.1: icmp_seq=9 ttl=64 time=1.03 ms
64 bytes from 192.168.1.1: icmp_seq=10 ttl=64 time=1.04 ms
--- 192.168.1.1 ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9015ms
rtt min/avg/max/mdev = 0.936/1.020/1.144/0.063 ms
- eth1(外网):
ping -I eth1 -c 10 www.baidu.com
PING www.a.shifen.com (14.215.177.39) from 168.168.108.98 eth1: 56(84) bytes of data.
64 bytes from 14.215.177.39: icmp_seq=1 ttl=56 time=8.03 ms
64 bytes from 14.215.177.39: icmp_seq=2 ttl=56 time=5.61 ms
64 bytes from 14.215.177.39: icmp_seq=3 ttl=56 time=5.46 ms
64 bytes from 14.215.177.39: icmp_seq=4 ttl=56 time=5.35 ms
64 bytes from 14.215.177.39: icmp_seq=5 ttl=56 time=5.68 ms
64 bytes from 14.215.177.39: icmp_seq=6 ttl=56 time=5.59 ms
64 bytes from 14.215.177.39: icmp_seq=7 ttl=56 time=5.70 ms
64 bytes from 14.215.177.39: icmp_seq=8 ttl=56 time=5.54 ms
64 bytes from 14.215.177.39: icmp_seq=9 ttl=56 time=5.74 ms
64 bytes from 14.215.177.39: icmp_seq=10 ttl=56 time=5.43 ms
--- www.a.shifen.com ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9015ms
rtt min/avg/max/mdev = 5.354/5.816/8.031/0.753 ms
以上是关于[ROC-RK3568-PC] [Firefly-Android] 10min带你了解Ethernet的使用的主要内容,如果未能解决你的问题,请参考以下文章
[ROC-RK3568-PC] Kernel配置支持docker或者k8s
[ROC-RK3568-PC] [Firefly-Android] 10min带你了解ADC的使用
[ROC-RK3568-PC] [Firefly-Android] 10min带你了解ADC的使用
[ROC-RK3568-PC] [Firefly-Android] 10min带你了解LED的使用