Admin firmware update (OTA) of a repeater over the mesh #28

Open
opened 2026-11-14 15:01:17 +01:00 by tth · 1 comment
Owner

Goal

Update a repeater's firmware from the app, as its admin, over the mesh -- typically standing under a mast with a companion (T1000-E, Wio L1, ...) 0 hops from the repeater. The firmware side exists in meshcore-tth (*-ota / *-observer-ota images, fw ... admin commands); the reference client is a Python tool. This issue is about porting that client into the app.

Firmware side and protocol:

What the app already has

  • Admin login to a repeater and a CLI screen (repeater_login_dialog.dart, repeater_cli_screen.dart).
  • Binary requests through the companion: cmdSendBinaryReq and pushCodeBinaryResponse (meshcore_protocol.dart). The firmware chunks travel as exactly these.
  • http, crypto (sha256) and cryptography (Ed25519) as dependencies.

What to add

1. Find the package (~1 day)

  • fw status on the node gives the running image's size and sha256 prefix (its delta base).
  • From the public releases of tth-pub/meshcore-tth (no token needed), pick the delta <artifact>-<tag>.from-<base tag>.mcfw that starts from that base, download it and check its sha256 against SHA256SUMS.
  • Checking the ssh signature of SHA256SUMS (namespace meshcore-ota, key in tools/ota_allowed_signers) is nice to have but not a safety requirement. The node checks the package's own Ed25519 manifest signature, target, base and version, and refuses a wrong package after its first chunks.
  • Only deltas: the node refuses a full image over the mesh (fw begin > 64 kB).

2. Transfer (~1-2 days), port of ota_mesh_push.py

  1. fw begin <bytes> <sid>.
  2. Binary chunks REQ_FW 'w': sid, offset, crc16 and 128 B of data. They get no reply.
  3. Bitmap query 'm' for the missing units. Further rounds while the list shrinks; text fw w <off> <base64> as the fallback.
  4. fw verify (poll fw status while it says verifying), then fw apply. Wait ~60 s, log in again, ver and fw status confirm the new image.

Also needed:

  • Airtime budget: a token bucket, as --duty in the tool. The default must stay polite on a shared channel.
  • Resume: the node keeps received chunks until the next fw begin or a reboot, so a stopped transfer continues with fw missing + text chunks, no new begin (--resume in the tool).
  • Lost replies are normal: retry the bitmap query, never throw away a whole round because of one missing answer.

3. UI (~1 day)

  • Repeater hub: "Firmware update" -- current version, the target version, delta size, estimated airtime/time.
  • Progress with chunks, rounds and airtime used; Cancel; an explicit confirmation before fw apply.
  • Keep the screen on or run a foreground service for the transfer: Android drops the BLE link to the companion when the app goes to the background.

Numbers and constraints

  • 0 hops at SF7: a 25 kB delta is about 40 s on air, i.e. roughly 7-10 minutes at the 10 % duty cycle of 869.4-869.65 MHz.
  • fw apply refuses below 3.8 V on battery; force is local-console only and must not be offered over the mesh.
  • A power cut during the ~30 s rewrite leaves the node in its bootloader: no half image runs, but recovery needs USB/BLE DFU on site. The UI should say so before apply.

Testing

On the bench: phone -> companion -> XIAO repeater on an *-observer-ota image. Cover a clean run, a transfer interrupted mid-way and resumed, a package for the wrong base (refused after the manifest), and the app going to the background mid-transfer.

## Goal Update a repeater's firmware from the app, as its admin, over the mesh -- typically standing under a mast with a companion (T1000-E, Wio L1, ...) 0 hops from the repeater. The firmware side exists in [meshcore-tth](https://git.rfa.cz/tth-pub/meshcore-tth) (`*-ota` / `*-observer-ota` images, `fw ...` admin commands); the reference client is a Python tool. This issue is about porting that client into the app. Firmware side and protocol: - https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/docs/ota.md - https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/src/helpers/FwUpdate.cpp - reference client: https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/tools/ota_mesh_push.py - package lookup and checks: https://git.rfa.cz/tth-pub/meshcore-tth/src/branch/main/tools/ota_pack.py (`fetch`) ## What the app already has - Admin login to a repeater and a CLI screen (`repeater_login_dialog.dart`, `repeater_cli_screen.dart`). - Binary requests through the companion: `cmdSendBinaryReq` and `pushCodeBinaryResponse` (`meshcore_protocol.dart`). The firmware chunks travel as exactly these. - `http`, `crypto` (sha256) and `cryptography` (Ed25519) as dependencies. ## What to add ### 1. Find the package (~1 day) - `fw status` on the node gives the running image's size and sha256 prefix (its delta base). - From the public releases of `tth-pub/meshcore-tth` (no token needed), pick the delta `<artifact>-<tag>.from-<base tag>.mcfw` that starts from that base, download it and check its sha256 against `SHA256SUMS`. - Checking the ssh signature of `SHA256SUMS` (namespace `meshcore-ota`, key in `tools/ota_allowed_signers`) is nice to have but not a safety requirement. The node checks the package's own Ed25519 manifest signature, target, base and version, and refuses a wrong package after its first chunks. - Only deltas: the node refuses a full image over the mesh (`fw begin` > 64 kB). ### 2. Transfer (~1-2 days), port of `ota_mesh_push.py` 1. `fw begin <bytes> <sid>`. 2. Binary chunks `REQ_FW 'w'`: sid, offset, crc16 and 128 B of data. They get no reply. 3. Bitmap query `'m'` for the missing units. Further rounds while the list shrinks; text `fw w <off> <base64>` as the fallback. 4. `fw verify` (poll `fw status` while it says `verifying`), then `fw apply`. Wait ~60 s, log in again, `ver` and `fw status` confirm the new image. Also needed: - **Airtime budget:** a token bucket, as `--duty` in the tool. The default must stay polite on a shared channel. - **Resume:** the node keeps received chunks until the next `fw begin` or a reboot, so a stopped transfer continues with `fw missing` + text chunks, no new `begin` (`--resume` in the tool). - **Lost replies are normal:** retry the bitmap query, never throw away a whole round because of one missing answer. ### 3. UI (~1 day) - Repeater hub: "Firmware update" -- current version, the target version, delta size, estimated airtime/time. - Progress with chunks, rounds and airtime used; Cancel; an explicit confirmation before `fw apply`. - Keep the screen on or run a foreground service for the transfer: Android drops the BLE link to the companion when the app goes to the background. ## Numbers and constraints - 0 hops at SF7: a 25 kB delta is about 40 s on air, i.e. roughly 7-10 minutes at the 10 % duty cycle of 869.4-869.65 MHz. - `fw apply` refuses below 3.8 V on battery; `force` is local-console only and must not be offered over the mesh. - A power cut during the ~30 s rewrite leaves the node in its bootloader: no half image runs, but recovery needs USB/BLE DFU on site. The UI should say so before apply. ## Testing On the bench: phone -> companion -> XIAO repeater on an `*-observer-ota` image. Cover a clean run, a transfer interrupted mid-way and resumed, a package for the wrong base (refused after the manifest), and the app going to the background mid-transfer.
Author
Owner

Chybi tlacitko na zjisteni verze ktery by rovnou napsalo ze fw je aktualni a neni potreba update

Chybi tlacitko na zjisteni verze ktery by rovnou napsalo ze fw je aktualni a neni potreba update
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: tth-pub/meshcore-open#28