- connects to NervesHub and shows as online,
- trusts your signing key and installs updates sent over the air,
- has a remote IEx console,
- reports health, logs and errors, and
- optionally takes delta updates.
Before you start
You need:- Hardware to run it on. A Raspberry Pi 4 is a good option, and any of the Nerves supported targets works well.
- A Nerves project,
my_app, that builds and boots on your target. If you do not have one, create it with the Nerves Getting started guide first. The examples userpi4. On other hardware, put your target’s name whereverrpi4appears.nerves_hub_link2.13.0 and later need Elixir 1.15 or later. - An account on a NervesHub instance, in an organization. The examples use
acme. - The
nhCLI, signed in. See CLI installation for other install methods. For a self-hosted instance, pointnhat it before you sign in, as described in CLI configuration.
my_app project directory with MIX_TARGET=rpi4 exported and MIX_ENV left at its default, so every build lands at _build/rpi4_dev/nerves/images/my_app.fw.
The guide builds five firmware versions:
The parts
- Connect the device
- Take a signed update
- Report health, logs and errors
- Send smaller updates with deltas (optional)
- Where you are now: the complete configuration and what to do next
Part 1: Connect the device
Create the product
In the web UI, open the organization’s Products page. If the organization has no products yet, the page shows a Create your first product form: enter the namemy_app and click Create product. Every device extension starts on. Otherwise click New product, enter the name my_app, leave the device extensions checked, and click Create Product. The name must match the firmware’s product name and cannot be changed later. See Products.
Then save your defaults so you can leave out --org and --product:
Add the dependency
Addnerves_hub_link inside the deps function in mix.exs, then fetch it:
Choose how the device authenticates
Pick one tab. A shared secret is the quickest. A local certificate is more work, but each device gets its own key, and it is what the complete device guide builds on. Either way, you create the oneconfig :nerves_hub_link block in config/target.exs that the rest of this guide adds to. host is the host name devices connect to, which is usually not the web UI’s host. See Connecting devices.
- Local certificate
Check it works
Open Devices inmy_app. The device is listed and shows as Online. From the CLI:
host. With a shared secret, check that the key is active and the device clock is right. With a certificate, check that the device exists and that the files are at the two paths above. The troubleshooting lists are on Add NervesHubLink to a project and each authentication page.
Go deeper: Add NervesHubLink to a project, Connecting devices, Products, Devices, Shared secret, Device certificates, Quickstart.
Part 2: Take a signed update
Create the signing key
Every firmware file is signed with a private key you hold. Firmware signing explains the whole scheme.nh key create registers the public key with the acme organization and saves both halves under ~/.nh/keys/acme/. It offers an optional passphrase for the private key. Copy the value in the KEY column for my_app_key.
Add the key and the console to the firmware
Add two keys to theconfig :nerves_hub_link block in config/target.exs:
nerves_hub_link 2.13.0, a device that holds no public key refuses updates.
remote_iex: true lets you open an IEx session on the device from NervesHub. It is off by default. See Remote console.
Burn 1.0.0
Set the version inmix.exs to 1.0.0. Then build and write the SD card:
Upload 1.1.0
Set the version inmix.exs to 1.1.0. Build, then sign and upload:
nh shows the firmware’s metadata, signs a copy and uploads it. Add --password <passphrase> if you set one. Copy the UUID it prints. Firmware covers the other ways to supply the key.
Create the bench group
A deployment group connects firmware to the devices that should run it. Create one group,bench, that you use for the rest of this guide. It has no tag or version conditions, so it matches your device whatever its tags, and it is created turned on:
fwup_public_keys, installs it and reboots. With no client module, it applies every update it is offered. How firmware updates work describes each step, and Applying updates shows how to control them.
Check it works
1
The version changed
Wait for the device to reboot and come back online, then run:It reports firmware version
1.1.0. The device page in the web UI shows the same.2
The console opens
Open the device in the web UI and select the Console tab. An IEx prompt appears.
Part 3: Report health, logs and errors
Extensions are what a device sends to NervesHub besides taking firmware. This part sets up three of them: Health for metrics and alarms, Logging for the device’sLogger output, and Error reports for crashes.
An extension runs only when the firmware includes it, the product has it on, and the device has it on.
Logging and Error reports need ClickHouse on the NervesHub instance. Health reports without it, but metric history charts and health profiles need it. See Feature prerequisites.
Add the extensions to the firmware
Health is in the default extension list. Logging and Error reports are not, so you name them. Add two keys to theconfig :nerves_hub_link block in config/target.exs:
level: :info sends :info and above, which is also the default. Change it to :warning if the device is on a metered connection. See Choose what is sent.
Set the version in mix.exs to 1.2.0, build, and release it to bench. --deploy creates a release on the group as soon as the upload succeeds:
Turn the extensions on for the product
1
Check the product switches
Open Product settings for
my_app and find the Device extensions card on the General tab. Make sure Health, Logging and Error reports are switched on.A product created in the web UI, as in part 1, starts with every extension on. A product created with nh or the API starts with every extension off, and the device sends nothing until you switch them on. See Device extensions.2
Leave the device switches on
On the device’s Settings tab, the Extensions card has a switch for each extension. They are on by default, so there is nothing to change.
3
Reconnect the device
NervesHub decides which extensions a device may use when the device connects. If you switched an extension on while the device was connected, reconnect it:A device that updated to
1.2.0 after you set the switches has already reconnected.Check it works
Confirm the device runs1.2.0. Then open the remote console and check which extensions NervesHub has attached:
attached?: true.
Send a test error from the same console:
Without ClickHouse, health status is also judged against fixed thresholds, not your health profile. ClickHouse for a self-hosted instance lists everything that is missing.
Go deeper: Extensions overview, Health extension, Logging extension, Error reports extension, Health monitoring, Feature prerequisites, ClickHouse.
Part 4: Send smaller updates with deltas (optional)
A delta update sends a device the difference between the firmware it runs and the new firmware, instead of the whole.fw file. It is worth setting up when download size costs you something, such as on cellular or metered links. On a fast, unmetered network, skip it.
The instance needs xdelta3 on the server. See Feature prerequisites.
Check your system’s fwup.conf
NervesHub can build a delta only if the upgrade tasks in your Nerves system’s fwup.conf say where the old copy of a resource is. Official Nerves systems, nerves_system_rpi4 included, already declare delta sources. With rpi4 you have nothing to change here.
To check another system, copy its fwup.conf out and look. The copy option needs nerves 1.15.0 or later:
grep prints lines, delete the copy and move on. If it prints nothing, add a delta source for rootfs.img to the upgrade.a and upgrade.b tasks of the copy, as shown in Enable delta updates. Then point the build at the copy, in config/config.exs:
Build for smaller deltas
This step is optional. A compressed root filesystem changes throughout when a few files change, so deltas of it save little. Turn squashfs compression off and fix the build date inconfig/config.exs:
mksquashfs_flags to the config :nerves, :firmware entry you already have. Keep your own rootfs_overlay value, and fwup_conf if you added it. A project generated by mix nerves.new already sets source_date_epoch. Keep its value.
The trade-off is a larger root filesystem on the device and a larger full download. If the build stops with fwup: file size assertion failed on ... combined.squashfs, the uncompressed root filesystem no longer fits your system’s root filesystem partition. Remove mksquashfs_flags again and rebuild.
Check fwup on the device
fwup on the device applies the delta, and it comes from the Nerves system. A raw delta needs fwup 1.6.0 or later. A system that also declares FAT delta sources, as nerves_system_rpi4 does, needs 1.10.0. Check from the remote console:
fwup is sent the full firmware.
Send 1.3.0 in full, then turn deltas on
A change tofwup.conf has to reach a device as a full update before the device can take patches. The build settings work the same way, because a delta is computed against the firmware the device already runs.
1
Release 1.3.0 with delta updates off
Turn delta updates off for Set the version to Wait until the device runs
bench, so the device downloads the full file:1.3.0, build, and release it:1.3.0. If you changed neither fwup.conf nor the build settings, you can skip this step and the next. Your delta is then built from 1.2.0, and the last step’s release is your 1.3.0.2
Turn delta updates on for bench
Open the
bench group, go to the Settings tab, switch Delta updates on, and click Save. Or run:3
Release 1.4.0
Make a small change, set the version to
1.4.0, and build and release it with the same two commands. NervesHub builds a delta from 1.3.0 and holds the release until it is ready.Check it works
- Open
1.4.0from the product’s Firmware page. Delta updates to must not read “This firmware can’t be delta updated, so devices always download the full file.” - On the
benchgroup’s Releases tab, expand the release. Delta updates lists a delta from1.3.0that moves from Building to Ready. A small delta can be Ready within seconds. - After the device updates, the group’s Stats tab shows Delta in the Download column for
1.3.0.
Where you are now
Your device runs1.4.0, or 1.2.0 if you skipped part 4.
The complete configuration
config :nerves in config/config.exs, not this block.
What to do with the bench group
A device belongs to at most one deployment group, and changing a device’s tags never takes it out of the group it is in. Keepbench for now, whichever guide you read next:
- Basic fleet operations uses
benchfor one last release from your machine, then deletes it when it creates the taggedqaandproductiongroups. Your device can only join one of those once it has leftbench. - The complete device guide releases its firmware through
bench.
Where to go next
- Complete Nerves device setup continues from here: per-device certificates from your own CA, control over when updates are applied, the remaining extensions, and connection tuning.
- Basic fleet operations moves from one bench device to a fleet: firmware built and signed in CI,
qaandproductiongroups, and Slack notifications.

