Skip to content

feat: OTA firmware and config updates over wifi#804

Open
Gheop wants to merge 1 commit into
BitMaker-hub:mainfrom
Gheop:feat/ota-wifi
Open

feat: OTA firmware and config updates over wifi#804
Gheop wants to merge 1 commit into
BitMaker-hub:mainfrom
Gheop:feat/ota-wifi

Conversation

@Gheop

@Gheop Gheop commented Jul 14, 2026

Copy link
Copy Markdown

Adds ArduinoOTA to the NerdminerV2 env so both the firmware and the SPIFFS config can be flashed over wifi, no USB needed:

pio run -e NerdminerV2-OTA -t upload   --upload-port <ip>
pio run -e NerdminerV2-OTA -t uploadfs --upload-port <ip>

Details

  • 16 MB dual-app partition table (default_16MB.csv) for A/B OTA slots.
  • mDNS hostname nerdminer-<mac4>, advertising fw_version in its TXT record (avahi-browse -r _arduino._tcp).
  • OTA password comes from the NERDMINER_OTA_PWD env var at build time; a static_assert fails the build if it is unset, so no password is ever committed.
  • A stall-watchdog task reboots the device if a transfer stalls >90 s, since ArduinoOTA.handle() blocks inside loop().

The tricky part: SHA engine deadlock

Suspending a hardware miner mid-hash keeps the SHA hardware lock (esp_sha_acquire_hardware). Update.end() then calls esp_image_verify(), which computes the image SHA-256 with that same engine → deadlock: the transfer reaches 100 % and the device hangs with no error until the watchdog reboots it.

Fix: the miner tasks poll an ota_active flag and idle at a safe point with the lock released; in-flight jobs get 300 ms to drain before the (SHA-free) monitor and stratum tasks are suspended. Isolated with an OTA_ONLY_TEST build (wifi + OTA only) that always succeeded, which pinpointed the miner tasks as the cause.

Note

Switching the env to the 16 MB table wipes SPIFFS on the first USB flash — re-push config.json with -t uploadfs afterwards (wifi credentials live in NVS and survive). Tested end to end on a LilyGo T-Display-S3: firmware + config OTA both succeed with the miners, screen and stratum all running.

Adds ArduinoOTA to the NerdminerV2 env so the firmware and the SPIFFS
config can be flashed over wifi:
  pio run -e NerdminerV2-OTA -t upload   --upload-port <ip>
  pio run -e NerdminerV2-OTA -t uploadfs --upload-port <ip>

- 16MB dual-app partition table (default_16MB.csv) for A/B OTA slots.
- mDNS hostname nerdminer-<mac4>, advertising fw_version in its TXT record.
- OTA password taken from the NERDMINER_OTA_PWD env var at build time; the
  build fails (static_assert) if it is unset, so no password is committed.
- During a transfer the miner tasks idle at a safe point via an ota_active
  flag and RELEASE the SHA hardware lock first: otherwise suspending a hw
  miner mid-hash keeps that lock and Update.end()'s image SHA-256 check
  deadlocks (transfer reaches 100%, device hangs). The monitor and stratum
  tasks (which don't touch the SHA engine) are simply suspended.
- A watchdog task reboots the device if a transfer stalls >90s, since
  ArduinoOTA.handle() blocks inside loop().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant