From ff27178acffe3f2c765dad808bd72d1b5f232a73 Mon Sep 17 00:00:00 2001 From: libc0607 <332559105@qq.com> Date: Wed, 17 Apr 2024 01:32:17 +0800 Subject: [PATCH] Add RTL8812EU driver & wifibroadcast script support for FPV firmware (#1393) Co-authored-by: Dmitry Ilyin --- general/package/Config.in | 1 + .../0001-fix-extra-cflags.patch | 11 +++++++++ general/package/rtl88x2eu-openipc/Config.in | 16 +++++++++++++ .../rtl88x2eu-openipc/rtl88x2eu-openipc.mk | 24 +++++++++++++++++++ .../package/wifibroadcast/files/wifibroadcast | 13 ++++++++++ 5 files changed, 65 insertions(+) create mode 100644 general/package/rtl88x2eu-openipc/0001-fix-extra-cflags.patch create mode 100644 general/package/rtl88x2eu-openipc/Config.in create mode 100644 general/package/rtl88x2eu-openipc/rtl88x2eu-openipc.mk diff --git a/general/package/Config.in b/general/package/Config.in index 3a386082..3bd3de86 100644 --- a/general/package/Config.in +++ b/general/package/Config.in @@ -78,6 +78,7 @@ source "$BR2_EXTERNAL_GENERAL_PATH/package/osd-openipc/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/quirc-openipc/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/rcjoystick/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/rockchip-osdrv-rv11xx/Config.in" +source "$BR2_EXTERNAL_GENERAL_PATH/package/rtl88x2eu-openipc/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/rtl8812au/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/rtl8188eus-openipc/Config.in" source "$BR2_EXTERNAL_GENERAL_PATH/package/rtl8188fu-openipc/Config.in" diff --git a/general/package/rtl88x2eu-openipc/0001-fix-extra-cflags.patch b/general/package/rtl88x2eu-openipc/0001-fix-extra-cflags.patch new file mode 100644 index 00000000..4dd1de6f --- /dev/null +++ b/general/package/rtl88x2eu-openipc/0001-fix-extra-cflags.patch @@ -0,0 +1,11 @@ +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,7 @@ + EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS) +-EXTRA_CFLAGS += -O1 ++EXTRA_CFLAGS += -Os + #EXTRA_CFLAGS += -O3 ++EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT + #EXTRA_CFLAGS += -Wall + #EXTRA_CFLAGS += -Wextra + #EXTRA_CFLAGS += -Werror diff --git a/general/package/rtl88x2eu-openipc/Config.in b/general/package/rtl88x2eu-openipc/Config.in new file mode 100644 index 00000000..5c473696 --- /dev/null +++ b/general/package/rtl88x2eu-openipc/Config.in @@ -0,0 +1,16 @@ +config BR2_PACKAGE_RTL88X2EU_OPENIPC + bool "rtl88x2eu-openipc" + depends on BR2_LINUX_KERNEL + help + A standalone driver for the RTL88X2EU Dual Band + USB Wi-Fi adapter. + + Make sure your target kernel has the CONFIG_WIRELESS_EXT + config option enabled. + + Note: this package needs a firmware loading mechanism to + load the binary blob for the chip to work. + + +comment "rtl88x2eu needs a Linux kernel to be built" + depends on !BR2_LINUX_KERNEL diff --git a/general/package/rtl88x2eu-openipc/rtl88x2eu-openipc.mk b/general/package/rtl88x2eu-openipc/rtl88x2eu-openipc.mk new file mode 100644 index 00000000..3a2cefa2 --- /dev/null +++ b/general/package/rtl88x2eu-openipc/rtl88x2eu-openipc.mk @@ -0,0 +1,24 @@ +################################################################################ +# +# rtl88x2eu-openipc +# +################################################################################ + +ifeq ($(LOCAL_DOWNLOAD),y) +RTL88X2EU_OPENIPC_SITE_METHOD = git +RTL88X2EU_OPENIPC_SITE = https://github.com/libc0607/rtl88x2eu-20230815 +RTL88X2EU_OPENIPC_VERSION = $(shell git ls-remote $(RTL88X2EU_OPENIPC_SITE) HEAD | head -1 | cut -f1) +else +RTL88X2EU_OPENIPC_SITE = https://github.com/libc0607/rtl88x2eu-20230815/archive +RTL88X2EU_OPENIPC_SOURCE = master.tar.gz +endif + +RTL88X2EU_OPENIPC_LICENSE = GPL-2.0 +RTL88X2EU_OPENIPC_LICENSE_FILES = COPYING + +RTL88X2EU_OPENIPC_MODULE_MAKE_OPTS = CONFIG_RTL8822EU=m \ + KVER=$(LINUX_VERSION_PROBED) \ + KSRC=$(LINUX_DIR) + +$(eval $(kernel-module)) +$(eval $(generic-package)) diff --git a/general/package/wifibroadcast/files/wifibroadcast b/general/package/wifibroadcast/files/wifibroadcast index 905cd9c4..c50b80be 100755 --- a/general/package/wifibroadcast/files/wifibroadcast +++ b/general/package/wifibroadcast/files/wifibroadcast @@ -30,6 +30,10 @@ set_mcs() { fi } +# "0bda:8813" -> (8814) -> 8814au +# "0846:9052" -> (8811) -> 8821au +# "0bda:a81a" -> 88x2eu + detect_wifi_card() { devices=$(lsusb | cut -d ' ' -f6 | sort | uniq) for card in $devices; do @@ -39,6 +43,11 @@ detect_wifi_card() { modprobe 88XXau rtw_tx_pwr_idx_override="$driver_txpower_override" ;; + "0bda:a81a") + driver="realtek_8812eu" + modprobe 8812eu rtw_regd_src=1 rtw_tx_pwr_by_rate=0 rtw_tx_pwr_lmt_enable=0 + ;; + "0cf3:9271" | "040d:3801") driver="atheros" if ! [ "$unit" = "gs" ]; then @@ -78,6 +87,10 @@ load_interface() { if [ "$driver" = "realtek" ]; then ifconfig "$wlan" up iwconfig "$wlan" mode monitor + elif [ ${driver} = "realtek_8812eu" ]; then + ifconfig ${wlan} up + iwconfig ${wlan} mode monitor + iw dev ${wlan} set txpower fixed $(expr ${driver_txpower_override} * 50) elif [ "$driver" = "atheros" ]; then iwconfig "$wlan" mode monitor ifconfig "$wlan" up