Skip to content

Commit f5eb970

Browse files
committed
feat: reduce build tar size
1 parent c1b4ee9 commit f5eb970

2 files changed

Lines changed: 87 additions & 10 deletions

File tree

.github/workflows/light-firmware-build.yml

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,79 @@ jobs:
175175
cd esp-matter/examples/light
176176
idf.py -B "../../../${BUILD_DIR}" build
177177
178+
- name: Prepare provisioning support bundle
179+
shell: bash
180+
run: |
181+
set -euo pipefail
182+
CHIP_ROOT="esp-matter/connectedhomeip/connectedhomeip"
183+
BUNDLE_ROOT="provisioning-support/connectedhomeip"
184+
mkdir -p "${BUNDLE_ROOT}/scripts/tools"
185+
mkdir -p "${BUNDLE_ROOT}/scripts/setup"
186+
mkdir -p "${BUNDLE_ROOT}/src/setup_payload"
187+
mkdir -p "${BUNDLE_ROOT}/credentials/test"
188+
cp "${CHIP_ROOT}/scripts/tools/generate_esp32_chip_factory_bin.py" "${BUNDLE_ROOT}/scripts/tools/"
189+
cp -R "${CHIP_ROOT}/scripts/tools/spake2p" "${BUNDLE_ROOT}/scripts/tools/"
190+
cp "${CHIP_ROOT}/scripts/setup/requirements.setuppayload.txt" "${BUNDLE_ROOT}/scripts/setup/"
191+
cp -R "${CHIP_ROOT}/src/setup_payload/python" "${BUNDLE_ROOT}/src/setup_payload/"
192+
cp -R "${CHIP_ROOT}/credentials/test/attestation" "${BUNDLE_ROOT}/credentials/test/"
193+
cp -R "${CHIP_ROOT}/credentials/test/certification-declaration" "${BUNDLE_ROOT}/credentials/test/"
194+
if [ -f "${CHIP_ROOT}/out/host/chip-cert" ]; then
195+
mkdir -p "${BUNDLE_ROOT}/out/host"
196+
cp "${CHIP_ROOT}/out/host/chip-cert" "${BUNDLE_ROOT}/out/host/"
197+
fi
198+
199+
- name: Prepare flashable firmware bundle
200+
shell: bash
201+
run: |
202+
set -euo pipefail
203+
python3 - <<'PY'
204+
import json
205+
import pathlib
206+
import shutil
207+
208+
build_dir = pathlib.Path("build/light-c6-thread")
209+
bundle_dir = pathlib.Path("release-bundle") / build_dir
210+
bundle_dir.mkdir(parents=True, exist_ok=True)
211+
212+
flasher_args_path = build_dir / "flasher_args.json"
213+
with flasher_args_path.open(encoding="utf-8") as flasher_args_file:
214+
flasher_args = json.load(flasher_args_file)
215+
216+
shutil.copy2(flasher_args_path, bundle_dir / "flasher_args.json")
217+
for relative_path in flasher_args["flash_files"].values():
218+
source = pathlib.PurePosixPath(relative_path)
219+
if source.is_absolute() or ".." in source.parts:
220+
raise SystemExit(f"Unsafe flash file path: {relative_path}")
221+
source_path = build_dir / pathlib.Path(*source.parts)
222+
target_path = bundle_dir / pathlib.Path(*source.parts)
223+
if not source_path.is_file():
224+
raise SystemExit(f"Missing flash file: {source_path}")
225+
target_path.parent.mkdir(parents=True, exist_ok=True)
226+
shutil.copy2(source_path, target_path)
227+
PY
228+
mkdir -p dist/light-core-input
229+
tar -C release-bundle -cf dist/light-core-input/light-c6-thread-firmware-bundle.tar build/light-c6-thread
230+
178231
- name: Save compiler cache
179232
if: always() && steps.restore-ccache.outputs.cache-hit != 'true'
180233
uses: actions/cache/save@v4
181234
with:
182235
path: .ccache
183236
key: ${{ steps.restore-ccache.outputs.cache-primary-key }}
184237

185-
- name: Upload raw build tree
238+
- name: Upload flashable firmware bundle
239+
uses: actions/upload-artifact@v4
240+
with:
241+
name: light-c6-thread-firmware-bundle
242+
path: dist/light-core-input/light-c6-thread-firmware-bundle.tar
243+
if-no-files-found: error
244+
compression-level: 0
245+
246+
- name: Upload provisioning support bundle
186247
uses: actions/upload-artifact@v4
187248
with:
188-
name: light-c6-thread-build-tree
189-
path: build/light-c6-thread
249+
name: light-c6-thread-provisioning-support
250+
path: provisioning-support
190251
if-no-files-found: error
191252
compression-level: 0
192253

@@ -199,18 +260,25 @@ jobs:
199260
- name: Checkout repository
200261
uses: actions/checkout@v4
201262

202-
- name: Download raw build tree
263+
- name: Download flashable firmware bundle
264+
uses: actions/download-artifact@v4
265+
with:
266+
name: light-c6-thread-firmware-bundle
267+
path: dist/light-core-input
268+
269+
- name: Download provisioning support bundle
203270
uses: actions/download-artifact@v4
204271
with:
205-
name: light-c6-thread-build-tree
206-
path: build/light-c6-thread
272+
name: light-c6-thread-provisioning-support
273+
path: .
207274

208275
- name: Package build artifacts
209276
shell: bash
210277
run: |
211278
set -euo pipefail
212279
mkdir -p dist/light-core
213-
tar -C build -czf dist/light-core/light-c6-thread-build.tar.gz light-c6-thread
280+
tar -xf dist/light-core-input/light-c6-thread-firmware-bundle.tar
281+
tar -czf dist/light-core/light-c6-thread-build.tar.gz build/light-c6-thread provisioning-support
214282
cp docs/ci-and-releases.md dist/light-core/README-device-specific-build.md
215283
216284
- name: Upload packaged artifact

docs/ci-and-releases.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ This repo ships two GitHub workflows:
1212
The firmware workflow builds:
1313

1414
- `build/light-c6-thread/`
15-
- all standard ESP-IDF build outputs under that directory
15+
- `flasher_args.json` and the firmware binaries referenced by it
16+
- `provisioning-support/connectedhomeip/`
1617
- a release tarball: `light-c6-thread-build.tar.gz`
1718

1819
This is a base firmware build, not a per-device commissioned release bundle.
@@ -29,7 +30,11 @@ Those are intentionally generated later from `tools/`.
2930
## How To Use Released Core Build
3031

3132
1. Download `light-c6-thread-build.tar.gz` from GitHub Actions artifacts or the GitHub Release page.
32-
2. Extract it under repo root so the build tree ends up at `build/light-c6-thread/`.
33+
2. Extract it under repo root so you get:
34+
35+
- `build/light-c6-thread/`
36+
- `provisioning-support/connectedhomeip/`
37+
3338
3. Generate device-specific data:
3439

3540
```bash
@@ -59,9 +64,13 @@ This split keeps CI artifacts reusable:
5964
- firmware build only needs source + toolchain
6065
- per-device provisioning stays local and reproducible
6166
- users do not need to rebuild the full firmware for every manufactured device
67+
- `run --skip-build` can provision from the extracted bundle without initializing git submodules first
6268

6369
## Notes
6470

65-
- `run --port` flashes automatically, but monitor stays opt-in with `--monitor`.
71+
- `run --skip-build` can reuse `provisioning-support/connectedhomeip` from the release bundle when `esp-matter/` is not checked out.
72+
- direct flashing still works from the extracted build tree because it uses generated `esptool.py` commands.
73+
- `--erase` and serial monitor still require the full `esp-matter/examples/light` checkout.
74+
- factory-mode custom attestation may still need a working `chip-cert` binary if you generate your own DAC/PAI/CD assets.
6675
- repo patches under `patches/` stay non-mutating by default; use `--apply-patches` if you explicitly need them applied before build.
6776
- `tools/device_manifest.csv` reuse remains default when present. Delete it or change `--manifest` path if you want a fresh manifest.

0 commit comments

Comments
 (0)