Terminology
| Term | Definition |
|---|---|
| host | The computer on which you are editing source code, compiling, and assembling firmware |
| target | The platform for which your firmware is built (for example, Raspberry Pi Zero W, Raspberry Pi 4, or Beaglebone Black) |
| toolchain | The tools required to build code for the target, such as compilers, linkers, binutils, and C runtime |
| system | A lean Buildroot-based Linux distribution that has been customized and cross-compiled for a particular target |
| firmware bundle | A single file with the extension .fw that contains your compiled application and everything else needed to run on your target |
| firmware image | Built from a firmware bundle. It's a raw representation of what's on the MicroSD card. These aren't used in normal development and firmware updates. |
Nerves systems
| Nerves system | MIX_TARGET | Hardware |
|---|---|---|
| nerves_system_rpi | rpi | Raspberry Pi A+, B, B+ |
| nerves_system_rpi0 | rpi0 | Raspberry Pi Zero and Zero W |
| nerves_system_rpi2 | rpi2 | Raspberry Pi 2 |
| nerves_system_rpi3 | rpi3 | Raspberry Pi 3 B, B+ |
| nerves_system_rpi3a | rpi3a | Raspberry Pi 3A and Zero 2 W (32-bit) |
| nerves_system_rpi0_2 | rpi0_2 | Raspberry Pi Zero 2 W and 3A (64-bit) |
| nerves_system_rpi4 | rpi4 | Raspberry Pi 4 |
| nerves_system_rpi5 | rpi5 | Raspberry Pi 5 |
| nerves_system_bbb | bbb | BeagleBone Black, Green, Green Wireless, and PocketBeagle |
| nerves_system_osd32mp1 | osd32mp1 | OSD32MP1 |
| nerves_system_x86_64 | x86_64 | Generic x86_64 |
| nerves_system_grisp2 | grisp2 | GRiSP 2 |
| nerves_system_mangopi_mq_pro | mangopi_mq_pro | MangoPi MQ Pro |
While the Nerves core team only officially supports the above hardware, the community has added support for other boards. See Nerves Systems on hex.pm.
Useful shell commands
Making a new firmware from scratch
Creating a Nerves application
$ mix nerves.new hello_nerves
$ cd hello_nerves
Specifying Nerves target
$ export MIX_TARGET=<target>
Installing dependencies
$ mix deps.get
Building firmware
$ mix firmware
Creating a bootable MicroSD card
$ mix burn
The mix burn command discovers any MicroSD cards on your computer. It will confirm before writing the card.
Uploading firmware to a Nerves device over SSH
$ export MIX_TARGET=<target>
$ mix upload nerves.local
Substitute nerves.local with nerves-abcd.local when you have multiple Nerves devices.
Connecting to the target over SSH
Testing the network connection
$ ping nerves.local
Making the network connection
$ ssh nerves.local
Connecting to the target with a serial cable
Serial ports
On boards with USB gadget support (e.g., rpi0, rpi0_2, bbb), the IEx prompt is
available over a virtual serial port on the USB cable. Other boards (e.g.,
rpi5) require a separate USB-to-serial adapter. Serial devices show up as
/dev/tty.usbmodem* or /dev/ttyUSB0.
Using screen
$ screen /dev/tty<device> 115200
Exit screen with CTRL+A, CTRL+\
Using picocom
$ picocom -b 115200 /dev/tty<device>
Exit picocom with CTRL+A, CTRL+X
Misc
Printing Nerves information
$ mix nerves.info
Discovering Nerves devices on the local network
$ mix nerves.discover
Listing Nerves artifacts cached locally
$ ls ~/.nerves/artifacts
Listing Nerves downloads cached locally
$ ls ~/.nerves/dl
If
$XDG_DATA_HOMEis set, Nerves stores data under$XDG_DATA_HOME/nerves/instead of~/.nerves.
Useful IEx commands
Firmware
iex> uname
iex> reboot
iex> Nerves.Runtime.revert
iex> Nerves.Runtime.KV.get_all
iex> NervesMOTD.printLogging
iex> log_attach
iex> log_detach
iex> RingLogger.viewerLinux commands
iex> cmd "ps"Reverse search
<CTRL+R>text to findMisc
iex> h Toolshed
iex> hostname
iex> top
iex> weather
iex> cat "/proc/cpuinfo"
iex> hex 255