You are browsing documentation for a version other than the latest stable release. Switch to the latest stable release, 1.5.

Yocto Project build

Your project is using a fork of U-Boot which conflicts with the U-Boot Mender uses

When Building a Mender Yocto Project image for your own project and device, you encounter a build error similar to the following:

ERROR: Multiple .bb files are due to be built which each provide u-boot (.../tisdk/sources/meta-variscite/recipes-bsp/u-boot/ .../tisdk/sources/meta-ti/recipes-bsp/u-boot/
 This usually means one provides something the other doesn't and should.

Mender needs to configure U-Boot in order to support robust rootfs rollback. If your project relies on a fork of U-Boot this needs to be integrated. For more information, see Integrating with U-Boot, in particular the section on Forks of U-boot.

A U-Boot component is failing to compile, and it compiles without Mender

This may be an indication that Mender's automatic U-Boot patching has failed for the particular board that's being built for, and a manual patch may be required. For information on how to create such a patch, go to the Manual U-Boot integration section.

U-Boot and the Linux kernel do not agree about the indexes of storage devices

Sometimes it happens that U-Boot will refer to a storage device as mmc 0, whereas the Linux kernel will refer to the same device as /dev/mmcblk1 (note the different index). In this case the Mender build system must be told explicitly about this disagreement. To do so, you can set the following two variables:


which will set the index that U-Boot will use. All non-U-Boot references to the storage device, including the root argument passed by U-Boot to the Linux kernel when booting it, will keep using the /dev/mmcblk1 variant derived from MENDER_STORAGE_DEVICE variables.

Bootloader is missing from boot partition, but is required for my device

By default Mender does not add any bootloader files to the boot partition. If your device requires this you need to specify the files in the IMAGE_BOOT_FILES variable in the machine.conf file for your device. For example:

IMAGE_BOOT_FILES ?= "u-boot.bin MLO"

See the Yocto Project documentation for more information about the IMAGE_BOOT_FILES variable.

U-Boot lacks support for Boot Count Limit

In order to support robust rootfs rollback, Mender depends on being able to tell the bootloader to roll back to the known-working rootfs if attempts to boot the updated rootfs fails a given number of times. Currently, Mender uses the Boot Count Limit feature of U-Boot to achieve this. If you see errors similar to the following during the Yocto Project build process, the U-Boot you are using most likely does not support this feature.

include/config_mender.h:34:3: error: #error CONFIG_BOOTCOUNT_ENV is required for Mender to work

There are two alternatives to resolve this issue. Either you can upgrade to U-Boot v2014.07 or newer, where Boot Count Limit was introduced, or you can patch your current U-Boot version to support this or a similar feature. Please see Bootloader support for more information.

The build produces an error message "__populate_fs: Could not allocate block in ext2 filesystem while writing file..."

This is most likely because you are producing an image that has a lot of small files, so many that the filesystem runs out of blocks, even if there is enough space when counting bytes. There are several ways this can be remedied:

  • Check if you have dbg-pkgs set in IMAGE_FEATURES or EXTRA_IMAGE_FEATURES. This will cause debug packages to be included in the image, which typically contain a lot of small files. If you don't need the debug information, this feature can be disabled.

  • Increase the size of the image by increasing the value in MENDER_STORAGE_TOTAL_SIZE_MB (see description in Variables), which will also increase the number of blocks. However, note that unless it is increased greatly, this will still give you a filesystem which is fairly close to the block limit, so the problem could happen during production instead, if the device writes enough files.

  • Decrease the size of each block. This can be done by setting EXTRA_IMAGECMD_ext4 = " -b 1024" in local.conf. The default is 4096, it must be a power of 2, and it must not be smaller than 1024.

I get a build error "fw_printenv: File format not recognized"

The symptom is an error message similar to this:

ERROR: u-boot-fw-utils-mender-auto-provided-1.0-r0 do_package: objcopy failed with exit code 1 (cmd was 'arm-poky-linux-gnueabi-objcopy' --only-keep-debug '/home/user/poky/build/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/u-boot-fw-utils-mender-auto-provided/1.0-r0/package/sbin/fw_printenv' '/home/user/poky/build/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/u-boot-fw-utils-mender-auto-provided/1.0-r0/package/sbin/.debug/fw_printenv'):
arm-poky-linux-gnueabi-objcopy:/home/user/poky/build/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/u-boot-fw-utils-mender-auto-provided/1.0-r0/package/sbin/fw_printenv: File format not recognized
ERROR: u-boot-fw-utils-mender-auto-provided-1.0-r0 do_package: Function failed: split_and_strip_files
ERROR: Logfile of failure stored in: /home/user/poky/build/tmp/work/cortexa7hf-neon-poky-linux-gnueabi/u-boot-fw-utils-mender-auto-provided/1.0-r0/temp/log.do_package.15130
ERROR: Task (/home/user/poky/meta-mender/meta-mender-core/recipes-bsp/u-boot/ failed with exit code '1'

This is a known bug in U-Boot versions prior to v2017.05. If you get this error, the auto-provided recipe won't work, so you will have to carry out the steps in the u-boot-fw-utils guide. Note that only the section under "u-boot-fw-utils" is necessary, the other sections on the same page, such as MENDER_UBOOT_AUTO_CONFIGURE = "0", should not be necessary to carry out unless you have other reasons to do so.

I get a build error if I am using PREFERRED_PROVIDER_virtual/bootloader instead of PREFERRED_PROVIDER_u-boot

The symptom is an error message similar to this:

ERROR: Nothing PROVIDES 'u-boot'
u-boot was skipped: PREFERRED_PROVIDER_virtual/bootloader set to u-boot-rockchip, not u-boot
ERROR: Required build target 'core-image-base' has no buildable providers.
Missing or unbuildable dependency chain was: ['core-image-base', 'u-boot']

This error stems from the fact that custom u-boot fork recipes are missing hard dependency required by mender recipes. If you get this error you need to add following lines to your custom u-boot fork recipe:

PROVIDES += "u-boot"
RPROVIDES_${PN} = "u-boot"

Detailed explanation how to do it you can find in Integrating with U-Boot section.

I'm using Flash/UBI setup and getting the message that BOOTENV_SIZE is too big to fit two copies inside MENDER_RESERVED_SPACE_BOOTLOADER_DATA with proper alignment, but my Flash size should be big enough

The message may look something like this:

ERROR: u-boot-toradex-2016.11+gitAUTOINC+087e95a2dc-r0 do_provide_mender_defines: BOOTENV_SIZE (0x20000) is too big to fit two copies inside MENDER_RESERVED_SPACE_BOOTLOADER_DATA (253952) with proper alignment. Please either: 1. Increase MENDER_RESERVED_SPACE_BOOTLOADER_DATA manually and make sure it is an *even* multiple of MENDER_PARTITION_ALIGNMENT. -or- 2. Decrease BOOTENV_SIZE in the U-Boot recipe so that it can fit two copies inside MENDER_RESERVED_SPACE_BOOTLOADER_DATA.
ERROR: u-boot-toradex-2016.11+gitAUTOINC+087e95a2dc-r0 do_provide_mender_defines: Function failed: do_provide_mender_defines (log file is located at /home/user/poky/build/colibri-imx7-mender/tmp/work/colibri_imx7_mender-poky-linux-gnueabi/u-boot-toradex/2016.11+gitAUTOINC+087e95a2dc-r0/temp/log.do_provide_mender_defines.22000)
ERROR: Logfile of failure stored in: /home/user/poky/build/colibri-imx7-mender/tmp/work/colibri_imx7_mender-poky-linux-gnueabi/u-boot-toradex/2016.11+gitAUTOINC+087e95a2dc-r0/temp/log.do_provide_mender_defines.22000
ERROR: Task (/home/user/poky/src/meta-freescale-3rdparty/recipes-bsp/u-boot/ failed with exit code '1'

The problem is that the U-Boot environment that Mender uses is written to a UBI volume, not to pure Flash memory, and UBI block sizes (LEB sizes) are smaller than physical Flash block sizes (PEB sizes). UBI uses these extra bytes for its own purposes, so they are not available for storage. Therefore the U-Boot environment must be adjusted to fit inside Mender's UBI volume if it fit exactly into physical sectors before introducing Mender.

There are two simple ways to fix the problem; which one should be used depends on the situation.

  1. Decrease the BOOTENV_SIZE variable, so that it's no longer too big to fit two copies. This is generally the recommended solution unless you really need BOOTENV_SIZE size to be a certain size.

  2. Multiply MENDER_RESERVED_SPACE_BOOTLOADER_DATA, whose value you can see in the error message, by some even value, like 2, and set that in the configuration for the board.

In the UBI case, MENDER_RESERVED_SPACE_BOOTLOADER_DATA is generally not a power two, so watch out for this. It should be an even multiple of MENDER_PARTITION_ALIGNMENT, which is itself defined from MENDER_UBI_LEB_SIZE, both of which you can get by running bitbake -e core-image-minimal | egrep '^(MENDER_UBI_LEB_SIZE|MENDER_PARTITION_ALIGNMENT)='.

do_mender_uboot_auto_configure fails when executing tools/env/fw_printenv -l fw_printenv.lock

Typical symptoms is that there is some output similar to this:

+ tools/env/fw_printenv -l fw_printenv.lock
*** buffer overflow detected ***: tools/env/fw_printenv terminated
======= Backtrace: =========
======= Memory map: ========
00400000-00407000 r-xp 00000000 08:01 8197150                            /home/user/poky/build-vexpress-qemu/tmp/work/vexpress_qemu-poky-linux-gnueabi/u-boot/1_2018.01-r0/tmp-src/tools/env/fw_printenv
00606000-00607000 r--p 00006000 08:01 8197150                            /home/user/poky/build-vexpress-qemu/tmp/work/vexpress_qemu-poky-linux-gnueabi/u-boot/1_2018.01-r0/tmp-src/tools/env/fw_printenv
00607000-00609000 rw-p 00007000 08:01 8197150                            /home/user/poky/build-vexpress-qemu/tmp/work/vexpress_qemu-poky-linux-gnueabi/u-boot/1_2018.01-r0/tmp-src/tools/env/fw_printenv
01456000-01477000 rw-p 00000000 00:00 0                                  [heap]
7fee9e1e1000-7fee9e1f7000 r-xp 00000000 08:01 1961                       /lib/x86_64-linux-gnu/
7fee9e1f7000-7fee9e3f6000 ---p 00016000 08:01 1961                       /lib/x86_64-linux-gnu/
7fee9e3f6000-7fee9e3f7000 rw-p 00015000 08:01 1961                       /lib/x86_64-linux-gnu/
7fee9e3f7000-7fee9e5b7000 r-xp 00000000 08:01 1967                       /lib/x86_64-linux-gnu/
7fee9e5b7000-7fee9e7b7000 ---p 001c0000 08:01 1967                       /lib/x86_64-linux-gnu/
7fee9e7b7000-7fee9e7bb000 r--p 001c0000 08:01 1967                       /lib/x86_64-linux-gnu/
7fee9e7bb000-7fee9e7bd000 rw-p 001c4000 08:01 1967                       /lib/x86_64-linux-gnu/
7fee9e7bd000-7fee9e7c1000 rw-p 00000000 00:00 0
7fee9e7c1000-7fee9e7e7000 r-xp 00000000 08:01 1965                       /lib/x86_64-linux-gnu/
7fee9e9d9000-7fee9e9dc000 rw-p 00000000 00:00 0
7fee9e9e5000-7fee9e9e6000 rw-p 00000000 00:00 0
7fee9e9e6000-7fee9e9e7000 r--p 00025000 08:01 1965                       /lib/x86_64-linux-gnu/
7fee9e9e7000-7fee9e9e8000 rw-p 00026000 08:01 1965                       /lib/x86_64-linux-gnu/
7fee9e9e8000-7fee9e9e9000 rw-p 00000000 00:00 0
7ffd719dc000-7ffd719ff000 rw-p 00000000 00:00 0                          [stack]
7ffd71a73000-7ffd71a76000 r--p 00000000 00:00 0                          [vvar]
7ffd71a76000-7ffd71a78000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
./ line 120:  3631 Aborted                 (core dumped) tools/env/fw_printenv -l fw_printenv.lock > "$TMP_DIR/compiled-environment.txt"
WARNING: exit code 134 from a shell command.
ERROR: Function failed: do_mender_uboot_auto_configure (log file is located at /home/user/poky/build-vexpress-qemu/tmp/work/vexpress_qemu-poky-linux-gnueabi/u-boot/1_2018.01-r0/temp/log.do_mender_uboot_auto_configure.29863)

This is a known bug in U-Boot versions prior to v2018.05. If you hit this you will need to include this patch in your U-Boot sources. After adding the patch file to your layer, in your U-Boot .bb or .bbappend file, add the following:

SRC_URI_append = " file://0005-fw_env_main.c-Fix-incorrect-size-for-malloc-ed-strin.patch"