NanoKVMGo.Hardware (nano_kvm_go v0.4.0)

Copy Markdown View Source

The NanoKVM-Go as Linux sees it: the board, its SoC, memory and microSD card, and the parts on the board with the drivers that run them.

NanoKVMGo.Hardware.info()
#=> %{
#=>   model: "Sipeed NanoKVM-Go",
#=>   compatible: ["sipeed,nanokvm-go", "axera,ax620qe"],
#=>   soc: "Axera AX620QE",
#=>   cpu: %{model: "Cortex-A53", cores: 2},
#=>   memory: 510_390_272,
#=>   serial_number: "0123456789abcdef",
#=>   linux: "7.3.0"
#=> }

NanoKVMGo.Hardware.components()
#=> [
#=>   %{id: :video_bridge, name: "Video input bridge", chip: "Lontium LT7911EXC",
#=>     bus: :i2c, device: "0-0041", driver: "lt7911exc"},
#=>   ...
#=> ]

A part whose device is nil is missing: the kernel made no device of it, because its driver is not built or its device tree node is off. A part with a device but no driver has none bound: the driver failed to probe, or was unbound.

storage/1 tells the microSD card, its partitions and how full their file systems are.

The functions read procfs and sysfs, with no process.

Options

  • :root - the root of the file system with procfs and sysfs, "/" by default
  • :df - for storage/1, the df program that tells the use of the file systems, "df" by default, found in the PATH

Summary

Types

The microSD card: SD or MMC, its name and manufacturer, the month it was made ("2022-12") and its size in bytes.

A part of the board: what it does, its chip, and the bus, device and driver Linux has for it.

The board: its model and device tree compatibles, the SoC, the CPU cores, the memory Linux has in bytes, the SoC's serial number and the Linux release.

A partition of the card, in bytes, with its part in the Nerves system: the boot files, the two root file systems firmware updates alternate between, and the application's data. A mounted partition has its file system's type and use; the root file system is read-only and full.

Functions

The parts of the board, each with its device and driver.

The board, its SoC, CPU and memory, and the Linux release.

The microSD card and its partitions, with the use of the mounted ones.

Types

card()

@type card() :: %{
  type: String.t() | nil,
  name: String.t() | nil,
  manufacturer: String.t() | nil,
  manufacturer_id: non_neg_integer() | nil,
  date: String.t() | nil,
  size: non_neg_integer()
}

The microSD card: SD or MMC, its name and manufacturer, the month it was made ("2022-12") and its size in bytes.

component()

@type component() :: %{
  id: component_id(),
  name: String.t(),
  chip: String.t() | nil,
  bus: :platform | :i2c | :spi | :sdio | :mmc | nil,
  device: String.t() | nil,
  driver: String.t() | nil
}

A part of the board: what it does, its chip, and the bus, device and driver Linux has for it.

component_id()

@type component_id() ::
  :video_bridge
  | :video_capture
  | :h264_encoder
  | :jpeg_encoder
  | :input_audio
  | :usb
  | :usb_phy
  | :lcd
  | :backlight
  | :touch
  | :button
  | :wifi
  | :sd_card
  | :temperature
  | :watchdog

filesystem()

@type filesystem() :: %{
  type: String.t(),
  size: non_neg_integer() | nil,
  used: non_neg_integer() | nil,
  available: non_neg_integer() | nil
}

info()

@type info() :: %{
  model: String.t() | nil,
  compatible: [String.t()],
  soc: String.t() | nil,
  cpu: %{model: String.t() | nil, cores: non_neg_integer()},
  memory: non_neg_integer() | nil,
  serial_number: String.t() | nil,
  linux: String.t() | nil
}

The board: its model and device tree compatibles, the SoC, the CPU cores, the memory Linux has in bytes, the SoC's serial number and the Linux release.

option()

@type option() :: {:root, Path.t()}

partition()

@type partition() :: %{
  number: pos_integer(),
  role: :boot | :rootfs_a | :rootfs_b | :data | nil,
  start: non_neg_integer(),
  size: non_neg_integer(),
  mount: Path.t() | nil,
  filesystem: filesystem() | nil
}

A partition of the card, in bytes, with its part in the Nerves system: the boot files, the two root file systems firmware updates alternate between, and the application's data. A mounted partition has its file system's type and use; the root file system is read-only and full.

storage()

@type storage() :: %{card: card() | nil, partitions: [partition()]}

storage_option()

@type storage_option() :: option() | {:df, String.t()}

Functions

components(opts \\ [])

@spec components([option()]) :: [component()]

The parts of the board, each with its device and driver.

info(opts \\ [])

@spec info([option()]) :: info()

The board, its SoC, CPU and memory, and the Linux release.

storage(opts \\ [])

@spec storage([storage_option()]) :: storage()

The microSD card and its partitions, with the use of the mounted ones.