Skip to content

Commit 324957c

Browse files
committed
add c3
1 parent 5845b09 commit 324957c

File tree

2 files changed

+123
-5
lines changed

2 files changed

+123
-5
lines changed

.github/workflows/build esp32 mpy1.25.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
# 开发板矩阵,可以添加不同的开发板
27+
# 开发板矩阵,暂不支持ESP32-C3
2828
include:
2929
- board: ESP32_GENERIC_S3
3030
variant: SPIRAM_OCT
3131
flash_size: 16
3232
- board: ESP32_GENERIC_S3
3333
variant: SPIRAM_OCT
3434
flash_size: 4
35-
- board: ESP32_GENERIC_C3
35+
- board: ESP32_GENERIC_S3
3636
variant: ""
37-
flash_size: 8
37+
flash_size: 16
3838
- board: ESP32_GENERIC
3939
variant: SPIRAM
40-
flash_size: 4
40+
flash_size: 16
4141

4242
steps:
4343
# 1. 检出当前仓库(其实没用)
@@ -82,7 +82,7 @@ jobs:
8282
git clone --depth 1 --branch ${{ env.ESP_IDF_VERSION }} \
8383
https://github.com/espressif/esp-idf.git ${{ env.ESP_IDF_DIR }}
8484
git -C ${{ env.ESP_IDF_DIR }} submodule update --init --recursive --filter=tree:0
85-
${{ env.ESP_IDF_DIR }}/install.sh esp32,esp32s3,esp32c3
85+
${{ env.ESP_IDF_DIR }}/install.sh esp32,esp32s3
8686
8787
# 6. 编译固件
8888
- name: Build firmware
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: build esp32 mpy 1.25
2+
3+
# 仅手动触发
4+
on:
5+
workflow_dispatch:
6+
7+
# 并发控制:同一分支只保留最新一次
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
env:
13+
MICROPYTHON_DIR: ${{ github.workspace }}/micropython
14+
ESP_IDF_DIR: ${{ github.workspace }}/esp-idf
15+
ARTIFACTS_DIR: ${{ github.workspace }}/artifacts
16+
# micropython版本,可以修改
17+
MPY_VERSION: v1.25.0
18+
# esp-idf版本,不建议修改
19+
ESP_IDF_VERSION: v5.2.2
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-24.04
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
# 开发板矩阵,C3/C6
28+
include:
29+
- board: ESP32_GENERIC_C3
30+
variant: ""
31+
flash_size: 16
32+
- board: ESP32_GENERIC_C3
33+
variant: ""
34+
flash_size: 8
35+
- board: ESP32_GENERIC_C6
36+
variant: ""
37+
flash_size: 16
38+
- board: ESP32_GENERIC_C6
39+
variant: ""
40+
flash_size: 8
41+
42+
steps:
43+
# 1. 检出当前仓库(其实没用)
44+
- name: Checkout repo
45+
uses: actions/checkout@v4
46+
47+
# 2. 缓存 ESP-IDF 与 MicroPython
48+
- name: Cache ESP-IDF and MicroPython
49+
id: cache_all
50+
uses: actions/cache@v4
51+
with:
52+
path: |
53+
${{ env.ESP_IDF_DIR }}
54+
~/.espressif/
55+
~/.cache/pip/
56+
${{ env.MICROPYTHON_DIR }}
57+
key: mpy-${{ env.MPY_VERSION }}-idf-${{ env.ESP_IDF_VERSION }}
58+
59+
# 3. 安装系统依赖(仅在缓存未命中时)
60+
- name: Install system dependencies
61+
if: steps.cache_all.outputs.cache-hit != 'true'
62+
run: |
63+
sudo apt-get update
64+
sudo apt-get install -y \
65+
git wget flex bison gperf python3 python3-pip python3-venv \
66+
cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0
67+
68+
# 4. 克隆 MicroPython(仅在缓存未命中时)
69+
- name: Clone MicroPython
70+
if: steps.cache_all.outputs.cache-hit != 'true'
71+
run: |
72+
git clone --depth 1 --branch ${{ env.MPY_VERSION }} \
73+
https://github.com/micropython/micropython.git ${{ env.MICROPYTHON_DIR }}
74+
cd ${{ env.MICROPYTHON_DIR }}
75+
git submodule update --init --depth 1
76+
make -C mpy-cross
77+
78+
# 5. 克隆并配置 ESP-IDF(仅在缓存未命中时)
79+
- name: Clone & setup ESP-IDF
80+
if: steps.cache_all.outputs.cache-hit != 'true'
81+
run: |
82+
git clone --depth 1 --branch ${{ env.ESP_IDF_VERSION }} \
83+
https://github.com/espressif/esp-idf.git ${{ env.ESP_IDF_DIR }}
84+
git -C ${{ env.ESP_IDF_DIR }} submodule update --init --recursive --filter=tree:0
85+
${{ env.ESP_IDF_DIR }}/install.sh esp32c3,esp32c6
86+
87+
# 6. 编译固件
88+
- name: Build firmware
89+
run: |
90+
source ${{ env.ESP_IDF_DIR }}/export.sh
91+
cd ${{ env.MICROPYTHON_DIR }}/ports/esp32
92+
make BOARD=${{ matrix.board }} \
93+
BOARD_VARIANT=${{ matrix.variant }} \
94+
FLASH_SIZE=${{ matrix.flash_size }}MB \
95+
-j$(nproc)
96+
97+
# 7. 重命名并收集固件
98+
- name: Rename firmware
99+
run: |
100+
mkdir -p ${{ env.ARTIFACTS_DIR }}
101+
BOARD_NAME="${{ matrix.board }}"
102+
[[ -n "${{ matrix.variant }}" ]] && BOARD_NAME+="-${{ matrix.variant }}"
103+
FW_PATH="${{ env.MICROPYTHON_DIR }}/ports/esp32/build-${BOARD_NAME}/firmware.bin"
104+
OUT_NAME="${{ matrix.board }}${{ matrix.variant && format('_{0}', matrix.variant) || '' }}_${{ matrix.flash_size }}MB.bin"
105+
106+
if [[ -f "$FW_PATH" ]]; then
107+
cp "$FW_PATH" "${{ env.ARTIFACTS_DIR }}/$OUT_NAME"
108+
else
109+
echo "Firmware not found at $FW_PATH"
110+
exit 1
111+
fi
112+
113+
# 8. 上传构建产物
114+
- name: Upload artifact
115+
uses: actions/upload-artifact@v4
116+
with:
117+
name: mpy1.25-${{ matrix.board }}${{ matrix.variant && format('_{0}', matrix.variant) || '' }}_${{ matrix.flash_size }}MB
118+
path: ${{ env.ARTIFACTS_DIR }}/*.bin

0 commit comments

Comments
 (0)