Skip to content

Firmware Updates

Roman Kuraev edited this page Jul 10, 2026 · 2 revisions

Firmware Updates

Rewair updates the STM32F411 application from the device portal. The packed web UI is linked into the application image, so firmware and portal assets are installed and rolled back together. F103 firmware is not part of this process.

User flow

The initial Rewair installation must program the OTA-capable bootloader over SWD. The precompiled installer and source-build flash path both do this; see Getting Started or Building and Flashing.

After bootstrap, open Settings → Firmware → Update in the device UI and select the raw F411 application .bin. A source build produces it under:

../third_party/wiced-emw3165/build/
  rewair_local_bridge-AWAIR-FreeRTOS-LwIP-SDIO/binary/
  rewair_local_bridge-AWAIR-FreeRTOS-LwIP-SDIO.bin

For automated bench work, scripts/ota_upload.py <device-ip> <image.bin> uses the same protocol as the portal.

External-flash layout

Region Purpose
0x000000–0x07FFFF Incoming image; header at 0x000000, data at 0x000100
0x080000–0x0FFFFF Known-good copy of the complete 464 KiB app region
0x100000–0x100FFF Append-only, CRC-protected state journal
0x101000–0x101FFF WICED application lookup table
0x102000–0x135FFF BCM43362A2 WLAN firmware
0x136000–0x1FFFFF Reserved/free

The upload API accepts sequential 16 KiB chunks. The device calculates its own CRC, reads the staged bytes back, validates size and the STM32 vector table, writes the staging header last, and only then marks the image ready.

Boot and rollback sequence

  1. The bootloader copies the current internal app region to the known-good external slot and verifies its CRC.
  2. It copies the staged image into internal sectors 3–7. The operation is idempotent; an interrupted copy is repeated on the next boot.
  3. The new image remains a trial until the RWFS image validates and the HTTP server has stayed healthy for 15 seconds. A six-minute monitor also covers slow station-to-setup-AP fallback.
  4. Three unconfirmed trial boots restore and verify the known-good image.

A partial upload has neither a valid header nor a ready journal entry, so it cannot replace the running application.

Security boundary

OTA checks CRC, image size, and vector addresses, but it does not verify a cryptographic signature. Use it only on a trusted local network. Firmware OTA is not exposed over the unauthenticated Bluetooth transport.

Platform constraints

The F411 has 512 KiB of internal flash and the application occupies sectors 3–7. Rewair uses a part-specific erase path because the generic WICED F4 helper continues into sectors that do not exist on the STM32F411CE.

Bench status

Normal upload, install, reboot, and health confirmation have passed. The remaining destructive acceptance work is:

  • interrupt power during staging and confirm the old app remains bootable;
  • interrupt power during the internal copy and confirm it resumes;
  • boot a deliberately unhealthy image and confirm rollback after three trials.

Keep the SWD probe and the complete Step 0 stock backup available during fault injection. See SPI Flash and Recovery.

Clone this wiki locally