文章目录
- 前言
- 一、硬件确认
- 1.1、RLT8152B硬件
- 二、驱动配置
- 2.1、驱动位置
- 2.2、使用config宏配置驱动
- 2.3、RTL8152 驱动调试中遇到的问题
- 2.3.1、问题描述
- 2.3.2、分析问题
- 2.3.3、处理问题
- 三、RTL8152网络测试
- 3.1、ifconfig配置ip
- 3.2、ping测试
- 3.3、iperf测试
前言
由于T507这款soc中,100M的emac被其他的功能使用了,而项目中需要两个以太网接口,所以采用了RLT8152B usb转以太网进行调试。
一、硬件确认
1.1、RLT8152B硬件
通过原理图确认RLT8152B硬件的电压供应,本项目中,电源是上电即可供应,所以不需要通过额外的配置进行供电。
二、驱动配置
2.1、驱动位置
定为驱动,使用内核中的驱动即可,包括mcp2515驱动,spi总线以及can网络配置
r8152驱动:
kernel/linux-4.9/drivers/net/usb/r8152.c
usb网络:
kernel/linux-4.9/drivers/net/usb
2.2、使用config宏配置驱动
diff --git a/kernel/linux-4.9/arch/arm64/configs/sun50iw9p1smp_longan_defconfig b/kernel/linux-4.9/arch/arm64/configs/sun50iw9p1smp_longan_defconfig
index d9b09b74ab..9ec92f7774 100755
--- a/kernel/linux-4.9/arch/arm64/configs/sun50iw9p1smp_longan_defconfig
+++ b/kernel/linux-4.9/arch/arm64/configs/sun50iw9p1smp_longan_defconfig
+ CONFIG_USB_NET_DRIVERS=y
+ CONFIG_USB_RTL8150=y
+ CONFIG_USB_RTL8152=y
+ CONFIG_USB_USBNET=y
+ CONFIG_MII=y
2.3、RTL8152 驱动调试中遇到的问题
2.3.1、问题描述
调试RTL8152 usb转以太网过程中,发现led灯异常,绿灯常亮,黄灯没有亮起
2.3.2、分析问题
驱动中没有对相应的寄存器配置好,结合原理图只用了LED0和LED1。
2.3.3、处理问题
与fae沟通后,需要在驱动中进行寄存器读写,配置OCP的0xDD90h写入0x0CA7
diff --git a/kernel/linux-4.9/drivers/net/usb/r8152.c b/kernel/linux-4.9/drivers/net/usb/r8152.c
index 02e29562d2..4253bae2cb 100755
--- a/kernel/linux-4.9/drivers/net/usb/r8152.c
+++ b/kernel/linux-4.9/drivers/net/usb/r8152.c
@@ -3383,7 +3383,7 @@ static void r8152b_init(struct r8152 *tp)
ocp_data &= ~LED_MODE_MASK;
ocp_write_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE, ocp_data);
}
-
+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_LEDSEL, 0x0CA7);
r8152_power_cut_en(tp, false);
ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR);
三、RTL8152网络测试
3.1、ifconfig配置ip
sh-4.4# ifconfig
eth0 Link encap:Ethernet HWaddr 36:C9:E3:F1:B8:05
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:258 (258.0 B)
Interrupt:71
sh-4.4# ifconfig eth0 192.168.81.11 up
sh-4.4# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 36:C9:E3:F1:B8:05
inet addr:192.168.81.11 Bcast:192.168.81.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:258 (258.0 B)
Interrupt:71
sh-4.4#
3.2、ping测试
sh-4.4# ping -I eth0 192.168.81.28
PING 192.168.81.28 (192.168.81.28): 56 data bytes
64 bytes from 192.168.81.28: seq=0 ttl=128 time=1.970 ms
64 bytes from 192.168.81.28: seq=1 ttl=128 time=1.126 ms
64 bytes from 192.168.81.28: seq=2 ttl=128 time=1.158 ms
64 bytes from 192.168.81.28: seq=3 ttl=128 time=1.049 ms
64 bytes from 192.168.81.28: seq=4 ttl=128 time=1.053 ms
64 bytes from 192.168.81.28: seq=5 ttl=128 time=0.997 ms
64 bytes from 192.168.81.28: seq=6 ttl=128 time=1.026 ms
64 bytes from 192.168.81.28: seq=7 ttl=128 time=1.139 ms
64 bytes from 192.168.81.28: seq=8 ttl=128 time=1.178 ms
^C
--- 192.168.81.28 ping statistics ---
9 packets transmitted, 9 packets received, 0% packet loss
round-trip min/avg/max = 0.997/1.188/1.970 ms
sh-4.4#
3.3、iperf测试
ARM端:
sh-4.4# iperf -c 192.168.81.28
------------------------------------------------------------
Client connecting to 192.168.81.28, TCP port 5001
TCP window size: 162 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.81.11 port 40236 connected with 192.168.81.28 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 114 MBytes 95.4 Mbits/sec
sh-4.4#
PC端:
C:\Users\B0413>iperf.exe -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 64.0 KByte (default)
------------------------------------------------------------
[384] local 192.168.81.28 port 5001 connected with 192.168.81.11 port 40236
[ ID] Interval Transfer Bandwidth
[384] 0.0-10.1 sec 114 MBytes 94.9 Mbits/sec