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, 5.10, 5.15 and 6.18. 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_delay support may require direct code modification.

Prerequisites

Install dependencies on Linux:

sudo apt-get install build-essential
sudo apt install dhcpcd hostapd dhcpd
sudo apt install python3-pip
sudo pip3 install kconfiglib
  1. In directory /component/wifi/whc/whc_host_linux , run command make prepare

  2. Copy whc_host_linux into the Linux host

  3. Open new terminal and compile

    cd {driver_path}/whc_host_linux
    make menuconfig
    
    1. Select the interface type:

      (Top)  WHC host options  Host controller interface (HCI)
      Main menu
         ( ) IPC
         (X) SDIO
         ( ) SPI
         ( ) USB
      
    2. Select the target IC:

      (Top)  WHC host options  Target IC
      Main menu
         ( ) AmebaDplus (RTL8721Dx)
         (X) AmebaGreen2
         ( ) AmebaX (RTL8720F)
      
    3. Configure host options based on the host’s operating mode. If the chip boots from HCI (Boot from HCI), enable Firmware download

      (Top)  WHC host options
      Main menu
         Host controller interface (HCI) (SDIO)  --->
         Target IC (AmebaGreen2)  --->
         [*] WPAoH host with cfg80211 (WIFI API path)
         [*] WHC command path
         [ ] Firmware download over the host interface
      
    4. Enable nan and p2p as needed

      (Top)  WHC host options
      Main menu
         Host controller interface (HCI) (SDIO)  --->
         Target IC (AmebaGreen2)  --->
         [*] WPAoH host with cfg80211 (WIFI API path)
         [*] WHC command path
         [ ] Firmware download over the host interface
            *** Features ***
         [ ] NAN (Wi-Fi Aware)
         [ ] Wi-Fi Direct (P2P)
      
    5. Run make to build

  4. Interface Activation

    • Linux PC: Skip this step

    • Raspberry Pi:

    SDIO:

    Configure SDIO via dtoverlay.

    For Raspberry Pi 4:

    sudo dtoverlay sdio poll_once=off
    

    For Raspberry Pi 5:

    sudo dtoverlay sdio
    
  5. Driver Loading

    SDIO:

    Module Path: /whc_host_linux/driver/sdio/whc_sdio.ko

    sudo su
    cp sdio/whc_sdio.ko /lib/modules/$(uname -r)/
    depmod
    modprobe whc_sdio
    

    After successful loading, run ifconfig to verify Wi-Fi devices.

    Sample Output:

    • Station mode MAC prefix: 00:e0:4c

    • SoftAP mode MAC prefix: 00:e1:4c

    ../../_images/ifconfig_sta_softap.png

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.conf

    ctrl_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 wlanX
    
  • Configuring SoftAP

    1. 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
    
    1. 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
    
    1. Start SoftAP

    hostapd /etc/hostapd/hostapd.conf -i wlanX
    
    1. Set AP IP address

    ifconfig wlanX 192.168.43.1 netmask 255.255.255.0
    
    1. 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.conf

    ctrl_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

    1. Launch Cust Path demo

    cd ${SDK}/component/wifi/whc/whc_host_linux/app
    sudo ./whc_cust_path_demo
    
    1. Execute initialization

    > init
    
    1. Enter the following command in the demo to instruct Ameba to obtain an IP address

    > dhcp
    
    1. Based 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

  1. 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
    
  2. Firmware Compilation

    Generate target files:

    ameba.py build
    

    Output files:

    • boot.bin

    • app.bin

  3. 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,12345678
    

    Note

    ap_test represents the target AP’s SSID, 12345678 is 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.