jjcarstens

jjcarstens

Nerves Core Team

Nerves Raspberry Pi Systems v2.0.0 release candidates

The Raspberry Pi is a very popular hardware platform for Nerves users and the official systems are getting an upgrade! :tada: :beers:

Whats New?

The biggest change is that the rpi* systems now utilizes initramfs to load a very minimal root filesystem, nerves_initramfs, before mounting the real rootfs. This allows us to do really early pre-start checks via a nerves_initramfs.config script file.

With this new found power, each rpi* system now does a simple firmware validation check before loading the rootfs. If it fails, it triggers a revert to the last firmware automatically. This helps prevent infinite boot loops when errors are caused after compilation but before startup, such as kernel panics, bad erlinit.config, etc etc.

But…

with-great-power

This change requires the firmware to be marked as valid at runtime. Because the answer to “What makes my firmware valid?” differs drastically, Nerves makes no assumptions here and you, the user, are required to validate your firmware based on your conditions by calling Nerves.Runtime.validate_firmware().

For most situations, just getting to runtime is valid enough and you could mark it as your application is starting. Something like:

defmodule My.Application do
  use Application

  def start(_type, _args) do
    Nerves.Runtime.validate_firmware()
   # ... all your other startup things
  end
end

For others, you might have conditions to be connected to a specific network, hardware needs to be detected, MQTT connection must be established, etc etc, before considering the firmware valid. If you have such conditions, check out the post “You Gotta Have Heart” about using the Erlang :heart module to tie these checks into the hardware watchdog for triggering reverts when your conditions aren’t met.

Can I update existing devices?

Yes…with a tiny bit of work.

The pre-start check looks for a UBoot variable nerves_fw_validated. fwup also checks this variable before updating to ensure you have a working, validated firmware on the device before putting an new one on. This is a hardened check to prevent bricking a device by updating a bad firmware with another bad firmware.

Nerves rpi* systems < v2.0.0 don’t have this UBoot variable set, so any attempt to update via fwup (such as SSH or upload.sh script) will fail with an error like:

“Please check the media being upgraded. It doesn’t look like either the A or B partitions are active.”

So before updating, you’ll need to manually validate the running firmware with:

Nerves.Runtime.validate_firmware()

Or

Nerves.Runtime.KV.put("nerves_fw_validated", "1")

Then update like normal :beers:

Why 2.0.0?

Introducing nerves_initramfs and the revert scheme is a decent size change to how the system functions. It’s a new tool and startup path which, we feel, warrants a major version bump. Our hope is that others try out the release candidates and submit issues to help us iron out any kinks.

How Can I Try It?

The release candiates are on hex.pm:

Where Next?

Popular in News & Updates Top

fhunleth
We’ve released new versions of all of the officially maintained Nerves Systems. The official systems, nerves_system_rpi0, nerves_system_b...
New
hugobarauna
This post announces the Livebook desktop app, a way to install Livebook on your machine without the requirement to have Elixir installed ...
New
josevalim
Hi everyone, We have just released Mime v2.0.4 with a potential security fix. Before this version, Mime.extensions("foo/bar+baz") would ...
New
lawik
It is my pleasure to announce the official release of the new generation of NervesHub with the v2.0.0 release. Containers are tagged. :p...
New
zachdaniel
:police_car_light: New AshAuthentication Installers :police_car_light: The AshAuthentication igniter installers are released! Today on s...
New
zachdaniel
What if you had full stack types for SPAs built with tech like React, Inertia, Vue, Svelte… but all of the power Ash Framework and Elixir...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement