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

optarg for hush builtin getopt

PATH

colon separated list of paths to search for executables

PROMPT_COMMAND

command to execute prior to each primary prompt

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

1.8.2. global.*

Variable

Description

global.9p.debug

9P debugging level

global.arch

Name of architecture as used by Linux

global.autoboot

Autoboot state. Possible values: countdown (default), abort, halt, menu, boot

global.autoboot_abort_key

Which key allows to interrupt autoboot. Possible values: ‘any’, ‘ctrl-c’ or any other single ascii character.

global.autoboot_timeout

Timeout before autoboot starts in seconds

global.buildsystem.version

version of buildsystem barebox was built with

global.console.ctrlc_allowed

If true, scripts can be aborted with ctrl-c

global.endianness

The barebox endianness

global.env.autoprobe

Automatically probe known block devices for environment

global.firmware.path

Firmware search path

global.hostname

shortname of the board. Also used as hostname for DHCP requests

global.layerscape_pcie.share_stream_ids

If true, use a stream_id per host controller and not per device

global.machine_id

Persistent device-specific, hexadecimal, 32-character id

global.model

Product name of this hardware

global.nfs.port

Sets both NFS -o {port.mountport}= to the specified non-zero value

global.partitions.first_usable_lba

first usable LBA used for creating partitions

global.serial_number

Board serial number

global.tutorial.step

Next tutorial step.

global.version

The barebox version

1.8.2.1. global.boot.*

Variable

Description

global.boot.default

default boot order

global.boot.watchdog_timeout

Watchdog enable timeout in seconds before booting

1.8.2.2. global.bootchooser.*

Variable

Description

global.bootchooser.default_attempts

bootchooser: Default number of attempts for a target

global.bootchooser.default_priority

bootchooser: Default priority for a target

global.bootchooser.disable_on_zero_attempts

bootchooser: Disable target when remaining attempts counter reaches 0

global.bootchooser.reset_attempts

bootchooser: Choose condition to reset number of attempts for all enabled targets (‘power-on’, ‘all-zero’, ‘reset’)

global.bootchooser.reset_priorities

bootchooser: Choosen condition to reset priority of all targets (default: ‘’, ‘all-zero’)

global.bootchooser.retry

bootchooser: Try again when booting a target fails

global.bootchooser.state_prefix

bootchooser: state name prefix, empty for nv backend

global.bootchooser.targets

bootchooser: Space separated list of target names

1.8.2.3. global.bootm.*

Variable

Description

global.bootm.appendroot

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)

global.bootm.dryrun

bootm default dryrun level

global.bootm.earlycon

Add earlycon option to Kernel for early log output

global.bootm.image

bootm default boot image

global.bootm.image.loadaddr

bootm default boot image loadaddr

global.bootm.initrd

bootm default initrd

global.bootm.initrd.loadaddr

bootm default initrd loadaddr

global.bootm.oftree

bootm default oftree

global.bootm.provide_hostname

If true, append systemd.hostname=$global.hostname to Kernel command line

global.bootm.provide_machine_id

If true, append systemd.machine_id=$global.machine_id to Kernel command line

global.bootm.root_dev

bootm default root device (overrides default device in global.bootm.appendroot)

global.bootm.tee

bootm default tee image

global.bootm.verbose

bootm default verbosity level (0=quiet)

global.bootm.verify

bootm default verify level

1.8.2.4. global.dhcp.*

Variable

Description

global.dhcp.bootfile

bootfile returned from DHCP request

global.dhcp.client_id

client id to send to the DHCP server

global.dhcp.client_uuid

client uuid to send to the DHCP server

global.dhcp.oftree_file

OF tree returned from DHCP request (option 224)

global.dhcp.option224

private data to send to the DHCP server (option 224)

global.dhcp.retries

retry limit

global.dhcp.rootpath

rootpath returned from DHCP request

global.dhcp.tftp_server_name

TFTP server Name returned from DHCP request

global.dhcp.user_class

user class to send to the DHCP server

global.dhcp.vendor_id

vendor id to send to the DHCP server

1.8.2.5. global.fastboot.*

Variable

Description

global.fastboot.bbu

Export barebox update handlers via fastboot

global.fastboot.max_download_size

Fastboot maximum download size

global.fastboot.net.autostart

If true, automatically start fastboot over UDP during startup

global.fastboot.partitions

Partitions exported for update via fastboot

1.8.2.6. global.linux.*

Variable

Description

global.linux.blkdevparts.*

Linux blkdevparts variables

global.linux.bootargs_append

append to original oftree bootargs

global.linux.mtdparts.*

Linux mtdparts variables

global.linux.rootwait

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

global.linux.bootargs.*

Linux bootargs variables

global.linux.bootargs.console

console= argument for Linux from the stdout-path property in /chosen node

1.8.2.8. global.login.*

Variable

Description

global.login.fail_command

command to run when password entry failed

global.login.timeout

timeout to type the password

1.8.2.9. global.mtd_peb.*

Variable

Description

global.mtd_peb.chk_io

If true, written data will be verified

global.mtd_peb.emulate_bitflip

random bitflips, on average every #nth access returns -EUCLEAN

global.mtd_peb.emulate_erase_failures

random erase failures, on average every #nth access returns erase failure

global.mtd_peb.emulate_write_failure

random write failures, on average every #nth access returns write failure

1.8.2.10. global.net.*

Variable

Description

global.net.domainname

Domain name used for DNS requests

global.net.ifup_force_detect

net: force detection of devices on ifup -a

global.net.nameserver

The DNS server used for resolving host names

global.net.server

Standard server used for NFS/TFTP

1.8.2.11. global.of.*

Variable

Description

global.of.kernel.add_machine_compatible

Extra machine/board compatible to prepend to kernel DT compatible

1.8.2.12. global.of.overlay.*

Variable

Description

global.of.overlay.compatible

space separated list of compatibles an overlay must match

global.of.overlay.filter

space separated list of filters

global.of.overlay.path

Path to look for dt overlays or a path to a FIT image

global.of.overlay.pattern

space separated list of filename or fit config-node name patterns an overlay must match

1.8.2.13. global.system.*

Variable

Description

global.system.partitions

board-specific list of updatable partitions

global.system.reset

The reason for the last system reset

global.system.reset_instance

The reset reason instance number

1.8.2.14. global.system.reboot_mode.*

Variable

Description

global.system.reboot_mode.next

reboot-mode: Mode to set next, to be evaluated after reset

global.system.reboot_mode.prev

reboot-mode: Mode set previously, before barebox start

1.8.2.15. global.ubifs.*

Variable

Description

global.ubifs.allow_authenticated_unauthenticated

If true, allow to mount authenticated UBIFS images without doing authentication

global.ubifs.allow_encrypted

If true, allow to mount UBIFS with encrypted files

1.8.2.16. global.usbgadget.*

Variable

Description

global.usbgadget.acm

usbgadget: Create CDC ACM function

global.usbgadget.autostart

usbgadget: Automatically start usbgadget on boot

global.usbgadget.dfu_function

usbgadget: Create DFU function

1.8.3. arm-specific variables

Variable

Description

aimage_noverwrite_bootargs

Disable overwrite of the bootargs with the one present in aimage

aimage_noverwrite_tags

Disable overwrite of the tags addr with the one present in aimage

armlinux_architecture

ARM machine ID

armlinux_system_rev

ARM system revision

armlinux_system_serial

ARM system serial

global.bootm.boot_atag

If true, ignore device tree and boot using ATAGs

1.8.4. kvx-specific variables

Variable

Description

kvx.arch_rev

KVX architecture revision

kvx.board_sn

KVX board sn

kvx.mppa_id

KVX MPPA chip id

1.8.5. riscv-specific variables

Variable

Description

global.hartid

RISC-V hartid

1.8.6. Board-specific variables

1.8.6.1. crystalfontz-cfa10036

Variable

Description

global.board.variant

The board variant

1.8.6.2. kindle-mx50

Variable

Description

global.board.bootmode

The bootmode in ATAG_BOOTMODE to fill /proc/bootmode

global.board.mac

The wifi MAC in ATAG_MACADDR visible as /proc/mac_addr

global.board.postmode

The postmode in ATAG_BOOTMODE to fill /proc/postmode

global.board.revision16

The boardid in ATAG_REVISION16 to fill /proc/boardid

global.board.sec

The sec code in ATAG_MACADDR visible as /proc/mac_sec

global.board.serial16

The device serial in ATAG_SERIAL16, visible in /proc/cpuinfo

1.8.6.3. rockchip-rk3568-bpi-r2pro

Variable

Description

global.board.hwid

The board hardware ID

1.8.6.4. rockchip-rk3568-evb

Variable

Description

global.board.hwid

The board hardware ID

1.8.6.5. skov-arm9cpu

Variable

Description

board.mem

The detected memory size in MiB