Skip to main content
NervesHub has a server, a client library on each device, and a CLI on your workstation or in CI.

Components

NervesHub server

A Phoenix application. It serves the web UI and the HTTP API, accepts device WebSocket connections, decides which devices get which firmware, and relays remote console sessions.

Firmware storage

Firmware and archive files are stored on a local disk or in S3-compatible object storage. Devices download them over HTTP, separately from the WebSocket.

NervesHubLink

The Elixir library in your Nerves firmware. It holds the WebSocket connection, downloads firmware, hands it to fwup, and carries the remote console and extensions over the same connection.

The nh CLI

Signs and uploads firmware, manages signing keys, devices and deployment groups, and opens device consoles. It talks to the HTTP API.

fwup

The tool that builds .fw firmware archives, signs them, and applies them on the device. It runs on your build machine and on the device.

Other device clients

Clients for Linux without Nerves, ESP-IDF and AtomVM speak the same device protocol. See Integrations.
fwup (.fw) is the default firmware format. NervesHub can also accept ESP-IDF application images (.bin), AtomVM packbeams (.avm) and RAUC bundles (.raucb). These are experimental and off by default. Each has to be enabled on the instance and then per product. See Updates overview and Feature prerequisites.

Server nodes

One NervesHub release can run in three roles, chosen with the NERVES_HUB_APP environment variable. The device endpoint serves HTTPS itself and terminates mutual TLS, because device certificates are how devices authenticate. A proxy in front of it has to pass the TLS connection through. When you run more than one node, every node joins one Erlang cluster. A single node needs no cluster configuration.

What stores what

Without ClickHouse, NervesHub still connects devices and delivers updates, and current metric values still work because they are read from PostgreSQL. The Insights pages, connection and metric history, and the logging, error reports and metrics extensions need it. See ClickHouse and Feature prerequisites.

How a firmware update flows

  1. You build firmware, then sign and upload it with nh firmware upload. NervesHub checks the signature against your organization’s signing keys and stores the file.
  2. You point a deployment group at the firmware. This creates a release in the group.
  3. When a device connects, NervesHub places it in an active deployment group whose conditions it matches.
  4. The deployment orchestrator picks devices to update, within the group’s rollout limits, and NervesHub sends each one an update message over its WebSocket. The message carries a URL for the firmware.
  5. On the device, NervesHubLink asks your client module whether to apply the update now, later, or not at all. See Applying updates.
  6. NervesHubLink downloads the firmware from the URL and hands it to fwup, which verifies the signature against the device’s trusted public keys and writes the update. The device reports progress to NervesHub while this happens.
  7. The device reboots into the new firmware, reconnects, and reports the firmware it now runs and whether that firmware has been validated.
With the S3 backend, the URL is a presigned URL for the bucket, so the download does not pass through the NervesHub server.
Delta updates follow the same flow. NervesHub builds a patch from the firmware the device runs to the target firmware, and the device downloads the patch instead of the full file. For fwup firmware the server builds it with xdelta3. See Delta updates.

Security model

NervesHub keeps two questions apart: is this device who it says it is, and is this firmware from you.

Device identity

Devices connect over TLS and verify the server’s certificate. They then authenticate in one of two ways:
  • Certificates. The device presents an X.509 certificate during the TLS handshake (mutual TLS). NervesHub accepts a certificate it has on file for the device, or one signed by a CA certificate you registered with your organization. See Device certificates and PKI.
  • Shared secrets. The device sends a key and signs its identifier with the matching secret. The instance has to allow this. See Shared secrets.
You register only the CA certificate with NervesHub. The CA’s private key stays with you, and a device’s private key stays on the device or in its NervesKey or TPM.

Firmware integrity

You sign firmware with a private key that stays on your build machine or in your CI secrets. NervesHub holds the matching public key and refuses fwup firmware that is not signed by a key registered for your organization. The device checks the signature again. fwup verifies the firmware against the public keys in the device’s fwup_public_keys configuration before it applies the update. A device with no keys configured asks NervesHub for your organization’s keys when it connects. From nerves_hub_link 2.13.0, a device that has no keys at all refuses updates. See Firmware signing.

Who holds which secret

Scale

  • Device connections and the web UI can run on separate nodes, so you can add device nodes as the fleet grows.
  • A deployment group’s rollout limits control how many devices update at once.
  • With S3-compatible storage, firmware downloads go to the bucket, or to a CDN in front of it, and do not load the NervesHub nodes.
  • On shutdown, a device node disconnects its sockets in batches, so reconnecting devices spread across the remaining nodes.