Driver Wifi RTL8723du

Hi guys,

I have board MYZR LS1012A-EK200 that is not in openwrt board support, but it is related with ls1012ardb that is available in openwrt board support (Target System (NXP Layerscape), Subtarget (ARMv8 64-bit based boards), Target Profile (NXP LS1012A-RDB)). For openwrt built root I fork from nxp's repository using branch 20.09.

git clone https://source.codeaurora.org/external/qoriq/qoriq-components/openwrt --branch layerscape-20.09 openwrt-layerscape-20.09

This board built with onboard wifi rtl8723du, which is not available in openwrt built root. There for I need to built this wifi's driver.

I have a problem when I build driver for wifi rtl8723du. I know this device's driver is not in main kernel. I found this git repository that host this device's driver, but I need to create the package's Makefile for this driver. After days of try and error I able to create Makefile for the package.

#
# Copyright (C) 2008 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=rtl8723du
PKG_VERSION:=5.13.4
PKG_RELEASE=5
PKG_LICENSE:=GPLv2

PKG_SOURCE_URL:=https://github.com/lwfinger/rtl8723du
PKG_SOURCE_PROTO:=git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=b3d0f897a405987571ebd54cbbce425d18ff693e
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.xz

PKG_MAINTAINER:=Larry Finger <Larry.Finger@lwfinger.net>
PKG_BUILD_PARALLEL:=1

include $(INCLUDE_DIR)/package.mk

define KernelPackage/rtl8723du
  SUBMENU:=Wireless Drivers
  TITLE:=rtl8723du Support
  DEPENDS:=@USB_SUPPORT +kmod-cfg80211 +@DRIVER_WEXT_SUPPORT +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT
  FILES:=$(PKG_BUILD_DIR)/rtl8723du.ko
  AUTOLOAD:=$(call AutoLoad,90,rtl8723du)
  PROVIDES:=kmod-rtl8723du
endef

define Build/Prepare
	$(PKG_UNPACK)
	DOLAR_SIGN="$$$$"
	sed -i "2544i \\\techo $$$$\(RTL871X\)" "$(PKG_BUILD_DIR)"/Makefile
	sed -i "2544i \\\techo $$$$\(KERNELRELEASE\)" "$(PKG_BUILD_DIR)"/Makefile
	sed -i "2544i \\\techo $$$$\(obj-m\) and $$$$\(obj-y\)" "$(PKG_BUILD_DIR)"/Makefile
	sed -i "17i src=$$$$\(PROJECT_DIR\)" "$(PKG_BUILD_DIR)"/Makefile
endef

EXTRA_KCONFIG:=\
	CONFIG_RTL8723DU=m \
	CONFIG_IOCTL_CFG80211=y \
	CONFIG_LITTLE_ENDIAN=y \
	CONFIG_BT_COEXIST_SOCKET_TRX=y \
	CONFIG_CONCURRENT_MODE=y \
	USER_MODULE_NAME=rtl8723du 

EXTRA_CFLAGS:= \
	$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=m,%,$(filter %=m,$(EXTRA_KCONFIG)))) \
	$(patsubst CONFIG_%, -DCONFIG_%=1, $(patsubst %=y,%,$(filter %=y,$(EXTRA_KCONFIG)))) \
	-DRTW_USE_CFG80211_STA_EVENT

MAKE_OPTS:= \
	KSRC="$(LINUX_DIR)" \
	SUBDIRS="$(PKG_BUILD_DIR)" \
	USER_EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
	$(EXTRA_KCONFIG) \
	PROJECT_DIR="$(PKG_BUILD_DIR)" \
	NOSTDINC_FLAGS="$(NOSTDINC_FLAGS)"

define Build/Compile
	$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
		ARCH="$(LINUX_KARCH)" \
		CROSS_COMPILE="$(TARGET_CROSS)" \
		$(MAKE_OPTS)
endef

$(eval $(call KernelPackage,rtl8723du))

I am new for building package for driver.

It will compile all needed part for the device, but then I got error in modpost process.

...
  Building modules, stage 2.
  MODPOST 1 modules
ERROR: "ieee80211_frequency_to_channel" [/home/hp/openwrt/openwrt-layerscape-20.09/build_dir/target-aarch64_generic_glibc/linux-layerscape_armv8_64b/rtl8723du-5.13.4/rtl8723du.ko] undefined!
ERROR: "cfg80211_rx_mgmt" [/home/hp/openwrt/openwrt-layerscape-20.09/build_dir/target-aarch64_generic_glibc/linux-layerscape_armv8_64b/rtl8723du-5.13.4/rtl8723du.ko] undefined!
ERROR: "ieee80211_get_channel" [/home/hp/openwrt/openwrt-layerscape-20.09/build_dir/target-aarch64_generic_glibc/linux-layerscape_armv8_64b/rtl8723du-5.13.4/rtl8723du.ko] undefined!
scripts/Makefile.modpost:93: recipe for target '__modpost' failed
make[6]: *** [__modpost] Error 1
Makefile:1620: recipe for target 'modules' failed
make[5]: *** [modules] Error 2
make[5]: Leaving directory '/home/hp/openwrt/openwrt-layerscape-20.09/build_dir/target-aarch64_generic_glibc/linux-layerscape_armv8_64b/linux-5.4.52'
Makefile:2467: recipe for target 'modules' failed
make[4]: *** [modules] Error 2
make[4]: Leaving directory '/home/hp/openwrt/openwrt-layerscape-20.09/build_dir/target-aarch64_generic_glibc/linux-layerscape_armv8_64b/rtl8723du-5.13.4'
Makefile:94: recipe for target '/home/hp/openwrt/openwrt-layerscape-20.09/build_dir/target-aarch64_generic_glibc/linux-layerscape_armv8_64b/rtl8723du-5.13.4/.built' failed
make[3]: *** [/home/hp/openwrt/openwrt-layerscape-20.09/build_dir/target-aarch64_generic_glibc/linux-layerscape_armv8_64b/rtl8723du-5.13.4/.built] Error 2
make[3]: Leaving directory '/home/hp/openwrt/openwrt-layerscape-20.09/package/rtl8723du'
...

It seems like the driver has dependency to other driver, am I right?

Then, after some browsing, I found that openwrt use backport kernel for wifi driver. From that Makefile I compile it using the source's Makefile then the process will be forwarded to the linux's Makefile (variable KSRC="$(LINUX_DIR)") to compile driver's component. Thus, I can assume that I need to add this driver to the backport driver.

If I am right, then is there any work around that I can try to compile this driver to openwrt? Or maybe some tutorials for how to create backport for wifi driver?

Any suggestions and advice regarding this problem is big help for me.

Best regards,

Huda.

It appears you are using firmware that is not from the official OpenWrt project.

When using forks/offshoots/vendor-specific builds that are "based on OpenWrt", there may be many differences compared to the official versions (hosted by OpenWrt.org). Some of these customizations may fundamentally change the way that OpenWrt works. You might need help from people with specific/specialized knowledge about the firmware you are using, so it is possible that advice you get here may not be useful.

You may find that the best options are:

  1. Install an official version of OpenWrt, if your device is supported (see https://firmware-selector.openwrt.org).
  2. Ask for help from the maintainer(s) or user community of the specific firmware that you are using.
  3. Provide the source code for the firmware so that users on this forum can understand how your firmware works (OpenWrt forum users are volunteers, so somebody might look at the code if they have time and are interested in your issue).

If you believe that this specific issue is common to generic/official OpenWrt and/or the maintainers of your build have indicated as such, please feel free to clarify.

Please talk to your NXP representative, we can't help you with their SDK (and there is no OpenWrt 20.09 to begin with). Just in general, Realtek wireless -USB in particular- is pretty much a no-go area.

2 Likes