-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add web installer, extract
build-esp
GH action
- Loading branch information
Showing
13 changed files
with
167 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Build ESP binaries | ||
description: Build ESP binaries | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- uses: pnpm/action-setup@v2 | ||
with: | ||
version: latest | ||
- name: Install node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20.10.0' | ||
cache: 'pnpm' | ||
- name: Install frontend dependencies and build frontend | ||
run: | | ||
pnpm i | ||
pnpm build | ||
shell: bash | ||
- name: Cache esp-idf build | ||
uses: actions/cache@v3 | ||
with: | ||
# TODO This caching seems useless | ||
path: 'build' | ||
key: ${{ runner.os }}-build-v7 | ||
- name: Cache managed components | ||
uses: actions/cache@v3 | ||
with: | ||
path: 'managed_components' | ||
key: ${{ runner.os }}-managed_components-${{ hashFiles('dependencies.lock') }}-v2 | ||
- name: Address ESP-IDF component hash bug | ||
run: | | ||
rm -rf managed_components/bblanchon__arduinojson/.component_hash | ||
shell: bash | ||
- name: esp-idf build and merge firmware | ||
run: | | ||
docker run -t -e IDF_TARGET="esp32" -e GITHUB_ACTIONS=true -v "${GITHUB_WORKSPACE}:/app/${{ github.repository }}" \ | ||
-w "/app/${{ github.repository }}" espressif/idf:release-v5.1 \ | ||
/bin/bash -c 'git config --global --add safe.directory "*" && idf.py build && cd /app/${{ github.repository }}/scripts && ./merge_firmware.sh' | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ repos: | |
exclude_types: | ||
- python | ||
- image | ||
- shell | ||
entry: pnpm exec prettier --write | ||
|
||
- id: clang-format | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
body { | ||
--esp-tools-button-color: var(--md-primary-fg-color); | ||
--esp-tools-button-text-color: black; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Firmware Web Installer | ||
|
||
Click the button below to installer the latest development firmware onto your device. | ||
|
||
<!-- TODO The dialog styling does not match the rest, fix it --> | ||
<esp-web-install-button manifest="/installer/manifest.json"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import mkdocs_gen_files | ||
|
||
|
||
def generate_index(): | ||
in_path = "README.md" | ||
out_path = "index.md" | ||
|
||
with open(in_path, "r") as file: | ||
filedata = file.read() | ||
|
||
filedata = filedata.replace('src="docs/', 'src="') | ||
|
||
with mkdocs_gen_files.open(out_path, "w") as file: | ||
file.write(filedata) | ||
|
||
|
||
generate_index() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import json | ||
from pathlib import Path | ||
import shutil | ||
|
||
IN_FIRMWARE_PATH = Path(__file__).parent.parent / "build" / "merged-firmware.bin" | ||
|
||
|
||
def get_firmware_content(): | ||
if not IN_FIRMWARE_PATH.exists(): | ||
print( | ||
f"Could not find firmware at {IN_FIRMWARE_PATH}, using dummy firmware" | ||
) | ||
|
||
return "{}" | ||
|
||
manifest = { | ||
"name": "SunTransit", | ||
# TODO Get version from somewhere, like Git (hash / hash-dirty) | ||
"version": "0.1", | ||
"new_install_prompt_erase": False, | ||
"builds": [ | ||
{ | ||
"chipFamily": "ESP32", | ||
"parts": [{"path": IN_FIRMWARE_PATH.name, "offset": 0}], | ||
} | ||
], | ||
} | ||
|
||
return json.dumps(manifest, indent=4) | ||
|
||
|
||
def generate_espwebtools_manifest(site_dir: str): | ||
MANIFEST_PATH = Path(site_dir) / "installer" / "manifest.json" | ||
|
||
with open(MANIFEST_PATH, "w") as out_file: | ||
out_file.write(get_firmware_content()) | ||
|
||
def copy_firmware(site_dir: str): | ||
if not IN_FIRMWARE_PATH.exists(): | ||
return | ||
|
||
OUT_FIRMWARE_PATH = Path(site_dir) / "installer" / IN_FIRMWARE_PATH.name | ||
|
||
shutil.copyfile(IN_FIRMWARE_PATH, OUT_FIRMWARE_PATH) | ||
|
||
|
||
def on_post_build(config, **kwargs): | ||
generate_espwebtools_manifest(config["site_dir"]) | ||
copy_firmware(config["site_dir"]) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
esptool.py --chip esp32 merge_bin \ | ||
-o ../build/merged-firmware.bin \ | ||
--flash_mode dio \ | ||
--flash_freq 80m \ | ||
--flash_size 4MB \ | ||
0x1000 ../build/bootloader/bootloader.bin \ | ||
0x8000 ../build/partition_table/partition-table.bin \ | ||
0x10000 ../build/suntransit.bin \ | ||
0x290000 ../build/www.bin \ |