Skip to main content
An archive is a signed fwup file that NervesHub delivers to devices without it being installed as firmware. Use one for data that changes on a different schedule from your firmware: calibration data, a modem image, machine learning models. An archive travels with a deployment group’s release, so it reaches the devices that run that release’s firmware. nerves_hub_link downloads the archive, verifies its signature, and hands your application the path. What happens to the file after that is up to your code.

Requirements

How delivery works

  1. NervesHub offers a device the archive when the device connects, when its deployment group gets a release with a different archive, and when the device or its group membership changes.
  2. A device is only offered the archive of its group’s current release, and only while it runs that release’s firmware. A device still on older firmware gets the archive on the connection after it has updated.
  3. A device with updates turned off, or in the penalty box, is not offered archives. A device in device-managed mode is.
  4. On the device, nerves_hub_link checks it holds a public key, then calls archive_available/1.
  5. If your code returns :download, the file is downloaded and verified with fwup. On success archive_ready/2 is called with the path.
NervesHub does not track which devices have an archive. It offers the archive again every time the device connects. Your archive_available/1 must return :ignore for an archive it has already handled, or the device downloads it on every connection.

Set it up

1

Handle archives in your Client

The default Client ignores archives. Override both callbacks in your Client module:
MyApp.Archives stands for your own code. It has to unpack the file, use its contents, and remember the UUID so the archive is not downloaded again. nerves_hub_link does not delete the file for you.
2

Make sure the device has verification keys

If your firmware already sets fwup_public_keys, archives are verified with those keys and there is nothing to do. See Signing keys for the other options.
3

Build the archive

An archive is a .fw file made with fwup. NervesHub requires the meta-product, meta-platform, meta-architecture and meta-version metadata, and meta-version must be a valid SemVer version. fwup adds meta-uuid itself.A minimal archive.conf that packages one file:
The result is a ZIP file with meta.conf and your file under data/.
4

Sign and upload it

nh checks the metadata, signs the archive with fwup, and uploads it to the current product. The key options are the same as for firmware: --key, --key-file, --password, the NERVES_HUB_PRIVATE_KEY environment variable, and --skip-signing for a file that is already signed.You can also upload in the web UI. Open the product’s Archives page and click Upload archive, or drop the file on the page. The file must already be signed.NervesHub refuses an archive that is not signed by one of your organization’s keys.
5

Attach it to a release

In the web UI, open the deployment group and click New release. Pick the archive in the Archive field, then click Create release. The field starts on the current release’s archive.With nh:
A release made with nh deployment release create has no archive unless you pass --archive, whatever the previous release had. To add an archive while keeping the current firmware, run nh deployment update <group> --archive <archive-uuid>, which creates a new release.A release’s archive cannot be changed after the release is made.

Check that it works

  • On the product’s Archives page, the Delivered by column shows which deployment groups have the archive in their current release.
  • Open the archive to see Deployment groups delivering it and Releases with this archive.
  • On the device, the log shows [NervesHubLink] Archive Download complete once the download finishes, followed by your archive_ready/2 running.
  • NervesHub writes an audit log entry for the device when it sends an archive after a change, though not for the offer made on every connect.
If the device logs Archive could not be validated, your public signing keys maybe be incorrectly configured, the signature did not match any key the device holds. archive_ready/2 is not called.

Callbacks

archive_available/1

Called with a NervesHubLink.Message.ArchiveInfo struct: Return one of:

archive_ready/2

Called with the same struct and the path of the verified file. The file is stored at <data_path>/archives/<file name>, where data_path defaults to /data/nerves-hub. Return :ok.

Signing keys

Archives are verified with their own key list, archive_public_keys. nerves_hub_link picks the keys in this order:
  1. If request_archive_public_keys is true, it asks NervesHub for keys when it connects.
  2. Otherwise, if archive_public_keys has entries, it uses those.
  3. Otherwise, if fwup_public_keys has entries, it uses those.
  4. Otherwise, it asks NervesHub for keys when it connects.
To always request them from NervesHub:
NervesHub replies with all of the organization’s Ed25519 public keys. Requested keys come from the same server that supplies the archive. See the trade-off in Firmware signing. Since nerves_hub_link 2.13.0, a device with no usable archive key refuses the archive without calling archive_available/1. It logs Refusing archive : no public keys are available to verify the archive signature.

Limits

  • One archive per release.
  • An archive is downloaded with the same downloader and retry settings as firmware. It is written straight to a file. The updater strategies do not apply.
  • There is no progress report to NervesHub for archive downloads.
  • nh has no command to delete an archive. Delete archives from the archive’s page in the web UI.