From f25d3fdb367a9b899f745e67c9795405750c867a Mon Sep 17 00:00:00 2001 From: Shivtej Gaikwad <91597404+ShivtejG236@users.noreply.github.com> Date: Fri, 13 Nov 2026 19:48:46 +0000 Subject: [PATCH] Add a browser-based flasher built from the release manifest - web/index.html lists the boards in manifest.json and flashes the chosen one over WebSerial with ESP Web Tools - tools/release.py --site assembles the page, the images and one ESP Web Tools manifest per board - the release workflow uploads the site and deploys it to GitHub Pages when the PAGES_DEPLOY repository variable is true --- .github/workflows/build.yml | 6 +- .github/workflows/release.yml | 22 +++- .gitignore | 1 + CHANGELOG.md | 3 + README.md | 15 ++- scripts/__pycache__/boards.cpython-313.pyc | Bin 4974 -> 4974 bytes tools/release.py | 34 ++++++ web/index.html | 123 +++++++++++++++++++++ 8 files changed, 200 insertions(+), 4 deletions(-) create mode 100644 web/index.html diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c1c7dfd..0d87a53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,9 +41,13 @@ jobs: - name: Assemble release images (dry run) run: | version="$(sed -nE 's/^#define MSNS_FW_VERSION "(.*)"/\1/p' include/version.h)" - python tools/release.py --tag "v${version}" --out dist + python tools/release.py --tag "v${version}" --out dist --site site cat dist/manifest.json - uses: actions/upload-artifact@v4 with: name: firmware-images path: dist/ + - uses: actions/upload-artifact@v4 + with: + name: web-flasher + path: site/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0d78aad..034ebcc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,7 @@ name: Release # MSNS_FW_VERSION in include/version.h. # # Flash with navkit: nav flash +# From a browser: the web flasher on GitHub Pages (see below) # Or by hand: esptool --chip esp32 write-flash 0x0 msns-firmware-esp32dev-v0.2.0.bin on: @@ -25,8 +26,27 @@ jobs: - run: pip install platformio "esptool>=5" - run: python3 tools/check_boards.py - run: pio run - - run: python tools/release.py --tag "$GITHUB_REF_NAME" --out dist + - run: python tools/release.py --tag "$GITHUB_REF_NAME" --out dist --site site - name: Publish release env: GH_TOKEN: ${{ github.token }} run: gh release create "$GITHUB_REF_NAME" dist/* --title "$GITHUB_REF_NAME" --generate-notes + - uses: actions/upload-pages-artifact@v3 + with: + path: site/ + + # Web flasher. Enable once: repository Settings → Pages → Source "GitHub + # Actions", then set the repository variable PAGES_DEPLOY=true. + pages: + needs: release + if: vars.PAGES_DEPLOY == 'true' + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deploy.outputs.page_url }} + steps: + - id: deploy + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore index 324cfcc..bd013f7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .vscode .DS_Store dist/ +site/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 68bce31..203dcbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). - Host output moved out of `main.cpp` into `src/transport.cpp`. ### Added +- **Web flasher** (`web/index.html`, built by `tools/release.py --site`): + flash any released board from Chrome or Edge with no install. Deployed to + GitHub Pages by the release workflow when `PAGES_DEPLOY=true`. - **Board manifests** (`targets/.json`): pins, flash layout and status per board, applied to the build by `scripts/board.py`. Adding a board is one JSON file and one PlatformIO environment. See `docs/boards.md`. diff --git a/README.md b/README.md index bb1e147..6291c8a 100644 --- a/README.md +++ b/README.md @@ -311,7 +311,8 @@ firmware/ ├── tools/ │ ├── host/ # Host-side protocol tests + golden stream generator │ ├── check_boards.py # CI check: manifests ↔ PlatformIO environments -│ └── release.py # Merges release images and writes manifest.json +│ └── release.py # Merges release images, writes manifest.json, builds the web flasher +├── web/index.html # Web flasher page (ESP Web Tools) ├── platformio.ini # PlatformIO build config ├── sdkconfig.defaults # ESP-IDF SDK overrides (task WDT tuning) └── docs/ @@ -338,12 +339,22 @@ Managed by PlatformIO — no manual installation needed. ## Build & Flash +### Without a toolchain + +| Route | How | +|---|---| +| Terminal | `nav flash` from [Repo 2](https://github.com/multi-sensor-navigation-system/data-pipeline): detects the board, downloads the matching release image, verifies its SHA-256, flashes it | +| Browser | The web flasher published with each release (Chrome or Edge on a desktop): pick the board, press Flash | +| By hand | Download `msns-firmware--.bin` from Releases, then `esptool --chip esp32 write-flash 0x0 ` | + +### From source + ```bash # Build and flash the default (binary) firmware pio run -e esp32dev --target upload ``` -Replace `esp32dev` with another board id from [`docs/boards.md`](docs/boards.md) to build for it. Released images can be flashed without PlatformIO: `nav flash` from [Repo 2](https://github.com/multi-sensor-navigation-system/data-pipeline) detects the board and downloads the right one. +Replace `esp32dev` with another board id from [`docs/boards.md`](docs/boards.md) to build for it. The binary stream is not readable in a serial monitor; log it with the host logger from [Repo 2](https://github.com/multi-sensor-navigation-system/data-pipeline), which prints the firmware's messages and writes the CSV. diff --git a/scripts/__pycache__/boards.cpython-313.pyc b/scripts/__pycache__/boards.cpython-313.pyc index 48df08887972370862bd2954a69ce485cb7e058a..e94ff8894152f1c657fa5e4ca43199e837129500 100644 GIT binary patch delta 18 YcmaE-_D+rSGcPX}0}xbf= 5 on PATH. """ @@ -14,6 +15,7 @@ import hashlib import json import re +import shutil import subprocess import sys from pathlib import Path @@ -60,12 +62,42 @@ def merge(board: dict, build_dir: Path, boot_app0: Path, out: Path) -> None: subprocess.run(cmd, check=True) +# esptool chip id → ESP Web Tools chipFamily +CHIP_FAMILY = {"esp32": "ESP32", "esp32s2": "ESP32-S2", "esp32s3": "ESP32-S3", + "esp32c3": "ESP32-C3", "esp32c6": "ESP32-C6", "esp32h2": "ESP32-H2"} + + +def build_site(manifest: dict, dist: Path, site: Path) -> None: + """The web flasher: web/index.html, the images, and one ESP Web Tools manifest per board. + + The images are copied next to the page because browsers cannot fetch + GitHub release assets cross-origin. + """ + (site / "web").mkdir(parents=True, exist_ok=True) + shutil.copy(ROOT / "web" / "index.html", site / "index.html") + shutil.copy(dist / "manifest.json", site / "manifest.json") + for board_id, entry in manifest["boards"].items(): + shutil.copy(dist / entry["image"], site / entry["image"]) + web_manifest = { + "name": f"MSNS firmware — {entry['name']}", + "version": manifest["version"], + "new_install_prompt_erase": False, + "builds": [{ + "chipFamily": CHIP_FAMILY[entry["chip"]], + "parts": [{"path": f"../{entry['image']}", "offset": 0}], + }], + } + (site / "web" / f"{board_id}.json").write_text(json.dumps(web_manifest, indent=2) + "\n") + print(f" web flasher → {site}") + + def main() -> int: ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) ap.add_argument("--tag", required=True, help="release tag, e.g. v0.2.0") ap.add_argument("--out", type=Path, default=ROOT / "dist") ap.add_argument("--build-root", type=Path, default=ROOT / ".pio" / "build") ap.add_argument("--boot-app0", type=Path, default=DEFAULT_BOOT_APP0) + ap.add_argument("--site", type=Path, help="also build the web flasher into this directory") args = ap.parse_args() fw_version = macro("version.h", "MSNS_FW_VERSION") @@ -96,6 +128,8 @@ def main() -> int: (args.out / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n") print(f" manifest.json ({len(manifest['boards'])} boards, proto {manifest['proto']})") + if args.site: + build_site(manifest, args.out, args.site) return 0 diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..07c47dc --- /dev/null +++ b/web/index.html @@ -0,0 +1,123 @@ + + + + + +Flash firmware · Multi-Sensor Navigation System + + + + +
+

Flash the firmware from your browser

+

Plug the board in over USB, pick it below, and choose its serial port when the browser asks. Nothing to install.

+ + + +
Loading firmware list…
+
+ +
    +
  1. If no port appears, the board's USB chip needs a driver (CP210x or CH340), or the cable is charge-only.
  2. +
  3. If flashing does not start, hold the board's BOOT button while it connects.
  4. +
  5. Flashing replaces whatever firmware is on the board.
  6. +
+ +
+ Prefer a terminal? nav flash from + navkit + detects the board, verifies the download and flashes it. + Source: firmware. +
+
+ + + +