WHC Wi-Fi Slim Host Driver 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/wifi/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.

    ./fullmac_setup.sh sdio [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

    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
    

    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

Demo Introduction

In Slim Host mode, standard Wi-Fi APIs are unavailable, and the CUST_PATH must be used for Wi-Fi control. Therefore, we need to develop a non-standard demo program for demonstration purposes.

The application supports bidirectional communication between User Space and Kernel Space through two command types:

  1. Kernel-Level Configuration

    • setmac:Configure device MAC address

    • netifon:Activate network interface carrier

  2. Device-Level Control

    • getmac: Retrieve device MAC address

    • getip: Retrieve device IP configuration

    • setrdy: Notify device state

    • tickps: Tickless Power Save command, Notify the device that it can enter low-power mode

    • wifion: Notify device to initialize WiFi

The communication architecture is shown below:

../../../_images/fullmac_crtlapp_control_flow.svg

Supported Commands

Command Format

Description

init

Initialize kernel Netlink communication channel

getmac <device_idx>

Retrieve specified device MAC address

device_idx: Device port index (0 or 1 only)

  • 0: Corresponds to wlan0 (STA on device)

  • 1: Corresponds to wlan1 (SoftAP on device)

getip <device_idx>

Retrieve device network layer configuration

device_idx: Device port index (same as getmac)

setrdy <state>

Notifies the device of the host state

state:ready (active) or unready (inactive)

setmac <device_idx> <mac>

Configure interface hardware address

  • device_idx: Device port index (same as getmac)

  • mac: MAC format (xx:xx:xx:xx:xx:xx)

netifon <device_idx>

Activate physical layer carrier

device_idx: Device port index (same as getmac)

tickps <subtype>

Tickless Power Save command

subtype: Tickless Power Save command type

  • cg: Set device sleep mode to clock gating

  • pg: Set device sleep mode to power gating

  • r: Notify device that it can enter low-power mode

wifion

Notify device to initialize WiFi

connect <ssid> <pw>

Notify device to connect

  • ssid: Target AP’s SSID

  • pw: Target AP’s password (defaults to open AP if not specified)

dhcp

Notify device for IP negotiation

Compilation and Execution

# Enter module directory
cd ${SDK}/component/wifi/whc/whc_host_linux/app

# Compile executable
make

# Run with privileged mode
sudo ./whc_slim_host_demo

Functional Verification And Demo

  • Run the demo

    cd ${SDK}/component/wifi/whc/whc_host_linux/app
    sudo ./whc_slim_host_demo
    
  • Execute initialization sequence in demo

    > init
    > wifion
    > getmac 0
    00:E0:4C:XX:XX:XX
    > setmac 0 00:E0:4C:XX:XX:XX
    
  • Perform Wi-Fi scan in demo

    > scan
    
  • Establish wireless connection in demo

    > netifon 0
    > connect ap_test 12345678
    

    Note

    ap_test represents the target AP’s SSID, 12345678 is the target AP’s password. Omit password parameter for open networks.

  • Execute the following command in the terminal to dynamically obtain an IP address

    > dhcpcd wlanX
    

    Note

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

  • Network Testing

    ping 192.168.x.x