1.7. Variables¶
We already have seen some variables in Device parameters. But there is more to variables.
1.7.1. The global device¶
The global device is a special purpose device. It only exists as a
storage for global variables. Some global variables are created internally
in barebox (see Magic variables). Additional variables can be created with
the global - create or set global variables command:
global myvar
This creates the global.myvar variable which now can be used like any
other variable. You can also directly assign a value during creation:
global myvar1=foobar
NOTE: creating a variable with global myvar1=foobar looks very similar
to assigning a value with global.myvar1=foobar, but the latter fails when
a variable has not been created before.
1.7.2. Non volatile variables¶
Additionally to global variables barebox also has non volatile (nv) variables. Unlike the global variables the config variables are persistent over reboots.
Each nv variable is linked with the global variable of the same name. Whenever the nv variable changes its value the corresponding global variable also changes its value. The other way round though is not true: Changing a global variable does not change the corresponding nv variable. This means that changing a global variable changes the behaviour for the currently running barebox, while changing a nv variable changes the behaviour persistently over reboots.
nv variables can be created or removed with the nv - create, set or remove non volatile (NV) variables command.
The nv variables are made persistent using the environment facilities of barebox. They are saved automatically to the storage medium whenever barebox shuts down (that is, a reset - perform RESET of the CPU is issued or a kernel is started).
examples:
barebox@Phytec phyCARD-i.MX27:/ devinfo nv
barebox@Phytec phyCARD-i.MX27:/ nv model=myboard
barebox@myboard:/ devinfo nv
Parameters:
model: myboard
barebox@myboard:/ devinfo global
Parameters:
[...]
model: myboard
[...]
barebox@myboard:/ global.model=yourboard
barebox@yourboard:/ devinfo nv
Parameters:
model: myboard
barebox@yourboard:/
1.7.3. Non volatile device variables¶
Non volatile device variables are used to make device parameters persistent. They are regular nv variables but are linked with other devices instead of the global device. Every nv variable in the form nv.dev.<devname>.<paramname> will be mirrored to the corresponding <devname>.<paramname> variable.
This example changes the partitioning of the nand0 device:
barebox@Phytec phyCARD-i.MX27:/ nv dev.nand0.partitions: 4M(barebox),1M(barebox-environment),-(root)
barebox@Phytec phyCARD-i.MX27:/ devinfo nand0
Parameters:
[...]
partitions: 4M(barebox),1M(barebox-environment),8M(kernel),1011M(root)
[...]
1.8. Magic variables¶
Some variables have special meanings and influence the behaviour of barebox. Most but not all of them are consolidated in the The global device. Since it’s hard to remember which variables these are and if the current barebox has support for them the magicvar - list information about magic variables command can print a list of all active variables with special meaning along with a short description:
barebox:/ magicvar
OPTARG optarg for hush builtin getopt
PATH colon separated list of paths to search for executables
PS1 hush prompt
automount_path mountpath passed to automount scripts
bootargs Linux Kernel parameters
bootsource The source barebox has been booted from
bootsource_instance The instance of the source barebox has been booted from
global.boot.default default boot order
...
Above output will only list magic variables that were compiled. Below is a full listing of all currently documented magic variables:
1.8.1. No prefix¶
Variable |
Description |
|---|---|
|
optarg for hush builtin getopt |
|
colon separated list of paths to search for executables |
|
command to execute prior to each primary prompt |
|
hush prompt |
|
mountpath passed to automount scripts |
|
Linux kernel parameters |
|
The source barebox has been booted from |
|
The instance of the source barebox has been booted from |
1.8.2. global.*¶
Variable |
Description |
|---|---|
|
9P debugging level |
|
Name of architecture as used by Linux |
|
Autoboot state. Possible values: countdown (default), abort, halt, menu, boot |
|
Which key allows to interrupt autoboot. Possible values: ‘any’, ‘ctrl-c’ or any other single ascii character. |
|
Timeout before autoboot starts in seconds |
|
version of buildsystem barebox was built with |
|
If true, scripts can be aborted with ctrl-c |
|
The barebox endianness |
|
Automatically probe known block devices for environment |
|
Firmware search path |
|
shortname of the board. Also used as hostname for DHCP requests |
If true, use a stream_id per host controller and not per device |
|
|
Persistent device-specific, hexadecimal, 32-character id |
|
Product name of this hardware |
|
Sets both NFS -o {port.mountport}= to the specified non-zero value |
|
first usable LBA used for creating partitions |
|
Board serial number |
|
Next tutorial step. |
|
The barebox version |
1.8.2.1. global.boot.*¶
Variable |
Description |
|---|---|
|
default boot order |
|
Watchdog enable timeout in seconds before booting |
1.8.2.2. global.bootchooser.*¶
Variable |
Description |
|---|---|
|
bootchooser: Default number of attempts for a target |
|
bootchooser: Default priority for a target |
|
bootchooser: Disable target when remaining attempts counter reaches 0 |
|
bootchooser: Choose condition to reset number of attempts for all enabled targets (‘power-on’, ‘all-zero’, ‘reset’) |
|
bootchooser: Choosen condition to reset priority of all targets (default: ‘’, ‘all-zero’) |
|
bootchooser: Try again when booting a target fails |
|
bootchooser: state name prefix, empty for nv backend |
|
bootchooser: Space separated list of target names |
1.8.2.3. global.bootm.*¶
Variable |
Description |
|---|---|
|
Add root= option to Kernel to mount rootfs from the device the Kernel comes from (default, device can be overridden via global.bootm.root_dev) |
|
bootm default dryrun level |
|
Add earlycon option to Kernel for early log output |
|
bootm default boot image |
|
bootm default boot image loadaddr |
|
bootm default initrd |
|
bootm default initrd loadaddr |
|
bootm default oftree |
|
If true, append systemd.hostname=$global.hostname to Kernel command line |
|
If true, append systemd.machine_id=$global.machine_id to Kernel command line |
|
bootm default root device (overrides default device in global.bootm.appendroot) |
|
bootm default tee image |
|
bootm default verbosity level (0=quiet) |
|
bootm default verify level |
1.8.2.4. global.dhcp.*¶
Variable |
Description |
|---|---|
|
bootfile returned from DHCP request |
|
client id to send to the DHCP server |
|
client uuid to send to the DHCP server |
|
OF tree returned from DHCP request (option 224) |
|
private data to send to the DHCP server (option 224) |
|
retry limit |
|
rootpath returned from DHCP request |
|
TFTP server Name returned from DHCP request |
|
user class to send to the DHCP server |
|
vendor id to send to the DHCP server |
1.8.2.5. global.fastboot.*¶
Variable |
Description |
|---|---|
|
Export barebox update handlers via fastboot |
|
Fastboot maximum download size |
|
If true, automatically start fastboot over UDP during startup |
|
Partitions exported for update via fastboot |
1.8.2.6. global.linux.*¶
Variable |
Description |
|---|---|
|
Linux blkdevparts variables |
|
append to original oftree bootargs |
|
Linux mtdparts variables |
|
Argument (in seconds) for Linux rootwait= option if it’s fixed up. A negative value waits indefinitely |
1.8.2.7. global.linux.bootargs.*¶
Variable |
Description |
|---|---|
|
Linux bootargs variables |
|
console= argument for Linux from the stdout-path property in /chosen node |
1.8.2.8. global.login.*¶
Variable |
Description |
|---|---|
|
command to run when password entry failed |
|
timeout to type the password |
1.8.2.9. global.mtd_peb.*¶
Variable |
Description |
|---|---|
|
If true, written data will be verified |
|
random bitflips, on average every #nth access returns -EUCLEAN |
|
random erase failures, on average every #nth access returns erase failure |
|
random write failures, on average every #nth access returns write failure |
1.8.2.10. global.net.*¶
Variable |
Description |
|---|---|
|
Domain name used for DNS requests |
|
net: force detection of devices on ifup -a |
|
The DNS server used for resolving host names |
|
Standard server used for NFS/TFTP |
1.8.2.11. global.of.*¶
Variable |
Description |
|---|---|
|
Extra machine/board compatible to prepend to kernel DT compatible |
1.8.2.12. global.of.overlay.*¶
Variable |
Description |
|---|---|
|
space separated list of compatibles an overlay must match |
|
space separated list of filters |
|
Path to look for dt overlays or a path to a FIT image |
|
space separated list of filename or fit config-node name patterns an overlay must match |
1.8.2.13. global.system.*¶
Variable |
Description |
|---|---|
|
board-specific list of updatable partitions |
|
The reason for the last system reset |
|
The reset reason instance number |
1.8.2.14. global.system.reboot_mode.*¶
Variable |
Description |
|---|---|
|
reboot-mode: Mode to set next, to be evaluated after reset |
|
reboot-mode: Mode set previously, before barebox start |
1.8.2.15. global.ubifs.*¶
Variable |
Description |
|---|---|
|
If true, allow to mount authenticated UBIFS images without doing authentication |
|
If true, allow to mount UBIFS with encrypted files |
1.8.2.16. global.usbgadget.*¶
Variable |
Description |
|---|---|
|
usbgadget: Create CDC ACM function |
|
usbgadget: Automatically start usbgadget on boot |
|
usbgadget: Create DFU function |
1.8.3. arm-specific variables¶
Variable |
Description |
|---|---|
|
Disable overwrite of the bootargs with the one present in aimage |
Disable overwrite of the tags addr with the one present in aimage |
|
|
ARM machine ID |
|
ARM system revision |
|
ARM system serial |
|
If true, ignore device tree and boot using ATAGs |
1.8.4. kvx-specific variables¶
Variable |
Description |
|---|---|
|
KVX architecture revision |
|
KVX board sn |
|
KVX MPPA chip id |
1.8.5. riscv-specific variables¶
Variable |
Description |
|---|---|
|
RISC-V hartid |
1.8.6. Board-specific variables¶
1.8.6.1. crystalfontz-cfa10036¶
Variable |
Description |
|---|---|
|
The board variant |
1.8.6.2. kindle-mx50¶
Variable |
Description |
|---|---|
|
The bootmode in ATAG_BOOTMODE to fill /proc/bootmode |
|
The wifi MAC in ATAG_MACADDR visible as /proc/mac_addr |
|
The postmode in ATAG_BOOTMODE to fill /proc/postmode |
|
The boardid in ATAG_REVISION16 to fill /proc/boardid |
|
The sec code in ATAG_MACADDR visible as /proc/mac_sec |
|
The device serial in ATAG_SERIAL16, visible in /proc/cpuinfo |
1.8.6.3. rockchip-rk3568-bpi-r2pro¶
Variable |
Description |
|---|---|
|
The board hardware ID |
1.8.6.4. rockchip-rk3568-evb¶
Variable |
Description |
|---|---|
|
The board hardware ID |
1.8.6.5. skov-arm9cpu¶
Variable |
Description |
|---|---|
|
The detected memory size in MiB |