From 8baa8d1da82f35aba7bede4a519d2c94133477bb Mon Sep 17 00:00:00 2001 From: Lawrence-Tang Date: Fri, 2 Jun 2023 01:12:01 +0800 Subject: [PATCH] add a example for adding wifi driver to friendlywrt --- .github/workflows/build.yml | 3 ++- scripts/wifi/add_rtl8852be.sh | 39 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 scripts/wifi/add_rtl8852be.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8f89de7..d96c76e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -249,8 +249,9 @@ jobs: - name: Compile uboot and kernel run: | cd project - ./build.sh kernel ./build.sh uboot + ./build.sh kernel + source ../scripts/wifi/add_rtl8852be.sh - name: Build sd image id: build_sd_image diff --git a/scripts/wifi/add_rtl8852be.sh b/scripts/wifi/add_rtl8852be.sh new file mode 100755 index 0000000..5c7a16c --- /dev/null +++ b/scripts/wifi/add_rtl8852be.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -eu + +pushd kernel +kernel_ver=`make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 kernelrelease` +popd +modules_dir=$(readlink -f ./out/output_*_kmodules/lib/modules/${kernel_ver}) +[ -d ${modules_dir} ] || { + echo "please build kernel first." + exit 1 +} +firmware_dir="$(pwd)/rtl8852be/lib/firmware/rtw89" +config_dir="$(pwd)/rtl8852be/etc/modules.d/" +mkdir ${firmware_dir} ${config_dir} -p + +# download firmware +wget http://lwfinger.com/download/rtw8852b_fw-1.bin -O ${firmware_dir}/rtw8852b_fw-1.bin +wget http://lwfinger.com/download/rtw8852b_fw.bin -O ${firmware_dir}/rtw8852b_fw.bin +wget http://lwfinger.com/download/rtw8851b_fw.bin -O ${firmware_dir}/rtw8851b_fw.bin +wget http://lwfinger.com/download/rtw8852a_fw.bin -O ${firmware_dir}/rtw8852a_fw.bin +wget http://lwfinger.com/download/rtw8852c_fw.bin -O ${firmware_dir}/rtw8852c_fw.bin +wget https://github.com/armbian/firmware/blob/master/rtl8852bu_fw -O ${firmware_dir}/rtl8852bu_fw.bin + +# build wifi driver +git clone https://github.com/lwfinger/rtw89.git -b main +(cd rtw89 && { + git reset 38b8a48d04b8440266db6ea730e9b9cf84463981 --hard + export PATH=/opt/FriendlyARM/toolchain/11.3-aarch64:$PATH + make CROSS_COMPILE=aarch64-linux-gnu- ARCH=arm64 -C ../kernel M=$(pwd) + cp *.ko ${modules_dir}/ -afv +}) + +# load module on boot +echo "rtw_8852be" > ${config_dir}/11-rtw89 + +# add files to rootfs +if ! grep -q rtl8852be .current_config.mk; then + echo "FRIENDLYWRT_FILES+=(rtl8852be)" >> .current_config.mk +fi