UBootEnv (uboot_env v1.0.3)

Copy Markdown View Source

UBootEnv reads and writes U-Boot environment blocks

It's like the commandline tools fw_setenv and fw_printenv except in pure Elixir. It also uses /etc/fw_env.config by default to figure out where the environment exists so that you need not store the configuration in two places.

Summary

Types

U-Boot environment key type

U-Boot environment key-value pairs

U-Boot environment value type

Functions

Load the U-Boot environment configuration

Read the U-Boot environment into a map or key value pairs

Read the U-Boot environment into a map or key value pairs

Write a map of key value pairs to the U-Boot environment

Write a map of key-value pairs to the U-Boot environment

Types

key()

@type key() :: binary()

U-Boot environment key type

Keys are ASCII strings. The = and \0 characters are not allowed.

kv_map()

@type kv_map() :: %{required(key()) => value()}

U-Boot environment key-value pairs

value()

@type value() :: binary()

U-Boot environment value type

Values are ASCII strings. \0 characters are not allowed.

Functions

configuration()

@spec configuration() :: {:ok, UBootEnv.Config.t()} | {:error, atom()}

Load the U-Boot environment configuration

This is returns the default U-Boot environment configuration from "/etc/fw_env.config". If you do not want this, see UBootEnv.Config.from_file/1 or UBootEnv.Config.from_string/1 for creating or loading a custom configuration.

read()

@spec read() :: {:ok, kv_map()} | {:error, reason :: atom()}

Read the U-Boot environment into a map or key value pairs

The configuration from "/etc/fw_env.config" is used to find the location of the environment block. See read/1 for specifying a custom location.

read(config)

@spec read(UBootEnv.Config.t()) :: {:ok, kv_map()} | {:error, atom()}

Read the U-Boot environment into a map or key value pairs

write(kv)

@spec write(kv_map()) :: :ok | {:error, reason :: atom()}

Write a map of key value pairs to the U-Boot environment

The configuration from "/etc/fw_env.config" is used to find the location of the environment block. See write/2 for specifying a custom location.

Keys and values must only contain valid characters for U-Boot environment blocks.

Raises ArgumentError when a key contains NUL or =, or when a value contains NUL. Returns errors for configuration and write failures.

write(kv, config)

@spec write(kv_map(), UBootEnv.Config.t()) :: :ok | {:error, atom()}

Write a map of key-value pairs to the U-Boot environment

Keys and values must only contain valid characters for U-Boot environment blocks.

Raises ArgumentError when a key contains NUL or =, or when a value contains NUL. Returns errors for write failures.