Open uberf0x opened 1 year ago
Hi. I will check this.
Thanks, i've already found the problem. The errors above were caused by base kernel headers utilizing slightly different wiphy structure. Rebuilding the module against the backport solve the issue.
The module seems working fine now via ssh, but an attempt to enable radio in LuCI interface hangs it forever.
To be exact iw dev wlanN del
hangs the module making it useless in OpenWrt, which does this command internally.
RTW: cfg80211_rtw_del_virtual_intf(wlan2) unregister ndev RTW: rtw_wdev_unregister(wdev=62cdac68)
Then any network operations hang and the kernel is unable to reboot properly.
Looks like it's the common Realtek drivers problem according to this thread:
https://github.com/morrownr/8821cu-20210916/issues/63
I've tested rtl8188eu drivers from other developers and got the same results. Both https://github.com/aircrack-ng/rtl8188eus and https://github.com/lwfinger/rtl8188eu/tree/v5.2.2.4 hang OpenWrt 22.03.0 after iw dev wlanN del
command.
Then i did the same experiment with OpenWrt 21.02.0 r16279-5cc0535800 you mentioned as tested.
I built the drivers from all three repositories and ran iw dev wlanN del
on OpenWrt 21.02.0.
Results as below:
ivanovborislav - ok
aircrack-ng - hangs
lwfinger - hangs
Your driver is the only has no "delete interface" issue, but for OpenWrt 21.02.0 only. Going to test lower OpenWrt version to make sure.
I did tests for all three drivers on OpenWrt 19.07.10 with the same results as for OpenWrt 21.02.0. Your driver is the only usable, but also has "client mode authorization" issue on this version of OpenWrt: https://github.com/ivanovborislav/rtl8188eu/issues/14
Thanks, i've already found the problem. The errors above were caused by base kernel headers utilizing slightly different wiphy structure. Rebuilding the module against the backport solve the issue. The module seems working fine now via ssh, but an attempt to enable radio in LuCI interface hangs it forever. To be exact
iw dev wlanN del
hangs the module making it useless in OpenWrt, which does this command internally.RTW: cfg80211_rtw_del_virtual_intf(wlan2) unregister ndev RTW: rtw_wdev_unregister(wdev=62cdac68)
Then any network operations hang and the kernel is unable to reboot properly.
I think I am running into similar issues (on openwrt 22.03), can you pls detail better how did you built against backport? I tried setting: NOSTDINC_FLAGS="-I$(STAGING_DIR)/usr/include/mac80211 \ -I$(STAGING_DIR)/usr/include/mac80211/uapi \ -I$(STAGING_DIR)/usr/include/mac80211-backport \ -include backport/backport.h"
But I get weird build errors.
In file included from /home/valter/scorpio_v_next/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-bcm27xx_scorpio/linux-5.10.161/include/linux/bits.h:6, from /home/valter/scorpio_v_next/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/bits.h:9, from /home/valter/scorpio_v_next/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-bcm27xx_scorpio/linux-5.10.161/include/linux/bitops.h:5, from /home/valter/scorpio_v_next/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/bitops.h:3, from /home/valter/scorpio_v_next/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-bcm27xx_scorpio/linux-5.10.161/include/linux/kernel.h:12, from /home/valter/scorpio_v_next/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include/mac80211-backport/linux/kernel.h:3, from /home/valter/scorpio_v_next/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-bcm27xx_scorpio/linux-5.10.161/include/linux/list.h:9, from /home/valter/scorpio_v_next/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-bcm27xx_scorpio/linux-5.10.161/include/linux/module.h:12, from /home/valter/scorpio_v_next/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-bcm27xx_scorpio/rtl8188eu-regular/rtl8188eu-b68c7da8/include/basic_types.h:76, from /home/valter/scorpio_v_next/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-bcm27xx_scorpio/rtl8188eu-regular/rtl8188eu-b68c7da8/include/drv_types.h:26, from /home/valter/scorpio_v_next/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-bcm27xx_scorpio/rtl8188eu-regular/rtl8188eu-b68c7da8/core/rtw_cmd.c:17: /home/valter/scorpio_v_next/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-bcm27xx_scorpio/linux-5.10.161/include/vdso/bits.h:7:33: error: expected identifier before '(' token 7 | #define BIT(nr) (UL(1) << (nr)) | ^ /home/valter/scorpio_v_next/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-bcm27xx_scorpio/rtl8188eu-regular/rtl8188eu-b68c7da8/include/ieee80211.h:61:23: note: in expansion of macro 'BIT' 61 | #define WLAN_STA_AUTH BIT(0) | ^~~
I managed to build the driver, now the device is detected and I can do a scan, but as soon as it tries to join a network it hangs. I am using openwrt 22.0.3 on an arm64 device.
I managed to build the driver, now the device is detected and I can do a scan, but as soon as it tries to join a network it hangs. I am using openwrt 22.0.3 on an arm64 device.
Looks like the same issue i described above. When adding or modifying a network Openwrt internally executing delete and add a virtual wireless interface commands:
iw dev wlan2 del
iw phy phy2 interface add wlan2 type managed
Try via ssh iw dev wlanN del
where N is your interface number (wlan2 in my case). It hangs for me in OpenWrt 22.03, but OpenWrt 21.02 and below passes ok.
Here is my OpenWrt Makefile:
include $(TOPDIR)/rules.mk
PKG_NAME:=rtl8188eu
PKG_RELEASE=1
STAMP_CONFIGURED_DEPENDS := $(STAGING_DIR)/usr/include/mac80211-backport/backport/autoconf.h
include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/package.mk
define KernelPackage/rtl8188eu
SUBMENU:=Wireless Drivers
TITLE:=Driver for RTL8188EU Wireless Chipsets
DEPENDS:= +kmod-cfg80211 +rtl8188eu-firmware +kmod-usb-core +@DRIVER_11N_SUPPORT
FILES:=$(PKG_BUILD_DIR)/8188eu.ko
AUTOLOAD:=$(call AutoProbe,8188eu)
PROVIDES:=kmod-rtl8188eu
endef
NOSTDINC_FLAGS := \
$(KERNEL_NOSTDINC_FLAGS) \
-I$(PKG_BUILD_DIR) \
-I$(PKG_BUILD_DIR)/include \
-I$(STAGING_DIR)/usr/include/mac80211-backport \
-I$(STAGING_DIR)/usr/include/mac80211-backport/uapi \
-I$(STAGING_DIR)/usr/include/mac80211 \
-I$(STAGING_DIR)/usr/include/mac80211/uapi \
-include backport/backport.h
CT_MAKEDEFS += CONFIG_RTL8188EU=m
NOSTDINC_FLAGS+=-DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT -DBUILD_OPENWRT -D_LINUX_BYTEORDER_SWAB_H -DCONFIG_LITTLE_ENDIAN
define Build/Compile
+$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \
$(KERNEL_MAKE_FLAGS) \
M="$(PKG_BUILD_DIR)" \
NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)" \
$(CT_MAKEDEFS) modules
endef
$(eval $(call KernelPackage,rtl8188eu))
Also, the driver source requires some fixes to build against OpenWrt tree:
1) rename include/linux/wireless.h
to include/linux/old_unused_rtl_wireless.h
2) rename include/autoconf.h
to include/rtl_autoconf.h
3) edit include/drv_conf.h
:
add #include <generated/autoconf.h>
replace #include "autoconf.h"
with #include "rtl_autoconf.h"
4) edit Makefile
(optional, depends on your device):
replace CONFIG_PLATFORM_I386_PC = y
with CONFIG_PLATFORM_I386_PC = n
I managed to build the driver, now the device is detected and I can do a scan, but as soon as it tries to join a network it hangs. I am using openwrt 22.0.3 on an arm64 device.
Looks like the same issue i described above. When adding or modifying a network Openwrt internally executing delete and add a virtual wireless interface commands:
iw dev wlan2 del iw phy phy2 interface add wlan2 type managed
Try via ssh
iw dev wlanN del
where N is your interface number (wlan2 in my case). It hangs for me in OpenWrt 22.03, but OpenWrt 21.02 and below passes ok.
Yes, it's exactly the same issue. I see that if I rmmod/insmod the driver the adapter is re-initialized, but not when it's stuck in that condition. I am thinking about replacing iw dev del commands in the mac80211.sh script. In this way it will work with web UI and UCI, that is what I need ATM.
This is my makefile and patches, I think I solved the issues more or less in the same way you did. I also tried to check other realtek drivers that have a similar structure to see if they solved the issue but, ATM, no luck.
I didn't test enough before posting this workaround, it still has issues if you change the adapter configuration.
Ok, I have a kind of nasty workaround for openwrt. I changed /ib/netifd/wireless to unload/reload the module when iw dev del is called. It relies on the fact that my interface is always named wlan1 so it probably won't work for many other people as it is, but can still be useful as a starting point and (hopefully) temporary workaround for people who stumble on this issue.
Second (hopefully better) attempt. Issue is due to the fact that the driver does not support composite interfaces. iw dev del doesn't check this and the driver buggy implementation does the rest. Actually openwrt scripts expect iw dev del to fail in this case. I made a fix to not call iw dev del for my adapter. Probably a better fix would be to return an error on the call that removes the interface. I don't have time to look into this ATM.
Second (hopefully better) attempt. Issue is due to the fact that the driver does not support composite interfaces. iw dev del doesn't check this and the driver buggy implementation does the rest. Actually openwrt scripts expect iw dev del to fail in this case. I made a fix to not call iw dev del for my adapter. Probably a better fix would be to return an error on the call that removes the interface. I don't have time to look into this ATM.
After reading this post I came to the same conclusion about the need to patch the driver for error on delete interface attempt. Unfortunately i have not enough skills for this. But your solution modifying ash script is easy and efficient, thanks. Going to test it more, but seems everything works as it should. Except unknown signal quality and bitrate values for a connection in client mode, but seems it's Realtek and iwinfo
compatibilty problem unrelated to the main issue.
Summing it up, the problem is not in OpenWrt, the problem is Realtek drivers do not support virtual interfaces. But for some reason their driver allows iw
command to delete its interface. Which leads to unpredictable bugs depending on OpenWrt (kernel) version.
Until Realtek or someone else fix the driver we can use custom mac80211 posted above.
And more, maybe this will be useful for someone. As i wrote before this version of driver is the only that doesn't hang for earlier OpenWrt versions on iw dev del
comparing to other repositories. I found the difference:
NOSTDINC_FLAGS += -DRTW_SINGLE_WIPHY
Building aircrack-ng or lwfinger driver with this option will fix hanging issue for OpenWrt 21.02 and below, but other problems remain anyway.
Hi, the driver was successfully built for OpenWrt using buildroot, but doesn't recognize my adapter (TL-WN 722N v3). Seems like the module is loaded ok, but when inserting an adapter it fails to init. Kernel log and other info are below:
lsmod | grep 8188
lsusb
uname -r
Xiaomi Router 3G v1 using OpenWrt 22.03.0 r19685-512e76967f (ramips/mt7621)
Any suggestions how to fix it?