WiFi USB dongle devices on DPX2 platform

DrivePX2 platform does not support any WiFi USB dongle devices by default. But it’s possible to enable some WiFi USB dongle devices on DPX2 platform with kernel tweaks. The basic steps can be summarized as

  1. Find the chip information of the WiFi device. a. Goto wikidevi.com b. Search for the target WiFi device c. Find the Linux Driver Information.
  2. If the Linux driver for this device is included in kernel source a. Enable the device support in the kernel by using "make menuconfig" or updating the kernel defconfig b. Recompile the kernel c. Copy the kernel image and device driver modules to the right places, reflash the board. d. On the target, install the firmware package "apt-get install linux-firmware"
  3. If the device does not have a driver included in kernel source a. Search the vendor website/github to find if a Linux driver exists. i. Compile the kernel driver. ii. Cross compile the device driver with kernel source code. iii. Install the driver and flash the board.

Examples for DPX2 5.0.5 SDK release.

  • RTL8812au is not supported in kernel 4.9
  • Enable wifi support in kernel [i] CONFIG_MAC80211=y CONFIG_CFG80211_WEXT=y[/i]
  • Follow the SDK document to recompile the kernel/modules
  • Get driver from https://github.com/gordboy/rtl8812au
  • Apply the spin-lock patch attached if RT kernel is used.
From 31d32634a8d32dc6d7568cb54ace47bd533b1b89 Mon Sep 17 00:00:00 2001
From: Jerry Wang <jerryw@nvidia.com>
Date: Wed, 23 May 2018 18:46:21 +0800
Subject: [PATCH 2/2] Fix memory access violation in rt_spin_lock()

Current implementation add additional 4 bytes when allocate
memory buffer of STA info for the alignment, which is not
needed for ARMv5 and above since they are already 64-bit aligned.

The additional 4 bytes also caused memory access violation
in rt_spin_lock() for Linux with RT patches.
---
 Makefile           |  1 +
 core/rtw_sta_mgt.c | 13 ++++++++++++-
 include/sta_info.h |  2 ++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index f784a1d..373d17e 100755
--- a/Makefile
+++ b/Makefile
@@ -1010,6 +1010,7 @@ ifeq ($(CONFIG_PLATFORM_ARM64), y)
 #ARCH := arm64
 EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
 EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
+EXTRA_CFLAGS += -DCONFIG_PLATFORM_ARM64
 #CROSS_COMPILE := aarch64-linux-gnu-
 #KVER ?= $(shell uname -r)
 KSRC := /work/codebase/drive5.0-pdk/5.0.7.2/output/drive-oss-src/out-t186ref-linux/
diff --git a/core/rtw_sta_mgt.c b/core/rtw_sta_mgt.c
index 0d3794a..9fff09e 100644
--- a/core/rtw_sta_mgt.c
+++ b/core/rtw_sta_mgt.c
@@ -232,7 +232,7 @@ u32	_rtw_init_sta_priv(struct	sta_priv *pstapriv)
 	struct sta_info *psta;
 	s32 i;
 
-
+#ifndef CONFIG_PLATFORM_ARM64
 	pstapriv->pallocated_stainfo_buf = rtw_zvmalloc(sizeof(struct sta_info) * NUM_STA + 4);
 
 	if (!pstapriv->pallocated_stainfo_buf)
@@ -240,6 +240,12 @@ u32	_rtw_init_sta_priv(struct	sta_priv *pstapriv)
 
 	pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 -
 			 ((SIZE_PTR)(pstapriv->pallocated_stainfo_buf) & 3);
+#else
+	pstapriv->pstainfo_buf = rtw_zvmalloc(sizeof(struct sta_info) * NUM_STA);
+
+	if (!pstapriv->pstainfo_buf)
+		return _FAIL;
+#endif
 
 	_rtw_init_queue(&pstapriv->free_sta_queue);
 
@@ -442,8 +448,13 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)
 		rtw_pre_link_sta_ctl_deinit(pstapriv);
 #endif
 
+#ifndef CONFIG_PLATFORM_ARM64
 		if (pstapriv->pallocated_stainfo_buf)
 			rtw_vmfree(pstapriv->pallocated_stainfo_buf, sizeof(struct sta_info) * NUM_STA + 4);
+#else
+		if (pstapriv->pstainfo_buf)
+			rtw_vmfree(pstapriv->pstainfo_buf, sizeof(struct sta_info) * NUM_STA);
+#endif
 	}
 
 	return _SUCCESS;
diff --git a/include/sta_info.h b/include/sta_info.h
index 8834e19..9cf2c2f 100644
--- a/include/sta_info.h
+++ b/include/sta_info.h
@@ -548,7 +548,9 @@ struct sta_info {
 
 struct	sta_priv {
 
+#ifndef CONFIG_PLATFORM_ARM64
 	u8 *pallocated_stainfo_buf;
+#endif
 	u8 *pstainfo_buf;
 	_queue	free_sta_queue;
 
-- 
2.1.4
  • Update the makefile to use the cross-compile tool chain released in the SDK
-CONFIG_PLATFORM_I386_PC = y
+CONFIG_PLATFORM_I386_PC = n
 
@@ -1005,6 +1006,16 @@ INSTALL_PREFIX :=
STAGINGMODDIR := /lib/modules/$(KVER)/kernel/drivers/staging
endif
+CONFIG_PLATFORM_ARM64 = y 
+ifeq ($(CONFIG_PLATFORM_ARM64), y)
+EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
+EXTRA_CFLAGS += -DCONFIG_TRAFFIC_PROTECT
+EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
+
+ARCH := arm64
+CROSS_COMPILE := $PDK/drive-oss-src/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-
+KSRC := $PDK/drive-oss-src/out-t186ref-linux
+endif
  • Follow the instructions in github project to cross-compile/install the driver
  • Flash the board with updated kernel/rootfs