Skip to content

Commit 61f7d48

Browse files
[bsp][ESP32_C3]增加ble和wifi驱动|add ble & wifi drivers (#8104)
1 parent 38e42b7 commit 61f7d48

17 files changed

+971
-32
lines changed

bsp/ESP32_C3/.config

+26-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,9 @@ CONFIG_FINSH_USING_OPTION_COMPLETION=y
117117
#
118118
CONFIG_RT_USING_DEVICE_IPC=y
119119
CONFIG_RT_UNAMED_PIPE_NUMBER=64
120-
# CONFIG_RT_USING_SYSTEM_WORKQUEUE is not set
120+
CONFIG_RT_USING_SYSTEM_WORKQUEUE=y
121+
CONFIG_RT_SYSTEM_WORKQUEUE_STACKSIZE=2048
122+
CONFIG_RT_SYSTEM_WORKQUEUE_PRIORITY=23
121123
CONFIG_RT_USING_SERIAL=y
122124
CONFIG_RT_USING_SERIAL_V1=y
123125
# CONFIG_RT_USING_SERIAL_V2 is not set
@@ -207,6 +209,10 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
207209
# CONFIG_RT_USING_SAL is not set
208210
# CONFIG_RT_USING_NETDEV is not set
209211
# CONFIG_RT_USING_LWIP is not set
212+
# CONFIG_RT_USING_LWIP141 is not set
213+
# CONFIG_RT_USING_LWIP203 is not set
214+
# CONFIG_RT_USING_LWIP212 is not set
215+
# CONFIG_RT_USING_LWIP_LATEST is not set
210216
# CONFIG_RT_USING_AT is not set
211217

212218
#
@@ -220,6 +226,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
220226
# CONFIG_RT_USING_ADT is not set
221227
# CONFIG_RT_USING_RT_LINK is not set
222228
# CONFIG_RT_USING_VBUS is not set
229+
# CONFIG_RT_USING_KTIME is not set
223230

224231
#
225232
# RT-Thread Utestcases
@@ -261,6 +268,11 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
261268
#
262269
# CONFIG_PKG_USING_WLAN_WICED is not set
263270
# CONFIG_PKG_USING_RW007 is not set
271+
272+
#
273+
# CYW43012 WiFi
274+
#
275+
# CONFIG_PKG_USING_WLAN_CYW43012 is not set
264276
# CONFIG_PKG_USING_COAP is not set
265277
# CONFIG_PKG_USING_NOPOLL is not set
266278
# CONFIG_PKG_USING_NETUTILS is not set
@@ -303,6 +315,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
303315
# CONFIG_PKG_USING_NMEALIB is not set
304316
# CONFIG_PKG_USING_PDULIB is not set
305317
# CONFIG_PKG_USING_BTSTACK is not set
318+
# CONFIG_PKG_USING_BT_CYW43012 is not set
306319
# CONFIG_PKG_USING_LORAWAN_ED_STACK is not set
307320
# CONFIG_PKG_USING_WAYZ_IOTKIT is not set
308321
# CONFIG_PKG_USING_MAVLINK is not set
@@ -322,6 +335,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
322335
# CONFIG_PKG_USING_ZFTP is not set
323336
# CONFIG_PKG_USING_WOL is not set
324337
# CONFIG_PKG_USING_ZEPHYR_POLLING is not set
338+
# CONFIG_PKG_USING_MATTER_ADAPTATION_LAYER is not set
325339

326340
#
327341
# security packages
@@ -368,7 +382,6 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
368382
# LVGL: powerful and easy-to-use embedded GUI library
369383
#
370384
# CONFIG_PKG_USING_LVGL is not set
371-
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
372385
# CONFIG_PKG_USING_LV_MUSIC_DEMO is not set
373386
# CONFIG_PKG_USING_GUI_GUIDER_DEMO is not set
374387

@@ -443,6 +456,7 @@ CONFIG_RT_LIBC_TZ_DEFAULT_SEC=0
443456
# CONFIG_PKG_USING_HASH_MATCH is not set
444457
# CONFIG_PKG_USING_ARMV7M_DWT_TOOL is not set
445458
# CONFIG_PKG_USING_VOFA_PLUS is not set
459+
# CONFIG_PKG_USING_ZDEBUG is not set
446460

447461
#
448462
# system packages
@@ -484,6 +498,8 @@ CONFIG_PKG_FREERTOS_USING_CONFIG_H=y
484498
# CONFIG_PKG_FREERTOS_USING_MEMMANG is not set
485499
CONFIG_PKG_USING_FREERTOS_WRAPPER_LATEST_VERSION=y
486500
CONFIG_PKG_FREERTOS_WRAPPER_VER="latest"
501+
# CONFIG_PKG_USING_LITEOS_SDK is not set
502+
# CONFIG_PKG_USING_TZ_DATABASE is not set
487503
# CONFIG_PKG_USING_CAIRO is not set
488504
# CONFIG_PKG_USING_PIXMAN is not set
489505
# CONFIG_PKG_USING_PARTITION is not set
@@ -507,6 +523,7 @@ CONFIG_PKG_FREERTOS_WRAPPER_VER="latest"
507523
# CONFIG_PKG_USING_QBOOT is not set
508524
# CONFIG_PKG_USING_PPOOL is not set
509525
# CONFIG_PKG_USING_OPENAMP is not set
526+
# CONFIG_PKG_USING_RPMSG_LITE is not set
510527
# CONFIG_PKG_USING_LPM is not set
511528
# CONFIG_PKG_USING_TLSF is not set
512529
# CONFIG_PKG_USING_EVENT_RECORDER is not set
@@ -520,6 +537,8 @@ CONFIG_PKG_FREERTOS_WRAPPER_VER="latest"
520537
# CONFIG_PKG_USING_AGILE_UPGRADE is not set
521538
# CONFIG_PKG_USING_FLASH_BLOB is not set
522539
# CONFIG_PKG_USING_MLIBC is not set
540+
# CONFIG_PKG_USING_TASK_MSG_BUS is not set
541+
# CONFIG_PKG_USING_SFDB is not set
523542

524543
#
525544
# peripheral libraries and drivers
@@ -710,6 +729,7 @@ CONFIG_PKG_ESP_IDF_VER="latest"
710729
# CONFIG_PKG_USING_UKAL is not set
711730
# CONFIG_PKG_USING_DIGITALCTRL is not set
712731
# CONFIG_PKG_USING_KISSFFT is not set
732+
# CONFIG_PKG_USING_CMSIS_DSP is not set
713733

714734
#
715735
# miscellaneous packages
@@ -931,6 +951,7 @@ CONFIG_PKG_ESP_IDF_VER="latest"
931951
#
932952
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_GFX_LIBRARY is not set
933953
# CONFIG_PKG_USING_ARDUINO_U8G2 is not set
954+
# CONFIG_PKG_USING_ARDUINO_TFT_ESPI is not set
934955
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ST7735 is not set
935956
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SSD1306 is not set
936957
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ILI9341 is not set
@@ -1015,3 +1036,6 @@ CONFIG_RT_BSP_UART_RX_PIN=20
10151036
CONFIG_BSP_USING_GPIO=y
10161037
CONFIG_BSP_USING_UART=y
10171038
# CONFIG_BSP_USING_I2C0 is not set
1039+
# CONFIG_BSP_USING_WIFI is not set
1040+
# CONFIG_BSP_USING_BLE is not set
1041+
# CONFIG_BSP_ENABLE_GDBSTUB is not set

bsp/ESP32_C3/README.md

+46
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,52 @@ Each peripheral supporting condition for this BSP is as follows:
4242
| GPIO | Support | |
4343
| UART | Support | Using LUATOS_ESP32C3 development board requires connecting serial port to USB chip UART0_TX and UART0_RX (such as CP2102) |
4444
| JTAG debug | Support | ESP32C3 usb-linked development boards can be debugged |
45+
| WIFI | Partial support | There are currently some problems, such as `rt_mq_recive` cannot be used in ISR, etc., and we are still trying to solve it |
46+
| BLE | Partially supported | There are currently some problems, such as running errors caused by the same `PC` and `SP` pointers after `NimBLE` is started for a period of time |
47+
| GDBStub | Support | You can use the GDB provided by ESP-IDF by turning on the `BSP_ENABLE_GDBSTUB` switch, which will enter GDB mode after a chip error |
48+
49+
Note:
50+
51+
1. WIFI and BLE cannot be enabled at the same time. When using the BLE driver, be sure to turn off the `RT_USING_WIFI` and `LWIP` switches in `menuconfig`. In addition, due to limited personal abilities and lack of debugging equipment, there are problems with the operation of WIFI and BLE drivers. If you can solve it, please contact me [[email protected]](mailto:[email protected]), I will be grateful.
52+
53+
2. The BLE driver only supports `NimBLE` and is provided by the `bluetooth` component in `esp-idf`. To use the BLE driver, please refer to `bsp/ESP32_C3/packages/ESP-IDF-latest/examples/bluetooth/nimble` Sample program, please note that the `esp_timer_init()` function must be called to initialize the clock driver before calling the `NimBLE` related interface.
54+
55+
One way to run the BLE sample is to add the sample program to `scons` compilation and call the clock initialization program and sample program entry in `bsp/ESP32_C3/main/main.c`.
56+
57+
```c
58+
int main(void) {
59+
...
60+
#ifdef BSP_USING_BLE
61+
esp_timer_init(); //Call clock initialization program
62+
app_main(); //Call the BLE sample program entry
63+
#endif
64+
...
65+
}
66+
```
67+
68+
3、 Regarding the use of the GDBStub component, please see [ESP-IDF official documentation on GDBStub](https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32c3/api-guides/tools/idf- monitor.html?#gdbstub-gdb), currently I have provided a debugging script `esp32c3.gdb`, the specific usage method is as follows.
69+
70+
```sh
71+
wcx@tim  ~/rt-thread/bsp/ESP32_C3   esp32 ±  sudo riscv32-esp-elf-gdb # Enter gdb debugging
72+
GNU gdb (crosstool-NG esp-2022r1-RC1) 9.2.90.20200913-git
73+
Copyright (C) 2020 Free Software Foundation, Inc.
74+
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
75+
This is free software: you are free to change and redistribute it.
76+
There is NO WARRANTY, to the extent permitted by law.
77+
Type "show copying" and "show warranty" for details.
78+
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=riscv32-esp-elf".
79+
Type "show configuration" for configuration details.
80+
For bug reporting instructions, please see:
81+
<http://www.gnu.org/software/gdb/bugs/>.
82+
Find the GDB manual and other documentation resources online at:
83+
<http://www.gnu.org/software/gdb/documentation/>.
84+
85+
For help, type "help".
86+
Type "apropos word" to search for commands related to "word".
87+
(gdb) source esp32c3.gpb # Load gdb script
88+
0x3fca8c30 in __stack_start__ ()
89+
(gdb)
90+
```
4591

4692
## Environment construction and compilation
4793

bsp/ESP32_C3/README_ZH.md

+47
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,53 @@
4949
| GPIO | 支持 | |
5050
| UART | 支持 | 使用LUATOS_ESP32C3开发板需要在UART0_TX和UART0_RX连接串口转USB芯片(如CP2102)|
5151
| JTAG调试 | 支持 | ESP32C3采用USB方式和PC链接的开发板可以调试 |
52+
| WIFI | 部分支持 | 目前存在一些问题,例如不能在ISR中使用`rt_mq_recive`等,还在尝试解决中 |
53+
| BLE | 部分支持 | 目前存在一些问题,例如`NimBLE`启动一段时间后`PC``SP`指针相同导致运行错误 |
54+
| GDBStub | 支持 | 通过开启`BSP_ENABLE_GDBSTUB`开关即可使用ESP-IDF所提供的GDB,其会在芯片出错后进入GDB模式 |
55+
56+
注:
57+
58+
1、WIFI和BLE不能同时启用,在使用BLE驱动时注意在`menuconfig`中关闭`RT_USING_WIFI``LWIP`开关。另外由于个人能力有限且缺乏调试设备,WIFI和BLE驱动运行都有问题,如果可以解决联系我[[email protected]](mailto:[email protected]),本人感激不尽。
59+
60+
2、BLE驱动仅支持`NimBLE`,并且由`esp-idf`中的`bluetooth`组件提供,使用BLE驱动可以参考`bsp/ESP32_C3/packages/ESP-IDF-latest/examples/bluetooth/nimble`下的样例程序,注意在调用`NimBLE`相关接口之前要调用`esp_timer_init()`函数初始化时钟驱动。
61+
62+
一种运行BLE样例的方案是将样例程序加入到`scons`编译并在`bsp/ESP32_C3/main/main.c`中调用时钟初始化程序和样例程序入口。
63+
64+
```c
65+
int main(void) {
66+
...
67+
#ifdef BSP_USING_BLE
68+
esp_timer_init(); //调用时钟初始化程序
69+
app_main(); //调用BLE样例程序入口
70+
#endif
71+
...
72+
}
73+
```
74+
75+
3、关于GDBStub组件的使用,文档见[ESP-IDF关于GDBStub官方文档](https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32c3/api-guides/tools/idf-monitor.html?#gdbstub-gdb),目前个人提供了一个调试脚本`esp32c3.gdb`,具体使用方法如下。
76+
77+
```sh
78+
wcx@tim  ~/rt-thread/bsp/ESP32_C3   esp32 ±  sudo riscv32-esp-elf-gdb # 进入gdb调试
79+
GNU gdb (crosstool-NG esp-2022r1-RC1) 9.2.90.20200913-git
80+
Copyright (C) 2020 Free Software Foundation, Inc.
81+
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
82+
This is free software: you are free to change and redistribute it.
83+
There is NO WARRANTY, to the extent permitted by law.
84+
Type "show copying" and "show warranty" for details.
85+
This GDB was configured as "--host=x86_64-build_pc-linux-gnu --target=riscv32-esp-elf".
86+
Type "show configuration" for configuration details.
87+
For bug reporting instructions, please see:
88+
<http://www.gnu.org/software/gdb/bugs/>.
89+
Find the GDB manual and other documentation resources online at:
90+
<http://www.gnu.org/software/gdb/documentation/>.
91+
92+
For help, type "help".
93+
Type "apropos word" to search for commands related to "word".
94+
(gdb) source esp32c3.gpb # 加载gdb脚本
95+
0x3fca8c30 in __stack_start__ ()
96+
(gdb)
97+
```
98+
5299

53100
## 环境搭建及编译
54101

0 Bytes
Binary file not shown.

bsp/ESP32_C3/drivers/Kconfig

+14
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,22 @@ menu "On-chip Peripheral Drivers"
6666
bool "Enable I2C0"
6767
select RT_USING_I2C
6868
default n
69+
70+
config BSP_USING_WIFI
71+
bool "Enable WIFI"
72+
select RT_USING_WIFI
73+
default n
74+
75+
config BSP_USING_BLE
76+
bool "Enable BLE"
77+
default n
78+
6979
endmenu
7080

81+
config BSP_ENABLE_GDBSTUB
82+
bool "Enable ESP_GDBSTUB compontent"
83+
default n
84+
7185
endmenu
7286

7387

0 commit comments

Comments
 (0)