S5P4418:RTL8152B 网卡驱动移植

1. 前言

限于作者能力水平,本文可能存在的谬误,因此而给读者带来的损失,作者不做任何承诺。

2. 背景

移植 RTL8125B 网卡驱动到 S5P4418 + Linux 3.4.y 系统。

3. 适配和测试

3.1 适配网卡驱动

(1) 将驱动代码 r8152.ccompatibility.h 放到目录 drivers/net/usb 下。
修改文件 drivers/net/usb/Makefile,在文件中增加内容:

obj-$(CONFIG_USB_RTL8152)	+= r8152.o

修改文件drivers/net/usb/Kconfig,在文件中增加内容:

config USB_R8152
	tristate "USB RTL8152 based ethernet device support"
	select NET_CORE
	select MII
	help
	  Say Y here if you have RTL8152 based usb-ethernet adapter.
	  Send me <petkan@users.sourceforge.net> any comments you may have.
	  You can also check for updates at <http://pegasus2.sourceforge.net/>.

	  To compile this driver as a module, choose M here: the module will be called rtl8152.

(2) 修改文件 drivers/net/Makefile ,在文件中增加内容:

obj-$(CONFIG_USB_R8152)       += usb/

(3) 修改文件drivers/net/usb/r8152.c中的函数r8152b_init()

static void r8152b_init(struct r8152 *tp)
{
	…

	/* configure LED0, LED1. */
#if 1
	ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LEDSEL);
	ocp_data = 0x3CA9;
	ocp_write_word(tp, MCU_TYPE_PLA, PLA_LEDSEL, ocp_data);
#endif

	r8152b_enable_eee(tp);
	…
}

默认的驱动代码,对 LED0,LED1 的配置有点问题。

(4) 默认开启 RTL8152B 网卡。本步骤不是必须的。
修改文件 arch/arm/configs/nanopi2_linux_defconfig,增加如下内容:

CONFIG_USB_R8152=y

3.2 测试网卡

重新编译内核并下载内核到开发板,之后插入网线测试网卡。
(1) 检验 LED0 (绿色)LED1 (黄)灯的状态。在插入网线前,LED0LED1 均不亮为正常。目前工作不正常。在插入网线后,LED0 长亮,LED1 不停闪烁为正常。更多的状态可参考 RTL 手册。
(2) 是否检测到网络设备,是否能正常上网。
运行ifconfig –a命令,查看是否发现eth1设备(系统上还有一块内置的网卡),发现则正常;运行命令ifconfig eth1 192.168.1.234配置网卡ip,然后可以向服务器192.168.1.163发送请求,如ping 192.168.1.163 测试网卡上网功能。
(3) iperf工具测试,以及更多的网卡测试。

posted @ 2025-04-08 09:04  JiMoKuangXiangQu  阅读(115)  评论(0)    收藏  举报