Implementation of Dual WiFi Functionality on RK3399 with Android 10

Starting from Android 9, the WiFi concurrency feature has been supported, with the following official description:

Android 9 introduces a feature that allows devices to operate in both STA and AP modes simultaneously. For devices that support Dual Band Simultaneous (DBS), this feature enables new functionalities, such as not interrupting the STA WLAN when the user wants to enable the hotspot (softAP).

https://source.android.google.cn/docs/core/connect/wifi-sta-ap-concurrency?hl=en

Based on this feature, WiFi STA and AP modes can work simultaneously on the following hardware, allowing both WiFi and hotspot functionalities to be enabled in the Android settings interface. This relies on the following configuration items and driver requirements:

Enable a build-time flag to support both interfaces in the HAL. This flag is located in device/<oem>/<device>/BoardConfig-common.mk.

1. WIFI_HIDL_FEATURE_DUAL_INTERFACE := true

2. Display two network interfaces: wlan0 and wlan1

On the RK3399 platform, many manufacturers use the ZTE WiFi module, which now supports concurrent mode, meaning the module can operate in both STA and AP modes simultaneously. After loading the driver, two network device nodes, wlan0 and wlan1, will be mapped.

Based on the above content, we made the following modifications for verification:

1. Modify the device/rockchip/rk3399/rk3399_firefly_aio/BoardConfig.mk file, with the following content:

--- a/device/rockchip/rk3399/rk3399_firefly_aio/BoardConfig.mk+++ b/device/rockchip/rk3399/rk3399_firefly_aio/BoardConfig.mk@@ -10,6 +10,8 @@ BOARD_GYROSCOPE_SENSOR_SUPPORT := true BUILD_WITH_GOOGLE_GMS_EXPRESS := false CAMERA_SUPPORT_AUTOFOCUS:= false
+WIFI_HIDL_FEATURE_DUAL_INTERFACE := true+ # AB image definition #BOARD_USES_AB_IMAGE := false #BOARD_HAS_RK_4G_MODEM := true

2. Driver modifications

1) WiFi module is AP6356S

Modify the kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/Makefile file, with the following content:

--- a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/Makefile+++ b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/Makefile@@ -17,6 +17,8 @@ CONFIG_BCMDHD_AUTO_SELECT := y #CONFIG_BCMDHD_DEBUG := y #CONFIG_BCMDHD_WAPI := y
+CONFIG_BCMDHD_STATIC_IF := y+ CONFIG_MACH_PLATFORM := y #CONFIG_BCMDHD_DTS := y
@@ -42,7 +44,8 @@ DHDOFILES = aiutils.o siutils.o sbutils.o bcmutils.o bcmwifi_channels.o   \        dhd_config.o dhd_ccode.o wl_event.o wl_android_ext.o wl_escan.o

-ifeq ($(BCMDHD_STATIC_IF),y)+#ifeq ($(BCMDHD_STATIC_IF),y)+ifeq ($(CONFIG_BCMDHD_STATIC_IF),y)        DHDCFLAGS += -DWL_STATIC_IF endif

2) WiFi module is AP6275S

Modify the kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd_wifi6/Makefile file, with the following content:

--- a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd_wifi6/Makefile+++ b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd_wifi6/Makefile@@ -14,6 +14,8 @@ CONFIG_BCMDHD_AG := y CONFIG_VTS_SUPPORT := y #CONFIG_BCMDHD_DEBUG := y
+CONFIG_BCMDHD_STATIC_IF := y+ CONFIG_MACH_PLATFORM := y #CONFIG_BCMDHD_DTS := y
@@ -39,7 +41,8 @@ DHDOFILES = aiutils.o siutils.o sbutils.o bcmutils.o bcmwifi_channels.o   \        dhd_linux_exportfs.o dhd_linux_pktdump.o                              \        dhd_config.o wl_event.o wl_android_ext.o wl_escan.o
-ifeq ($(BCMDHD_STATIC_IF),y)+#ifeq ($(BCMDHD_STATIC_IF),y)+ifeq ($(CONFIG_BCMDHD_STATIC_IF),y)        DHDCFLAGS += -DWL_STATIC_IF endif

3) Other WiFi modules

If the WiFi module does not support STA+AP Concurrent mode, then two WiFi modules are required to achieve this, meaning two WiFi modules must work together to implement the WiFi STA/AP concurrent mode functionality configured for Android 9 and above. By default, the two WiFi modules must be recognized as wlan0 and wlan1 network device nodes after loading the drivers.

3. Verification

After performing the above driver and system configurations, recompiling the Android system source code, and flashing it onto the board, you can enter the “Settings” application interface, where both Wi-Fi settings and hotspot settings can be opened simultaneously without needing to distinguish the order of opening.

Implementing simultaneous operation of WiFi STA and AP modes primarily addresses the following application scenarios:

Generally, when an Android device opens AP mode, it cannot connect to the router in STA mode. However, on our Android device, both modes can work simultaneously, allowing the STA to connect to the home router for internet access while the AP broadcasts to other devices. This enables devices connected to the AP to access the internet through the router connected via STA. This resolves the issue where devices like smartphones cannot access the internet when connected to our Android device’s hotspot, allowing for screen mirroring while also accessing online resources; or during interactive gaming sessions, multiple smartphones can connect to our Android device, and if account management is in place, they can access the internet through the router connected via our Android device’s WiFi.

Leave a Comment