View Source DtsBuddy.Backend (dts_buddy v0.1.0)
Collection of functions that actually check system status, compile DTS files, check overlay status.
Summary
Functions
Helper to display all system checks. Quite frugal for now, but should be extended.
Compiles a static DTS string to the given name. Files written are /data/<name>.dts and /data/<name>.dtbo.
Injects an EEx template and compiles it.
Checks the presence of the dtc binary.
Calls mount -t configfs none /sys/kernel/config.
Loads an overlay. This function is meant to be directly called with the
output of DtsBuddy.compile/2 or DtsBuddy.compile_eex/3, that is, a tuple
of the form {:error, term()} or {:ok, path, name} where path is the
location of the compiled dtbo file, and name is the desired overlay name.
Checks the presence of the /sys/kernel/config/device-tree/overlays directory.
Reads /sys/kernel/config/device-tree/overlays/<name>/status and gives the result
as :applied or :unapplied.
Functions
Helper to display all system checks. Quite frugal for now, but should be extended.
Compiles a static DTS string to the given name. Files written are /data/<name>.dts and /data/<name>.dtbo.
The name is used verbatim to build filesystem paths and is validated with
DtsBuddy.Paths.valid_name?/1; an invalid name returns
{:error, {:invalid_name, name}} without touching the filesystem.
@spec compile_eex(binary(), keyword(), binary()) :: {:error, {any(), pos_integer()}} | {:ok, binary(), binary()}
Injects an EEx template and compiles it.
@spec device_tree_compiler_present?() :: boolean()
Checks the presence of the dtc binary.
@spec enable_overlays() :: :ok | {:error, {any(), pos_integer()}}
Calls mount -t configfs none /sys/kernel/config.
Loads an overlay. This function is meant to be directly called with the
output of DtsBuddy.compile/2 or DtsBuddy.compile_eex/3, that is, a tuple
of the form {:error, term()} or {:ok, path, name} where path is the
location of the compiled dtbo file, and name is the desired overlay name.
@spec overlays_enabled?() :: boolean()
Checks the presence of the /sys/kernel/config/device-tree/overlays directory.
@spec status(binary()) :: :applied | :unapplied
Reads /sys/kernel/config/device-tree/overlays/<name>/status and gives the result
as :applied or :unapplied.