Using Nerves
View SourceDeploying your firmware
Once you have installed your project dependencies you can build a Nerves Firmware bundle. This bundle contains a minimal Linux platform and your application packaged as an OTP release.
The first time you compile your application or it's dependencies Nerves will
fetch the System and Toolchain from one of our cache mirrors. These artifacts
are cached locally in ~/.nerves/artifacts so they can be shared across
projects.
For remote deployment information, see "How do I push firmware updates remotely?" in the FAQ.
Deleting cached artifacts
Running rm -fr ~/.nerves is a safe operation as any archives
that you're using will be re-downloaded when you next run mix deps.get.
Create the firmware bundle
You can create the firmware bundle with the following command:
mix firmware
or
MIX_TARGET=rpi0_2 mix firmware
This will result in a hello_nerves.fw firmware bundle file.
Create a bootable SD card
To create a bootable SD card, use the following command:
mix firmware.burn
or
MIX_TARGET=rpi0_2 mix firmware.burn
This command will attempt to automatically discover the SD card inserted in your host.
More than one SD cards or disk images?
mix firmware.burn may fail to correctly detect your SD card if you have
more than one SD card inserted or you have disk images mounted.
If this happens, you can specify the intended device by passing the
-d <device> argument to the command. For example
mix firmware.burn -d /dev/rdisk3
You can also use -d <filename> to specify an output file that is a raw
image of the SD card. This binary image can be burned to an SD card using
Raspberry Pi Imager, Etcher, dd, Win32DiskImager, or other image copying utilities.
For more options, refer to the mix firmware.burn documentation.
Now that you have your SD card burned, you can insert it into your device and boot it up.
Connecting to your device
There are multiple ways to connect to your Nerves target device, and different targets may support different connection methods:
- USB to TTL serial cable (aka FTDI cable)
- HDMI cable
- USB data cable
- Ethernet
- WiFi
When connecting to your target device using a USB to TTL serial cable or an HDMI cable, and before booting up your device, you may see device messages related to the booting process in the IEx console.
For more info, refer to Connecting to your Nerves Target.
What features does Nerves support for my device?
Refer to the documentation of nerves_system_<target> projects for their
supported features. As an example, when your target is rpi0_2,
visit https://hexdocs.pm/nerves_system_rpi0_2.