WHC Wi-Fi Fat Host Driver Porting

Linux cfg80211 Porting

Driver Porting

FullMAC 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. However, 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
  1. Interface 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
    
  2. In directory /component/whc/whc_host_linux, run the following cmd. nan and p2p is an optional parameter and should be added only when Wi-Fi NAN and Wi-Fi P2P needs to be enabled.

    SDIO

    ./fullmac_setup.sh sdio [nan] [p2p]
    

    SPI

    ./fullmac_setup.sh spi [nan] [p2p]
    

    USB

    ./fullmac_setup.sh usb [nan] [p2p]
    
  3. Select 1 or 2 based on the host operation mode

    choose target host mode:
    1) Fat host with cfg80211
    2) Slim host without cfg80211
    choose target host mode:
    
  4. Copy whc_host_linux to Linux kernel source tree

  5. Open new terminal and compile

    cd {driver_path}/whc_host_linux
    make
    
  1. Driver Loading

    SDIO

    Module Path: /whc_host_linux/sdio/fullmac_sdio.ko

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

    SPI

    Module Path: /whc_host_linux/spi/fullmac_spi.ko

    sudo su
    cp spi/fullmac_spi.ko /lib/modules/$(uname -r)/
    depmod -a
    modprobe fullmac_spi
    

    USB

    Module Path: /whc_host_linux/usb/fullmac_usb.ko

    sudo su
    cp usb/fullmac_usb.ko /lib/modules/$(uname -r)/
    depmod -a
    modprobe fullmac_usb
    

    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

  • Driver Loading Verification

    After successful modprobe loading, execute ifconfig to view Wi-Fi device information.

    Example Output:

    • Station mode: Device MAC address prefix is 00:e0:4c

    • SoftAP mode: Device MAC address prefix is 00:e1:4c

    ../../_images/ifconfig_sta_softap.png
  • 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
    

    Note

    wlanX is the name of the wireless interface device, execute ifconfig -a` in the terminal to retrieve its information

  • 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

Dual TCPIP Mode Verification

  • Driver Loading Verification

    After successful modprobe loading, execute ifconfig to view Wi-Fi device information.

    Example Output:

    • Station mode: Device MAC address prefix is 00:e0:4c

    • SoftAP mode: Device MAC address prefix is 00:e1:4c

    ../../_images/ifconfig_sta_softap.png
  • 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
    

    Note

    wlanX is the name of the wireless interface device, execute ifconfig -a` in the terminal to retrieve its information

  • Obtaining IP Address

    1. Launch slim host demo

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

    > init
    
    1. Trigger IP address acquisition

    > dhcp
    
    1. Configure host network settings

    sudo ip addr add 192.168.x.x/24 dev wlanX
    sudo ip link set wlanX up
    sudo ip route add default via 192.168.x.x dev wlanX
    
  • Network Testing

    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 Driver Porting

Driver Porting

Programming Guide for Ameba as FullMAC Host

  1. Environment Setup

    Execute the configuration tool in the directory {SDK}/amebadplus_gcc_project

    (Top) -> CONFIG WHC INTF -> WHC_MODE
    ----Configuration----
          ( ) WHC_IPC
          ( ) FULLMAC_DEV
          (X) FULLMAC_HOST
    
    (Top) -> CONFIG WHC INTF -> FULLMAC HOST config
    ----Configuration----
          (X) Support WHC CMD PATH
          (X) Support WHC WIFI API PATH
    
  2. Firmware Compilation

    Generate target files:

    ./build.py
    

    Output files:

    • km4_boot_all.bin

    • km0_km4_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

  • Perform WiFi scan

    > AT+WLSCAN
    
  • Establish wireless connection in

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

  • Network Testing

    AT+WLPING=192.168.x.x
    

CUST_PATH Guide

In Fat Host mode,if custom communication between Host and Device is required beyond standard Wi-Fi/BT/Socket programming, the CUST_PATH can be utilized.