WHC Wi-Fi WPAoH Host-Side Driver
Linux (cfg80211) Host-Side Driver
Driver Porting
WHC Host is currently tested and validated on Linux kernels 5.4 and 5.10. If you encounter compilation issues on other kernel versions, please contact us.
Note
SPI initiates data transfer immediately after CS pin is pulled low and CLK is detected. Corner cases may occur during bus busy states.
Testing shows adding a 7μs delay between CS low and host CLK push ensures safe data transmission.
Older SPI drivers without
spi_delaysupport may require direct code modification.
Prerequisites
Install dependencies on Linux:
sudo apt-get install build-essential
sudo apt install dhcpcd hostapd dhcpd
In directory
/component/wifi/whc/whc_host_linux, run the following cmd.nanandp2pis an optional parameter and should be added only when Wi-Fi NAN and Wi-Fi P2P needs to be enabled../whc_setup.sh sdio [nan] [p2p]
./whc_setup.sh spi [nan] [p2p]
./whc_setup.sh usb [nan] [p2p]
Select 1 or 2 based on the host operation mode
choose target host mode: 1) WPAoH host with cfg80211 2) WPAoD host without cfg80211 choose target host mode:
Select the target IC based on the chip model and interface type.
If the chip is configured to Boot from SDIO , select the FW_DOWNLOAD option.
When FW_DOWNLOAD is enabled, place the firmware binary files (
RTL8851FS_FW_1.binandRTL8851FS_FW_2.bin) in the/opt/images/directory on the host. The host driver will automatically download these images to the device during boot. The firmware file path can be modified incommon/fwdl/whc_hal_rtlxxx.c.Select the appropriate IC based on the chip model.
If the chip is configured to Boot from USB , select the FW_DOWNLOAD option.
When FW_DOWNLOAD is enabled, place the firmware binary files (
RTL8851FU_FW_1.binandRTL8851FU_FW_2.bin) in the/opt/images/directory on the host. The host driver will automatically download these images to the device during boot. The firmware file path can be modified incommon/fwdl/whc_hal_rtlxxx.c.Copy
whc_host_linuxto Linux kernel source treeInterface Activation
Linux PC: Skip this step
Raspberry Pi:
Configure SDIO via
dtoverlay.For Raspberry Pi 4:
sudo dtoverlay sdio poll_once=off
For Raspberry Pi 5:
sudo dtoverlay sdio
Open new terminal and compile
cd {driver_path}/whc_host_linux make
Driver Loading
Module Path:
/whc_host_linux/common/sdio/whc_sdio.kosudo su cp sdio/whc_sdio.ko /lib/modules/$(uname -r)/ depmod modprobe whc_sdio
Module Path:
/whc_host_linux/common/spi/whc_spi.kosudo su cp spi/whc_spi.ko /lib/modules/$(uname -r)/ depmod modprobe whc_spi
Module Path:
/whc_host_linux/common/usb/whc_usb.kosudo su cp usb/whc_usb.ko /lib/modules/$(uname -r)/ depmod modprobe whc_usb
After successful loading, run
ifconfigto verify Wi-Fi devices.Sample Output:
Station mode MAC prefix:
00:e0:4cSoftAP mode MAC prefix:
00:e1:4c
Normal Mode Verification
Stop NetworkManager and DHCP services to avoid conflicts
Ubuntu System Note: When connecting via command line, you stop NetworkManager and DHCP services to avoid conflicts
sudo systemctl stop NetworkManager dhcpcd.service sudo systemctl disable NetworkManager
Create configuration file
/etc/wpa_supplicant/wpa_supplicant.confctrl_interface=/var/run/wpa_supplicant network={ ssid="HUAWEI-JX2UX5_HiLink_5G" psk="12345678" }Start WPA connection
wpa_supplicant -D nl80211 -i wlanX -c /etc/wpa_supplicant/wpa_supplicant.conf -dd > /var/wifi_log
Obtain IP address
dhcpcd wlanXConfiguring SoftAP
Create configuration file
/etc/hostapd/hostapd.conf
driver=nl80211 logger_syslog=-1 logger_syslog_level=2 hw_mode=g channel=6 ssid=aaa_test wpa=2 wpa_passphrase=12345678 wpa_key_mgmt=WPA-PSK wpa_pairwise=CCMP
Create DHCP configuration file
/etc/udhcpd_wlanX.conf
start 192.168.43.20 end 192.168.43.254 interface wlanX opt dns 192.168.43.1 option subnet 255.255.255.0 opt router 192.168.43.1
Start SoftAP
hostapd /etc/hostapd/hostapd.conf -i wlanX
Set AP IP address
ifconfig wlanX 192.168.43.1 netmask 255.255.255.0
Start DHCP service
udhcpd -f /etc/udhcpd_wlanX.conf
Note
wlanX is the name of the wireless interface device, execute ifconfig -a in the terminal to retrieve its information
Device-Side TCP/IP Keep-Alive Verification
Stop NetworkManager and DHCP services to avoid conflicts
Ubuntu System Note: When connecting via command line, you stop NetworkManager and DHCP services to avoid conflicts
sudo systemctl stop NetworkManager dhcpcd.service sudo systemctl disable NetworkManager
Create configuration file
/etc/wpa_supplicant/wpa_supplicant.confctrl_interface=/var/run/wpa_supplicant network={ ssid="HUAWEI-JX2UX5_HiLink_5G" psk="12345678" }Start WPA connection
wpa_supplicant -D nl80211 -i wlanX -c /etc/wpa_supplicant/wpa_supplicant.conf -dd > /var/wifi_log
Obtaining IP Address
Launch Cust Path demo
cd ${SDK}/component/wifi/whc/whc_host_linux/app sudo ./whc_cust_path_demo
Execute initialization
> initEnter the following command in the demo to instruct Ameba to obtain an IP address
> dhcpBased on the IP address information returned by Ameba, configure the IP address and default gateway in the terminal
# Configure the IP address for wlanX sudo ip addr add 192.168.x.x/24 dev wlanX # Enable the wlanX interface sudo ip link set wlanX up # Configure the default gateway IP address sudo ip route add default via 192.168.x.x dev wlanX
Test network connectivity
ping 192.168.x.x
Note
wlanX is the name of the wireless interface device, execute ifconfig -a in the terminal to retrieve its information
RTOS Host-Side Driver
Driver Porting
Programming Guide for Ameba as WHC Host
Environment Setup
Execute the configuration command
(Top) -> CONFIG WHC INTF -> WHC_MODE ----Configuration---- ( ) WHC_IPC ( ) WHC_DEV (X) WHC_HOST (Top) -> CONFIG WHC INTF -> WHC HOST config ----Configuration---- (X) Support WHC CMD PATH (X) Support WHC WIFI API PATH
Firmware Compilation
Generate target files:
ameba.py buildOutput files:
boot.binapp.bin
Firmware Burning
Use the dedicated burning tool to write the firmware to the development board
Third-party Platform Porting
When using other Host chips, the component/os/freertos directory must be ported to the target system.
Functional Verification
Enter the following command in the serial terminal to perform a WiFi scan
AT+WLSCAN
Enter the following command in the serial terminal to establish a wireless connection
AT+WLCONN=ssid,ap_test,pw,12345678Note
ap_testrepresents the target AP’s SSID,12345678is the target AP’s password. Omit password parameter for open networks.Test network connectivity
AT+WLPING=192.168.x.x
CUST_PATH Guide
In WPAoH mode, if custom communication between Host and Device is required beyond standard Wi-Fi/BT/Socket programming, the CUST_PATH can be utilized.