Skip to content

Commit cef5ad8

Browse files
committed
[bsp][gd32]:gd32vw553h-eval add wifi support
1 parent 68da106 commit cef5ad8

27 files changed

Lines changed: 911 additions & 129 deletions

bsp/gd32/risc-v/gd32vw553h-eval/README.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,51 @@ msh >
170170

171171
完成上述配置后即可点击调试选项进行调试,调试时boot管脚均置为低电平即可,调试时同样会进行固件下载。
172172

173-
## 4 注意事项
173+
## 4.WIFI使用
174+
175+
使用ENV,menuconfig,修改和使能下面的配置
176+
177+
* 修改 RT_NAME_MAX为24
178+
179+
![image-20260205145545039](figures/image-20260205145545039.png)
180+
181+
* 使能 BSP_USING_WLAN
182+
183+
![image-20260205145642371](figures/image-20260205145642371.png)
184+
185+
* 修改LWIP的版本为V2.1.2
186+
187+
![image-20260205145806668](figures/image-20260205145806668.png)
188+
189+
* 关闭 RT_WLAN_PROT_ENABLE
190+
191+
![image-20260205145856756](figures/image-20260205145856756.png)
192+
193+
进行编译 scons -jx ,下载。
194+
195+
![image-20260205150826393](figures/image-20260205150826393.png)
196+
197+
可以使用help查看wifi指令,下面演示连接wifi以及ping
198+
199+
![image-20260205151251937](figures/image-20260205151251937.png)
200+
201+
### 使用NETDEV
202+
203+
* 使能 RT_USING_NETDEV
204+
205+
![image-20260205151356304](figures/image-20260205151356304.png)
206+
207+
重新编译,下载。
208+
209+
* wifi 连接以及ping
210+
211+
![image-20260205151712234](figures/image-20260205151712234.png)
212+
213+
* ifconfig:
214+
215+
![image-20260205151644687](figures/image-20260205151644687.png)
216+
217+
## 5 注意事项
174218

175219
- Cortex-Debug插件优先选用v1.4.4版本,高版本可能会出现与GDB版本不匹配的问题。
176220

bsp/gd32/risc-v/gd32vw553h-eval/applications/main.c

Lines changed: 104 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,57 @@
1313
#include <rtthread.h>
1414
#include <rtdevice.h>
1515
#include <board.h>
16-
16+
#ifdef BSP_USING_WLAN
17+
#include "gd32vw55x_platform.h"
18+
#include "wrapper_os.h"
19+
#include "wifi_management.h"
20+
#include "wifi_init.h"
21+
#include "user_setting.h"
22+
#include "util.h"
23+
#endif /* BSP_USING_WLAN */
1724
/* LED1 ~ LED3 pin: PA4 PA5 PA6 */
1825
#define LED1_PIN GET_PIN(A, 4)
1926

20-
int main(void)
27+
28+
#ifdef RT_USING_WIFI
29+
#define START_TASK_STACK_SIZE 512
30+
#define START_TASK_PRIO 4
31+
32+
static void application_init(void)
2133
{
22-
rt_kprintf("Hello GD32VW553H\n");
23-
/* set LED1 pin mode to output */
24-
rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);
34+
util_init();
35+
36+
user_setting_init();
37+
38+
if (wifi_init()) {
39+
rt_kprintf("wifi init failed\r\n");
40+
} else {
41+
// rt_kprintf("wifi init success\r\n");
42+
}
43+
}
44+
45+
static rt_sem_t init_done_sem = RT_NULL;
46+
47+
static void start_task(void *param)
48+
{
49+
(void)param;
50+
51+
application_init();
52+
// rt_kprintf("Start task completed, exiting.\n");
53+
54+
/* Note: In RT-Thread, task should exit by returning, not by calling sys_task_delete(NULL).
55+
* When the task function returns, RT-Thread will automatically clean up the task.
56+
*/
57+
58+
rt_sem_release(init_done_sem);
59+
}
60+
61+
#endif /* RT_USING_WIFI */
62+
63+
/* LED blink thread */
64+
static void led_thread_entry(void *param)
65+
{
66+
(void)param;
2567

2668
while (1)
2769
{
@@ -30,6 +72,63 @@ int main(void)
3072
rt_pin_write(LED1_PIN, PIN_LOW);
3173
rt_thread_mdelay(500);
3274
}
75+
}
76+
77+
int main(void)
78+
{
79+
rt_thread_t led_thread;
80+
81+
rt_kprintf("Hello GD32VW553H\n");
82+
/* set LED1 pin mode to output */
83+
rt_pin_mode(LED1_PIN, PIN_MODE_OUTPUT);
84+
85+
#ifdef RT_USING_WIFI
86+
/* Create semaphore for synchronization */
87+
init_done_sem = rt_sem_create("init_done", 0, RT_IPC_FLAG_PRIO);
88+
if (init_done_sem == RT_NULL) {
89+
rt_kprintf("Failed to create semaphore\n");
90+
return -RT_ERROR;
91+
}
92+
93+
if (sys_task_create_dynamic((const uint8_t *)"start_task",
94+
START_TASK_STACK_SIZE, OS_TASK_PRIORITY(START_TASK_PRIO), start_task, NULL) == NULL) {
95+
rt_kprintf("Create start task failed\r\n");
96+
return -RT_ERROR;
97+
}
98+
99+
// rt_kprintf("Waiting for initialization to complete...\n");
100+
/* Wait for initialization task to complete */
101+
rt_sem_take(init_done_sem, RT_WAITING_FOREVER);
102+
// rt_kprintf("Initialization completed, continuing...\n");
103+
104+
/* Clean up semaphore */
105+
rt_sem_delete(init_done_sem);
106+
init_done_sem = RT_NULL;
107+
108+
/* set wifi work mode */
109+
rt_wlan_set_mode(RT_WLAN_DEVICE_STA_NAME, RT_WLAN_STATION);
110+
rt_wlan_set_mode(RT_WLAN_DEVICE_AP_NAME, RT_WLAN_AP);
111+
#ifdef RT_USING_NETDEV
112+
rt_thread_mdelay(1000);
113+
extern int wifi_netdev_register(void);
114+
wifi_netdev_register();
115+
#endif /* RT_USING_NETDEV */
116+
#endif /* RT_USING_WIFI */
117+
118+
/* Create LED blink thread */
119+
led_thread = rt_thread_create("led",
120+
led_thread_entry,
121+
RT_NULL,
122+
1024,
123+
25, /* Lower priority to not block shell */
124+
10);
125+
if (led_thread != RT_NULL) {
126+
rt_thread_startup(led_thread);
127+
rt_kprintf("LED thread started\n");
128+
} else {
129+
rt_kprintf("Failed to create LED thread\n");
130+
}
33131

132+
/* Return from main to allow shell to work properly */
34133
return RT_EOK;
35134
}

bsp/gd32/risc-v/gd32vw553h-eval/board/Kconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,34 @@ config SOC_GD32VW553H
1313

1414
menu "Onboard Peripheral Drivers"
1515

16+
menuconfig BSP_USING_WLAN
17+
bool "Enable WiFi (GD32VW553H Internal)"
18+
select RT_USING_WIFI
19+
select PKG_USING_GD32VW55X_WIFI
20+
select RT_USING_MEMHEAP
21+
select RT_USING_SYSTEM_WORKQUEUE
22+
default n
23+
24+
if BSP_USING_WLAN
25+
config BSP_WLAN_SSID_MAX_LENGTH
26+
int "WiFi SSID max length"
27+
range 1 32
28+
default 32
29+
30+
config BSP_WLAN_PASSWORD_MAX_LENGTH
31+
int "WiFi password max length"
32+
range 8 64
33+
default 64
34+
35+
config BSP_WLAN_SCAN_CACHE_NUM
36+
int "WiFi scan result cache number"
37+
range 4 32
38+
default 16
39+
40+
# Include GD32VW55x WIFI package configuration
41+
osource "$(BSP_DIR)/packages/gd32vw55x-wifi/Kconfig"
42+
endif
43+
1644
endmenu
1745

1846
menu "On-chip Peripheral Drivers"

bsp/gd32/risc-v/gd32vw553h-eval/board/SConscript

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ board.c
1212
trap_gcc.S
1313
''')
1414

15+
# add WiFi driver
16+
if GetDepend(['BSP_USING_WLAN']):
17+
src += ['drv_wlan.c']
18+
1519
path = [cwd]
1620

1721
# add startup txt path
1822
startup_path_prefix = os.getcwd() + '/../'
1923

2024
if rtconfig.PLATFORM in ['gcc']:
25+
# Use standard peripheral library startup files for compatibility
2126
src += [startup_path_prefix + '/packages/gd32-riscv-series-latest/GD32VW55x/RISCV/env_Eclipse/start.S']
2227
src += [startup_path_prefix + '/packages/gd32-riscv-series-latest/GD32VW55x/RISCV/env_Eclipse/entry.S']
2328

0 commit comments

Comments
 (0)