未验证 提交 82bf18b7 编写于 作者: T tangzz98 提交者: GitHub

ESP32: Support applying patch to local IDF (#6467)

上级 5debfdd8
......@@ -657,37 +657,77 @@ CONFIG_PKG_ESP_IDF_VER="latest"
# CONFIG_PKG_USING_RTDUINO is not set
#
# Sensor libraries
# Projects
#
# CONFIG_PKG_USING_ARDUINO_ULTRASOUND_RADAR is not set
# CONFIG_PKG_USING_ARDUINO_SENSOR_KIT is not set
#
# Sensors
#
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SENSOR is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BUSIO is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_AHTX0 is not set
# CONFIG_PKG_USING_ARDUINO_DHT_SENSOR is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BMP280 is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_INA219 is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DHT is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_MAX1704X is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ICM20X is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_DPS310 is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SHT4X is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_SHT31 is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_ADXL343 is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BME280 is not set
# CONFIG_PKG_USING_ARDUINO_SEEED_BMP280 is not set
# CONFIG_PKG_USING_ARDUINO_SEEED_LIS3DHTR is not set
# CONFIG_PKG_USING_ARDUINO_CAPACITIVESENSOR is not set
#
# Display libraries
# Display
#
# CONFIG_PKG_USING_ARDUINO_U8G2 is not set
#
# Timing libraries
# Timing
#
# CONFIG_PKG_USING_ARDUINO_MSTIMER2 is not set
#
# Project libraries
# Data Processing
#
# CONFIG_PKG_USING_ARDUINO_KALMANFILTER is not set
#
# Data Storage
#
#
# Communication
#
#
# Device Control
#
#
# Other
#
#
# Signal IO
#
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_BUSIO is not set
# CONFIG_PKG_USING_ARDUINO_ADAFRUIT_TCA8418 is not set
#
# Uncategorized
#
# CONFIG_PKG_USING_ARDUINO_ULTRASOUND_RADAR is not set
# CONFIG_PKG_USING_ARDUINO_SENSOR_KIT is not set
CONFIG_SOC_ESPRESSIF=y
CONFIG_SOC_ESP32_C3=y
#
# Hardware Drivers Config
#
# CONFIG_BSP_USING_LOCAL_ESP_IDF is not set
CONFIG_BSP_BOARD_LUATOS_ESP32C3=y
# CONFIG_BSP_BOARD_HX_EXP32C3 is not set
......
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.16)
set(COMPONENTS esptool_py main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(freertos_root /Users/tangyi/rt-thread/bsp/ESP32_C3/packages/FreeRTOS_Wrapper-latest/FreeRTOS)
project(rtthread)
......@@ -43,33 +43,55 @@ Each peripheral supporting condition for this BSP is as follows:
| UART | Support | Using LUATOS_ESP32C3 development board requires connecting serial port to USB chip UART0_TX and UART0_RX (such as CP2102) |
| JTAG debug | Support | ESP32C3 usb-linked development boards can be debugged |
## Quick Start Guide
1. Download ESP-IDF package
## Install ESP-IDF
ESP-IDF can be installed in two ways
1. Use Env tool
- Download the package
```
pkgs --update
```
2. Go to ESP-IDF package directory and install IDF tools. This command only needs to be run once after the package is downloaded for the first time.
- Go to ESP-IDF package directory and install IDF tools. This command only needs to be run once after the package is downloaded for the first time.
```
cd packages/ESP-IDF-latest
./install.sh
# Use install.bat in Windows environment
```
3. Under the ESP-IDF package directory, export IDF environment variables. This commands need to be run every time when the BSP is built in a new terminal.
- Under the ESP-IDF package directory, export IDF environment variables. This commands need to be run every time when the BSP is built in a new terminal.
```
. export.sh
# Use export.bat in Windows environment
```
4. Configure RT-Thread under the BSP directory
2. Apply patch to a local installation of ESP-IDF
- Select the below option with `SCons --menuconfig`
```
Hardware Drivers Config
[*] Use local ESP-IDF installation
```
And deselect ESP-IDF package
```
RT-Thread online packages
peripheral libraries and drivers
[ ] ESP-IDF: Espressif IoT Development Framework
```
- Any convenient method to install ESP-IDF can be used, such as [VSCode plugin](https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/install.md). Make sure to install the master version of ESP-IDF.
- Enter the local ESP-IDF directory and run the following commands
```
git checkout 5c1044d84d625219eafa18c24758d9f0e4006b2c
# Replace rtt.patch with the actual directory of rtt.patch under the BSP directory
git am rtt.patch
```
- After applying the patch, ESP-IDF FreeRTOS projects can be compiled as usual
## Compile and Upload
- Configure RT-Thread under the BSP directory
```
scons --menuconfig
```
5. Whenever RT-Thread configuration is changed with `scons --menuconfig`, a new `CMakeLists.txt` needs to be generated with the command below
- Whenever RT-Thread configuration is changed with `scons --menuconfig`, a new `CMakeLists.txt` needs to be generated with the command below
```
scons --target=esp-idf
```
6. Use `idf.py` to compile and upload the program. Refer to [Espressif official documents](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/get-started/index.html#build-your-first-project) for reference.
7. Once the project is successfully downloaded, the system runs automatically, the red LED will blink in 1s on cycles.
- If ESP-IDf is installed using Env, use `idf.py` to compile and upload the program. Refer to [Espressif official documents](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/get-started/index.html#build-your-first-project) for reference. Otherwise follow the appropriate steps depending on how ESP-IDF was installed, such as using [VSCode plugin](https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/install.md).
- Once the project is successfully downloaded, the system runs automatically, the red LED will blink in 1s on cycles.
## Notes
......
......@@ -50,33 +50,56 @@
| UART | 支持 | 使用LUATOS_ESP32C3开发板需要在UART0_TX和UART0_RX连接串口转USB芯片(如CP2102)|
| JTAG调试 | 支持 | ESP32C3采用USB方式和PC链接的开发板可以调试 |
## 使用说明
1. 下载ESP-IDF软件包
## 安装ESP-IDF
可以使用两种方法安装ESP-IDF
1. 使用Env工具安装
- 下载软件包
```
pkgs --update
```
2. 进入到ESP-IDF软件包路径,安装IDf工具链。此命令只需要在下载完软件包后执行一次。
- 进入到ESP-IDF软件包路径,安装IDf工具链。此命令只需要在下载完软件包后执行一次。
```
cd packages/ESP-IDF-latest
./install.sh
# Windows环境下使用install.bat
```
3. 在软件包路径下设置IDF路径。每当在新的命令行编译BSP时需要执行此命令。
- 在软件包路径下设置IDF路径。每当在新的命令行编译BSP时需要执行此命令。
```
. export.sh
# Windows环境下使用export.bat
```
4. 在BSP路径下配置RT-Thread
2. 在本地ESP-IDF加载patch
- 通过`SCons --menuconfig`选择
```
Hardware Drivers Config
[*] Use local ESP-IDF installation
```
并取消勾选ESP-IDF软件包
```
RT-Thread online packages
peripheral libraries and drivers
[ ] ESP-IDF: Espressif IoT Development Framework
```
- 可以选择其他方式在本地安装ESP-IDF,如[VSCode插件](https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/install.md)。确保安装的ESP-IDF是master版本。
- 进入本地ESP-IDF目录执行以下命令
```
git checkout 5c1044d84d625219eafa18c24758d9f0e4006b2c
# 把rtt.patch换成BSP目录下rtt.patch的正确路径
git am rtt.patch
```
- 加载patch后不会影响使用ESP-IDF编译基于FreeRTOS的工程
## 编译和烧录
1. 在BSP路径下配置RT-Thread
```
scons --menuconfig
```
5. 每当使用`scons --menuconfig`更改RT-Thread配置后需要重新生成`CMakeLists.txt`
2. 每当使用`scons --menuconfig`更改RT-Thread配置后需要重新生成`CMakeLists.txt`
```
scons --target=esp-idf
```
6. 使用`idf.py`命令编译,烧录。具体参考[乐鑫官网](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/get-started/index.html#build-your-first-project)
7. 下载程序成功之后,系统会运行,红色的 LED灯以 1S 周期闪烁。
3. 如果使用Env安装了ESP-IDF,使用`idf.py`命令编译,烧录。具体参考[乐鑫官网](https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/get-started/index.html#build-your-first-project)。如果使用了在本地ESP-IDF加载patch的方式,可使用其他相应的编译和烧录方法,如[VSCode插件](https://github.com/espressif/vscode-esp-idf-extension/blob/master/docs/tutorial/install.md)
4. 下载程序成功之后,系统会运行,红色的 LED灯以 1S 周期闪烁。
## 注意事项
......
......@@ -7,11 +7,15 @@ config SOC_ESP32_C3
select SOC_ESPRESSIF
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
select PKG_USING_ESP_IDF
select PKG_USING_ESP_IDF if BSP_USING_LOCAL_ESP_IDF = n
default y
menu "Hardware Drivers Config"
config BSP_USING_LOCAL_ESP_IDF
bool "Use local ESP-IDF installation"
default n
choice
prompt "Select BSP board "
default BSP_BOARD_LUATOS_ESP32C3
......
......@@ -176,16 +176,33 @@
/* Arduino libraries */
/* Sensor libraries */
/* Projects */
/* Display libraries */
/* Sensors */
/* Timing libraries */
/* Display */
/* Project libraries */
/* Timing */
/* Data Processing */
/* Data Storage */
/* Communication */
/* Device Control */
/* Other */
/* Signal IO */
/* Uncategorized */
#define SOC_ESPRESSIF
#define SOC_ESP32_C3
......
此差异已折叠。
......@@ -34,13 +34,23 @@ def GenerateCFiles(env,project):
cm_file.write( "\t" + path.replace("\\", "/") + "\n")
cm_file.write(")\n\n")
print(init_export)
n = len(init_export)
if n:
cm_file.write("target_link_libraries(${COMPONENT_LIB}\n")
for i in range(n):
cm_file.write("\tINTERFACE \"-u __rt_init_" + init_export[i] + "\"\n")
cm_file.write(")\n")
cm_file.close()
cm_file = open('CMakeLists.txt', 'w')
if cm_file:
cm_file.write("cmake_minimum_required(VERSION 3.16)\n")
cm_file.write("set(COMPONENTS esptool_py main)\n")
cm_file.write("include($ENV{IDF_PATH}/tools/cmake/project.cmake)\n")
freertos_root = os.getcwd().replace('\\', '/') + '/packages/FreeRTOS_Wrapper-latest/FreeRTOS'
cm_file.write("set(freertos_root " + freertos_root + ')\n')
cm_file.write("project(rtthread)\n")
cm_file.close()
def ESPIDFProject(env,project):
print('Update setting files for CMakeLists.txt...')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册