Commit Graph
3060 Commits
Author SHA1 Message Date
Valentin Kivachuk Burda 949acb2b7d dev-only: fork rolling-CI workflow + venv .gitignore + EndF/apply-sim helper scripts dev-latest 2026-07-11 15:48:37 +02:00
Valentin Kivachuk Burda 872413231d ota: extract the motatool CLI to its own repo (github.com/vk496/motatool)
The host-side build/verify/inspect/serve CLI now lives as a standalone Rust
project at https://github.com/vk496/motatool. Remove the in-tree C++ copy
(tools/motatool/) and repoint the docs (ota_protocol.md, ota_user_guide.md,
tools/mota/README.md) at the standalone repo.

No cross-dependency either direction: MeshCore's firmware build never invoked
motatool (only tools/mota/ Python glue runs in the build), and motatool depends
only on the shared .mota wire spec in docs/ota_protocol.md. tools/mota/
(pio_endf.py EndF hook, motalib.py reference lib, gen_targets.py) is unchanged.
2026-07-11 14:47:11 +02:00
Valentin Kivachuk Burda ee6e548746 variants: enable OTA on Heltec T096 (nRF52840, shared rak4631_hw recipe)
The T096 is an nRF52840 with the same S140 v6 SoftDevice and flash geometry as
the RAK4631, so it can reuse the shared rak4631_hw OTA recipe (ENABLE_OTA +
OtaFlashLayout_nrf52.h — APP_BASE 0x26000, staging ceiling 0xD4000, all
static_asserts satisfied by the stock nrf52840_s140_v6[_extrafs] ldscripts).

With the OTAFIX bootloader (oltaco PR #42 adds the T096 board) a node applies
in place; without it the node still discovers/relays/serves OTA and merely
fetch-refuses apply — so a T096 is a useful OTA relay/seeder regardless.

MOTA_HW_ID='"Heltec_t096"' tags the EndF trailer so a .mota built for other
hardware is refused. Propagates to every T096 role via ${Heltec_t096.*}.

Verified: repeater + companion_radio_usb build clean, 14 OTA objects each,
EndF stamped (hw='Heltec_t096', v1.17.0).
2026-07-11 14:42:12 +02:00
Valentin Kivachuk Burda cbdc629f20 docs: clarify the warm-start capture workflow (--seed flag + validate switch)
Spell out how the warm-start seed is actually applied (a user asked): the seed is the --seed <file> given to `motatool serve`, NOT a file dropped into the --dir destination (which starts empty). motatool stamps that one seed into the fresh .part on every `… folder validate` begin, so it's always the named file — no guessing. `validate` is the switch (a plain folder pull fetches from 0); a re-pull re-begins fresh (never resumes a stale partial); a mismatched/absent seed just falls back to fetching those blocks over the radio (correct result, only slower).
2026-07-03 08:16:56 +02:00
Valentin Kivachuk Burda 0319a81d69 ota: stamp the real FIRMWARE_VERSION into the EndF trailer (was v0.0.0)
The EndF post-build stamper read the version via _cppdef('FIRMWARE_VERSION'), which only sees -D build flags — but MeshCore authors FIRMWARE_VERSION as a header #define in each example, so the stamper found nothing and defaulted fw_version to 0. Every .mota / OTA advert then reported v0.0.0 while `ver` (which reads the header at runtime) showed the real version.

Read the header value as a fallback WITHOUT moving where MeshCore authors it: honor a -D override first (the header's #ifndef guard invites it, for release builds), else read the #define from the example this env builds (via build_src_filter), falling back to the repo-wide value when unambiguous. Purely additive to our own EndF tooling — no MeshCore source changed.

HW-verified: RAK4631 now reports `fw v1.17.0` in ota stats/ls (was v0.0.0), matching `ver`.
2026-07-03 08:02:59 +02:00
Valentin Kivachuk Burda b159737ede ota: admin OTA statistics — ota stats reply
Add an admin-only `ota stats` reply: one dense line with the running firmware's merkle content-id (mid) AND its EndF body_hash (only body_hash was surfaced before), version, served-set count + digest, live fetch state/progress, and policy — snprintf-bounded to the 160-byte reply. The remote CLI path is already admin-gated, so it's admin-only over the mesh (send it from the app's repeater command screen, or the WiFi/serial OTA console). A new servedDigest() accessor exposes the beacon set-digest.

HW-verified on RAK4631: reports the fw identity + live fetch state (incl. during a warm-start capture).
2026-07-03 08:02:37 +02:00
Valentin Kivachuk Burda 8953214761 ota: fragment-level want_mask requests (anti-burst) + warm-start leaf-diff capture
Protocol: OTA_REQ and OTA_GET_MANIFEST now carry a want_mask bitmap, so a fetcher asks for specific fragments (all on the first request, only the still-missing holes on a retry) instead of a whole block/manifest window. The WANT_MANIFEST and FETCHING retry loops re-ask only on a no-progress tick, so a lost fragment costs one fragment to recover and a re-request can't collide with an in-flight multi-fragment burst on half-duplex radios.

Warm-start (motatool folder-capture only): new OTA_GET_LEAVES/OTA_LEAVES let `ota pull <#> folder validate` bulk-fetch the target's merkle leaves, authenticate them against the manifest root, diff a similar seed build already staged in the destination, and pull DATA over LoRa only for the blocks that differ. Leaves are bitmap-fragmented + no-progress retry-gated like the manifest, capped at OTA_DIFF_MAX_BLOCKS so the want_mask stays a fixed uint16, and the diff runs a bounded batch per loop tick so it never starves the mesh loop. motatool `serve --seed <build.mota>` injects the seed payload into the destination .part on OP_BEGIN.
2026-07-02 19:03:28 +02:00
Valentin Kivachuk Burda 4a601486ac ota: nRF52 mOTA flash-layout safety net + tests
Route both begin() and reopen() through a pure mota_nrf52_stage_plan() that bottom-aligns a received .mota below the filesystem region (trailer ending at FS_START, where the bootloader scans) and refuses any size that would overrun that ceiling or overlap the running image — the single place the FS/prefs-safe bounds are enforced. Add compile-time static_asserts pinning the flash-layout ordering (app < staging ceiling < bootloader; in-place workspace ends at/below the ceiling) so an inconsistent constant fails the build instead of silently corrupting user prefs. Cover the pure planner in test/test_ota/test_ota_flashplan.cpp.
2026-07-02 19:03:06 +02:00
Valentin Kivachuk Burda 49820b57aa docs: pull a firmware .mota off the mesh into a motatool folder
Document `ota pull <#> <dest>` (flash|folder, destination mandatory), the folder
pull that captures a device's exact firmware to the host as <mid>.mota (for
delta-building), the paused/resume-on-reconnect behaviour, and that a `motatool
serve` link doubles as the pull-to-folder store. (protocol §10, user guide,
motatool README)
2026-07-02 08:52:40 +02:00
Valentin Kivachuk Burda 28e3df02f9 ota: pause a folder pull on link loss, resume + rescan on reconnect
If an `ota pull <#> folder` block-write fails mid-transfer (the motatool seeder
link dropped), the fetch enters a new PAUSED state instead of failing or falling
back to RAM/flash: progress stays on the host, the manager stops requesting, and
loop()/stall-detection leave it untouched (it waits indefinitely). On reconnect
the ESP32 seeder re-registers the folder destination and, if PAUSED, calls
resumeStaged(): OP_STAT re-attaches the host's partial, the leaves are re-read,
and only the missing blocks are re-requested (a brand-new/absent file restarts
from 0). `ota status` reports the paused state.
2026-07-02 08:50:20 +02:00
Valentin Kivachuk Burda 10fa434412 ota: pull a fetched .mota to a host folder (ota pull <#> folder) — firmware side
FolderMotaStore: an OtaStore that streams an in-transit .mota straight to the host
folder over the seeder link (OP_BEGIN/WRITE/SREAD/STAT/FIN) instead of RAM/flash —
the device holds no local staging for it. Wired as a selectable pull destination:

- OtaContext gains a folder_dest (registered by the app while a motatool `serve`
  link is up) + its human id (e.g. "tcp 192.168.4.5").
- `ota pull <#> <dest>` now takes a MANDATORY destination; `ota pull <#>` with none
  lists the choices (flash always; folder + its link id when connected).
- The ESP32 WiFi seeder registers/clears the folder destination on connect/close —
  the same connection both serves the folder and accepts pulls into it.

Captures an exact copy of a device's firmware over the mesh to build a delta
against. Pause/resume on a mid-pull disconnect follows.
2026-07-02 08:44:10 +02:00
Valentin Kivachuk Burda bd2ecb80a7 ota: seeder storage protocol (pull-to-folder) + motatool serve storage handlers
Add the device->host WRITE half of the mota-seeder link so a device can capture
a .mota it is fetching off-mesh into the host folder (the same --dir used for
serving), stored as <mid>.mota — e.g. to grab an exact copy of a device's
firmware to build a delta against firmware you don't otherwise have.

- MotaSeederProto: OP_STAT / OP_BEGIN / OP_WRITE / OP_SREAD / OP_FIN (keyed by
  mid). Resume needs no host bookkeeping: BEGIN 0xFF-fills the file; on reconnect
  the device SREADs the leaves and re-requests only missing blocks (same as flash
  resume). Partial = <midhex>.mota.part, published to <midhex>.mota on FIN.
- motatool `serve --dir <folder>` now also handles the storage ops on the same
  folder/connection (SeederCore gains the store dir; serve_loop frames the
  variable-length WRITE). Host round-trip test added.

Firmware side (FolderMotaStore + `ota pull <#> <dest>` + pause/resume) follows.
2026-07-02 08:32:00 +02:00
Valentin Kivachuk Burda 259802b706 ota: configurable hop limit (ota config hops) + accept-gate + forward RAM guard
Bound OTA-over-LoRa duty cycle across repeaters with one runtime-tunable,
persisted limit (OtaManager::max_hops, `ota config hops <0..8>`, default 3):

- Accept-gate: a node ignores OTA that arrived from more than max_hops hops
  away (neither processes nor relays it). 0 = direct only.
- Forward-cap: relay a flood only while still under max_hops, appending this
  node's path-hash (hop count increments like the mesh flood routing).
- RAM guard: relay an OTA flood only while more than OTA_FWD_MIN_FREE packet-
  pool slots stay free, so heavy OTA (best-effort, lowest-priority) can never
  monopolise the shared pool and starve real traffic — a dropped relay is
  re-requested by the source.

Persisted in NodePrefs (CommonCLI) and shown in `ota config`. Docs updated.
2026-06-30 20:35:48 +02:00
Valentin Kivachuk Burda 9ff1c883c2 ota: configurable advertise interval (default 24h) + advertise on served-set change
The discovery beacon previously re-announced at a random 3-10 min interval.
Replace that with a fixed, user-configurable cadence:

- OtaManager::advert_mins() — re-advertise every N minutes after the boot
  burst; 0 disables periodic re-advertise (boot burst only). Default 24h.
- Persisted in NodePrefs (CommonCLI) and runtime-tunable: `ota config advert
  <minutes>` (0..10080; 0 = off), and shown in `ota config`.
- When periodic advert is disabled, the scheduler still re-checks the config
  on a slow timer, so a later `ota config advert <mins>` takes effect live.

Also advertise immediately whenever the served set changes — when a motatool
folder is attached to / detached from the ESP32 WiFi seeder — so peers learn
about newly-available firmware without waiting for the next interval (the
`ota folder` serial path already announced on attach).

Docs: protocol beacon-cadence note + user-guide `ota config advert`.
2026-06-30 14:29:38 +02:00
Valentin Kivachuk Burda 0a1cf2b231 ota: enable OTA on the nRF52 variants the OTAFIX bootloader supports
Switch these existing variants from `nrf52_base` to `rak4631_hw` (which adds
ENABLE_OTA + the in-place flash store + the EndF post-build hook), so they get
OTA-over-LoRa. Scope is limited to variants already covered by the
Adafruit_nRF52_Bootloader_OTAFIX in-place apply — no new variants are added.
OtaTargets.h is regenerated to include their target ids.
2026-06-29 20:44:59 +02:00
Valentin Kivachuk Burda 4cb118b422 ota: faster post-boot beacon + periodic re-announce + clearer ota ls
Discovery was hard to use — a node only advertised at boot, so a peer that
ran `ota ls` minutes later saw "no neighbours".

- First self-advert ~8s after boot, then a short burst (~1 min), then
  re-announce at a random 3-10 min interval so a long-running node stays
  discoverable without all nodes beaconing in lockstep. The beacon is tiny,
  lowest-priority and duty-gated, so a few-minute cadence is cheap.
- `ota ls` now shows the raw target id (`hw XXXXXXXX`) when the env name is
  not in this build's OtaTargets.h table, instead of a blank "[other hw]".
2026-06-29 20:24:24 +02:00
Valentin Kivachuk Burda 280b9b1555 ota: serve & manage OTA over WiFi (motatool --tcp + ESP32 companion seeder/console)
Extends the USB-serial folder relay to WiFi so an ESP32 companion can both
serve .mota and be operated headlessly:

- motatool `serve --tcp <host[:port]>`: a TcpTransport sibling of the serial
  transport (default port 5001). SeederCore/Folder are reused unchanged — the
  COUNT/DESCRIBE/READ protocol is transport-agnostic.
- ESP32 companion: a dedicated OTA seeder port (5001) for `serve --tcp`, plus
  an OTA text console on 5002 (`nc <ip> 5002` -> `ota status|ls|announce|...`,
  the same handle_ota_command CLI serial nodes have). Both run alongside the
  phone-app port (5000); all three coexist.
- WiFi.setSleep(false): ESP32 STA mode's modem power-save periodically sleeps
  the modem/CPU and stalls the SX1262 SPI+DIO servicing, leaving LoRa deaf
  while WiFi is associated. Disabling it restores the radio (HW-validated:
  a V3 WiFi companion is then discovered over LoRa and discovers its peers).
- docs: serving .mota over WiFi (protocol §10.2 + user guide).
2026-06-29 20:24:24 +02:00
Valentin Kivachuk Burda 54c8b586c1 ota: protocol spec + user guide 2026-06-29 20:24:24 +02:00
Valentin Kivachuk Burda e3dd6b417f ota: native unit tests (format/merkle/detools/apply vectors) 2026-06-29 20:24:24 +02:00
Valentin Kivachuk Burda 2092500d2b ota: motatool — portable C++ .mota packager + relay (build/verify/inspect/serve/keygen) 2026-06-29 20:24:24 +02:00
Valentin Kivachuk Burda 4680d1052f ota: build/board enablement (platformio, build.sh, variants) + Python tooling (.mota reference, EndF/target/vector generators) 2026-06-29 20:24:24 +02:00
Valentin Kivachuk Burda 543c90119e ota: CLI commands + node/CommonCLI integration + example hooks 2026-06-29 20:24:24 +02:00
Valentin Kivachuk Burda 9beaf6848e ota: relay an external folder of .mota over USB serial (MotaSource) 2026-06-29 20:17:07 +02:00
Valentin Kivachuk Burda 9b61169c16 ota: platform apply + flash staging (ESP32 A/B, nRF52 in-place via bootloader) 2026-06-29 20:17:07 +02:00
Valentin Kivachuk Burda 5da783040f ota: LoRa transfer protocol + session manager (discovery, block fetch/serve) 2026-06-29 20:17:07 +02:00
Valentin Kivachuk Burda 6b4f2355e9 ota: vendor detools 0.53.0 in-place/CRLE decoder (NONE+CRLE config) 2026-06-29 20:17:07 +02:00
Valentin Kivachuk Burda 07b20f042e ota: .mota container format, merkle tree, EndF self-identity, signature verify 2026-06-29 20:17:07 +02:00
Liam Cottle 1869b57d62 Merge pull request #2853 from HDDen/dev
Add Data-Type to number_allocations.md
2026-06-29 21:49:19 +12:00
HDDen 58b0f7df9c Update number_allocations.md 2026-06-29 12:41:44 +03:00
HDDen bc35208682 Update number_allocations.md
Added Data-Type range for MeshCore Images codec (range is for small reserve to future versions)
2026-06-28 00:32:22 +03:00
Scott Powell 4f8cb8db78 * ACK packets being 'clipped' (in Dispatcher send). Needed to extend max_airtime timeout calc for short packets 2026-06-27 21:06:01 +10:00
Liam Cottle 5ff39c6243 Merge pull request #2570 from IoTThinks/MCdev-Fixed-flashmode-XiaoC6-202605
Added flash_mode=dio to avoid boot loop when flashing using merge.bin
2026-06-27 11:32:10 +12:00
Liam Cottle dc200cf22d Merge pull request #2639 from sefinek/fix/typos-in-comments
fix: fix typos in source code comments
2026-06-27 11:26:54 +12:00
Liam Cottle 62b95b4e48 Merge pull request #2844 from oltaco/fix-rx-boosted-gain
Fix for Rx boosted gain on LR1110
2026-06-27 11:22:47 +12:00
taco f3d4d8cd5e always save boosted gain setting 2026-06-26 22:36:49 +10:00
Liam Cottle 3d4eec4a6a Merge pull request #1194 from ViezeVingertjes/nibble_zero_connect
Added support for the nibble zero connect
2026-06-26 13:59:59 +12:00
taco b07aba7937 fix: report error when rxgain setting is unsupported or rejected 2026-06-26 08:45:03 +10:00
taco 1f9bb67400 return bool when setting rx boost 2026-06-26 07:44:01 +10:00
ViezeVingertjes b8f1fad654 Add trailing underscore to nibble_screen_connect env names to exclude from automatic builds 2026-06-25 23:27:07 +02:00
ViezeVingertjes eb938a9b78 Address review comments and sync with dev 2026-06-25 23:26:55 +02:00
ViezeVingertjes 69df5c7a95 Remove NeoPixel configuration as its unused. 2026-06-25 23:26:55 +02:00
ViezeVingertjes 9c7d71b9be Added support for the nibble zero connect 2026-06-25 23:26:55 +02:00
taco 5d0ff7fe6e remove guard on MyMesh::setRxBoostedGain() 2026-06-26 07:06:37 +10:00
ripplebiz 3192684582 Merge pull request #2752 from Quency-D/heltec-tower-v2
Add Heltec tower v2
2026-06-23 11:51:03 +10:00
ripplebiz aa1cb1f663 Merge pull request #2765 from fizzyfuzzle/ESP32-Reset-Reason
Add ESP32 Reset Reason to existing pwrmgt.bootreason cli command
2026-06-23 11:41:57 +10:00
ripplebiz 6a63dfce1c Merge pull request #2771 from oltaco/nrf52-framework-buildfix
Point Heltec Mesh Solar and Mesh Pocket at our NRF52 framework fork
2026-06-23 11:37:03 +10:00
Liam Cottle c2cfba4af3 Merge pull request #2810 from IoTThinks/MCDev-Fixed-GPS-Time-for-T114-202606
Fixed GPS time sync for Heltec T114
2026-06-22 14:19:09 +12:00
Kevin Le 62849ef114 Fixed GPS time sync for Heltec T114 2026-06-22 09:13:36 +07:00
ripplebiz 60ea4a91bf Merge pull request #1727 from weebl2000/use-hardware-channel-activity-detection
Use hardware channel activity detection for checking interference
2026-06-15 19:51:59 +10:00
taco dd9b3b32c3 build fix for Heltec Mesh Solar and Mesh Pocket 2026-06-15 00:57:12 +10:00