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

This commit is contained in:
tangzz98 2022-09-26 00:55:51 -04:00 committed by GitHub
parent 5debfdd84d
commit 82bf18b771
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 496 additions and 15155 deletions

View File

@ -657,37 +657,77 @@ CONFIG_PKG_ESP_IDF_VER="latest"
# CONFIG_PKG_USING_RTDUINO is not set # 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_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_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_BMP280 is not set
# CONFIG_PKG_USING_ARDUINO_SEEED_LIS3DHTR is not set # CONFIG_PKG_USING_ARDUINO_SEEED_LIS3DHTR is not set
# CONFIG_PKG_USING_ARDUINO_CAPACITIVESENSOR is not set # CONFIG_PKG_USING_ARDUINO_CAPACITIVESENSOR is not set
# #
# Display libraries # Display
# #
# CONFIG_PKG_USING_ARDUINO_U8G2 is not set # CONFIG_PKG_USING_ARDUINO_U8G2 is not set
# #
# Timing libraries # Timing
# #
# CONFIG_PKG_USING_ARDUINO_MSTIMER2 is not set # 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_ESPRESSIF=y
CONFIG_SOC_ESP32_C3=y CONFIG_SOC_ESP32_C3=y
# #
# Hardware Drivers Config # Hardware Drivers Config
# #
# CONFIG_BSP_USING_LOCAL_ESP_IDF is not set
CONFIG_BSP_BOARD_LUATOS_ESP32C3=y CONFIG_BSP_BOARD_LUATOS_ESP32C3=y
# CONFIG_BSP_BOARD_HX_EXP32C3 is not set # CONFIG_BSP_BOARD_HX_EXP32C3 is not set

View File

@ -1,6 +1,5 @@
# 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) cmake_minimum_required(VERSION 3.16)
set(COMPONENTS esptool_py main) set(COMPONENTS esptool_py main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) 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) project(rtthread)

View File

@ -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) | | 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 | | JTAG debug | Support | ESP32C3 usb-linked development boards can be debugged |
## Quick Start Guide ## Install ESP-IDF
ESP-IDF can be installed in two ways
1. Download ESP-IDF package 1. Use Env tool
- Download the package
``` ```
pkgs --update 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 cd packages/ESP-IDF-latest
./install.sh ./install.sh
# Use install.bat in Windows environment # 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 . export.sh
# Use export.bat in Windows environment # 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 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 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. - 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).
7. Once the project is successfully downloaded, the system runs automatically, the red LED will blink in 1s on cycles. - Once the project is successfully downloaded, the system runs automatically, the red LED will blink in 1s on cycles.
## Notes ## Notes

View File

@ -50,33 +50,56 @@
| UART | 支持 | 使用LUATOS_ESP32C3开发板需要在UART0_TX和UART0_RX连接串口转USB芯片如CP2102| | UART | 支持 | 使用LUATOS_ESP32C3开发板需要在UART0_TX和UART0_RX连接串口转USB芯片如CP2102|
| JTAG调试 | 支持 | ESP32C3采用USB方式和PC链接的开发板可以调试 | | JTAG调试 | 支持 | ESP32C3采用USB方式和PC链接的开发板可以调试 |
## 使用说明 ## 安装ESP-IDF
可以使用两种方法安装ESP-IDF
1. 下载ESP-IDF软件包 1. 使用Env工具安装
- 下载软件包
``` ```
pkgs --update pkgs --update
``` ```
2. 进入到ESP-IDF软件包路径安装IDf工具链。此命令只需要在下载完软件包后执行一次。 - 进入到ESP-IDF软件包路径安装IDf工具链。此命令只需要在下载完软件包后执行一次。
``` ```
cd packages/ESP-IDF-latest cd packages/ESP-IDF-latest
./install.sh ./install.sh
# Windows环境下使用install.bat # Windows环境下使用install.bat
``` ```
3. 在软件包路径下设置IDF路径。每当在新的命令行编译BSP时需要执行此命令。 - 在软件包路径下设置IDF路径。每当在新的命令行编译BSP时需要执行此命令。
``` ```
. export.sh . export.sh
# Windows环境下使用export.bat # 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 scons --menuconfig
``` ```
5. 每当使用`scons --menuconfig`更改RT-Thread配置后需要重新生成`CMakeLists.txt`。 2. 每当使用`scons --menuconfig`更改RT-Thread配置后需要重新生成`CMakeLists.txt`。
``` ```
scons --target=esp-idf 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) 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)。
7. 下载程序成功之后,系统会运行,红色的 LED灯以 1S 周期闪烁。 4. 下载程序成功之后,系统会运行,红色的 LED灯以 1S 周期闪烁。
## 注意事项 ## 注意事项

View File

@ -7,11 +7,15 @@ config SOC_ESP32_C3
select SOC_ESPRESSIF select SOC_ESPRESSIF
select RT_USING_COMPONENTS_INIT select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN select RT_USING_USER_MAIN
select PKG_USING_ESP_IDF select PKG_USING_ESP_IDF if BSP_USING_LOCAL_ESP_IDF = n
default y default y
menu "Hardware Drivers Config" menu "Hardware Drivers Config"
config BSP_USING_LOCAL_ESP_IDF
bool "Use local ESP-IDF installation"
default n
choice choice
prompt "Select BSP board " prompt "Select BSP board "
default BSP_BOARD_LUATOS_ESP32C3 default BSP_BOARD_LUATOS_ESP32C3

View File

@ -176,16 +176,33 @@
/* Arduino libraries */ /* 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_ESPRESSIF
#define SOC_ESP32_C3 #define SOC_ESP32_C3

File diff suppressed because it is too large Load Diff

View File

@ -34,13 +34,23 @@ def GenerateCFiles(env,project):
cm_file.write( "\t" + path.replace("\\", "/") + "\n") cm_file.write( "\t" + path.replace("\\", "/") + "\n")
cm_file.write(")\n\n") cm_file.write(")\n\n")
print(init_export)
n = len(init_export) n = len(init_export)
if n: if n:
cm_file.write("target_link_libraries(${COMPONENT_LIB}\n") cm_file.write("target_link_libraries(${COMPONENT_LIB}\n")
for i in range(n): for i in range(n):
cm_file.write("\tINTERFACE \"-u __rt_init_" + init_export[i] + "\"\n") cm_file.write("\tINTERFACE \"-u __rt_init_" + init_export[i] + "\"\n")
cm_file.write(")\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): def ESPIDFProject(env,project):
print('Update setting files for CMakeLists.txt...') print('Update setting files for CMakeLists.txt...')