mongona

mongona
-- --
正在获取天气

RTL8811CU|RTL8821CU网卡移植到StarFive(Verison Five2)

RTL8811CU|RTL8821CU网卡移植到StarFive(Verison Five2)

星光板2(VisionFive 2)使用USB无线网卡,自行编译驱动。

情况说明:

       1、京东购入两个USB无线网卡EDUP EP-AC1651)芯片 RTL8811CU  链接直达

       2、手中两块板子 version five2, raspberry pi 2B

       3、version five2 使用官方debian镜像、 Raspberry Pi 2 Model B Rev 1.1 使用kali Linux for raspberry 镜像

 

0、基本编译环境准备

# 安装基本工具和编译工具
sudo apt install -y build-essential gcc-riscv64-linux-gnu libncurses-dev
sudo apt install -y git flex bison bc vim-tiny wget
sudo apt install iw im-config usbutils pciutils iputils-ping

 

一、先从简单的来:为Raspberry Pi 2 Model B Rev 1.1安装驱动(超级简单)亲测可用

        链接到伟大的GitHub: https://github.com/morrownr/8821cu-20210916 按照readme 一步一步操作即可

         

           

root@kali-pipipi-192.168.0.112 ~$ lsusb 

Bus 001 Device 004: ID 0bda:c811 Realtek Semiconductor Corp. 802.11ac NIC
Bus 001 Device 003: ID 0424:ec00 Microchip Technology, Inc. (formerly SMSC) SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Microchip Technology, Inc. (formerly SMSC) SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

root@kali-pipipi-192.168.0.112 ~$ dmesg -T
[Fri Jul  7 23:55:12 2023] RTW: rtw_ndev_init(wlan0) if1 mac_addr=e8:4e:06:99:16:59
[Fri Jul  7 23:55:12 2023] usbcore: registered new interface driver rtl8821cu
[Fri Jul  7 23:55:12 2023] RTW: module init ret=0
[Fri Jul  7 23:55:24 2023] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[Fri Jul  7 23:55:24 2023] RTW: wlan0- hw port(0) mac_addr =6e:5b:f6:14:3a:c1
[Fri Jul  7 23:55:30 2023] RTW: wlan0- hw port(0) mac_addr =6e:5b:f6:14:3a:c1

root@kali-pipipi-192.168.0.112 ~/8821cu-20210916$ ifconfig 
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether b8:27:eb:68:07:00  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 39331  bytes 4535436 (4.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 39331  bytes 4535436 (4.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.112  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::f252:f89a:6ee4:335  prefixlen 64  scopeid 0x20<link>
        ether e8:4e:06:99:16:59  txqueuelen 1000  (Ethernet)
        RX packets 155069  bytes 30403760 (28.9 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 96431  bytes 12968915 (12.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 

二、接下来是重头戏: 为 version five2 安装驱动:

下载赛昉官方提供了星光2系统的定制内核源码 时间超级长,repo很大
cd ~
// 1、准备系统内核源码
git clone git@github.com:starfive-tech/linux.git
cd linux
touch .scmversion
git checkout -b JH7110_VisionFive2_devel origin/JH7110_VisionFive2_devel
git pull
vi Makefile
// 编辑Makefile文件
VERSION = 5
PATCHLEVEL = 15
SUBLEVEL = 0
EXTRAVERSION = -starfive # 这里的版本号很重要, 需要和当前系统的内核版本号保持一致
NAME = Trick or Treat
// 编译
make starfive_visionfive2_defconfig
make -j3
// 系统内核准备完毕


cd ~
// 2、准备驱动文件源码
git clone git@github.com:brektrou/rtl8821CU.git

cd rtl8821CU
// 编辑Makefile文件
修改 CONFIG_PLATFORM_I386_PC = y
为 CONFIG_PLATFORM_I386_PC = n


增加
CONFIG_PLATFORM_RISCV = y
ifeq ($(CONFIG_PLATFORM_RISCV), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
ARCH ?= riscv
CROSS_COMPILE ?=
KVER ?= $(shell uname -r)
# 注意下面KSRC 修改为第一步系统内核源码的文件路径
KSRC ?= /root/linux
MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless/
endif
//

// 开始编译 漫长等待
make
// 如果不出意外
root@risc- ~/rtl8821CU$ ls
8821cu.ko   8821cu.mod.c  8821cu.o  LICENSE   Module.symvers  changelog.pdf  core    dkms-install.sh  dkms.conf  ifcfg-wlan0  modules.order  platform	  runwpa
8821cu.mod  8821cu.mod.o  Kconfig   Makefile  README.md       clean	     debian  dkms-remove.sh   hal	 include      os_dep	     rtl8821c.mk  wlan0dhcp
// 其中8821cu.ko就是我们要的文件 6.2M 大小,熬了一整夜!!!!
// 安装
make install
root@risc- ~/rtl8821CU$ make install
mkdir -p /lib/modules/5.15.0-starfive/kernel/drivers/net/wireless/
install -p -m 644 8821cu.ko  /lib/modules/5.15.0-starfive/kernel/drivers/net/wireless/
/sbin/depmod -a 5.15.0-starfive

// 或者
root@risc- ~/rtl8821CU$ insmod 8821cu.ko 

root@risc- ~/8821cu-20210916$ dmesg -T
[Sat Jul  8 11:15:00 2023] RTW: module init start
[Sat Jul  8 11:15:00 2023] RTW: rtl8821cu v5.4.1_28754.20180921_COEX20180712-3232
[Sat Jul  8 11:15:00 2023] RTW: build time: Jul  8 2023 10:54:41
[Sat Jul  8 11:15:00 2023] RTW: rtl8821cu BT-Coex version = COEX20180712-3232
[Sat Jul  8 11:15:00 2023] RTW: [HALMAC]11692M
                           HALMAC_MAJOR_VER = 1
                           HALMAC_PROTOTYPE_VER = 4
                           HALMAC_MINOR_VER = 19
                           HALMAC_PATCH_VER = 3
.....
Sat Jul  8 11:15:00 2023] RTW: rtw_regsty_chk_target_tx_power_valid return _FALSE for band:0, path:0, rs:0, t:-1
[Sat Jul  8 11:15:00 2023] RTW: rtw_ndev_init(wlan0) if1 mac_addr=e8:4e:06:99:83:de
[Sat Jul  8 11:15:00 2023] usbcore: registered new interface driver rtl8821cu
[Sat Jul  8 11:15:00 2023] RTW: module init ret=0
[Sat Jul  8 11:15:01 2023] rtl8821cu 1-1.3:1.0 enxe84e069983de: renamed from wlan0
// 安装成功!!!!!!
root@risc- ~/rtl8821CU$ ifconfig 
end0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.108  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::173a:7ac:c50f:dd70  prefixlen 64  scopeid 0x20<link>
        ether 6c:cf:39:00:63:a2  txqueuelen 1000  (Ethernet)
        RX packets 85049  bytes 12996610 (12.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 34532  bytes 6659880 (6.3 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 39  

end1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 6c:cf:39:00:63:a5  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 42  

enxe84e069983de: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether ae:23:aa:9b:08:55  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 10  bytes 1582 (1.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 1582 (1.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
如果
root@risc- ~/8821cu-20210916$ dmesg -T
[Sat Jul  8 10:44:20 2023] usb 1-1.3: USB disconnect, device number 3
[Sat Jul  8 10:44:22 2023] usb 1-1.3: new high-speed USB device number 4 using xhci_hcd
[Sat Jul  8 10:44:22 2023] 8821cu: version magic '5.15.0 SMP mod_unload riscv' should be '5.15.0-starfive SMP mod_unload riscv'
说明系统内核的 EXTRAVERSION 有问题需要修改为
EXTRAVERSION = -starfive 回到重新编译内核,继续以上步骤。

*****最后在给网卡重命名的时候一定要确定mac地址正确。 可以通过dmesg -T 查看mac地址*****

致谢:

https://github.com/gnab/rtl8812au/pull/227/files // Add RISC-V architecture makefile

https://blog.csdn.net/qq_41248872/article/details/82783296 // rtl8811cu双频网卡移植到ARM

https://blog.csdn.net/wangyijieonline/article/details/88797271  // vermagic 不对应

1
0
富强,民主,文明,和谐,自由,平等,公正,法治,爱国,敬业,诚信,友善。
打赏二维码