Wi-Fi Zephyr Architecture

The architecture of Wi-Fi Zephyr is shown in the following diagram:

../../rst_wifi/2_wifi_zephyr/figures/wifi_zephyr_arch.svg

Wi-Fi Zephyr File Structure

├─ zephyr/drivers/wifi/ameba/src
│  ├─ ameba_wifi_drv.c
│  └─ ameba_wifi.h
├─ modules/hal/realtek/ameba/common/wifi/source
│  ├─ ameba_wificfg.c
│  ├─ api
│  │  ├─ wifi_ind.c
│  │  └─ wifi_init_zephyr.c
│  ├─ common
│  │  ├─ rom_rtw_queue.c
│  │  ├─ rtw_atomic.c
│  │  └─ rtw_wakelock_zephyr.c
│  └─ inic/ipc
│     ├─ inic_ipc_msg_queue.h
│     ├─ inic_ipc_msg_queue.c
│     ├─ inic_ipc_host_zephyr.h
│     ├─ inic_ipc_host_zephyr.c
│     ├─ inic_ipc_host_trx.h
│     ├─ inic_ipc_host_trx.c
│     ├─ inic_ipc_host_api_ext.c
│     ├─ inic_ipc_host_api_basic.c
│     ├─ inic_ipc_host_api.c
│     ├─ inic_ipc_host.c
│     ├─ inic_ipc.h
│     └─ inic_ipc_cfg.h

Wi-Fi Zephyr Features

Features

Zephyr

Wi-Fi API

Zephyr Wi-Fi APIs

Wi-Fi mode

  • Station

  • SoftAP

Wi-Fi security

  • Open

  • WPA

  • WPA2

  • WPA3

Wowlan

TBD

Wi-Fi Zephyr Guide

Mandatory Macros:

CONFIG_WIFI=y
CONFIG_NET_L2_ETHERNET=y
CONFIG_NET_UDP_CHECKSUM=y
CONFIG_REALTEK_AMEBA_HAL_LIB=y
CONFIG_REALTEK_AMEBA_ZEPHYR_WIFI=y
CONFIG_WLAN=y
CONFIG_REALTEK_AMEBA_WIFI_INIC=n
CONFIG_ETH_DRIVER=y
CONFIG_ETH_PHY_DRIVER=y
CONFIG_NET_DHCPV4=y
CONFIG_WIFI_AMEBA=y
CONFIG_NETWORKING=y
CONFIG_NET_L2_WIFI_SHELL=y
CONFIG_NET_L2_WIFI_MGMT=y
CONFIG_NET_IPV4=y
CONFIG_NET_SHELL=y
CONFIG_NET_UDP=y
CONFIG_NET_MGMT=y
CONFIG_NET_DHCPV4_SERVER=y  # For SoftAP mode
CONFIG_NET_IF_MAX_IPV4_COUNT=2
CONFIG_NET_TCP=y
CONFIG_NET_LOG=y
CONFIG_ENTROPY_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y  # For testing

Macros for zperf Testing:

CONFIG_NET_ZPERF=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_SERVICE_THREAD_PRIO=-1
CONFIG_NET_SOCKETS_POLL_MAX=12
CONFIG_POSIX_API=y
CONFIG_NET_CONFIG_SETTINGS=y
# For TCP throughput tests in zperf
CONFIG_NET_PKT_RX_COUNT=40
CONFIG_NET_PKT_TX_COUNT=40
CONFIG_NET_BUF_RX_COUNT=160
CONFIG_NET_BUF_TX_COUNT=160
CONFIG_NET_BUF_DATA_SIZE=256

Build Commands:

In the {sdk} directory, execute:

./nuwa.py build -a applications/thread -d rtl872xd_evb -p

Firmware Flashing:

Firmware files in {sdk}/images include:

bootloader_all.bin
km0_km4_app.bin

Wi-Fi Zephyr APIs

Wi-Fi Shell Layer

Command Format

Description and Parameters

wifi scan

Scan surrounding wireless networks

wifi connect

Connect to specified AP

  • Required parameters:

    • -s “<SSID>” Specify AP name

  • Optional parameters:

    • -c “Scan channel” (0=all channels)

    • -p “<passphrase>” AP password (encrypted networks only)

    • -k “<0-3>” Key management type

      • 0:Open

      • 1:WPA2-PSK

      • 2:WPA2-PSK-256

      • 3:SAE

    • -m “<MAC>” Specify AP’s MAC address

wifi disconnect

Terminate current wireless connection

wifi ap enable

Enable SoftAP mode

  • Required parameters:

    • -s “<SSID>” Specify hotspot name

  • Optional parameters:

    • -c Operating channel

    • -p “<passphrase>” Hotspot password (8-63 characters)

    • -k “<0-3>” Encryption type (same as connect command)

wifi ap disable

Disable SoftAP mode

Net Shell Layer

Command Format

Description and Parameters

net ping <dst_ip>

Perform ICMP connectivity test

net iface

Display network interface status

net dhcpv4 server start <2> <base_ip>

Start DHCPv4 server

  • <2>: Fixed SoftAP interface index (Ameba platform specific)

  • <base_ip>: IP pool starting address (e.g., 192.168.45.100)

net dhcpv4 server stop <2>

Stop DHCPv4 service

net dhcpv4 server status

Show DHCP server status

net arp

Display current ARP cache table

zperf Shell Layer

Command Format

Description and Parameters

zperf setip <my_ip>

Set local IP address

zperf tcp upload <dst_ip> <port> <sec> <size>[K/M]

Start TCP upload test

Example: zperf tcp upload 192.168.1.100 5003 10 1M

zperf tcp download <port> <host>

Start TCP download test

Example: zperf tcp download 5003 192.168.1.100

zperf udp upload <dst_ip> <port> <sec> <size>[K/M]

Start UDP upload test

Example: zperf udp upload 192.168.1.100 5003 10 512K

zperf udp download <port> <host>

Start UDP download test

Example: zperf udp download 5003 192.168.1.100

Wi-Fi Zephyr Throughput

Test item

Bandwidth (20MHz)

TCP TX

TCP RX

UDP TX

UDP RX