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 nv 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

OLDPWD

Previous working directory, set by cd and used by ‘cd -’

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

bootfile

boot file name to request from the DHCP server

bootsource

The source barebox has been booted from

bootsource_instance

The instance of the source barebox has been booted from

bsec0.permanent_write_enable

Enable permanent writes (fuse blowing) to the BSEC OTP

fpga.programmed

Whether the FPGA is configured and in user mode

imx_ocotp0.permanent_write_enable

Enable permanent writes (fuse blowing) to the OCOTP via the ELE

loads_echo

If false, loads prints a dot every 100 lines instead of echoing them

otg.mode

Mode of the first USB OTG port: otg, host or peripheral

security.policy

Name of the active security policy (read-only)

xilinx_fpga.programmed

Whether the FPGA is programmed

1.8.2. efi.*

Variable

Description

efi.fw_revision

Revision of the EFI firmware

efi.fw_vendor

Vendor of the EFI firmware

efi.lang.codes

semicolon-separated list of RFC 4646 formatted languages for PlatformLangCodes

efi.loader

EFI loader state (inactive, boot, runtime)

efi.major

Major version of the EFI specification implemented by the firmware

efi.minor

Minor version of the EFI specification implemented by the firmware

efi.payload_default_path

The arch-specific removable media path

efi.secure_boot

UEFI Secure Boot is enabled

efi.secure_mode

UEFI Secure Boot is enabled and the firmware is not in Setup Mode

1.8.2.1. efi.vars.*

Variable

Description

efi.vars.bufsize

efiloader: Size in bytes of the memory area reserved for keeping UEFI variables

efi.vars.filestore

efiloader: Name of file within ESP to store variables to (WARNING: Not power-fail safe!)

1.8.3. fw_cfg.*

Variable

Description

fw_cfg.pio

Access QEMU fw_cfg via port I/O instead of DMA

fw_cfg.selector

QEMU fw_cfg item accessed through /dev/fw_cfg

1.8.4. global.*

Variable

Description

global.9p.debug

9P debugging level

global.allow_color

Allow colored console output

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.path

The path the environment is stored

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.log_max_messages

Maximum number of messages kept in the log buffer

global.loglevel

Console log level: only messages up to this level are printed

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.of_partition_binding

Partition binding for kernel device tree fixups: new, legacy, donttouch or adaptive

global.partitions.first_partition_offset

byte offset used by free-space searches for new partitions

global.product.uuid

SMBIOS-reported product UUID

global.serial_number

Board serial number

global.soc_uid

SoC Unique ID

global.soc_uid_hex

Raw SoC Unique ID representation

global.tftp.windowsize

TFTP windowsize to request for downloads, capped at CONFIG_FS_TFTP_MAX_WINDOW_SIZE

global.tutorial.step

Next tutorial step.

global.user

Username used by the default environment to construct network boot paths

global.version

The barebox version

1.8.4.1. global.boot.*

Variable

Description

global.boot.default

default boot order

global.boot.machine_id

If set, only boot bootloader spec entries with a matching machine-id

global.boot.watchdog_timeout

Watchdog enable timeout in seconds before booting

1.8.4.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.4.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.efi

efiloader: Behavior for EFI-stubbable boot images: EFI “disabled”, EFI if “available” (default), EFI is “required”

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.provide_policy

Add barebox.security.policy= option to Kernel

global.bootm.root_dev

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

global.bootm.root_param

bootm root parameter name (normally ‘root’ for root=/dev/…)

global.bootm.verbose

bootm default verbosity level (0=quiet)

global.bootm.verify

bootm default verify level

1.8.4.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.hostname

hostname to send to the DHCP server (default: global.hostname)

global.dhcp.ntpserver

NTP server used when none is given explicitly

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.4.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.4.6. global.linux.*

Variable

Description

global.linux.blkdevparts.*

Linux blkdevparts variables

global.linux.bootargs_append

append to original oftree bootargs

global.linux.efi.handover

Use legacy x86 handover protocol instead of StartImage BootService

global.linux.mtdparts.*

Linux mtdparts variables

global.linux.rootnfsopts

Options appended to the nfsroot= Linux parameter (default: v3,tcp)

global.linux.rootwait

Argument (in seconds) for Linux rootwait= option if it’s fixed up. A negative value waits indefinitely

1.8.4.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.4.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.4.9. global.mtd_peb.*

Variable

Description

global.mtd_peb.mtd_peb_chk_io

If true, written data will be verified

global.mtd_peb.mtd_peb_emulate_bitflip

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

global.mtd_peb.mtd_peb_emulate_erase_failures

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

global.mtd_peb.mtd_peb_emulate_write_failure

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

1.8.4.10. global.net.*

Variable

Description

global.net.domainname

Domain name used for DNS requests

global.net.fetchdir

The directory within which artifacts are fetched for network boot targets (/mnt/tftp by default)

global.net.gateway

The network gateway used when a host is not in any directly visible subnet

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.4.11. global.of.*

Variable

Description

global.of.kernel.add_machine_compatible

Extra machine/board compatible to prepend to kernel DT compatible

1.8.4.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.4.13. global.system.*

Variable

Description

global.system.gpt_refresh

When true, refresh GPT partitions when necessary

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.4.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.4.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.4.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.5. ocotp0.*

Variable

Description

ocotp0.mac_addr

Alias for ocotp0.mac_addr0

ocotp0.mac_addr0

MAC address of the first Ethernet controller in the fuses

ocotp0.mac_addr1

MAC address of the second Ethernet controller in the fuses (SoCs with two MACs only)

ocotp0.sense_enable

Read the fuses directly instead of from the shadow registers

1.8.6. soc0.*

Variable

Description

soc0.family

SoC family

soc0.machine

Machine model, defaults to the device tree model property

soc0.revision

SoC silicon revision

soc0.serial_number

SoC unique ID

soc0.soc_id

SoC model

1.8.7. arm-specific variables

Variable

Description

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

global.bootm.secure_state

ARM security state to start the kernel in: secure, nonsecure or hyp

iim.ethaddr*

MAC addresses in the fuses, one per barebox,provide-mac-address entry

iim.explicit_sense_enable

Read the fuses by explicit sensing instead of from the shadow registers

iim.permanent_write_enable

Enable permanent writes (fuse blowing) to the IIM

ocotp0.permanent_write_enable

Enable permanent writes (fuse blowing) to the OCOTP

psci.method

PSCI conduit: smc or hvc

psci.version

PSCI version implemented by the firmware

soc.name

AT91 SoC name

soc.subname

AT91 SoC subtype name

zynqmp_fw.ggs0

Global general storage register 0

zynqmp_fw.ggs1

Global general storage register 1

zynqmp_fw.ggs2

Global general storage register 2

zynqmp_fw.ggs3

Global general storage register 3

zynqmp_fw.pggs0

Persistent global general storage register 0

zynqmp_fw.pggs1

Persistent global general storage register 1

zynqmp_fw.pggs2

Persistent global general storage register 2

zynqmp_fw.pggs3

Persistent global general storage register 3

1.8.8. kvx-specific variables

Variable

Description

global.kvx.arch_rev

KVX architecture revision

global.kvx.board_sn

KVX board sn

global.kvx.mppa_id

KVX MPPA chip id

1.8.9. riscv-specific variables

Variable

Description

global.hartid

RISC-V hartid

1.8.10. Board-specific variables

1.8.10.1. beaglebone

Variable

Description

global.board.variant

The board variant

1.8.10.2. crystalfontz-cfa10036

Variable

Description

global.board.variant

The board variant

1.8.10.3. 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.10.4. kindle-mx6sl

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.10.5. raspberry-pi

Variable

Description

global.vc.boot_mode

Boot mode reported by the VideoCore firmware

global.vc.boot_partition

Boot partition reported by the VideoCore firmware

global.vc.bootargs

Kernel command line from the VideoCore device tree

global.vc.kernel

Default kernel image name for the CPU: kernel.img, kernel7.img or kernel8.img

global.vc.os_prefix

os_prefix from the VideoCore device tree

global.vc.overlay_prefix

overlay_prefix from the VideoCore device tree

1.8.10.6. rockchip-rk3568-bpi-r2pro

Variable

Description

global.board.hwid

The board hardware ID

1.8.10.7. rockchip-rk3568-evb

Variable

Description

global.board.hwid

The board hardware ID

1.8.10.8. skov-arm9cpu

Variable

Description

global.board.mem

The detected memory size in MiB