Add signed XIAO bootloader updates over LoRa
This commit is contained in:
1 parent
eb45e9d4f8
commit
b7c9e37d09
34 files changed
+1604
-78
No files matched your search
@@ -166,6 +166,7 @@ fix, no WiFi connection, an inactive bridge, or an nRF52 bootloader without
|
||||
| LoRa OTA | [`ota get`; `ota pull`; `ota download`](ota_protocol.md#11-cli-surface-otaclicpp) | LoRa OTA build; internal-store nRF52 installs in-place deltas, while matched SD/QSPI nRF52 also accepts full images | No | No | Yes |
|
||||
| LoRa OTA | [`ota install`; `ota apply`; `ota applydelta`](ota_protocol.md#11-cli-surface-otaclicpp) | Compatible bootloader and completed update | No | No | Yes |
|
||||
| LoRa OTA | [`ota rescue install <base_hash16>`](ota_protocol.md#12-apply-bootloader-contract) | Internal-flash nRF52 LoRa OTA build with failed app-side EndF validation | No | No | Feature |
|
||||
| LoRa OTA | [`ota bootloader`; `ota bootloader install <MID8> <HASH16>`](ota_nrf52_qspi.md#explicit-xiao-bootloader-updates-over-lora) | Boot-update-capable XIAO-module QSPI repeater with ABI-3 exact-board OTAFIX | No | No | Feature |
|
||||
| LoRa OTA | [`ota cancel`; `ota drop`; `ota stop`](ota_protocol.md#11-cli-surface-otaclicpp) | LoRa OTA build | No | No | Yes |
|
||||
| LoRa OTA | [`ota announce`; `ota adv`](ota_protocol.md#11-cli-surface-otaclicpp) | LoRa OTA build | No | No | Yes |
|
||||
| LoRa OTA | [`ota self`; `ota id`](ota_protocol.md#11-cli-surface-otaclicpp) | Firmware with EndF trailer | No | No | Yes |
|
||||
@@ -325,6 +326,7 @@ fix, no WiFi connection, an inactive bridge, or an nRF52 bootloader without
|
||||
| LoRa OTA | [`ota get`; `ota pull`; `ota download`](ota_protocol.md#11-cli-surface-otaclicpp) | LoRa OTA build | No | No | Yes | Yes | Yes |
|
||||
| LoRa OTA | [`ota install`; `ota apply`; `ota applydelta`](ota_protocol.md#11-cli-surface-otaclicpp) | Compatible completed update | No | No | Yes | Yes | Yes |
|
||||
| LoRa OTA | [`ota rescue install <base_hash16>`](ota_protocol.md#12-apply-bootloader-contract) | Internal-flash nRF52 LoRa OTA build with failed app-side EndF validation | No | No | Feature | No | No |
|
||||
| LoRa OTA | [`ota bootloader`; `ota bootloader install <MID8> <HASH16>`](ota_nrf52_qspi.md#explicit-xiao-bootloader-updates-over-lora) | nRF52 XIAO QSPI only | No | No | No | No | No |
|
||||
| LoRa OTA | [`ota cancel`; `ota drop`; `ota stop`](ota_protocol.md#11-cli-surface-otaclicpp) | LoRa OTA build | No | No | Yes | Yes | Yes |
|
||||
| LoRa OTA | [`ota announce`; `ota adv`](ota_protocol.md#11-cli-surface-otaclicpp) | LoRa OTA build | No | No | Yes | Yes | Yes |
|
||||
| LoRa OTA | [`ota self`; `ota id`](ota_protocol.md#11-cli-surface-otaclicpp) | Firmware with EndF trailer | No | No | Yes | Yes | Yes |
|
||||
|
||||
@@ -13,8 +13,13 @@ the right container, move the participating nodes to a temporary radio
|
||||
channel, serve and monitor the download, request installation, restore the
|
||||
controller, and check the rebooted node.
|
||||
|
||||
The script cannot install the destination's first OTA-capable firmware or its
|
||||
nRF52 bootloader. Do those one-time jobs over USB before using LoRa OTA.
|
||||
The script cannot install the destination's first OTA-capable firmware. It is
|
||||
also deliberately application-only: it rejects both v3 bootloader containers
|
||||
and a v2 container carrying the bootloader flag, and it never sends the
|
||||
privileged install command. Do the first nRF52 bootloader installation over USB;
|
||||
an already-capable XIAO QSPI repeater may later use the separate, manual
|
||||
[`ota bootloader install`](ota_nrf52_qspi.md#explicit-xiao-bootloader-updates-over-lora)
|
||||
workflow.
|
||||
|
||||
## Required topology
|
||||
|
||||
@@ -425,9 +430,10 @@ the destination.
|
||||
2. Authenticate to the target and query its target ID, hardware, running body
|
||||
hash, firmware version, bootloader version, and nRF52 bootloader
|
||||
capabilities.
|
||||
3. Select or build one compatible mOTA and verify all block hashes, Merkle
|
||||
root, full-image hash where applicable, identity fields, signature, codec,
|
||||
base, and the firmware's 1024-byte maximum block size.
|
||||
3. Select or build one compatible **v2 application** mOTA and verify all block
|
||||
hashes, Merkle root, full-image hash where applicable, identity fields,
|
||||
signature, codec, base, and the firmware's 1024-byte maximum block size.
|
||||
Version-3 bootloader packages are refused before any target state changes.
|
||||
4. Save the controller's normal radio tuple and show the confirmation prompt.
|
||||
5. Start TempRadio on the target, then far-to-near relays, then the source;
|
||||
finally switch the controller to the same tuple and read it back. The runner
|
||||
|
||||
@@ -333,6 +333,10 @@ Discovery is asynchronous. `ota ls` says `refreshing`; wait a few seconds and ru
|
||||
shows an older row. Select `[same target]`: it can say `full` for ESP32 and external SD/QSPI nRF52 targets,
|
||||
or `delta` for any supported nRF52 target. Do not select `[unsupported]` (for example, a source's self-served
|
||||
full image on an internal-staging nRF52).
|
||||
Rows labelled `bootloader` are also outside this ordinary application flow:
|
||||
they are never automatic and `ota install` refuses them. Only an already-capable
|
||||
XIAO QSPI repeater can use the separate
|
||||
[explicit bootloader workflow](ota_nrf52_qspi.md#explicit-xiao-bootloader-updates-over-lora).
|
||||
Use the row's stable eight-hex manifest ID rather than its changing list position:
|
||||
|
||||
```text
|
||||
|
||||
+62
-5
@@ -13,8 +13,9 @@ an update is downloaded.
|
||||
|
||||
## Supported repeater families
|
||||
|
||||
QSPI staging is enabled only for repeater-role environments on these currently
|
||||
matched families:
|
||||
QSPI staging is enabled only for explicitly matched repeater-role environments
|
||||
(and RS232 bridge variants that directly inherit one of those repeater targets)
|
||||
on these currently matched families:
|
||||
|
||||
- Seeed XIAO nRF52840 and XIAO nRF52840 Sense modules, including the
|
||||
`Xiao_nrf52`, SolarXiao 30S/33S, and XIAO-module Ikoka handheld, Nano, and
|
||||
@@ -40,8 +41,8 @@ T-Echo target.
|
||||
Companion builds are intentionally excluded. Some companion targets use the
|
||||
same external QSPI as a LittleFS message/data store, where raw OTA staging
|
||||
would corrupt the filesystem; other companions simply do not assign that chip
|
||||
to OTA. Room-server, sensor, KISS, and repeater-bridge roles are also unchanged.
|
||||
Raw QSPI OTA is scoped to the explicitly matched repeater environments.
|
||||
to OTA. Room-server, sensor, and KISS roles are unchanged. Raw QSPI OTA is
|
||||
scoped to the explicitly matched repeater-derived environments.
|
||||
|
||||
### RAK15001 placement and module conflicts
|
||||
|
||||
@@ -135,13 +136,21 @@ starting another pull; later capacity probes preserve that failure detail.
|
||||
The store reads the JEDEC capacity at runtime and accepts supported 1 MiB
|
||||
through 16 MiB devices using 24-bit addressing. QSPI capacity is not the final
|
||||
firmware limit. The reconstructed application, including its 56-byte `EndF`
|
||||
trailer, must fit below InternalFS at `0xED000`:
|
||||
trailer, must fit its build's linked application region:
|
||||
|
||||
| SoftDevice layout | Application region | Maximum image |
|
||||
| --- | --- | --- |
|
||||
| S140 v7, boot-update-capable XIAO module | `0x27000..0xE0000` | `0xB9000` (757,760 bytes) |
|
||||
| S140 v7, app base `0x27000` | `0x27000..0xED000` | `0xC6000` (811,008 bytes) |
|
||||
| S140 v6, app base `0x26000` | `0x26000..0xED000` | `0xC7000` (815,104 bytes) |
|
||||
|
||||
The XIAO limit is deliberately 52 KiB smaller. Its linker and post-link record
|
||||
cap every ordinary application at `0xE0000`; OTAFIX reserves
|
||||
`0xE0000..0xEA000` as a 40 KiB self-update scratch bank, with the remaining gap
|
||||
left unused before InternalFS. Full and delta application packages for these
|
||||
targets derive their effective application end from that `0xE0000` record and
|
||||
are rejected if their reconstructed image or detools geometry crosses it.
|
||||
|
||||
A full package needs only the new raw `firmware.hex` or non-merged application
|
||||
image. An in-place delta still needs the exact image currently running. The
|
||||
automation uses a conservative `0xC6000` detools workspace for external nRF52
|
||||
@@ -165,6 +174,54 @@ operator can deliberately override the routing target for a role change, so
|
||||
`target_id` is not an apply-time safety assertion; the destination still
|
||||
enforces the package's hardware identity before approval.
|
||||
|
||||
## Explicit XIAO bootloader updates over LoRa
|
||||
|
||||
Bootloader delivery is available only when all of these are already true:
|
||||
|
||||
- the application is an `OTA_QSPI_BOOTLOADER_UPDATE` XIAO-module repeater build
|
||||
linked below `0xE0000`;
|
||||
- `ota bootloader` shows a CRC-valid installed `XIAO_DFU` embedded identity for
|
||||
board ID `28860044` (base) or `28860045` (Sense);
|
||||
- the installed OTAFIX marker reports ABI 3 or newer and both QSPI (`0x04`) and
|
||||
boot-update (`0x08`) capability bits;
|
||||
- the package is the exact signed v3/40-KiB/1-KiB-block profile for that board,
|
||||
and its signer is already in `ota key`'s trusted allowlist.
|
||||
|
||||
This is not part of normal automation. Bootloader catalog rows are labelled
|
||||
`bootloader`; even a capable node never autofetches or autoinstalls them, and
|
||||
ordinary `ota install` rejects them in every application backend. The
|
||||
`tools/lora_ota` deployment runner also refuses v3 packages. Fetch and arm one
|
||||
only with the explicit flow:
|
||||
|
||||
```text
|
||||
ota ls
|
||||
ota pull <MID8> flash
|
||||
# wait for ota status to report the same bootloader download as ready
|
||||
ota bootloader
|
||||
# copy the exact mid= and hash= values printed above
|
||||
ota bootloader install <MID8> <HASH16>
|
||||
```
|
||||
|
||||
The pull command is only transport intent; it does not authorize an install.
|
||||
The final command must reproduce both the complete staged manifest ID and the
|
||||
first eight bytes of its signed image hash. Before approval the application
|
||||
again checks package/root/payload/image hashes, Ed25519 signature and trusted
|
||||
allowlist, exact signed `XIAO_BL_...` ID, installed and incoming embedded
|
||||
manifest/CRC/name/board identity, vector table, and ABI-3 QSPI+boot-update
|
||||
continuity. A signed older bootloader that would remove remote update support
|
||||
is refused.
|
||||
|
||||
After the reply drains, GPREGRET `0x6B` and GPREGRET2 `0x51` enter the special
|
||||
OTAFIX path. OTAFIX independently rechecks the package before using the
|
||||
reserved scratch bank to replace its own `0xF4000..0xFE000` region. The running
|
||||
application remains preserved; a rejected candidate returns to it unchanged.
|
||||
Post-reboot `ota status` reports bootloader-update diagnostics as `blup:C0` to
|
||||
`blup:CF` (`blup:C8` is success), separately from ordinary application `blrc`.
|
||||
|
||||
This feature cannot update a stock or old bootloader that lacks the capability
|
||||
marker: perform the first exact-board combined bootloader+SoftDevice migration
|
||||
over USB/BLE DFU or SWD. Do not attempt to bootstrap it with a v3 package.
|
||||
|
||||
## Storage ownership and recovery
|
||||
|
||||
The QSPI store is raw, not a file inside LittleFS. It owns the flash from
|
||||
|
||||
+50
-10
@@ -61,11 +61,13 @@ the authoritative reference for byte-level details.
|
||||
| Container `TRAILER` | `76 6B 34 39 36` | `vk496` |
|
||||
| `EndF` marker | `45 6E 64 46` | `EndF` |
|
||||
| `hash_algo` (sha2-256) | `0x12` | multihash code |
|
||||
| `format_ver` | `0x02` | this spec |
|
||||
| application `format_ver` | `0x02` | ordinary full/delta application package |
|
||||
| bootloader `format_ver` | `0x03` | privileged XIAO bootloader package only |
|
||||
| `approval` = not approved | `FF FF FF FF` | erased NOR word |
|
||||
| `approval` = approved | `41 50 52 56` | `APRV` |
|
||||
| `MFLAG_FULL` | `0x01` | flags bit0 |
|
||||
| `MFLAG_SIGNED` | `0x02` | flags bit1 |
|
||||
| `MFLAG_BOOTLOADER` | `0x04` | flags bit2; valid only in the exact v3 bootloader profile |
|
||||
| `CODEC_FULL` / `_SEQUENTIAL` / `_INPLACE` | `0` / `1` / `2` | Section 5 |
|
||||
| `PAYLOAD_TYPE_OTA` | `0x0C` | MeshCore packet type (`src/Packet.h`) |
|
||||
| `MAX_PACKET_PAYLOAD` | `184` | usable bytes per packet (`src/MeshCore.h`) |
|
||||
@@ -209,8 +211,8 @@ Only `leaves[]` is variable (one 4-byte hash per block). So the manifest-minus-l
|
||||
|
||||
```
|
||||
off size field notes
|
||||
0 1 format_ver = 0x02
|
||||
1 1 flags bit0 FULL (0=delta/partial, 1=full image); bit1 SIGNED; bits2-7 reserved 0
|
||||
0 1 format_ver = 0x02 application, or 0x03 privileged bootloader package
|
||||
1 1 flags bit0 FULL; bit1 SIGNED; bit2 BOOTLOADER; bits3-7 reserved 0
|
||||
2 1 hash_algo 0x12 = sha2-256
|
||||
3 4 target_id device/arch/role discriminator (Section 9)
|
||||
7 4 fw_version MAJOR<<24 | MINOR<<16 | PATCH<<8 | pre (comparable uint32)
|
||||
@@ -237,6 +239,11 @@ Manifest-minus-leaves size (`mfl`) is a constant **197 bytes** for every contain
|
||||
or unsigned). At 197 bytes the manifest exceeds one packet, so `OTA_MANIFEST` is always sent multi-fragment
|
||||
(Section 8.4, 2 fragments) and reassembled by the fetcher.
|
||||
|
||||
The two versions are deliberately disjoint. Version 2 accepts application packages only and rejects the
|
||||
BOOTLOADER bit. Version 3 accepts only flags exactly `FULL|SIGNED|BOOTLOADER`; a non-bootloader v3 package
|
||||
is invalid. Consequently, deployed v2-only application parsers reject a bootloader package before they can
|
||||
mistake its raw 40 KiB payload for an application image.
|
||||
|
||||
### 4.1 Signed region
|
||||
|
||||
`signature` covers manifest bytes `[0, 129)` - the head + `base_hash` + `signer_pubkey`. It does **not**
|
||||
@@ -253,6 +260,23 @@ cover `approval` or `leaves[]`:
|
||||
- Bound to this image (lives in this `.mota`'s manifest, re-erased when a new `.mota` is staged).
|
||||
- A **consent** marker, not a security primitive. Authenticity = `signature` + `image_hash` + `hw_id`.
|
||||
|
||||
### 4.3 Privileged XIAO bootloader package profile
|
||||
|
||||
A v3 bootloader package has a deliberately narrow, non-extensible profile:
|
||||
|
||||
- flags exactly `FULL|SIGNED|BOOTLOADER`, `CODEC_FULL`, nonzero `fw_version`, zero `base_hash`;
|
||||
- a raw payload and `image_size` of exactly `0xA000` (40 KiB), split into exactly forty 1024-byte blocks;
|
||||
- `target_id` equal to the installed OTAFIX embedded board ID (`0x28860044` for XIAO nRF52840 or
|
||||
`0x28860045` for XIAO nRF52840 Sense);
|
||||
- signed `hw_id` exactly `XIAO_BL_28860044` or `XIAO_BL_28860045`, derived from that board ID;
|
||||
- a sane nRF52840 vector table, a CRC-valid embedded manifest v1 with the exact padded device name
|
||||
`XIAO_DFU`, and a `MOTABLDR` marker advertising ABI >= 3, full codec, QSPI, and boot-update continuity.
|
||||
|
||||
The incoming embedded identity must exactly match the installed CRC-valid bootloader identity. Both scans
|
||||
consider every aligned structurally valid candidate so magic bytes in a literal pool cannot shadow the real
|
||||
manifest. A package must be signed by a key already in the device's trusted allowlist; unlike ordinary
|
||||
application packages, there is no unsigned manual-install exception.
|
||||
|
||||
---
|
||||
|
||||
## 5. Payload, codecs & delta base
|
||||
@@ -746,6 +770,9 @@ ota get | pull | download <mid8|#index> flash [rescue] | folder [validate]
|
||||
fetch by stable mid8 (preferred) or current page index
|
||||
ota install | apply | applydelta verify + approve + (ESP32) apply / (nRF52) reboot-to-bootloader
|
||||
ota rescue install <base_hash16> internal-flash nRF52 only: recover from failed app-side EndF validation
|
||||
ota bootloader [status] capable XIAO QSPI repeater: installed BL identity/caps + staged confirmation
|
||||
ota bootloader install <MID8> <HASH16>
|
||||
explicitly verify/arm one complete trusted v3 package; never automatic
|
||||
ota cancel | drop | stop drop the current fetch session (frees the slot)
|
||||
ota announce | adv serve self + send a beacon now
|
||||
ota self | id print this firmware's EndF (body/image size, base_hash)
|
||||
@@ -817,10 +844,22 @@ ota dev ... bring-up helpers (stage/recv/serve/verify)
|
||||
complete internal application region as workspace. Companion builds never enable this raw store: some use
|
||||
QSPI as a filesystem, while others simply leave that chip outside OTA ownership. See
|
||||
[the nRF52 QSPI guide](ota_nrf52_qspi.md).
|
||||
- **XIAO bootloader self-update (explicit only):** selected XIAO-module QSPI repeater builds link the
|
||||
ordinary application below `0xE0000`, reserving `0xE0000..0xEA000` as a 40 KiB internal scratch bank.
|
||||
They accept a v3 bootloader package only through an exact manual MID pull. Ordinary `ota install`,
|
||||
autofetch, autoinstall, and every application apply backend reject it. The operator then copies the
|
||||
staged package's exact values from `ota bootloader` into
|
||||
`ota bootloader install <MID8> <HASH16>`. The app repeats the strict v3 geometry, installed/candidate
|
||||
identity, vectors, embedded CRC/capabilities, complete payload/image hashes, signature, and trusted-key
|
||||
gates before writing `APRV`. GPREGRET `0x6B` plus GPREGRET2 `0x51` hands the QSPI package to OTAFIX.
|
||||
OTAFIX independently repeats all privileged checks, uses the scratch bank to preserve the running
|
||||
application while replacing `0xF4000..0xFE000`, and reports boot-update results in GPREGRET2 `0xC0..0xCF`
|
||||
(`0xC8` success). This mechanism cannot bootstrap a stock/older bootloader; install an ABI-3,
|
||||
boot-update-capable exact-board OTAFIX over USB/BLE DFU or SWD once first.
|
||||
|
||||
A signature, when present, proves author authenticity and must pass the device allowlist. Unsigned packages
|
||||
remain installable when local policy permits them. The one-shot `approval` marker records local consent for
|
||||
either form before the bootloader may apply it.
|
||||
A signature, when present, proves author authenticity and must pass the device allowlist. Unsigned v2
|
||||
application packages remain installable when local policy permits them. A v3 bootloader package is always
|
||||
signed and trusted. The one-shot `approval` marker records local consent before the bootloader may apply it.
|
||||
|
||||
> **Bootloader testing note:** always test apply with a *real different* image (base != target). A same-image
|
||||
> (X->X) "delta" trivially reproduces the target and gives a false positive.
|
||||
@@ -829,7 +868,8 @@ either form before the bootloader may apply it.
|
||||
|
||||
## 13. Versioning of this spec
|
||||
|
||||
`format_ver = 2`. A parser accepts exactly this value and rejects anything else - there is one container
|
||||
format, fixed-layout, and no compatibility shims to carry. If the format ever needs to change, bump
|
||||
`format_ver`; the multihash `hash_algo` separately allows swapping the digest family without a format
|
||||
bump. Unknown `codec_id` / `ota_msg_type` values are ignored (a node simply won't fetch what it can't apply).
|
||||
The fixed byte layout has two intentionally disjoint profiles: `format_ver = 2` for ordinary application
|
||||
packages and `format_ver = 3` only for the exact privileged bootloader profile in Section 4.3. A parser must
|
||||
reject v2+BOOTLOADER, v3 without exact `FULL|SIGNED|BOOTLOADER`, and every other version. The multihash
|
||||
`hash_algo` separately allows swapping the digest family without a format bump. Unknown `codec_id` /
|
||||
`ota_msg_type` values are ignored (a node simply will not fetch what it cannot apply).
|
||||
@@ -216,6 +216,40 @@ rejected; trusted signed images can auto-install only when that policy is enable
|
||||
|
||||
After it reboots, run `ota status` to confirm the new version.
|
||||
|
||||
### Updating a XIAO bootloader (advanced, explicit only)
|
||||
|
||||
This is available only on the specially marked XIAO nRF52840/Sense QSPI
|
||||
repeater builds after a one-time exact-board ABI-3 OTAFIX installation over
|
||||
USB/BLE DFU or SWD. It is not the normal firmware update path. Check support
|
||||
first:
|
||||
|
||||
```text
|
||||
ota bootloader
|
||||
```
|
||||
|
||||
The reply must show a valid `XIAO_DFU` board identity plus ABI 3 and the QSPI /
|
||||
boot-update capability bits. A bootloader package appears as `bootloader` in
|
||||
`ota ls`. It is never downloaded or installed automatically, even if both OTA
|
||||
automation settings are enabled. Use its stable ID explicitly:
|
||||
|
||||
```text
|
||||
ota pull <MID8> flash
|
||||
# wait until ota status says this bootloader download is ready
|
||||
ota bootloader
|
||||
ota bootloader install <MID8> <HASH16>
|
||||
```
|
||||
|
||||
Copy both confirmation values exactly from the second `ota bootloader` reply.
|
||||
Ordinary `ota install` deliberately refuses this package. The privileged
|
||||
command requires an exact 40 KiB candidate for the installed XIAO board, a
|
||||
valid embedded identity/CRC and vector table, continued boot-update support,
|
||||
and a valid signature from a key already in `ota key`'s trusted allowlist. It
|
||||
preserves the running application while OTAFIX replaces itself; `blup:C8` in
|
||||
post-reboot `ota status` means success. Any node lacking this command or those
|
||||
capabilities must update its bootloader locally instead. See
|
||||
[the nRF52 QSPI guide](ota_nrf52_qspi.md#explicit-xiao-bootloader-updates-over-lora)
|
||||
for the complete safety contract.
|
||||
|
||||
### 5. If something goes wrong
|
||||
|
||||
- A download that stalls or gets interrupted just **resumes** later, or you can `ota cancel` and try again.
|
||||
|
||||
Reference in new issue
Block a user