Environment variables

The U-Boot environment is a block of memory in persistent storage. It is used to store variables in the form name=value.

Where is the U-Boot environment?

The ConnectCore 6 reads the U-Boot environment (including the MAC addresses) from the boot media, which means:

  • If the device boots from the eMMC, it reads the environment from the eMMC.
  • If the device boots from microSD card, it reads the environment from the microSD card.
  • If it does not find a valid environment on the boot media, it uses a hard-coded default environment.

Boot from eMMC

When the ConnectCore 6 boots from the eMMC, it stores U-Boot on eMMC boot partition 1 (device /dev/mmcblk0boot0 in Linux) and saves the U-Boot environment to eMMC boot partition 2 (device /dev/mmcblk0boot1 in Linux).

The environment is located at the offset determined by constant CONFIG_ENV_OFFSET in U-Boot source code at include/configs/ccimx6_common.h.

The size of the environment is determined by constant CONFIG_ENV_SIZE in U-Boot source code at include/configs/digi_common.h.

There is a back-up copy of the environment in the same boot partition 2 (where the original copy is) at the offset determined by constant CONFIG_ENV_OFFSET_REDUND in U-Boot source code at include/configs/ccimx6_common.h.

Access U-Boot environment from Linux

You can access the U-Boot environment from a Linux application. In the U-Boot source tree, you can find the environment tools in the directory tools/env, which you can build with the following command:

make env

Digi Embedded Yocto also compiles this tool by default and installs it on your target's root file system as two executable files:

The tools work with the configuration file /etc/fw_env.config, which must contain one or two entries in the form: Device name, offset, size. The first entry must point to the U-Boot environment location. The second (if present) must point to its redundant copy, for example:

/etc/fw_env.config
1	# Configuration file for fw_(printenv/setenv) utility.
2	# Up to two entries are valid, in this case the redundant
3	# environment sector is assumed present.
4	# Device name        Offset      Size
5	/dev/mmcblk0boot1    0x1C0000    0x4000
6	/dev/mmcblk0boot1    0x1E0000    0x4000

Append boot arguments to the kernel command line

You can use the extra_bootargs variables to append commands to the default kernel command line.

Important U-Boot environment variables on the ConnectCore 6

The following U-Boot environment variables are worth mentioning:

MAC addresses

Variable Description Flags
ethaddr MAC address of the wired Ethernet interface change-default
wlanaddr MAC address of the Wi-Fi interface change-default
btaddr MAC address of the Bluetooth interface change-default

Note About flags

  • Variables with read-only flag are protected and will not be overwritten by setenv or env default commands (unless manually forced with -f option).
  • Variables with change-default flag can only be written once using setenv command (unless manually forced with -f option).

Digi programs the MAC addresses of the ConnectCore 6 during manufacturing and saves them in the U-Boot environment on the eMMC.

If the device boots from an external media different from the eMMC (for example microSD card), the system reads the U-Boot environment from it, so MAC addresses will not match the ones assigned by Digi during manufacturing. You must program the MAC addresses of the available interfaces and save the environment on your boot storage media.

Note You can find the Digi-assigned MAC address on the ConnectCore 6 module label. See Determine Digi MAC addresses for more information.

MMC boot device

Variable Description Flags
mmcbootdev MMC device index where U-Boot booted from write-once

During start-up, U-Boot initially sets this variable to the MMC device index where the device booted from. The update command uses this variable to determine the MMC device index to write the firmware to.

On the ConnectCore 6 SBC, this is:

You can modify this variable, and can use it to determine the MMC device the ConnectCore 6 booted from.

MMC device (update target)

Variable Description Flags
mmcdev MMC device index to update firmware to -

During start-up, U-Boot initially sets this variable to the MMC device index where the device booted from. The update command uses this variable to determine the MMC device index to write the firmware to.

On the ConnectCore 6 SBC, this is:

You can modify this variable as needed.

Module variant

Variable Description Flags
module_variant Variant ID code for the ConnectCore 6 System-On-Chip write-once

During start-up, U-Boot automatically sets this variable to the ConnectCore 6 System-On-Chip variant ID number (a hexadecimal code programmed in the SOM one-time programmable bits).

Carrier board version and ID

Variable Description Flags
board_version Version number of the carrier board write-once
board_id ID number of the carrier board write-once

During start-up, U-Boot automatically sets these variables to the carrier board's version and ID numbers (decimal numbers programmed in the SOM one-time programmable bits).