fwup. nerves_hub_link ships three. They differ in what they keep on disk, and so in what an interrupted update costs. Pick one based on how reliable the device’s connection and power are, and how much spare storage it has.
Requirements
Use
nerves_hub_link 2.13.0 or later with CachingUpdater. Earlier versions could corrupt a download that was resumed and then interrupted again, ignored the cache_dir setting, and did not clear a stale partial file.Compare the strategies
All three use the same downloader. When a connection drops mid-download, the downloader reconnects and continues with an HTTP
Range request, within the limits of the retry settings. The strategies differ in what happens when the download itself is lost, for example because the device reboots.
Streaming (default)
StreamingUpdater sends each chunk to fwup as it arrives. Nothing is written outside the firmware slot, so it needs no spare storage. If the application or the device restarts during an update, the next attempt downloads everything again.
It needs no configuration. To name it explicitly:
Caching
CachingUpdater writes the download to a file, then has fwup apply that file. If a partial file for the same firmware exists when an update starts, it continues from the size of that file.
Limits:
- The device needs room for the whole firmware file in
cache_dir, in addition to the firmware slot. - The updater trusts the size of the partial file. A partial file that was cut short mid-write or corrupted is treated as good, and the problem shows up later as an
fwuperror. - If the server answers a resumed download with 404 or 416, the cache is cleared so the next attempt starts clean.
Parts
PartsUpdater downloads the firmware in fixed-size parts and checks each part’s SHA-256 against the checksums NervesHub sends with the update. Use it for devices on slow or unreliable connections.
- A part that fails its check is thrown away and downloaded again. The parts before it are kept.
- After a restart, parts that were already verified are not downloaded again.
- When every part is verified, the parts are streamed into
fwupin order. The whole firmware never has to exist on disk twice. - The parts stay on disk after the update and are removed when a different firmware starts downloading. An update that is applied but does not stick does not have to be downloaded again.
Download several parts at once
Withmax_concurrent_parts above 1, the parts still needed are divided into that many contiguous ranges. Each range is downloaded over its own connection. Parts are still verified as they arrive and applied in order.
This helps on links where one connection cannot fill the available bandwidth, such as high-latency satellite or cellular. It costs one connection per range on the device and on whatever serves the firmware, for every device in a rollout.
Servers that send no part checksums
A NervesHub server older than 2.5.0 sends no part checksums.PartsUpdater then logs a warning and downloads the firmware as a single part. It verifies that part against the whole-file checksum if the server sent one.
Retry settings
The downloader’s retry behaviour applies to every strategy and to archive downloads:
If the configuration is invalid,
nerves_hub_link logs a warning and uses the defaults.
When a download gives up, the update fails. See failed updates.
Download connection options
Firmware is downloaded over a separate HTTPS connection from the WebSocket. Its TLS and proxy settings have their own keys,downloader_ssl and downloader_http_opts. See transport.
Write your own updater
Implement theNervesHubLink.UpdateManager.Updater behaviour. use NervesHubLink.UpdateManager.Updater gives you a GenServer with default implementations, so you only write the parts that differ:
start/1 and handle_downloader_message/2 have to do. See the NervesHubLink.UpdateManager.Updater module documentation for the full callback list, including handle_progress/3, added in 2.13.0.
To switch updaters at runtime, call NervesHubLink.UpdateManager.change_updater/1 with the module. It takes effect for the next update.

