Edit online

无线网络

本节描述如何调试 SDK 支持的各类 WiFi 外设模块,包括:
  • AIC8800
  • RTL8189
  • RTL8733
  • TXW901
Edit online

配置 SDMC 接口

由于 WiFi 模块统一使用 SDIO 接口,因此必须配置 SDMC 控制器,从而保障与 WiFi 模块之间的正常通信。

使用 SDMC 接口前,选中对应的 SDMC 接口,以 KunLun Pi 开发板为例。

使用 scons--meunconfig 命令,配置下列内容:
Board options
    [*] Using SDMC0                                                         # 硬件连接哪个 SDMC 接口,选择哪个 SDMC
     -*-  Enable the interrupt of SDMC
          SDMC0 Parameter  --->
             Select SDMC0 BUSWIDTH (sdmc 4-bit mode)  --->
            [ ] Using SDcard hotplug detection (NEW)
            [*] SDMC0 connect to a SDIO device
            (3) SDMC0 driver phase (NEW)
            (0) SDMC0 sample phase (NEW)
            (40000000) SDMC0 CMU clock frequency (NEW)                      # 建议使用 40Mhz
Edit online

配置 WiFi 模组

  1. 使用 scons--meunconfig 命令,打开配置界面。
  2. Board options 配置中,选择 WiFi 外设对应的专项配置,以 AIC8800 为例:
    注: 不同的 WiFi 模组参数配置也不相同,详情可查看 WiFi 模组参数说明
    Board options
        [*] Using Wireless lan --->
                [*]   AIC8800 wlan driver  --->
                    Wlan0 Parameter  --->
                            Select AIC8800 MODEL (select AIC8800D40L)  --->
                            Select AIC8800 power converter (select DCDC mode)  --->
                            Select AIC8800 work mode (select normal mode)  --->
                            [ ] enable aic8800 BT support
                            ()  aic8800 bt reset gpio
                            (PD.7) aic8800 wlan0 power on gpio
                            ()  aic8800 wlan0 reset gpio                        # Kunlun Pi WiFi 接口没有连接 reset 引脚,故不做设定
                            [ ] enable aic8800 debug messages                   # 若使用 WiFi 中遇到问题,可打开调试信息,联系我们,默认关闭
  3. pinmux.c 中配置 WiFi 模块所需使用的引脚:

    以下实例中,只需配置 Power On 引脚:

    struct aic_pinmux aic_pinmux_config[] = {
    ...
    #ifdef AIC_WIRELESS_LAN
        {1, PIN_PULL_DIS, 3, "PD.7"},  // WIFI_PWR_ON
    #endif
    ...
    };
Edit online

WiFi 模组参数说明

配置 WiFi 模组时,需要根据不同的WiFi 外设,在 Board options 配置中,选择对应的专项配置。

AIC8800 模组参数说明

[*] Using Wireless lan --->
            [*]   AIC8800 wlan driver  --->
                Wlan0 Parameter  --->
                        Select AIC8800 MODEL (select AIC8800D40L)  --->
                        Select AIC8800 power converter (select DCDC mode)  --->
                        Select AIC8800 work mode (select normal mode)  --->
                        [ ] enable aic8800 BT support
                        ()  aic8800 bt reset gpio
                        (PD.7) aic8800 wlan0 power on gpio
                        ()  aic8800 wlan0 reset gpio                        # Kunlun Pi WiFi 接口没有连接 reset 引脚,故不做设定
                        [ ] enable aic8800 debug messages                   # 若使用 WiFi 中遇到问题,可打开调试信息,联系我们,默认关闭

RTL8189 模组参数说明

[*] Using Wireless lan --->
    [*] Using Wireless lan --->
            [*] Using Realtek wlan driver --->
                Select Realtek wlan0 modul (rtl8189)--- >    # 以 RTL8189 为例, 使用 RTL8733 也行
                Realtek wlan0 paramete --->
                    (PD.7) realtek wlan0 power on gpio
                    (192.168.3.20) wlan0 ip addr
                    (192.168.3.1) wlan0 gateway addr
                    (255.255.255.0) wlan0 netmask
                    [*] Enable Realtek driver debug information
                    [ ] Enable Realtek driver full function  # 需要使用 P2P 或蓝牙需要打开,普通 STA / AP 模式无需配置

RTL8733 模组参数说明

[*] Using Wireless lan --->
    [*] Using Realtek wlan driver --->
                Select Realtek wlan0 modul (rtl8733)--- >    # 以 RTL8733 为例, 使用RTL8189也可以
                Realtek wlan0 paramete --->
                    (PD.7) realtek wlan0 power on gpio
                    (192.168.3.20) wlan0 ip addr
                    (192.168.3.1) wlan0 gateway addr
                    (255.255.255.0) wlan0 netmask
                    [*] Enable Realtek driver debug information
                    [ ] Enable Realtek driver full function  # 需要使用 P2P 或蓝牙需要打开,普通 STA / AP 模式无需配置

TXW901 模组参数说明

[*] HUGEIC wlan driver  --->
            --- HUGEIC wlan driver
                Wlan0 Parameter  --->
                        (PD.17) txw901 power on gpio                       # 泰芯模组默认没有电源控制引脚,使用默认值即可,无需配置
                        txw901 BLE provisioning (select manual provisioning mode)  ---> # 使用默认手动配网模式
                        [ ] enable txw901 debug messages                   # 若使用 WiFi 中遇到问题,可打开调试信息,联系我们,默认关闭
Edit online

配置内核和 lwIP

使用 scons --menuconfig 命令进入配置页面,并配置下列参数,以 AIC8800 WiFi 外设为例:
注: 对于不同外设,下列配置选项中的优先级配置并不相同,需根据厂家的建议值进行配置,详情可参考不同外设的内核和 IwIP 参数说明
故障: 配置完成之后可能会出现类似 d13x_os.itb file_size: 0x216800 is over much than part_size: 0x200000 的输出提示,此时可调整 OS 分区并使用 mb 命令重新编译 BootLoader 和 RTT 即可。
Rt-Thread options --->
    RT-Thread Kernel --->
        [*] Enable software timer with a timer thread
        (7)   The priority level value of timer thread
        (8192) The stack size of timer thread
    RT-Thread Components --->
        Device Drivers --->
            -*-   Using system default workqueue
            (8192)  The stack size for system workqueue thread
            (16384) The stack size for sdio irq thread
            (5)   The priority level value of sdio irq thread
            [*] Using Wi-Fi framework  --->
                (8192)  WLAN work queue thread size
                [*]   Enable WLAN Debugging Options  --->
                    [*]   Enable Debugging of wlan_cmd.c
        Network --->
            [ ] SAL: socket abstraction layer  ----
            [*] Enable network interface device  --->
            -*- LwIP: light weight TCP/IP stack  --->                             # 使用 RT-Thread 内核中的 lwIP
                --- LwIP: light weight TCP/IP stack
                (3)   the priority level value of lwIP thread
                (8192) the stack size of lwIP thread
                [*]   Enable IP reassembly and frag
                [*]   Enable netif loopback
Edit online

内核和 IwIP 参数说明

不同外设的优先级配置并不相同,需根据厂家的建议值进行配置。

AIC8800 参数配置建议

AIC8800 的参数配置建议如下:

Rt-Thread options --->
    RT-Thread Kernel --->
        [*] Enable software timer with a timer thread
        (7)   The priority level value of timer thread
        (8192) The stack size of timer thread
    RT-Thread Components --->
        Device Drivers --->
            -*-   Using system default workqueue
            (8192)  The stack size for system workqueue thread
            (16384) The stack size for sdio irq thread
            (5)   The priority level value of sdio irq thread
            [*] Using Wi-Fi framework  --->
                (8192)  WLAN work queue thread size
                [*]   Enable WLAN Debugging Options  --->
                    [*]   Enable Debugging of wlan_cmd.c
        Network --->
            [ ] SAL: socket abstraction layer  ----
            [*] Enable network interface device  --->
            -*- LwIP: light weight TCP/IP stack  --->                             # 使用 RT-Thread 内核中的 lwIP
                --- LwIP: light weight TCP/IP stack
                (3)   the priority level value of lwIP thread
                (8192) the stack size of lwIP thread
                [*]   Enable IP reassembly and frag
                [*]   Enable netif loopback

RTL8189/ RTL8733 参数配置建议

RTL8189/ RTL8189 的参数配置建议如下:

Rt-Thread options --->
    RT-Thread Kernel --->
        [*] Enable software timer with a timer thread
        (7)   The priority level value of timer thread
        (16384) The stack size of timer thread
    RT-Thread Components --->
        Device Drivers --->
            -*-   Using system default workqueue
            (8192)  The stack size for system workqueue thread
            (16384) The stack size for sdio irq thread
            (5)   The priority level value of sdio irq thread
            [*] Using Wi-Fi framework  --->
                [*]       Forced use of PBUF transmission
                [*]   Enable WLAN Debugging Options  --->
                    [*]   Enable Debugging of wlan_cmd.c
        Network --->
            [] SAL: socket abstraction layer  ----
            [*] Enable network interface device  --->
            -*- LwIP: light weight TCP/IP stack  --->                             # 使用 RT-Thread 内核中的 lwIP
                --- LwIP: light weight TCP/IP stack
                (3)   the priority level value of lwIP thread
                (8192) the stack size of lwIP thread

TXW901 参数配置建议

TXW901 的参数配置建议如下:

Rt-Thread options --->
    RT-Thread Kernel --->
        [*] Enable software timer with a timer thread
        (7)   The priority level value of timer thread
        (8192) The stack size of timer thread
    RT-Thread Components --->
        Device Drivers --->
            -*-   Using system default workqueue
            (8192)  The stack size for system workqueue thread
            (8192) The stack size for sdio irq thread
            (3)   The priority level value of sdio irq thread
            [*] Using Wi-Fi framework  --->
                [*]       Forced use of PBUF transmission
                (4096)  WLAN work queue thread size
                [*]   Enable WLAN Debugging Options  --->
                    [*]   Enable Debugging of wlan_cmd.c
        Network --->
            [ ] SAL: socket abstraction layer  ----
            [*] Enable network interface device  --->
            -*- LwIP: light weight TCP/IP stack  --->                             # 使用 RT-Thread 内核中的 lwIP
                --- LwIP: light weight TCP/IP stack
                (4)   the priority level value of lwIP thread
Edit online

打开调试工具

Local packages options  --->
    Third-party packages options  --->
        [ ] LwIP: light weight TCP/IP stack  ----                        # 关闭第三方包中的 lwIP
        [*] netutils: Networking utilities for RT-Thread  --->
            --- netutils: Networking utilities for RT-Thread
            [*]   Enable iperf-liked network performance tool
Edit online

执行测试命令

完成所有配置后,保存退出,编译、烧录。待系统启动后,可执行如下命令进行验证:

wifi -d mode sta wlan0      // 初始化 WiFi,并设置为 STA 模式

wifi join SSID PASSWORD     // 连接 AP

ping 192.168.1.1            // 假设网关IP为192.168.1.1,ping一下验证通路

wifi disc                   // 断开 WiFi 连接

wifi -d mode ap ap0         // 设备 WiFi 为 AP 模式

wifi ap SSID PASSWORD       // 生成 AP