NervesSystemOpenwrtOne.UBootEnvKVBackend
(nerves_system_openwrt_one v0.2.3)
Copy Markdown
View Source
A Nerves.Runtime.KVBackend for the OpenWRT One Nerves system.
The U-Boot environment lives in two redundant ubootenv UBI volumes
on SPI NAND. Reads use the Erlang UBootEnv library directly (just
opens the device, reads, decodes -- works fine on UBI character
devices via pread()). Writes shell out to the C fw_setenv tool,
because writing to a /dev/ubi* character device requires the
UBI_IOCVOLUP ioctl to enter atomic-update mode -- plain pwrite()
returns EPERM. The C tool issues that ioctl transparently for
/dev/ubi* paths; the Erlang library doesn't.
Usage
In your project's config/target.exs, configure :nerves_runtime
to use this backend instead of the default:
config :nerves_runtime,
kv_backend: {NervesSystemOpenwrtOne.UBootEnvKVBackend, []}Without this, Nerves.Runtime.KV.put/1 (and anything that uses it,
notably Nerves.Runtime.validate_firmware/0 and
Nerves.Runtime.StartupGuard) returns {:error, :eperm} and the
startup-time validation chain falls over.