Skip to content

Instantly share code, notes, and snippets.

@mnishiguchi
Last active March 14, 2024 04:02
Show Gist options
  • Save mnishiguchi/737b9905a6cd37fb051f1cccc3728e9e to your computer and use it in GitHub Desktop.
Save mnishiguchi/737b9905a6cd37fb051f1cccc3728e9e to your computer and use it in GitHub Desktop.
Nerves Quickstart (English)

Nerves Quickstart

For those exploring Nerves for the first time, we recommend Nerves Livebook. It allows you to try out the Nerves project on real hardware without needing to build a project from scratch.

Within minutes, you'll have a Raspberry Pi or Beaglebone running Nerves. You'll be able to run code in Livebook and work through Nerves tutorials from the comfort of your browser.

No prior knowledge about the Elixir programming language is required. You can learn it in Nerves Livebook.

Underjord has put together a fantastic video to help walk-through the entire setup process.

Install video

Shopping list

Install fwup

fwup is a command line utility that is used for burning a firmware image to MicroSD card.

The installation method differs depending on your host computer, so refer to the fwup documentation.

fwup-pup.png

Download the firmware

First, download the firmware image (.fw file) corresponding to your target computer from the Nerves Livebook Releases page. For example, if your target computer is Raspberry Pi 4, download nerves_livebook_rpi4.fw.

This is a one time step. There's a Livebook notebook for upgrading the firmware for when we make releases!

Burn the firmware to MicroSD

We will create a bootable MicroSD card.

Navigate to the directory where you downloaded the firmware earlier.

cd path/to/my-firmware

To be clear, this formats your MicroSD card, and you will lose all data on the SD card. Make sure you're OK with that.

fwup nerves_livebook_rpi4.fw

Depending on your OS, you'll likely be asked to authenticate this action. Go ahead and do so.

Use 15.84 GB memory card found at /dev/rdisk2? [y/N] y
Depending on your OS, you'll likely be asked to authenticate this action. Go ahead and do so.

|====================================| 100% (31.81 / 31.81) MB
Success!
Elapsed time: 3.595 s

Connect to your target computer

There can be multiple ways to connect to your target computer.

Workflows for Nerves

The supported connection methods vary depending on your target computer.

Nerves System Gadget Mode Ethernet UART
Raspberry Pi Zero W rpi0 x
Raspberry Pi 3 Model B rpi3 x
Raspberry Pi 4 Model B rpi4

If you are using a target computer that supports USB gadget mode, you can use the Micro-USB to USB cable for both power supply and networking by connecting it to the USB On-The-Go (OTG) port.

Run the firmware

Insert the MicroSD card into the target computer. Power up your target computer and connect a network cable. If you're using a Raspberry Pi Zero, Beaglebone or Raspberry Pi 4, a USB cable can provide both power and network.

Most, but not all supported devices, have an LED on them. Nerves Livebook will make it blink when the network is disconnected and change it to solid on when it's possible to connect over any network interface.

Once the device is ready, point your browser at http://nerves.local. The password is "nerves".

Livebook screenshot

Enjoy Nerves Livebook

You can actually run the Elixir code in your Livebook notebook, so you can learn Nerves and the Elixir language comfortably and happily on your browser. Here are some useful notebooks:

You may discover interesting notebooks from the Elixir community at https://notes.club.

Going further

At some point you may want to create your own custom Nerves firmware. See the Nerves Installation and Getting Started guides for details.

@mnishiguchi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment