Skip to content

Commit 9e9669b

Browse files
authored
[bsp] [ESP32C3] Add dockerfile and update README (#10313)
bsp: ESP32C3: Add dockerfile and update README
1 parent 5c23485 commit 9e9669b

File tree

3 files changed

+144
-5
lines changed

3 files changed

+144
-5
lines changed

bsp/ESP32_C3/README.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Each peripheral supporting condition for this BSP is as follows:
4141
| ------------------------ | --------------- | ------------------------------------------------------------ |
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) |
44+
| I2C | Supported | Hardware I2C may encounter transmission errors. Software I2C is recommended, but it occupies a general hardware system timer. |
45+
| SPI | Supported | Supports custom configuration |
4446
| JTAG debug | Support | ESP32C3 usb-linked development boards can be debugged |
4547
| WIFI | Partial support | There are currently some problems, such as `rt_mq_recive` cannot be used in ISR, etc. |
4648
| BLE | Partially supported | There are currently some problems, such as `NimBLE` running errors after starting for a while |
@@ -91,6 +93,48 @@ Type "apropos word" to search for commands related to "word".
9193

9294
## Environment construction and compilation
9395

96+
### Docker deploy
97+
98+
If you want to lightly experiment with the ESP32-C3, it is recommended to quickly set up the environment using Docker. Otherwise, use a native environment setup.
99+
100+
1. Ensure Docker is installed and the inner network environment is properly configured. You can obtain the Docker image either via a pre-built docker image or by building it from a Dockerfile. Note that the docker image may not always be up-to-date, while the Dockerfile allows you to fetch the latest main branch. Below are the setup commands:
101+
* Setting up the development environment using a Dockerfile:
102+
103+
```sh
104+
cd docker
105+
sudo docker build --build-arg HTTP_PROXY=http://ip:port --build-arg HTTPS_PROXY=http://ip:port -t image_name .
106+
```
107+
Replace ip:port with your proxy server's IP and port. Otherwise, network issues may occur when pulling repositories.
108+
109+
* Setting up the development environment using a pre-built Docker image:
110+
111+
```sh
112+
sudo docker pull 1078249029/rtthread_esp32c3:latest
113+
```
114+
115+
2. Enter the Docker container:
116+
117+
```sh
118+
sudo docker run -it --device=/dev/ttyUSB* image_name
119+
```
120+
121+
The --device parameter is used for debugging and flashing code. You can obtain the corresponding port by running ls /dev/ttyUSB* on the host machine. If you used the pre-built Docker image, replace image_name with 1078249029/rtthread_esp32c3.
122+
123+
3. Using the Environment:
124+
125+
Flashing firmware:
126+
127+
```sh
128+
sudo esptool.py -b 115200 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size detect --flash_freq 80m 0x0 path/to/your/bootloader.bin 0x08000 path/to/your/partition-table.bin 0x010000 path/to/your/rtthread.bin
129+
```
130+
131+
Debugging:
132+
133+
```sh
134+
sudo minicom -c on -D /dev/ttyUSB*
135+
```
136+
### Native setup
137+
94138
1. Download the RISC-V toolchain:
95139
96140
```sh
@@ -180,7 +224,8 @@ or we can check ESPRESSIF's [Troubleshooting](https://docs.espressif.com/project
180224
Maintainer:
181225

182226
- [supperthomas](https://github.com/supperthomas) email address: [[email protected]](mailto:[email protected])
183-
- [tangzz98](https://github.com/tangzz98) email address: [[email protected]]([email protected])
227+
- [tangzz98](https://github.com/tangzz98) email address: [[email protected]]([email protected])
228+
- [wumingzi](https://github.com/1078249029) email address: [[email protected]]([email protected])
184229

185230
Special thanks to [chenyingchun0312](https://github.com/chenyingchun0312) for providing support on the RISC-V part working.
186231

bsp/ESP32_C3/README_ZH.md

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
| :----------------- | :----------: | :------------------------------------- |
4949
| GPIO | 支持 | |
5050
| UART | 支持 | 使用LUATOS_ESP32C3开发板需要在UART0_TX和UART0_RX连接串口转USB芯片(如CP2102)|
51+
| I2C | 支持 | 硬件I2C会产生传输错误,推荐使用软件I2C,但使用软件I2C会占用一个硬件通用定时器 |
52+
| SPI | 支持 | 支持自定义配置|
5153
| JTAG调试 | 支持 | ESP32C3采用USB方式和PC链接的开发板可以调试 |
5254
| WIFI | 部分支持 | 目前存在一些问题,例如不能在ISR中使用`rt_mq_recive`|
5355
| BLE | 部分支持 | 目前存在一些问题,例如`NimBLE`启动一段时间后运行错误 |
@@ -99,12 +101,55 @@ Type "apropos word" to search for commands related to "word".
99101

100102
## 环境搭建及编译
101103

104+
### Docker
105+
106+
如果想要通轻度尝鲜esp32c3,推荐使用docker快速搭建环境,否则请使用原生环境搭建
107+
108+
1. 在确保已经安装 docker 并配置docker内部网络环境的基础上可以通过 docker image 或 dockerfile 获取镜像,docker image 不保证时效性,而 dockerfile 可以获取最新的主线分支,下面是对应的搭建命令
109+
* 通过 dockerfile 搭建开发环境
110+
111+
```sh
112+
cd docker
113+
sudo docker build --build-arg HTTP_PROXY=http://ip:port --build-arg HTTPS_PROXY=http://ip:port -t image_name .
114+
```
115+
这里的 ip:port 需要修改为代理服务器 ip 和端口号,否则拉取仓库时可能会出现网络问题
116+
117+
* 通过docker image搭建开发环境
118+
119+
```sh
120+
sudo docker pull 1078249029/rtthread_esp32c3:latest
121+
```
122+
123+
2. 进入 docker
124+
125+
```sh
126+
sudo docker run -it --device=/dev/ttyUSB* image_name
127+
```
128+
129+
device 参数用于调试、烧录代码,通过在宿主机内执行`ls /dev/ttyUSB*`即可获得对应端口,如果是通过 docker image 搭建环境的需要将 image_name 替换为`1078249029/rtthread_esp32c3`
130+
131+
3. 环境使用
132+
133+
使用下列命令烧录
134+
135+
```sh
136+
sudo esptool.py -b 115200 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size detect --flash_freq 80m 0x0 path/to/your/bootloader.bin 0x08000 path/to/your/partition-table.bin 0x010000 path/to/your/rtthread.bin
137+
```
138+
139+
使用下列命令调试
140+
141+
```sh
142+
sudo minicom -c on -D /dev/ttyUSB*
143+
```
144+
145+
### 原生环境搭建
146+
102147
1. 下载 RISC-V 工具链:
103148

104-
```sh
105-
wget https://github.com/espressif/crosstool-NG/releases/download/esp-2022r1-RC1/riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz
106-
tar xf riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz
107-
```
149+
```sh
150+
wget https://github.com/espressif/crosstool-NG/releases/download/esp-2022r1-RC1/riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz
151+
tar xf riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz
152+
```
108153

109154
2. 配置工具链的路径:
110155

@@ -190,6 +235,7 @@ Linux 下可以使用先前下载的 esptool 进行烧录
190235

191236
- [supperthomas](https://github.com/supperthomas) 邮箱:<[email protected]>
192237
- [tangzz98](https://github.com/tangzz98) 邮箱:<[email protected]>
238+
- [wumingzi](https://github.com/1078249029) 邮箱:<[email protected]>
193239

194240
## 特别感谢
195241

bsp/ESP32_C3/docker/Dockerfile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
FROM ubuntu:22.04
2+
3+
ARG HTTP_PROXY
4+
ARG HTTPS_PROXY
5+
ENV http_proxy=${HTTP_PROXY}
6+
ENV https_proxy=${HTTPS_PROXY}
7+
8+
9+
# 1. Basic options(with root)
10+
RUN apt update && \
11+
apt install -y software-properties-common && \
12+
add-apt-repository universe && \
13+
apt update && \
14+
apt install -y --no-install-recommends \
15+
sudo git wget python3 python3-pip scons vim xz-utils minicom && \
16+
pip3 install esptool && \
17+
useradd -m dev && \
18+
echo "dev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
19+
20+
# 2. Switch to dev user
21+
USER dev
22+
WORKDIR /home/dev
23+
24+
# 3. Install esp-idf toolchains
25+
RUN wget -q https://github.com/espressif/crosstool-NG/releases/download/esp-2022r1-RC1/riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz && \
26+
sudo tar -xf riscv32-esp-elf-gcc11_2_0-esp-2022r1-RC1-linux-amd64.tar.xz -C /opt
27+
28+
# 4. Clone RT-Thread and switch master
29+
RUN git clone https://github.com/RT-Thread/rt-thread.git && \
30+
cd rt-thread && \
31+
git switch master
32+
33+
# 5. Install env tools
34+
WORKDIR /home/dev/rt-thread
35+
RUN wget https://raw.githubusercontent.com/RT-Thread/env/master/install_ubuntu.sh && \
36+
chmod +x install_ubuntu.sh && \
37+
./install_ubuntu.sh
38+
39+
# 6. Modify toolchains path
40+
RUN sed -i "s|^.*EXEC_PATH.*| EXEC_PATH = r'/opt/riscv32-esp-elf/bin'|" bsp/ESP32_C3/rtconfig.py
41+
42+
# 7. Set enviroment variables
43+
ENV PATH="/opt/riscv32-esp-elf/bin:/home/dev/.env/tools/scripts:$PATH"
44+
45+
# 8. Update rtthread packages
46+
WORKDIR /home/dev/rt-thread/bsp/ESP32_C3
47+
RUN pkgs --update
48+

0 commit comments

Comments
 (0)