The contiguous memory (CMA) pools of video and the NPU.
Video capture with its encoders and the NPU need physically contiguous buffers, which Linux keeps in CMA pools: video uses the default pool, the NPU has its own. Movable pages use what a pool does not hold, so an idle pool costs little. The NanoKVM-Go system's U-Boot sizes both at every boot from its environment, so new sizes apply at the next boot:
NanoKVMGo.CMA.sizes()
#=> %{video: 192, npu: 64}
NanoKVMGo.CMA.persist_sizes(%{video: 160, npu: 96})
#=> :okSizes are in MiB: multiples of 8, video's at least 8, the NPU's 0 to turn
the NPU off, together leaving Linux at least 96 MiB of the DRAM.
:default stands for the board's size: 192 and 64 on the Go+ (512 MiB),
128 and 0 on the Go (256 MiB). 4K capture with JPEG and H.264 takes about
140 MiB with four capture buffers and 120 with three, as on the Go, counting
what else Linux keeps in the pool. On a card moved to the
other board, sizes that do not fit it give the board's, and apply again
back on the board they were set on.
The sizes for the next boots are in the U-Boot environment, through
Nerves.Runtime.KV or another module with its get/1 and put/1 (the
:kv option).
Trying sizes first
With trial: true the next boot runs the new sizes once. Validating the
firmware, Nerves.Runtime.validate_firmware/0, keeps them; any boot
before that, after a crash, the watchdog or a plain reboot, goes back to
the sizes before. trial/1 tells where a trial stands and
cancel_trial/1 drops it.
Summary
Types
A pool size in MiB, or :default for the board's.
A trial of sizes: :pending until the boot that runs them, then
:running.
Functions
Ends a trial of sizes: the next boots use the sizes from before it.
Persists pool sizes for the next boots: :video and :npu in MiB, or
:default. A size left out stays as it is, and a trial under way ends.
The sizes persisted for the next boots, :default for the device tree's.
During a trial, the sizes from before it: those the boots go back to unless
the firmware is validated.
The sizes of the pools in this boot, in MiB. The NPU's is 0 when the NPU is off.
The trial of sizes, nil without one.
Types
@type size() :: non_neg_integer() | :default
A pool size in MiB, or :default for the board's.
@type sizes() :: %{video: non_neg_integer(), npu: non_neg_integer()}
A trial of sizes: :pending until the boot that runs them, then
:running.
Functions
Ends a trial of sizes: the next boots use the sizes from before it.
Options
:kv- the U-Boot environment,Nerves.Runtime.KVby default
@spec persist_sizes(%{optional(:video | :npu) => size()}, [persist_option()]) :: :ok | {:error, term()}
Persists pool sizes for the next boots: :video and :npu in MiB, or
:default. A size left out stays as it is, and a trial under way ends.
A size U-Boot would not take on this board gives {:error, {:invalid_size, pool, size}}, and sizes that together leave Linux less
than 96 MiB {:error, {:too_large, total, max}}. A pool other than
:video and :npu, or a size that is neither a non-negative integer nor
:default, raises ArgumentError.
Options
:trial-trueto run the sizes at the next boot only, until the firmware is validated:kv- the U-Boot environment,Nerves.Runtime.KVby default:root- the root of the file system,"/"by default, where the DRAM's size comes from
The sizes persisted for the next boots, :default for the device tree's.
During a trial, the sizes from before it: those the boots go back to unless
the firmware is validated.
Options
:kv- the U-Boot environment,Nerves.Runtime.KVby default
The sizes of the pools in this boot, in MiB. The NPU's is 0 when the NPU is off.
Options
:root- the root of the file system to read,"/"by default
The trial of sizes, nil without one.
Options
:kv- the U-Boot environment,Nerves.Runtime.KVby default