Просмотр исходного кода

[bsp][gd32]:gd32vw553h-eval add wifi support#11175

CYFS 9 часов назад
Родитель
Сommit
737ae54878
26 измененных файлов с 856 добавлено и 111 удалено
  1. 9 0
      bsp/gd32/risc-v/gd32vw553h-eval/.ci/attachconfig/ci.attachconfig.yml
  2. 45 1
      bsp/gd32/risc-v/gd32vw553h-eval/README.md
  3. 28 0
      bsp/gd32/risc-v/gd32vw553h-eval/board/Kconfig
  4. 6 0
      bsp/gd32/risc-v/gd32vw553h-eval/board/SConscript
  5. 515 0
      bsp/gd32/risc-v/gd32vw553h-eval/board/drv_wlan.c
  6. 18 0
      bsp/gd32/risc-v/gd32vw553h-eval/board/drv_wlan.h
  7. 9 7
      bsp/gd32/risc-v/gd32vw553h-eval/board/trap_gcc.S
  8. 99 0
      bsp/gd32/risc-v/gd32vw553h-eval/board/wifi.c
  9. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145545039.png
  10. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145642371.png
  11. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145735119.png
  12. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145751469.png
  13. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145759739.png
  14. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145806668.png
  15. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145856756.png
  16. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145903955.png
  17. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205150826393.png
  18. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151251937.png
  19. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151356304.png
  20. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151403278.png
  21. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151409209.png
  22. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151644687.png
  23. BIN
      bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151712234.png
  24. 15 3
      bsp/gd32/risc-v/gd32vw553h-eval/rtconfig.py
  25. 108 100
      components/drivers/wlan/dev_wlan_cmd.c
  26. 4 0
      components/net/lwip/port/SConscript

+ 9 - 0
bsp/gd32/risc-v/gd32vw553h-eval/.ci/attachconfig/ci.attachconfig.yml

@@ -19,6 +19,15 @@ devices.i2c:
       - CONFIG_BSP_HW_I2C1_PIN_PB12_PB13=y
       - CONFIG_BSP_HW_I2C1_CLK=100
 
+devices.wlan:
+    kconfig:
+      - CONFIG_BSP_USING_WLAN=y
+      - CONFIG_RT_NAME_MAX=24
+      - CONFIG_RT_WLAN_PROT_ENABLE=n
+      - CONFIG_RT_USING_LWIP212=y
+
+
+
 # ------ peripheral CI ------
 peripheral.at24c02:
     kconfig:

+ 45 - 1
bsp/gd32/risc-v/gd32vw553h-eval/README.md

@@ -170,7 +170,51 @@ msh >
 
 完成上述配置后即可点击调试选项进行调试,调试时boot管脚均置为低电平即可,调试时同样会进行固件下载。
 
-## 4 注意事项
+## 4.WIFI使用
+
+使用ENV,menuconfig,修改和使能下面的配置
+
+* 修改 RT_NAME_MAX为24
+
+  ![image-20260205145545039](figures/image-20260205145545039.png)
+
+* 使能 BSP_USING_WLAN
+
+  ![image-20260205145642371](figures/image-20260205145642371.png)
+
+* 修改LWIP的版本为V2.1.2
+
+  ![image-20260205145806668](figures/image-20260205145806668.png)
+
+* 关闭 RT_WLAN_PROT_ENABLE
+
+  ![image-20260205145856756](figures/image-20260205145856756.png)
+
+进行编译 scons -jx ,下载。
+
+![image-20260205150826393](figures/image-20260205150826393.png)
+
+可以使用help查看wifi指令,下面演示连接wifi以及ping
+
+![image-20260205151251937](figures/image-20260205151251937.png)
+
+### 使用NETDEV
+
+* 使能 RT_USING_NETDEV
+
+  ![image-20260205151356304](figures/image-20260205151356304.png) 
+
+重新编译,下载。
+
+* wifi 连接以及ping 
+
+  ![image-20260205151712234](figures/image-20260205151712234.png)
+
+* ifconfig:
+
+  ![image-20260205151644687](figures/image-20260205151644687.png)
+
+## 5 注意事项
 
 - Cortex-Debug插件优先选用v1.4.4版本,高版本可能会出现与GDB版本不匹配的问题。
 

+ 28 - 0
bsp/gd32/risc-v/gd32vw553h-eval/board/Kconfig

@@ -13,6 +13,34 @@ config SOC_GD32VW553H
 
 menu "Onboard Peripheral Drivers"
 
+    menuconfig BSP_USING_WLAN
+        bool "Enable WiFi (GD32VW553H Internal)"
+        select RT_USING_WIFI
+        select PKG_USING_GD32VW55X_WIFI
+        select RT_USING_MEMHEAP
+        select RT_USING_SYSTEM_WORKQUEUE
+        default n
+
+    if BSP_USING_WLAN
+        config BSP_WLAN_SSID_MAX_LENGTH
+            int "WiFi SSID max length"
+            range 1 32
+            default 32
+
+        config BSP_WLAN_PASSWORD_MAX_LENGTH
+            int "WiFi password max length"
+            range 8 64
+            default 64
+
+        config BSP_WLAN_SCAN_CACHE_NUM
+            int "WiFi scan result cache number"
+            range 4 32
+            default 16
+
+        # Include GD32VW55x WIFI package configuration
+        osource "$(BSP_DIR)/packages/gd32vw55x-wifi/Kconfig"
+    endif
+
 endmenu
 
 menu "On-chip Peripheral Drivers"

+ 6 - 0
bsp/gd32/risc-v/gd32vw553h-eval/board/SConscript

@@ -12,12 +12,18 @@ board.c
 trap_gcc.S
 ''')
 
+# add WiFi driver
+if GetDepend(['BSP_USING_WLAN']):
+    src += ['drv_wlan.c']
+    src += ['wifi.c']
+
 path =  [cwd]
 
 # add startup txt path
 startup_path_prefix = os.getcwd() + '/../'
 
 if rtconfig.PLATFORM in ['gcc']:
+    # Use standard peripheral library startup files for compatibility
     src += [startup_path_prefix + '/packages/gd32-riscv-series-latest/GD32VW55x/RISCV/env_Eclipse/start.S']
     src += [startup_path_prefix + '/packages/gd32-riscv-series-latest/GD32VW55x/RISCV/env_Eclipse/entry.S']
 

+ 515 - 0
bsp/gd32/risc-v/gd32vw553h-eval/board/drv_wlan.c

@@ -0,0 +1,515 @@
+/*
+ * Copyright (c) 2006-2025, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2025-12-25     RT-Thread    first version
+ */
+
+#include <rtthread.h>
+#include <rtdevice.h>
+#include "board.h"
+
+#ifdef RT_USING_WIFI
+#include "drv_wlan.h"
+#include "gd32vw55x_platform.h"
+#include "wifi_management.h"
+#include "wifi_init.h"
+
+#define DBG_TAG "drv.wlan"
+#define DBG_LVL DBG_INFO
+#include <rtdbg.h>
+
+enum {
+    WIFI_VIF_STA = 0,
+    WIFI_VIF_AP,
+    WIFI_VIF_MAX
+};
+
+/* GD32VW553H WiFi device structure */
+struct gd32_wlan_device
+{
+    struct rt_wlan_device *wlan;
+    rt_uint8_t if_idx;      /* Interface index: 0 - STA, 1 - AP */
+    rt_uint8_t dev_addr[MAC_ADDR_LEN];  /* MAC address */
+};
+
+static struct gd32_wlan_device wlan_sta_device;
+static struct gd32_wlan_device wlan_ap_device;
+
+/**
+ * @brief WiFi initialization callback
+ */
+static rt_err_t gd32_wlan_init(struct rt_wlan_device *wlan)
+{
+    LOG_D("WiFi device init: %s", wlan->name);
+
+    return RT_EOK;
+}
+
+/**
+ * @brief WiFi mode configuration
+ */
+static rt_err_t gd32_wlan_mode(struct rt_wlan_device *wlan, rt_wlan_mode_t mode)
+{
+    LOG_D("Set WiFi mode: %d", mode);
+
+    /* TODO: Set WiFi mode (STA/AP/STA+AP) */
+
+    return RT_EOK;
+}
+
+static inline int wifi_freq_to_channel(uint16_t freq)
+{
+    if ((freq >= 2412) && (freq <= 2484)) {
+        if (freq == 2484)
+            return 14;
+        else
+            return (freq - 2407) / 5;
+    }
+    return 0;
+}
+
+static void scan_done_callback(void *eloop_data, void *user_ctx)
+{
+    int idx;
+    struct macif_scan_results *results = RT_NULL;
+    struct mac_scan_result *bss_info = RT_NULL;
+    struct rt_wlan_info wlan_info;
+    struct rt_wlan_buff buff;
+
+    results = (struct macif_scan_results *)rt_malloc(sizeof(struct macif_scan_results));
+    if (RT_NULL == results) {
+        LOG_E("Failed to allocate memory for scan results\r\n");
+        rt_wlan_dev_indicate_event_handle(wlan_sta_device.wlan, RT_WLAN_DEV_EVT_SCAN_DONE, RT_NULL);
+        return;
+    }
+
+    if (wifi_netlink_scan_results_get(WIFI_VIF_STA, results)) {
+        rt_free(results);
+        rt_kprintf("WIFI scan results get failed\r\n");
+        rt_wlan_dev_indicate_event_handle(wlan_sta_device.wlan, RT_WLAN_DEV_EVT_SCAN_DONE, RT_NULL);
+        return;
+    }
+
+    for (idx = 0; idx < results->result_cnt; idx++) {
+        bss_info = &results->result[idx];
+
+        rt_memset(&wlan_info, 0, sizeof(wlan_info));
+
+        rt_memcpy(&wlan_info.bssid[0], (char *)bss_info->bssid.array, MAC_ADDR_LEN);
+        rt_memcpy(wlan_info.ssid.val, (char *)bss_info->ssid.array, bss_info->ssid.length);
+        wlan_info.ssid.len = bss_info->ssid.length;
+        wlan_info.hidden = bss_info->ssid.length > 0 ? 0 : 1;
+
+        wlan_info.channel = wifi_freq_to_channel(bss_info->chan->freq);
+        wlan_info.rssi = bss_info->rssi;
+        wlan_info.band = RT_802_11_BAND_2_4GHZ;
+
+        wlan_info.security = SECURITY_UNKNOWN;
+
+        if (bss_info->akm & CO_BIT(MAC_AKM_NONE)) {
+            wlan_info.security = SECURITY_OPEN;
+        } else if (bss_info->akm == CO_BIT(MAC_AKM_PRE_RSN)) {
+            wlan_info.security = SECURITY_WEP_PSK;
+        } else if (bss_info->akm & CO_BIT(MAC_AKM_PRE_RSN)) {  // WPA
+            if (bss_info->pairwise_cipher & CO_BIT(MAC_CIPHER_TKIP)) {
+                wlan_info.security = SECURITY_WPA_TKIP_PSK;
+            } else if (bss_info->pairwise_cipher & CO_BIT(MAC_CIPHER_CCMP)) {
+                wlan_info.security = SECURITY_WPA_AES_PSK;
+            }
+        } else {  // WPA2
+            if ((bss_info->pairwise_cipher & CO_BIT(MAC_CIPHER_TKIP)) &&
+                (bss_info->pairwise_cipher & CO_BIT(MAC_CIPHER_CCMP))) {
+                wlan_info.security = SECURITY_WPA2_MIXED_PSK;
+            } else if (bss_info->pairwise_cipher & CO_BIT(MAC_CIPHER_TKIP)) {
+                wlan_info.security = SECURITY_WPA2_TKIP_PSK;
+            } else if (bss_info->pairwise_cipher & CO_BIT(MAC_CIPHER_CCMP)) {
+                wlan_info.security = SECURITY_WPA2_AES_PSK;
+            }
+        }
+
+        buff.data = &wlan_info;
+        buff.len = sizeof(wlan_info);
+        rt_wlan_dev_indicate_event_handle(wlan_sta_device.wlan, RT_WLAN_DEV_EVT_SCAN_REPORT, &buff);
+    }
+
+    rt_free(results);
+    rt_wlan_dev_indicate_event_handle(wlan_sta_device.wlan, RT_WLAN_DEV_EVT_SCAN_DONE, RT_NULL);
+
+    eloop_event_unregister(WIFI_MGMT_EVENT_SCAN_DONE);
+    eloop_event_unregister(WIFI_MGMT_EVENT_SCAN_FAIL);
+}
+
+static void scan_fail_callback(void *eloop_data, void *user_ctx)
+{
+    rt_kprintf("WIFI_SCAN: failed\r\n");
+    eloop_event_unregister(WIFI_MGMT_EVENT_SCAN_DONE);
+    eloop_event_unregister(WIFI_MGMT_EVENT_SCAN_FAIL);
+}
+
+/**
+ * @brief WiFi scan
+ */
+static rt_err_t gd32_wlan_scan(struct rt_wlan_device *wlan, struct rt_scan_info *scan_info)
+{
+    // rt_kprintf("WiFi scan start\r\n");
+
+    eloop_event_register(WIFI_MGMT_EVENT_SCAN_DONE, scan_done_callback, NULL, NULL);
+    eloop_event_register(WIFI_MGMT_EVENT_SCAN_FAIL, scan_fail_callback, NULL, NULL);
+
+    if (wifi_management_scan(false, NULL)) {
+        eloop_event_unregister(WIFI_MGMT_EVENT_SCAN_DONE);
+        eloop_event_unregister(WIFI_MGMT_EVENT_SCAN_FAIL);
+        rt_kprintf("Wifi scan failed\r\n");
+    }
+
+    return RT_EOK;
+}
+
+static void sta_conn_success_cb(void *eloop_data, void *user_ctx)
+{
+    LOG_D("WIFI_JOIN_SUCCESS");
+    rt_kprintf("WiFi connected successfully\r\n");
+
+    eloop_event_unregister(WIFI_MGMT_EVENT_CONNECT_SUCCESS);
+    eloop_event_unregister(WIFI_MGMT_EVENT_CONNECT_FAIL);
+
+    rt_wlan_dev_indicate_event_handle(wlan_sta_device.wlan, RT_WLAN_DEV_EVT_CONNECT, RT_NULL);
+}
+
+static void sta_conn_fail_cb(void *eloop_data, void *user_ctx)
+{
+    LOG_D("WIFI_JOIN_FAILED");
+    rt_kprintf("WiFi connection failed\r\n");
+
+    eloop_event_unregister(WIFI_MGMT_EVENT_CONNECT_SUCCESS);
+    eloop_event_unregister(WIFI_MGMT_EVENT_CONNECT_FAIL);
+
+    rt_wlan_dev_indicate_event_handle(wlan_sta_device.wlan, RT_WLAN_DEV_EVT_CONNECT_FAIL, RT_NULL);
+}
+
+/**
+ * @brief WiFi join (connect to AP)
+ */
+static rt_err_t gd32_wlan_join(struct rt_wlan_device *wlan, struct rt_sta_info *sta_info)
+{
+    LOG_D("WiFi join SSID: %s", sta_info->ssid.val);
+    rt_kprintf("WiFi join start\r\n");
+
+    // First, cancel any old callbacks that may exist
+    eloop_event_unregister(WIFI_MGMT_EVENT_CONNECT_SUCCESS);
+    eloop_event_unregister(WIFI_MGMT_EVENT_CONNECT_FAIL);
+
+    if (wifi_management_connect(sta_info->ssid.val, sta_info->key.val, 0) < 0) {
+        rt_kprintf("WiFi join failed\r\n");
+        return -RT_ERROR;
+    }
+
+    eloop_event_register(WIFI_MGMT_EVENT_CONNECT_SUCCESS, sta_conn_success_cb, NULL, NULL);
+    eloop_event_register(WIFI_MGMT_EVENT_CONNECT_FAIL, sta_conn_fail_cb, NULL, NULL);
+
+    return RT_EOK;
+}
+
+/**
+ * @brief WiFi softap start
+ */
+static rt_err_t gd32_wlan_softap(struct rt_wlan_device *wlan, struct rt_ap_info *ap_info)
+{
+    LOG_D("WiFi softap start SSID: %s", ap_info->ssid.val);
+
+    wifi_ap_auth_mode_t auth_mode;
+    char *ssid = ap_info->ssid.val;
+    char *passwd = ap_info->key.val;
+    uint32_t channel = ap_info->channel;
+    uint32_t hidden = ap_info->hidden;
+
+    if (wifi_management_concurrent_get() == 0) {
+        wifi_management_concurrent_set(1);
+    }
+
+    switch (ap_info->security)
+    {
+        case SECURITY_OPEN:
+            passwd = RT_NULL;
+            auth_mode = AUTH_MODE_OPEN;
+            break;
+
+        case SECURITY_WEP_PSK:
+        case SECURITY_WEP_SHARED:
+            auth_mode = AUTH_MODE_WEP;
+            break;
+
+        case SECURITY_WPA_TKIP_PSK:
+        case SECURITY_WPA_AES_PSK:
+            auth_mode = AUTH_MODE_WPA;
+            break;
+
+        case SECURITY_WPA2_TKIP_PSK:
+        case SECURITY_WPA2_AES_PSK:
+            auth_mode = AUTH_MODE_WPA2;
+            break;
+
+        case SECURITY_WPA2_MIXED_PSK:
+            auth_mode = AUTH_MODE_WPA_WPA2;
+            break;
+
+        case SECURITY_UNKNOWN:
+            auth_mode = AUTH_MODE_UNKNOWN;
+            break;
+
+        default:
+            rt_kprintf("Unsupported AP security mode %d, set to OPEN\r\n", ap_info->security);
+            auth_mode = AUTH_MODE_OPEN;
+            break;
+    }
+
+    if (wifi_management_ap_start(ssid, passwd, channel, auth_mode, hidden) < 0) {
+        rt_kprintf("WiFi softap start failed\r\n");
+        return -RT_ERROR;
+    }
+
+    rt_wlan_dev_indicate_event_handle(wlan_ap_device.wlan, RT_WLAN_DEV_EVT_AP_START, RT_NULL);
+
+    return RT_EOK;
+}
+
+/**
+ * @brief WiFi disconnect
+ */
+static rt_err_t gd32_wlan_disconnect(struct rt_wlan_device *wlan)
+{
+    LOG_D("WiFi disconnect");
+
+    wifi_management_disconnect();
+
+    rt_wlan_dev_indicate_event_handle(wlan_sta_device.wlan, RT_WLAN_DEV_EVT_DISCONNECT, RT_NULL);
+
+    return RT_EOK;
+}
+
+/**
+ * @brief WiFi AP disconnect station
+ */
+static rt_err_t gd32_wlan_ap_stop(struct rt_wlan_device *wlan)
+{
+    LOG_D("WiFi AP stop");
+
+    if (wifi_management_concurrent_get() == 0) {
+        wifi_management_concurrent_set(1);
+    }
+
+    if (wifi_management_ap_stop() < 0) {
+        rt_kprintf("WiFi AP stop failed\r\n");
+        return -RT_ERROR;
+    }
+
+    rt_wlan_dev_indicate_event_handle(wlan_ap_device.wlan, RT_WLAN_DEV_EVT_AP_STOP, RT_NULL);
+    return RT_EOK;
+}
+
+/**
+ * @brief WiFi AP deauthenticate station
+ */
+static rt_err_t gd32_wlan_ap_deauth(struct rt_wlan_device *wlan, rt_uint8_t mac[])
+{
+    LOG_D("WiFi AP deauth station");
+
+    if (wifi_management_concurrent_get() == 0) {
+        wifi_management_concurrent_set(1);
+    }
+
+    if (wifi_management_ap_delete_client(mac) < 0) {
+        rt_kprintf("WiFi AP deauth station failed\r\n");
+        return -RT_ERROR;
+    }
+
+    return RT_EOK;
+}
+
+/**
+ * @brief Get WiFi RSSI
+ */
+static rt_err_t gd32_wlan_scan_stop(struct rt_wlan_device *wlan)
+{
+    LOG_D("WiFi scan stop");
+
+    /* TODO: Stop WiFi scan */
+
+    return RT_EOK;
+}
+
+/**
+ * @brief Get WiFi channel
+ */
+static int gd32_wlan_get_rssi(struct rt_wlan_device *wlan)
+{
+    int rssi = 0;
+
+    /* TODO: Get current RSSI value */
+
+    return rssi;
+}
+
+/**
+ * @brief Set WiFi channel
+ */
+static rt_err_t gd32_wlan_set_channel(struct rt_wlan_device *wlan, int channel)
+{
+    LOG_D("Set WiFi channel: %d", channel);
+
+    /* TODO: Set WiFi channel */
+
+    return RT_EOK;
+}
+
+/**
+ * @brief Get WiFi channel
+ */
+static int gd32_wlan_get_channel(struct rt_wlan_device *wlan)
+{
+    int channel = 1;
+
+    /* TODO: Get current WiFi channel */
+
+    return channel;
+}
+
+/**
+ * @brief Set WiFi country code
+ */
+static rt_err_t gd32_wlan_set_country(struct rt_wlan_device *wlan, rt_country_code_t country_code)
+{
+    LOG_D("Set WiFi country code: %d", country_code);
+
+    /* TODO: Set WiFi country code */
+
+    return RT_EOK;
+}
+
+/**
+ * @brief Get WiFi country code
+ */
+static rt_country_code_t gd32_wlan_get_country(struct rt_wlan_device *wlan)
+{
+    /* TODO: Get WiFi country code */
+
+    return RT_COUNTRY_CHINA;
+}
+
+/**
+ * @brief Set WiFi MAC address
+ */
+static rt_err_t gd32_wlan_set_mac(struct rt_wlan_device *wlan, rt_uint8_t mac[])
+{
+    LOG_D("Set WiFi MAC: %02x:%02x:%02x:%02x:%02x:%02x",
+          mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+
+    /* TODO: Set WiFi MAC address */
+
+    return RT_EOK;
+}
+
+/**
+ * @brief Get WiFi MAC address
+ */
+static rt_err_t gd32_wlan_get_mac(struct rt_wlan_device *wlan, rt_uint8_t mac[])
+{
+    return RT_EOK;
+}
+
+/**
+ * @brief WiFi receive callback
+ */
+static int gd32_wlan_recv(struct rt_wlan_device *wlan, void *buff, int len)
+{
+    /* No need to implement - GD32 SDK LwIP internal processing of data reception */
+    /* Data receiving process: */
+    /* Hardware Interrupts -> MAC layer -> net if input() -> lwip tcpip input() -> Protocol stack processing */
+
+    return RT_EOK;
+}
+
+/**
+ * @brief WiFi send
+ */
+static int gd32_wlan_send(struct rt_wlan_device *wlan, void *buff, int len)
+{
+    /* No need to implement - GD32 SDK LwIP internal processing of data transmission */
+    /* Data sending process: */
+    /* Application -> Protocol stack processing -> lwip tcpip output() -> net if output() -> MAC layer -> Hardware */
+
+    return len;
+}
+
+/* WiFi operations */
+static const struct rt_wlan_dev_ops gd32_wlan_ops =
+{
+    .wlan_init            = gd32_wlan_init,
+    .wlan_mode            = gd32_wlan_mode,
+    .wlan_scan            = gd32_wlan_scan,
+    .wlan_join            = gd32_wlan_join,
+    .wlan_softap          = gd32_wlan_softap,
+    .wlan_disconnect      = gd32_wlan_disconnect,
+    .wlan_ap_stop         = gd32_wlan_ap_stop,
+    .wlan_ap_deauth       = gd32_wlan_ap_deauth,
+    .wlan_scan_stop       = gd32_wlan_scan_stop,
+    .wlan_get_rssi        = gd32_wlan_get_rssi,
+    .wlan_set_powersave   = RT_NULL,
+    .wlan_get_powersave   = RT_NULL,
+    .wlan_cfg_promisc     = RT_NULL,
+    .wlan_cfg_filter      = RT_NULL,
+    .wlan_set_channel     = gd32_wlan_set_channel,
+    .wlan_get_channel     = gd32_wlan_get_channel,
+    .wlan_set_country     = gd32_wlan_set_country,
+    .wlan_get_country     = gd32_wlan_get_country,
+    .wlan_set_mac         = gd32_wlan_set_mac,
+    .wlan_get_mac         = gd32_wlan_get_mac,
+    .wlan_recv            = gd32_wlan_recv,
+    .wlan_send            = gd32_wlan_send,
+};
+
+/**
+ * @brief Initialize WiFi driver
+ */
+int rt_hw_wlan_init(void)
+{
+    static rt_bool_t init_flag = RT_FALSE;
+
+    if (init_flag)
+    {
+        return RT_EOK;
+    }
+
+    platform_init();
+
+    /* Initialize WiFi device structure */
+    rt_memset(&wlan_sta_device, 0, sizeof(struct gd32_wlan_device));
+    rt_memset(&wlan_ap_device, 0, sizeof(struct gd32_wlan_device));
+
+    /* Register WiFi devices */
+    static struct rt_wlan_device wlan_sta;
+    static struct rt_wlan_device wlan_ap;
+
+    /* Register WiFi STA device */
+    wlan_sta_device.if_idx = WIFI_VIF_STA; /* STA interface */
+    rt_err_t ret = rt_wlan_dev_register(&wlan_sta, RT_WLAN_DEVICE_STA_NAME, &gd32_wlan_ops, 0, &wlan_sta_device);
+    wlan_sta_device.wlan = &wlan_sta;
+
+
+    /* Register WiFi AP device */
+    wlan_ap_device.if_idx = WIFI_VIF_AP; /* AP interface */
+    ret |= rt_wlan_dev_register(&wlan_ap, RT_WLAN_DEVICE_AP_NAME, &gd32_wlan_ops, 0, &wlan_ap_device);
+    wlan_ap_device.wlan = &wlan_ap;
+
+    init_flag = RT_TRUE;
+
+    LOG_I("GD32 WiFi driver initialized");
+
+    return ret;
+}
+INIT_DEVICE_EXPORT(rt_hw_wlan_init);
+#endif

+ 18 - 0
bsp/gd32/risc-v/gd32vw553h-eval/board/drv_wlan.h

@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2006-2025, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2025-12-25     RT-Thread    first version
+ */
+
+#ifndef __DRV_WIFI_H__
+#define __DRV_WIFI_H__
+
+#ifdef RT_USING_WIFI
+int rt_hw_wlan_init(void);
+#endif /* RT_USING_WIFI */
+
+#endif /* __DRV_WIFI_H__ */

+ 9 - 7
bsp/gd32/risc-v/gd32vw553h-eval/board/trap_gcc.S

@@ -2,18 +2,20 @@
 #include "riscv_encoding.h"
 
 .macro SAVE_CSR_CONTEXT
-    csrrwi  x0, CSR_PUSHMCAUSE, 11
-    csrrwi  x0, CSR_PUSHMEPC, 12
-    csrrwi  x0, CSR_PUSHMSUBM, 13
+    addi  sp, sp,  -16
+    csrrwi  x0, CSR_PUSHMCAUSE, 1
+    csrrwi  x0, CSR_PUSHMEPC, 2
+    csrrwi  x0, CSR_PUSHMSUBM, 3
 .endm
 
 .macro RESTORE_CSR_CONTEXT
-    LOAD x5,  13*REGBYTES(sp)
+    LOAD x5,  3*REGBYTES(sp)
     csrw CSR_MSUBM, x5
-    LOAD x5,  12*REGBYTES(sp)
+    LOAD x5,  2*REGBYTES(sp)
     csrw CSR_MEPC, x5
-    LOAD x5,  11*REGBYTES(sp)
+    LOAD x5,  1*REGBYTES(sp)
     csrw CSR_MCAUSE, x5
+    addi  sp, sp,  16
 .endm
 
 .macro DISABLE_MIE
@@ -42,4 +44,4 @@ rt_hw_do_after_save_above:
 
     LOAD  ra,  0 * REGBYTES(sp)
     addi  sp, sp,  4
-    ret
+    ret

+ 99 - 0
bsp/gd32/risc-v/gd32vw553h-eval/board/wifi.c

@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2006-2026, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date           Author       Notes
+ * 2026-02-25     CYFS         first version
+ */
+#include <stdio.h>
+#include <rtthread.h>
+#include <rtdevice.h>
+#include <board.h>
+#include "gd32vw55x_platform.h"
+#include "wrapper_os.h"
+#include "wifi_management.h"
+#include "wifi_init.h"
+#include "user_setting.h"
+#include "util.h"
+
+#ifdef RT_USING_WIFI
+#define START_TASK_STACK_SIZE       512
+#define START_TASK_PRIO             4
+
+static void application_init(void)
+{
+    util_init();
+
+    user_setting_init();
+
+    if (wifi_init())
+    {
+        rt_kprintf("wifi init failed\r\n");
+    } else {
+        /* rt_kprintf("wifi init success\r\n"); */
+    }
+}
+
+static rt_sem_t init_done_sem = RT_NULL;
+
+static void start_task(void *param)
+{
+    (void)param;
+
+    application_init();
+    /* rt_kprintf("Start task completed, exiting.\n"); */
+
+    /* Note: In RT-Thread, task should exit by returning, not by calling sys_task_delete(NULL).
+     * When the task function returns, RT-Thread will automatically clean up the task.
+     */
+
+    rt_sem_release(init_done_sem);
+}
+
+#endif /* RT_USING_WIFI */
+
+int wifi_app_init(void)
+{
+
+#ifdef RT_USING_WIFI
+    /* Create semaphore for synchronization */
+    init_done_sem = rt_sem_create("init_done", 0, RT_IPC_FLAG_PRIO);
+    if (init_done_sem == RT_NULL)
+    {
+        rt_kprintf("Failed to create semaphore\n");
+        return -RT_ERROR;
+    }
+
+    if (sys_task_create_dynamic((const uint8_t *)"start_task",
+            START_TASK_STACK_SIZE, OS_TASK_PRIORITY(START_TASK_PRIO), start_task, NULL) == NULL)
+            {
+        rt_kprintf("Create start task failed\r\n");
+        return -RT_ERROR;
+    }
+
+    /* rt_kprintf("Waiting for initialization to complete...\n"); */
+    /* Wait for initialization task to complete */
+    rt_sem_take(init_done_sem, RT_WAITING_FOREVER);
+    /* rt_kprintf("Initialization completed, continuing...\n"); */
+
+    /* Clean up semaphore */
+    rt_sem_delete(init_done_sem);
+    init_done_sem = RT_NULL;
+
+    /* set wifi work mode */
+    rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
+    rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP);
+#ifdef RT_USING_NETDEV
+    rt_thread_mdelay(1000);
+    extern int wifi_netdev_register(void);
+    wifi_netdev_register();
+#endif /* RT_USING_NETDEV */
+#endif /* RT_USING_WIFI */
+
+    return RT_EOK;
+}
+
+INIT_APP_EXPORT(wifi_app_init);
+

BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145545039.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145642371.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145735119.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145751469.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145759739.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145806668.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145856756.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205145903955.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205150826393.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151251937.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151356304.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151403278.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151409209.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151644687.png


BIN
bsp/gd32/risc-v/gd32vw553h-eval/figures/image-20260205151712234.png


+ 15 - 3
bsp/gd32/risc-v/gd32vw553h-eval/rtconfig.py

@@ -43,14 +43,26 @@ if PLATFORM == 'gcc':
     OBJDUMP = PREFIX + 'objdump'
     OBJCPY = PREFIX + 'objcopy'
 
-    DEVICE = ' -march=rv32imafdc -mcmodel=medany -msmall-data-limit=8 -mdiv -mabi=ilp32d -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections '
+    # 使用单精度硬件浮点ABI以匹配预编译的WiFi库 (libwifi.a, libwpas.a, librf.a)
+    # 预编译库架构: rv32imafcbp (包含单精度浮点 'f' 扩展)
+    # 原配置: -march=rv32imafdc -mabi=ilp32d (硬件双精度浮点)
+    # 修改为: -march=rv32imafc -mabi=ilp32f (硬件单精度浮点)
+    # 注意: GCC 8.2.0 不支持 -mpriv-spec 选项,链接时使用 --no-warn-mismatch 忽略特权规范版本差异
+    DEVICE = ' -march=rv32imafc -mcmodel=medany -msmall-data-limit=8 -mabi=ilp32f -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections '
 
     # C Compilation Parameters
     CFLAGS = DEVICE + ' -std=gnu11 -DUSE_STDPERIPH_DRIVE -save-temps=obj'
     # Assembly Compilation Parameters
     AFLAGS = DEVICE + '-c'+ ' -x assembler-with-cpp'
     # Linking Parameters
-    LFLAGS = DEVICE + ' -nostartfiles -Xlinker --gc-sections --specs=nano.specs --specs=nosys.specs ' + ' -T ' + LINK_FILE + ' -Wl,-Map=' + MAP_FILE
+    # 添加 --no-warn-mismatch 以忽略预编译库与当前工具链的特权规范版本差异
+    # 添加 WiFi ROM 符号表
+    wifi_pkg_path = os.path.join(os.path.dirname(__file__), 'packages', 'gd32vw55x-wifi-latest')
+    rom_symbol = os.path.join(wifi_pkg_path, 'rom_export', 'symbol', 'rom_symbol_m.gcc')
+    rom_symbol_flag = ''
+    if os.path.exists(rom_symbol):
+        rom_symbol_flag = ' -Wl,--just-symbols=' + rom_symbol
+    LFLAGS = DEVICE + ' -nostartfiles -Xlinker --gc-sections -Xlinker --no-warn-mismatch --specs=nano.specs --specs=nosys.specs ' + rom_symbol_flag + ' -T ' + LINK_FILE + ' -Wl,-Map=' + MAP_FILE
 
     CPATH = ''
     LPATH = ''
@@ -61,7 +73,7 @@ if PLATFORM == 'gcc':
     else:
         CFLAGS += ' -O2'
 
-    CXXFLAGS = CFLAGS 
+    CXXFLAGS = CFLAGS
 
     POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' + SIZE + ' $TARGET \n'
 

+ 108 - 100
components/drivers/wlan/dev_wlan_cmd.c

@@ -56,33 +56,35 @@ static int wifi_debug_set_autoconnect(int argc, char *argv[]);
 #endif
 
 /* cmd table */
-static const struct wifi_cmd_des cmd_tab[] =
-{
-    {"scan", wifi_scan},
-    {"help", wifi_help},
-    {"status", wifi_status},
-    {"join", wifi_join},
-    {"ap", wifi_ap},
-    {"list_sta", wifi_list_sta},
-    {"disc", wifi_disconnect},
-    {"ap_stop", wifi_ap_stop},
-    {"smartconfig", RT_NULL},
+static const struct wifi_cmd_des cmd_tab[] = {
+    { "scan", wifi_scan },
+    { "help", wifi_help },
+    { "status", wifi_status },
+    { "join", wifi_join },
+    { "ap", wifi_ap },
+    { "list_sta", wifi_list_sta },
+    { "disc", wifi_disconnect },
+    { "ap_stop", wifi_ap_stop },
+    { "smartconfig", RT_NULL },
 #ifdef RT_WLAN_CMD_DEBUG
-    {"-d", wifi_debug},
+    { "-d", wifi_debug },
 #endif
 };
 
 #ifdef RT_WLAN_CMD_DEBUG
 /* debug cmd table */
-static const struct wifi_cmd_des debug_tab[] =
-{
-    {"save_cfg", wifi_debug_save_cfg},
-    {"dump_cfg", wifi_debug_dump_cfg},
-    {"clear_cfg", wifi_debug_clear_cfg},
-    {"dump_prot", wifi_debug_dump_prot},
-    {"mode", wifi_debug_set_mode},
-    {"prot", wifi_debug_set_prot},
-    {"auto", wifi_debug_set_autoconnect},
+static const struct wifi_cmd_des debug_tab[] = {
+    { "save_cfg", wifi_debug_save_cfg },
+    { "dump_cfg", wifi_debug_dump_cfg },
+    { "clear_cfg", wifi_debug_clear_cfg },
+#ifdef RT_WLAN_PROT_ENABLE
+    { "dump_prot", wifi_debug_dump_prot },
+    { "mode", wifi_debug_set_mode },
+    { "prot", wifi_debug_set_prot },
+#else
+    { "mode", wifi_debug_set_mode },
+#endif /* RT_WLAN_PROT_ENABLE */
+    { "auto", wifi_debug_set_autoconnect },
 };
 #endif
 
@@ -171,7 +173,7 @@ static rt_bool_t wifi_info_isequ(struct rt_wlan_info *info1, struct rt_wlan_info
         is_equ &= rt_memcmp(&info2->ssid.val[0], &info1->ssid.val[0], info1->ssid.len) == 0;
     }
     if (is_equ && (rt_memcmp(&info1->bssid[0], bssid_zero, RT_WLAN_BSSID_MAX_LENGTH)) &&
-       (rt_memcmp(&info2->bssid[0], bssid_zero, RT_WLAN_BSSID_MAX_LENGTH)))
+        (rt_memcmp(&info2->bssid[0], bssid_zero, RT_WLAN_BSSID_MAX_LENGTH)))
     {
         is_equ &= rt_memcmp(&info1->bssid[0], &info2->bssid[0], RT_WLAN_BSSID_MAX_LENGTH) == 0;
     }
@@ -197,10 +199,11 @@ static rt_err_t wifi_scan_result_cache(struct rt_wlan_info *info)
     int i, insert = -1;
     rt_base_t level;
 
-    if ((info == RT_NULL) || (info->ssid.len == 0)) return -RT_EINVAL;
+    if ((info == RT_NULL) || (info->ssid.len == 0))
+        return -RT_EINVAL;
 
     LOG_D("ssid:%s len:%d mac:%02x:%02x:%02x:%02x:%02x:%02x", info->ssid.val, info->ssid.len,
-                  info->bssid[0], info->bssid[1], info->bssid[2], info->bssid[3], info->bssid[4], info->bssid[5]);
+          info->bssid[0], info->bssid[1], info->bssid[2], info->bssid[3], info->bssid[4], info->bssid[5]);
 
     /* scanning result filtering */
     level = rt_hw_interrupt_disable();
@@ -222,7 +225,7 @@ static rt_err_t wifi_scan_result_cache(struct rt_wlan_info *info)
     for (i = 0; i < scan_result.num; i++)
     {
         if ((info->ssid.len == scan_result.info[i].ssid.len) &&
-                (rt_memcmp(&info->bssid[0], &scan_result.info[i].bssid[0], RT_WLAN_BSSID_MAX_LENGTH) == 0))
+            (rt_memcmp(&info->bssid[0], &scan_result.info[i].bssid[0], RT_WLAN_BSSID_MAX_LENGTH) == 0))
         {
             return RT_EOK;
         }
@@ -283,7 +286,7 @@ static rt_err_t wifi_scan_result_cache(struct rt_wlan_info *info)
         LOG_E("wlan info malloc failed!");
         return -RT_ENOMEM;
     }
-    scan_result.num ++;
+    scan_result.num++;
 
     /* copy info */
     for (i = 0; i < scan_result.num; i++)
@@ -307,10 +310,8 @@ static rt_err_t wifi_scan_result_cache(struct rt_wlan_info *info)
 }
 
 
-
 static void wifi_scan_result_clean(void)
 {
-
     /* If there is data */
     if (scan_result.num)
     {
@@ -320,68 +321,66 @@ static void wifi_scan_result_clean(void)
     }
 }
 
-static void print_ap_info(struct rt_wlan_info *info,int index)
+static void print_ap_info(struct rt_wlan_info *info, int index)
 {
-        char *security;
+    char *security;
 
-        if(index == 0)
-        {
-            rt_kprintf("             SSID                      MAC            security    rssi chn Mbps\n");
-            rt_kprintf("------------------------------- -----------------  -------------- ---- --- ----\n");
-        }
+    if (index == 0)
+    {
+        rt_kprintf("             SSID                      MAC            security    rssi chn Mbps\n");
+        rt_kprintf("------------------------------- -----------------  -------------- ---- --- ----\n");
+    }
 
+    {
+        rt_kprintf("%-32.32s", &(info->ssid.val[0]));
+        rt_kprintf("%02x:%02x:%02x:%02x:%02x:%02x  ",
+                   info->bssid[0],
+                   info->bssid[1],
+                   info->bssid[2],
+                   info->bssid[3],
+                   info->bssid[4],
+                   info->bssid[5]);
+        switch (info->security)
         {
-            rt_kprintf("%-32.32s", &(info->ssid.val[0]));
-            rt_kprintf("%02x:%02x:%02x:%02x:%02x:%02x  ",
-                       info->bssid[0],
-                       info->bssid[1],
-                       info->bssid[2],
-                       info->bssid[3],
-                       info->bssid[4],
-                       info->bssid[5]
-                      );
-            switch (info->security)
-            {
-            case SECURITY_OPEN:
-                security = "OPEN";
-                break;
-            case SECURITY_WEP_PSK:
-                security = "WEP_PSK";
-                break;
-            case SECURITY_WEP_SHARED:
-                security = "WEP_SHARED";
-                break;
-            case SECURITY_WPA_TKIP_PSK:
-                security = "WPA_TKIP_PSK";
-                break;
-            case SECURITY_WPA_AES_PSK:
-                security = "WPA_AES_PSK";
-                break;
-            case SECURITY_WPA2_AES_PSK:
-                security = "WPA2_AES_PSK";
-                break;
-            case SECURITY_WPA2_TKIP_PSK:
-                security = "WPA2_TKIP_PSK";
-                break;
-            case SECURITY_WPA2_MIXED_PSK:
-                security = "WPA2_MIXED_PSK";
-                break;
-            case SECURITY_WPS_OPEN:
-                security = "WPS_OPEN";
-                break;
-            case SECURITY_WPS_SECURE:
-                security = "WPS_SECURE";
-                break;
-            default:
-                security = "UNKNOWN";
-                break;
-            }
-            rt_kprintf("%-14.14s ", security);
-            rt_kprintf("%-4d ", info->rssi);
-            rt_kprintf("%3d ", info->channel);
-            rt_kprintf("%4d\n", info->datarate / 1000000);
+        case SECURITY_OPEN:
+            security = "OPEN";
+            break;
+        case SECURITY_WEP_PSK:
+            security = "WEP_PSK";
+            break;
+        case SECURITY_WEP_SHARED:
+            security = "WEP_SHARED";
+            break;
+        case SECURITY_WPA_TKIP_PSK:
+            security = "WPA_TKIP_PSK";
+            break;
+        case SECURITY_WPA_AES_PSK:
+            security = "WPA_AES_PSK";
+            break;
+        case SECURITY_WPA2_AES_PSK:
+            security = "WPA2_AES_PSK";
+            break;
+        case SECURITY_WPA2_TKIP_PSK:
+            security = "WPA2_TKIP_PSK";
+            break;
+        case SECURITY_WPA2_MIXED_PSK:
+            security = "WPA2_MIXED_PSK";
+            break;
+        case SECURITY_WPS_OPEN:
+            security = "WPS_OPEN";
+            break;
+        case SECURITY_WPS_SECURE:
+            security = "WPS_SECURE";
+            break;
+        default:
+            security = "UNKNOWN";
+            break;
         }
-
+        rt_kprintf("%-14.14s ", security);
+        rt_kprintf("%-4d ", info->rssi);
+        rt_kprintf("%3d ", info->channel);
+        rt_kprintf("%4d\n", info->datarate / 1000000);
+    }
 }
 
 static void user_ap_info_callback(int event, struct rt_wlan_buff *buff, void *parameter)
@@ -399,25 +398,24 @@ static void user_ap_info_callback(int event, struct rt_wlan_buff *buff, void *pa
     index = *((int *)(parameter));
 
     ret = wifi_scan_result_cache(info);
-    if(ret == RT_EOK)
+    if (ret == RT_EOK)
     {
-        if(scan_filter == RT_NULL ||
-                (scan_filter != RT_NULL &&
-                 scan_filter->ssid.len == info->ssid.len &&
-                 rt_memcmp(&scan_filter->ssid.val[0], &info->ssid.val[0], scan_filter->ssid.len) == 0))
+        if (scan_filter == RT_NULL ||
+            (scan_filter != RT_NULL &&
+             scan_filter->ssid.len == info->ssid.len &&
+             rt_memcmp(&scan_filter->ssid.val[0], &info->ssid.val[0], scan_filter->ssid.len) == 0))
         {
             /*Check whether a new ap is added*/
             if (last_num < scan_result.num)
             {
                 /*Print the info*/
-                print_ap_info(info,index);
+                print_ap_info(info, index);
             }
 
             index++;
             *((int *)(parameter)) = index;
         }
     }
-
 }
 static int wifi_scan(int argc, char *argv[])
 {
@@ -436,14 +434,14 @@ static int wifi_scan(int argc, char *argv[])
         info = &filter;
     }
 
-    ret = rt_wlan_register_event_handler(RT_WLAN_EVT_SCAN_REPORT,user_ap_info_callback,&i);
-    if(ret != RT_EOK)
+    ret = rt_wlan_register_event_handler(RT_WLAN_EVT_SCAN_REPORT, user_ap_info_callback, &i);
+    if (ret != RT_EOK)
     {
-        LOG_E("Scan register user callback error:%d!\n",ret);
+        LOG_E("Scan register user callback error:%d!\n", ret);
         return 0;
     }
 
-    if(info)
+    if (info)
     {
         scan_filter = info;
     }
@@ -451,14 +449,14 @@ static int wifi_scan(int argc, char *argv[])
 
     /*Todo: what can i do for it return val */
     ret = rt_wlan_scan_with_info(info);
-    if(ret != RT_EOK)
+    if (ret != RT_EOK)
     {
-        LOG_E("Scan with info error:%d!\n",ret);
+        LOG_E("Scan with info error:%d!\n", ret);
     }
 
     /* clean scan result */
     wifi_scan_result_clean();
-    if(info)
+    if (info)
     {
         scan_filter = RT_NULL;
     }
@@ -472,7 +470,7 @@ static int wifi_join(int argc, char *argv[])
     struct rt_wlan_cfg_info cfg_info;
 
     rt_memset(&cfg_info, 0, sizeof(cfg_info));
-    if (argc ==  2)
+    if (argc == 2)
     {
 #ifdef RT_WLAN_CFG_ENABLE
         /* get info to connect */
@@ -678,7 +676,12 @@ static int wifi_debug_dump_prot(int argc, char *argv[])
 {
     if (argc == 1)
     {
+#ifdef RT_WLAN_PROT_ENABLE
         rt_wlan_prot_dump();
+#else
+        rt_kprintf("wlan protocol disabled\r\n");
+        return -1;
+#endif
     }
     else
     {
@@ -720,7 +723,12 @@ static int wifi_debug_set_prot(int argc, char *argv[])
         return -1;
     }
 
+#ifdef RT_WLAN_PROT_ENABLE
     rt_wlan_prot_attach(argv[2], argv[1]);
+#else
+    rt_kprintf("wlan protocol disabled\r\n");
+    return -1;
+#endif
     return 0;
 }
 

+ 4 - 0
components/net/lwip/port/SConscript

@@ -5,6 +5,10 @@ path  = [cwd]
 
 src  = Glob('*.c')
 
+# 如果使用了GD32 WiFi包,则排除sys_arch.c(GD32有自己的实现)
+if GetDepend(['PKG_USING_GD32VW55X_WIFI']):
+    src = [f for f in src if not str(f).endswith('sys_arch.c')]
+
 group = DefineGroup('lwIP', src, depend = ['RT_USING_LWIP'], CPPPATH = path)
 
 Return('group')