Add Wi-Fi OTA partition migration support

This commit is contained in:
mikecarper committed 2026-09-19 20:14:37 -07:00
1 parent 69681a2db6
commit 9844982b00
20 files changed
+1637 -62

No files matched your search

+6 -2
View File
@@ -28,7 +28,7 @@ and partition policy:
| Selection | Behavior |
| --- | --- |
| `auto` | For one explicit target, pass 1 builds the complete supported LoRa-OTA-capable recipe. ESP32 boards with a qualified expanded profile use it; other repeaters attempt the complete recipe in their current application region. A non-repeater keeps every capability declared by its resolved PlatformIO recipe, including LoRa OTA, and fails instead of silently removing one that does not fit. A measured repeater flash/partition overflow starts the standard `no_external_sensors` LoRa OTA pass. Internal-flash nRF52 repeaters publish that reduced pass even when the complete image fits, because the smaller running image leaves more room to stage a delta; matched QSPI/SD repeaters do not need the redundant artifact. Compiler errors and missing-capability checks never trigger or conceal a reduced build. Canonical bulk commands keep their established standard partition contract. |
| `auto` | For one explicit target, pass 1 builds the complete supported LoRa-OTA-capable recipe. ESP32 boards with a qualified expanded profile use it; other standalone repeaters and room servers attempt the complete recipe in their current application region. Other roles keep every capability declared by their resolved PlatformIO recipe, including LoRa OTA, and fail instead of silently removing one that does not fit. A measured repeater or room-server flash/partition overflow starts the standard `no_external_sensors` LoRa OTA pass. Internal-flash nRF52 repeaters and room servers publish that reduced pass even when the complete image fits, because the smaller running image leaves more room to stage a delta; matched QSPI/SD roles do not need the redundant artifact. Compiler errors and missing-capability checks never trigger or conceal a reduced build. Canonical bulk commands keep their established standard partition contract. |
| `standard` | Immediately uses the deployed/portable partition contract and its documented reductions. This is useful when the operator already knows the expanded or complete image is unsuitable. |
| `full` | Requires a qualified ESP32 expanded-partition target (or an explicitly named Full Companion). Install a matching merged image when this changes the partition table. |
@@ -60,6 +60,10 @@ canonical Full image under the normal target identity. Install its matching
merged image over USB once; mOTA rejects the incompatible partition signature
until that migration is complete, then later Full updates use the normal
target ID. The portable image remains available while deployed nodes move.
Legacy supported ESP32 Wi-Fi repeaters can use the
[Wi-Fi partition migration](esp32_wifi_partition_migration.md) bridge to
preserve their identity and install an expanded Full image without a USB flash.
The default `cascade` settings profile enables device and LoRa RX power saving;
saved preferences take precedence, and active USB/network services can prevent
device sleep. `--profile default` instead uses the upstream power-saving defaults.
@@ -96,7 +100,7 @@ getters; relaying a command over LoRa keeps its remote restrictions.
| Standard non-MQTT repeater or room server | Keeps the normal role CLI and, where USB is a safe plaintext console, embeds debug/packet logging behind persistent `get/set usb.logging`. The explicitly selected portable policy can omit WebConfig and browser WiFi OTA, so those commands are unavailable and the omission is recorded in the capability manifest. |
| Legacy standard logging | No longer emitted separately. Its behavior is compiled into the ordinary artifact. Size-constrained STM32 targets embed packet logging without verbose `MESH_DEBUG`. |
| LoRa-OTA (`-ota-`) | LoRa OTA adds the `ota ...` commands; it does not otherwise reduce the role CLI. ESP32 `no_external_sensors` artifacts retain the compact browser WiFi uploader, the complete CLI, and up to 254 neighbors, subject to recorded internal-DRAM reductions. |
| Internal-flash nRF52 repeater auto pair | `full-ota` retains the board's external-sensor drivers; `reduced-ota` omits the declared optional sensors to leave additional internal-flash staging room. RAK3401 and RAK4631 reduced builds retain INA219, INA226, INA260, and INA3221 I2C voltage/current monitors at a measured cost below 5 KiB. Both artifacts carry the same stable OTA target identity and are checked for `ota ...` and `retry.preset`; RAK artifacts also verify the retained monitor drivers. |
| Internal-flash nRF52 repeater/room-server auto pair | `full-ota` retains the board's external-sensor drivers; `reduced-ota` omits the declared optional sensors to leave additional internal-flash staging room. RAK3401 and RAK4631 reduced builds retain INA219, INA226, INA260, and INA3221 I2C voltage/current monitors at a measured cost below 5 KiB. Both artifacts carry the same stable OTA target identity and are checked for `ota ...` and `retry.preset`; RAK artifacts also verify the retained monitor drivers. |
| ESP32 MQTT observer or ESP-NOW bridge | Always uses the expanded FULL partition profile. The build never substitutes a reduced CLI to fit the legacy application slot. |
| FULL ESP32 USB + WiFi | Uses the matching MQTT target with packet logging on, verbose debug off, and the complete command surface supported by that role and hardware. `get/set logging.output off\|usb\|wifi\|both` selects and persists the active output paths. |
| FULL ESP32 logging fallback | Uses the matching non-MQTT target only when no WiFi MQTT sibling exists, with debug and packet logging enabled and the complete command surface supported by that role and hardware. Its persistent USB gate also covers output-off operation, avoiding a second FULL ESP-NOW image. |
+84
View File
@@ -0,0 +1,84 @@
# ESP32 legacy-partition migration over Wi-Fi
The partition-migration bridge lets a supported ESP32 node move from a small
dual-OTA layout to a verified larger dual-OTA layout without cable flashing.
It is designed for inaccessible repeaters: the bridge itself fits a legacy
1.25 MiB slot, replaces the table from Wi-Fi, and then exposes Wi-Fi again for
the full application image.
It currently has explicit, byte-for-byte generated target plans for Arduino
ESP32 `default_8MB.csv` and `default_16MB.csv`. It does not guess a table for
other flash sizes. Adding a board later means adding one reviewed target plan
and its generated table-prefix test; the bridge core is otherwise shared.
| Flash size | Target table | app0 / app1 size | Typical board |
| --- | --- | --- | --- |
| 8 MiB | `default_8MB.csv` | 0x330000 / 0x330000 | Seeed XIAO ESP32-S3 |
| 16 MiB | `default_16MB.csv` | 0x640000 / 0x640000 | Heltec V4 / V4.3 OLED |
## What the bridge preserves
Before it touches the partition table, the bridge reads the historical
`/identity/_main.id` SPIFFS file. It requires all 96 bytes (32-byte public key
followed by its 64-byte private key), stages them in an NVS namespace that is
unchanged by both target layouts, then changes the table. On the first boot
with the expanded layout it writes the staged value into SPIFFS, reads it back
byte-for-byte, and only then clears the NVS staging record and offers the final
uploader.
The private identity is the guaranteed preservation boundary. The old SPIFFS
image is deliberately not raw-copied into an expanded partition: SPIFFS is not
safe to resize that way. Other SPIFFS-backed settings can be recreated after
the full image boots.
## Eligible source layout
The bridge only accepts a source table that has all of the following:
- NVS at `0x9000`, size `0x5000`, and OTA metadata at `0xE000`, size `0x2000`.
- Two distinct, non-empty OTA application slots and a non-empty SPIFFS
partition, all inside the physical flash size.
- A known exact 8 MiB or 16 MiB physical flash capacity and a source table
different from that capacity's target table.
This means the source app-slot and SPIFFS sizes can vary; the bridge validates
the live geometry instead of carrying board-name rules. It also ensures it is
running from one source OTA slot. If it arrived in B, it CRC-copies itself to
the future A address, selects A in OTA metadata, writes the table, and
restarts. It therefore works whether the browser OTA updater placed the bridge
in legacy A or B.
Keep power stable while the bridge is replacing the 4 KiB table sector. A loss
of power before that point leaves the old table and source intact. After that
small critical write, the selected A copy of the bridge is the recovery path.
## Build and migrate a Seeed XIAO ESP32-S3
The production bridge is a legacy-slot application image:
```powershell
& "$env:USERPROFILE\.platformio\penv\Scripts\pio.exe" run -e xiao_s3_partition_migrator
```
Build the Full XIAO image with its 8 MiB table:
```powershell
$env:MESHCORE_ESP32_FULL_BUILD = '1'
& "$env:USERPROFILE\.platformio\penv\Scripts\pio.exe" run -e Xiao_S3_WIO_repeater_observer_mqtt
```
Upload the bridge through the legacy node's existing Wi-Fi browser updater.
Then join `MeshCore-Migrate` (password `meshcore-migrate`) and wait for
**Expanded layout ready**. Upload the Full app-only `.bin` from the second
build at `/update`. Do not upload an `-merged.bin`: merged images include
bootloader and table offsets for cable flashing, not browser OTA.
`xiao_s3_partition_legacy_seed` is a disposable-hardware test image only. It
models the legacy table and an identity file; it is not a deployable repeater.
## Heltec V4 / V4.3
Build `heltec_v4_partition_migrator`, upload it through the legacy Wi-Fi
updater, then upload the Full V4 app-only image after the bridge reports ready.
The 16 MiB target table creates two 6.25 MiB OTA slots. See the
[V4 build notes](heltec_v4_wifi_partition_migration.md) for its build command.
@@ -0,0 +1,22 @@
# Heltec V4 legacy-partition migration over Wi-Fi
Heltec V4/V4.3 OLED repeaters with their normal 16 MiB flash use the shared
[ESP32 Wi-Fi partition migration](esp32_wifi_partition_migration.md) bridge.
It changes Arduino's old `default.csv` layout, with two 1.25 MiB OTA slots,
to `default_16MB.csv`, with two 6.25 MiB OTA slots.
Build the bridge application image:
```powershell
& "$env:USERPROFILE\.platformio\penv\Scripts\pio.exe" run -e heltec_v4_partition_migrator
```
Upload `.pio/build/heltec_v4_partition_migrator/firmware.bin` through the
legacy browser Wi-Fi updater. Rejoin `MeshCore-Migrate` with password
`meshcore-migrate`; when it reports **Expanded layout ready**, upload the
app-only Full V4 repeater image at `/update`.
Do not use an `-merged.bin` in either browser uploader. Merged images contain
bootloader and table offsets for cable flashing. The bridge preserves the
private identity; other SPIFFS-backed settings may be recreated after the
Full image starts.
+7 -6
View File
@@ -82,7 +82,7 @@ Both paths require:
- A destination artifact explicitly identified by its release table as install-capable. Some lean internal
nRF52 builds carry `lora_ota_no_external_sensors` in the filename, while matched QSPI boards enable install
support in the normal full-sensor repeater artifact, so filename text alone is not authoritative. Confirm
support in the normal full-sensor repeater or room-server artifact, so filename text alone is not authoritative. Confirm
support with `ota self` and `ota status`. Intermediate repeaters do **not** need an install-capable build:
current repeater firmware relays OTA packets opaquely without storing or installing them.
- An OTA-enabled MeshCore source connected to the computer by USB serial, or
@@ -94,8 +94,9 @@ apply their normal forwarding filters, duplicate checks, and flood limits; they
payload. If any required window closes, the transfer stops making progress and can resume during a later
overlapping window.
`build.sh` provides a `*_repeater_lora_ota_no_external_sensors` build for standalone ESP32 and nRF52 repeater
targets that need a smaller internal update workspace. Those siblings omit selected optional environmental
`build.sh` provides a `*_repeater_lora_ota_no_external_sensors` or
`*_room_server_lora_ota_no_external_sensors` build for standalone ESP32 and nRF52
infrastructure targets that need a smaller internal update workspace. Those siblings omit selected optional environmental
and ranging drivers while retaining board-native features such as displays, buttons, battery monitoring,
and GPS where the target uses the GPS-preserving lean profile. RAK3401 and RAK4631 reduced builds also
retain INA219, INA226, INA260, and INA3221 I2C voltage/current monitors; together these drivers cost less
@@ -116,7 +117,7 @@ bus at those addresses. Keep RAK12500 at `0x42`, strap INA3221 A0 to SCL for `0x
Selected nRF52 boards with matched external
QSPI application and bootloader support can instead make the normal full-sensor
repeater install-capable; those targets do not need to reserve internal flash
repeater or room-server install-capable; those targets do not need to reserve internal flash
for the downloaded container. SolarXiao 30S and 33S use this matched external-QSPI
path and therefore do not emit redundant no-external-sensors siblings. A
RAK19007 can use the same separately wired W25Q16 with either RAK4631 or
@@ -131,13 +132,13 @@ as recorded in their capability manifests. RP2040 and STM32
repeaters do not currently have a safe self-apply path, but current repeater
firmware can still relay OTA packets opaquely during TempRadio.
For one explicitly selected internal-flash nRF52 repeater, the default
For one explicitly selected internal-flash nRF52 repeater or room server, the default
`--build-profile auto` run emits two install-capable choices. The
`*-full-ota-*` artifact retains external sensors, while the
`*_lora_ota_no_external_sensors-reduced-ota-*` artifact trades only those
optional drivers not explicitly retained by the board profile for more delta-staging space. They retain the same OTA target
identity so update tooling does not confuse the optimization choice with a
different board. QSPI- and SD-backed repeaters emit only the complete choice
different board. QSPI- and SD-backed repeater and room-server roles emit only the complete choice
unless a measured size failure requires a fallback.
nRF52 `-ota-` siblings are compiled with size optimization instead of the Adafruit platform's default
+12 -10
View File
@@ -133,12 +133,13 @@ artifacts, including room, sensor, and repeater roles, must fit the legacy slot
limit and the target's actual app partition. The ESP32-C6 `no_external_sensors` OTA siblings are the narrow
exception: the Arduino 3.x WiFi runtime cannot fit that cross-family ceiling, so those images retain their
established target-specific 1920 KiB or larger A/B app layout and are checked against the actual app
partition. For standalone ESP32 and nRF52 repeaters that need a lean staging
profile, `build.sh` also exposes an explicit `*_lora_ota_no_external_sensors`
artifact: the ordinary repeater remains sensor-enabled, while that sibling
trims selected optional environmental/ranging drivers for LoRa distribution. SolarXiao 30S and 33S use
matched external QSPI staging, so their ordinary full-sensor repeater is already install-capable and no
redundant lean sibling is generated. Integrated GPS and other
partition. For standalone ESP32 and nRF52 repeater and room-server roles that
need a lean staging profile, `build.sh` also exposes an explicit
`*_lora_ota_no_external_sensors` artifact: the ordinary role remains
sensor-enabled, while that sibling trims selected optional environmental/ranging
drivers for LoRa distribution. SolarXiao 30S and 33S use matched external QSPI
staging, so their ordinary full-sensor repeater and room-server images are
already install-capable and no redundant lean sibling is generated. Integrated GPS and other
board-native telemetry remain enabled where the target selects the GPS-preserving lean profile. The legacy
suffix describes a driver trim, not removal of the generic I2C bus. Reduced RAK3401 and RAK4631 profiles
retain INA219, INA226, INA260, and INA3221 voltage/current monitors. These are retained optional-sensor-table
@@ -167,9 +168,10 @@ WiFi-heavy non-companion roles are not reduced to fit the legacy application slo
promotes every ESP32 MQTT observer and ESP-NOW bridge to the expanded FULL partition profile. These artifacts
retain the complete role CLI, WebConfig where supported, display and optional sensor support, full timezone
and TLS behavior, and the board's normal power-management implementation. The compact CLI is not compiled
into any build. Ordinary repeater builds remain sensor-enabled; only explicitly named
`*_lora_ota_no_external_sensors` siblings trim selected optional environmental/ranging drivers for LoRa
distribution, and those siblings retain the complete CLI and target-declared I2C peripherals.
into any build. Ordinary repeater and room-server builds remain sensor-enabled;
only explicitly named `*_lora_ota_no_external_sensors` siblings trim selected
optional environmental/ranging drivers for LoRa distribution, and those
siblings retain the complete CLI and target-declared I2C peripherals.
MQTT observer radio and bridge preferences use verified temporary files plus a recoverable backup. A reset
during a settings save restores the last committed common preference image or publishes the completed new
@@ -192,7 +194,7 @@ full ElegantOTA where that target declares the required library, and LoRa OTA fo
including room servers, sensors, observers, and bridges. They use expanded A/B partition
tables: 1984 KiB application slots on 4 MiB boards and the framework's larger dual-OTA tables on 8 MiB
and 16 MiB boards. Explicit `*_lora_ota_no_external_sensors` targets are not duplicated; their ordinary
repeater build is the FULL, sensor-enabled counterpart. The
repeater or room-server build is the FULL, sensor-enabled counterpart. The
`*-full-usb-wifi-ota-*` profile enables USB packet logging and MQTT, with a
persistent `logging.output` selector; its verbose internal debug remains off.
The fallback `*-full-logging-ota-*` profile enables USB debug and packet