# Fw\_"printenv: File format not recognized" error when trying to integrate Mender with U-Boot on Karo TXUL-8013 board

**URL:** <https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402>\
**Category:** General Discussions\
**Created:** [September 7, 2020, 1:20pm UTC](https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402 "2020-09-07T13:20:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![saf](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@saf](https://hub.mender.io/u/saf)\
**Post date:** [September 7, 2020, 1:20pm UTC](https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402/1 "2020-09-07T13:20:43Z")

</div>

Hi everyone.

I am trying to integrate Mender into a working Yocto image for the Karo TXUL-8013 board. I used [this documentation to try and integrate it with U-Boot](https://docs.mender.io/2.4/devices/yocto-project/bootloader-support/u-boot). After doing so, I received an error very similar to [one listed in the troubleshooting section of the documentation](https://docs.mender.io/2.4/troubleshooting/yocto-project-build#i-get-a-build-error-fw_printenv-file-format-not-recognized). Here is the full message:

```
WARNING: u-boot-karo-git-r0 do_patch: Fuzz detected:

Applying patch 0001-Add-missing-header-which-fails-on-recent-GCC.patch
patching file tools/env/fw_env.c
Hunk #1 succeeded at 16 with fuzz 1 (offset -4 lines).

Applying patch 0003-Integration-of-Mender-boot-code-into-U-Boot.patch
patching file include/env_default.h
Hunk #1 succeeded at 10 with fuzz 1.
patching file scripts/Makefile.autoconf
Hunk #1 succeeded at 95 with fuzz 1.

Applying patch 0004-Disable-CONFIG_BOOTCOMMAND-and-enable-CONFIG_MENDER_.patch
patching file include/env_default.h
Hunk #1 succeeded at 34 with fuzz 1.

The context lines in the patches can be updated with devtool:

    devtool modify u-boot-karo
    devtool finish --force-patch-refresh u-boot-karo <layer_path>

Don't forget to review changes done by devtool!

WARNING: u-boot-karo-git-r0 do_patch: QA Issue: Patch log indicates that patches do not apply cleanly. [patch-fuzz]
WARNING: u-boot-karo-git-r0 do_provide_mender_defines: Found more than one dtb specified in KERNEL_DEVICETREE ( imx6ull-txul-8013.dtb imx6ull-txul-8013-mb7.dtb imx6ull-txul-8013-mainboard.dtb ). Only one should be specified. Choosing the last one: imx6ull-txul-8013-mainboard.dtb. Set KERNEL_DEVICETREE to the desired dtb file to silence this warning.
WARNING: u-boot-karo-git-r0 do_mender_uboot_auto_configure: Found more than one machine specified in UBOOT_MACHINE. Only one should be specified. Choosing the last one.
ERROR: u-boot-karo-git-r0 do_mender_uboot_auto_configure: Execution of '/home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/temp/run.do_mender_uboot_auto_configure.16041' failed with exit code 1:
If at any point you get an unexpanded variable, there is probably an argument
you haven't given.
+ SUB_X=-x
+ set -u
+ rm -rf /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/tmp-src
++ dirname /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/tmp-src
+ mkdir -p /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0
+ cp -r /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/git /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/tmp-src
+ cd /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/tmp-src
+ make 'HOSTCC=gcc -DMENDER_AUTO_PROBING' 'CC=arm-poky-linux-gnueabi-gcc -DMENDER_AUTO_PROBING' tx6ul-8013_config
  HOSTCC scripts/basic/fixdep
  HOSTCC scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC scripts/kconfig/zconf.tab.o
  HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
+ grep -q '^tools-all: *env\b' Makefile
+ ENV_TARGET=env
+ grep -q '^tools-all: *envtools\b' Makefile
+ '[' -z env ']'
+ bash -x /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/uboot_auto_patch.sh --patch-config-file
+ UBI=0
+++ dirname /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/uboot_auto_patch.sh
++ readlink -f /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0
+ SCRIPT_DIR=/home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0
+ '[' -z --patch-config-file ']'
+ '[' --patch-config-file = -h ']'
+ '[' --patch-config-file = --help ']'
+ set -e
+ '[' --patch-config-file = --patch-config-file ']'
+ '[' 1 -gt 1 ']'
+ sed -i -e 's/^[\t]*#[\t]*define[\t]*CONFIG_FILE\b.*/#define CONFIG_FILE "fw_env.config"/' tools/env/fw_env.h
+ exit 0
+ make 'HOSTCC=gcc -DMENDER_AUTO_PROBING' 'CC=gcc -DMENDER_AUTO_PROBING' env
scripts/kconfig/conf --silentoldconfig Kconfig
  CHK include/config.h
  UPD include/config.h
  GEN include/autoconf.mk
  GEN include/autoconf.mk.dep
  HOSTCC tools/env/fw_env.o
  HOSTCC tools/env/fw_env_main.o
  HOSTCC tools/env/crc32.o
  HOSTCC tools/env/ctype.o
  HOSTCC tools/env/linux_string.o
  HOSTCC tools/env/env_attr.o
  HOSTCC tools/env/env_flags.o
  HOSTCC tools/env/aes.o
  HOSTLD tools/env/fw_printenv
  STRIP tools/env/fw_printenv
arm-poky-linux-gnueabi-strip:tools/env/fw_printenv: file format not recognized
++ printf %d 0x20000
+ dd if=/dev/zero of=fake-env.txt count=1 bs=131072
1+0 records in
1+0 records out
131072 bytes (131 kB, 128 KiB) copied, 0.000281971 s, 465 MB/s
+ cat
+ mkdir -p fw_printenv.lock
+ ret=0
+ tools/env/fw_printenv -l fw_printenv.lock
tools/env/fw_printenv: invalid option -- 'l'
Try `fw_printenv --help' for more information.
+ ret=1
+ rm -rf fw_printenv.lock
+ '[' 1 -ne 0 ']'
+ '[' 1 -eq 134 -o 1 -eq 139 ']'
+ exit 1
WARNING: exit code 1 from a shell command.

ERROR: Logfile of failure stored in: /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/temp/log.do_mender_uboot_auto_configure.16041

```

I followed the [suggested fix here](https://docs.mender.io/2.4/devices/yocto-project/bootloader-support/u-boot/manual-u-boot-integration#u-boot-fw-utils), but bitbake returned the same error. I used the u-boot-fw-utils file in the poky directory, and made some minor changes. This is the content of the ‘u-boot-fw-utils-karo\_git.bb’ file:

```
require recipes-bsp/u-boot/u-boot-fw-utils-mender.inc

SUMMARY = "U-Boot bootloader fw_printenv/setenv utilities"
DEPENDS += "mtd-utils"

LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://Licenses/README;md5=30503fd321432fc713238f582193b78e"

SRCREV = "e5aee22e4be75e75a854ab64503fc80598bc2004"

SRC_URI = "git://git.denx.de/u-boot.git"

S = "${WORKDIR}/git"

INSANE_SKIP_${PN} = "already-stripped"
EXTRA_OEMAKE_class-target = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${CC} ${CFLAGS} ${LDFLAGS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" V=1'
EXTRA_OEMAKE_class-cross = 'HOSTCC="${CC} ${CFLAGS} ${LDFLAGS}" V=1'

inherit uboot-config

do_compile () {
	oe_runmake ${UBOOT_MACHINE}
	oe_runmake env
}

do_install () {
	install -d ${D}${base_sbindir}
	install -d ${D}${sysconfdir}
	install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_printenv
	install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_setenv
	install -m 0644 ${S}/tools/env/fw_env.config ${D}${sysconfdir}/fw_env.config
}

do_install_class-cross () {
	install -d ${D}${bindir_cross}
	install -m 755 ${S}/tools/env/fw_printenv ${D}${bindir_cross}/fw_printenv
	install -m 755 ${S}/tools/env/fw_printenv ${D}${bindir_cross}/fw_setenv
}

SYSROOT_DIRS_append_class-cross = " ${bindir_cross}"

PACKAGE_ARCH = "${MACHINE_ARCH}"
BBCLASSEXTEND = "cross"

PROVIDES_${PN} = "u-boot-fw-utils"
RPROVIDES_${PN} = "u-boot-fw-utils"

```

This is the content of ‘u-boot-karo\_git.bb’:

```
require recipes-bsp/u-boot/u-boot.inc
require recipes-bsp/u-boot/u-boot-mender.inc

DESCRIPTION = "U-Boot for Ka-Ro electronics TX Computer-On-Modules."
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM_mx6 = "file://Licenses/README;md5=0507cd7da8e7ad6d6701926ec9b84c95"
LIC_FILES_CHKSUM_stm32mp1 = "file://Licenses/README;md5=30503fd321432fc713238f582193b78e"

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

DEPENDS_append = " bc-native"
DEPENDS_append_stm32mp1 = " bison-native"

SRCBRANCH_mx6 = "master"
SRC_URI_mx6 = "git://github.com/karo-electronics/karo-tx-uboot.git;protocol=https;branch=${SRCBRANCH}"
SRCREV_mx6 = "6d7e3f066d2b977b02f6a471e749030d62ae5bde"

SRCBRANCH_stm32mp1 = "master"
SRC_URI_stm32mp1 = "git://git.denx.de/u-boot.git;protocol=git;branch=${SRCBRANCH}"
SRCREV_stm32mp1 = "e0718b3ab754860bd47677e6b4fc5b70da42c4ab"

S = "${WORKDIR}/git"

# append git hash to u-boot name
SCMVERSION ??= "y"
LOCALVERSION ??= "+karo"

UBOOT_LOCALVERSION = "${LOCALVERSION}"

do_compile_prepend() {
	if ["${SCMVERSION}" = "y"]; then
		# Add GIT revision to the local version
		head=`cd ${S} ; git rev-parse --verify --short HEAD 2> /dev/null`
		printf "%s%s%s" "${UBOOT_LOCALVERSION}" +g $head > ${S}/.scmversion
		printf "%s%s%s" "${UBOOT_LOCALVERSION}" +g $head > ${B}/.scmversion
    else
		printf "%s" "${UBOOT_LOCALVERSION}" > ${S}/.scmversion
		printf "%s" "${UBOOT_LOCALVERSION}" > ${B}/.scmversion
	fi
}

# -----------------------------------------------------------------------------
# Append deploy to handle specific device tree binary deployement
#
do_deploy_append_stm32mp1 () {
    if [-n "${UBOOT_CONFIG}"]; then
        unset i j k
        for config in ${UBOOT_MACHINE}; do
            i=$(expr $i + 1);
            for type in ${UBOOT_CONFIG}; do
                j=$(expr $j + 1);
                if [$j -eq $i]; then
                    install -m 644 ${B}/${config}/u-boot-${type}.bin ${DEPLOYDIR}

                    # As soon as SPL binary exists, install it
                    # This allow to mix u-boot configuration, with and without SPL
                    if [-f ${B}/${config}/u-boot-spl.stm32]; then
                        install -m 644 ${B}/${config}/u-boot-spl.stm32 ${DEPLOYDIR}
                    fi
                fi
            done
            unset j
        done
        unset i
    else
        bbfatal "Wrong u-boot-stm32mp configuration: please make sure to use UBOOT_CONFIG through BOOTSCHEME_LABELS config"
    fi
}

# ---------------------------------------------------------------------
# Avoid QA Issue: No GNU_HASH in the elf binary
INSANE_SKIP_${PN} += "ldflags"
# ---------------------------------------------------------------------
# Avoid QA Issue: ELF binary has relocations in .text
# (uboot no need -fPIC option : remove check)
INSANE_SKIP_${PN} += "textrel"

PACKAGE_ARCH = "${MACHINE_ARCH}"

COMPATIBLE_MACHINE_tx6 = "(tx6[qsu]-.*)"
COMPATIBLE_MACHINE_txul = "(txul-.*)"
COMPATIBLE_MACHINE_stm32mp1 = "(txmp-.*|qsmp-.*)"

UBOOT_NAME = "u-boot-${MACHINE}.bin"

```

I also added the following lines to the local.conf:

```
PREFERRED_PROVIDER_u-boot-fw-utils = "u-boot-fw-utils-karo"
PREFERRED_RPROVIDER_u-boot-fw-utils = "u-boot-fw-utils-karo"

```

I think the problem lies in the u-boot-fw-utils-karo\_git.bb file. As you can see from the error message, there appears to be a problem with one of the Mender U-Boot patches. I had to make some minor changes to the patch because the U-Boot fork was slightly different than what the patch expected. I don’t think this is what is causing the error above, but I have posted the modified patch below in case it’s relevant:

```
From f8cc3e077230572b4a0b557435833d24b89933f5 Mon Sep 17 00:00:00 2001
From: Marcin Pasinski <marcin.pasinski@northern.tech>
Date: Wed, 31 Jan 2018 18:10:04 +0100
Subject: [PATCH 3/4] Integration of Mender boot code into U-Boot.

Signed-off-by: Kristian Amlie <kristian.amlie@mender.io>
Signed-off-by: Maciej Borzecki <maciej.borzecki@rndity.com>
Signed-off-by: Marcin Pasinski <marcin.pasinski@northern.tech>
---
 include/env_default.h | 3 +++
 scripts/Makefile.autoconf | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/env_default.h b/include/env_default.h
index 56a8bae39a..472e2fda9a 100644
--- a/include/env_default.h
+++ b/include/env_default.h
@@ -10,6 +10,8 @@
 
 #include <env_callback.h>
 
+#include <env_mender.h>
+
 #ifdef DEFAULT_ENV_INSTANCE_EMBEDDED
 env_t environment __PPCENV__ = {
         ENV_CRC, /* CRC Sum */
@@ -22,6 +24,7 @@ static char default_environment[] = {
 #else
 const uchar default_environment[] = {
 #endif
+	MENDER_ENV_SETTINGS
 #ifdef	CONFIG_ENV_CALLBACK_LIST_DEFAULT
 	ENV_CALLBACK_VAR "=" CONFIG_ENV_CALLBACK_LIST_DEFAULT "\0"
 #endif
diff --git a/scripts/Makefile.autoconf b/scripts/Makefile.autoconf
index 00b8fb34aa..e312c8037d 100644
--- a/scripts/Makefile.autoconf
+++ b/scripts/Makefile.autoconf
@@ -95,7 +95,8 @@ define filechk_config_h
	echo \#include \<config_uncmd_spl.h\>; \
 	echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \
 	echo \#include \<asm/config.h\>; \
-	echo \#include \<config_fallbacks.h\>;)
+	echo \#include \<config_fallbacks.h\>; \
+	echo \#include \<config_mender.h\>;)
 endef
 
 include/config.h: scripts/Makefile.autoconf create_symlink FORCE
-- 
2.17.1

```

[Here is the](https://github.com/karo-electronics/meta-karo) BSP that makes up my image if that helps. I’d appreciate any help 🙂

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [September 8, 2020, 8:25pm UTC](https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402/2 "2020-09-08T20:25:05Z")

</div>

It looks like you have a few issues.

The first issue, (ie File format not recognized) is known and the analysis is [available here](https://docs.mender.io/2.4/troubleshooting/yocto-project-build#i-get-a-build-error-fw_printenv-file-format-not-recognized).

And as for the patches not applying cleanly, there are some very subtle things that can happen if they are applied with “fuzz”. I don’t know all the details, but I make it a habit to regenerate the patches when needed. You likely need to create custom versions of those patches for your BSP and use a combination of SRC\_URI\_append and SRC\_URI\_remove statements in your recipes to get the modified patches used instead of the ones from upstream.

Drew

---

<div class="post-metadata">

**Author:** ![saf](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@saf](https://hub.mender.io/u/saf)\
**Post date:** [September 9, 2020, 1:29pm UTC](https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402/3 "2020-09-09T13:29:50Z")

</div>

Thanks very much for your reply Drew. Following the link in your reply and by slightly adapting the u-boot-fw-utils recipe in the poky layer, this is the current u-boot-fw-utils-karo.bb file in my meta-karo/recipes-bsp/u-boot/ directory:

```
require recipes-bsp/u-boot/u-boot-fw-utils-mender.inc

SUMMARY = "U-Boot bootloader fw_printenv/setenv utilities"
DEPENDS += "mtd-utils"
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6"

SRCREV = "e5aee22e4be75e75a854ab64503fc80598bc2004"
SRC_URI = "git://git.denx.de/u-boot.git"

S = "${WORKDIR}/git"

INSANE_SKIP_${PN} = "already-stripped"
EXTRA_OEMAKE_class-target = 'CROSS_COMPILE=${TARGET_PREFIX} CC="${CC} ${CFLAGS} ${LDFLAGS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" V=1'
EXTRA_OEMAKE_class-cross = 'HOSTCC="${CC} ${CFLAGS} ${LDFLAGS}" V=1'

inherit uboot-config

do_compile () {
	oe_runmake ${UBOOT_MACHINE}
	oe_runmake envtools
}

do_install () {
	install -d ${D}${base_sbindir}
	install -d ${D}${sysconfdir}
	install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_printenv
	install -m 755 ${S}/tools/env/fw_printenv ${D}${base_sbindir}/fw_setenv
	install -m 0644 ${S}/tools/env/fw_env.config ${D}${sysconfdir}/fw_env.config
}

do_install_class-cross () {
	install -d ${D}${bindir_cross}
	install -m 755 ${S}/tools/env/fw_printenv ${D}${bindir_cross}/fw_printenv
	install -m 755 ${S}/tools/env/fw_printenv ${D}${bindir_cross}/fw_setenv
}

SYSROOT_DIRS_append_class-cross = " ${bindir_cross}"

PACKAGE_ARCH = "${MACHINE_ARCH}"
BBCLASSEXTEND = "cross"

PROVIDES_${PN} += "u-boot-fw-utils"
RPROVIDES_${PN} += "u-boot-fw-utils"

```

I’m still getting the same error listed in my original post. Do you have any idea what could be wrong with this? I’d really appreciate any advice here.

Also, bitbake returns this note/warning, which could be related to the issue:

```
NOTE: Multiple providers are available for u-boot-fw-utils (u-boot-fw-utils, u-boot-fw-utils-mender-auto-provided)
Consider defining a PREFERRED_PROVIDER entry to match u-boot-fw-utils

```

I don’t understand why this is showing up, given that I have included the following in my build/conf/local.conf:

```
PREFERRED_PROVIDER_u-boot-fw-utils = "u-boot-fw-utils-karo"
PREFERRED_RPROVIDER_u-boot-fw-utils = "u-boot-fw-utils-karo"
```

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [September 9, 2020, 2:15pm UTC](https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402/4 "2020-09-09T14:15:44Z")

</div>

It looks like the u-boot-fw-utils-karo recipes does not PROVIDE u-boot-fw-utils. I think you need to define it as follows instead of what you have:

```auto
PROVIDES += "u-boot-fw-utils"
RPROVIDES_${PN} += "u-boot-fw-utils"

```

---

<div class="post-metadata">

**Author:** ![saf](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@saf](https://hub.mender.io/u/saf)\
**Post date:** [September 9, 2020, 3:35pm UTC](https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402/5 "2020-09-09T15:35:14Z")

</div>

Thanks again Drew. After implementing your suggestion, bitbake no longer gives that warning, suggesting that it is using the correct recipe. Unfortunately, the errors:

```
arm-poky-linux-gnueabi-strip:tools/env/fw_printenv: file format not recognized

```

and

```
+ tools/env/fw_printenv -l fw_printenv.lock
tools/env/fw_printenv: invalid option -- 'l'
Try `fw_printenv --help' for more information.

```

still persist.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [September 11, 2020, 5:48am UTC](https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402/6 "2020-09-11T05:48:34Z")

</div>

This must be a quite old version of U-Boot. That flag was added in v2016.11. You can try to add [this patch](https://gitlab.denx.de/u-boot/u-boot/-/commit/d40dbfb7405cb74946ba0a6e9058045fdb5bddaf) to the list of U-Boot patches.

---

<div class="post-metadata">

**Author:** ![saf](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@saf](https://hub.mender.io/u/saf)\
**Post date:** [September 11, 2020, 4:43pm UTC](https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402/7 "2020-09-11T16:43:37Z")

</div>

Thanks very much for the link to the patch. I think the U-boot version in the Karo fork is from 2015, so I had to make some minor changes before I could apply the patch, but I no longer get the same error. Having some other problems, but they look solvable.

---

<div class="post-metadata">

**Author:** ![saf](https://avatars.discourse-cdn.com/v4/letter/s/59ef9b/32.png) [@saf](https://hub.mender.io/u/saf)\
**Post date:** [September 15, 2020, 4:02pm UTC](https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402/8 "2020-09-15T16:02:26Z")

</div>

The [Karo U-Boot fork](https://github.com/karo-electronics/karo-tx-uboot) is from around 2015 I think. So I used devshell to create a patch that replaces everything in tools/env with with tools/env from [the 2016.09 branch of the upstream U-Boot](https://github.com/u-boot/u-boot/tree/u-boot-2016.09.y/tools/env). When trying to compile u-boot-karo, bitbake encountered some other problems with files not existing due to the env directory being changed, so I had to add include/env\_flags.h and common/env\_flags.c from the 2016.09 branch of the upstream U-Boot.

After doing this, I then added the [patch provided by Kristian](https://gitlab.denx.de/u-boot/u-boot/-/commit/d40dbfb7405cb74946ba0a6e9058045fdb5bddaf) using devshell. I then ran into [this known error](http://docs.mender.io/troubleshoot/yocto-project-build#do_mender_uboot_auto_configure-fails-when-executing-tools-env-fw), which was resolved by [manually adding the linked patch via devshell](https://raw.githubusercontent.com/mendersoftware/meta-mender/27f9e8dabf461d59dec4d94bd93d6b7207be0040/meta-mender-core/recipes-bsp/u-boot/patches/0005-fw_env_main.c-Fix-incorrect-size-for-malloc-ed-strin.patch). This is the error I get now:

```
    NOTE: Executing Tasks
NOTE: Setscene tasks completed
WARNING: u-boot-karo-git-r0 do_mender_uboot_auto_configure: Found more than one machine specified in UBOOT_MACHINE. Only one should be specified. Choosing the last one.
ERROR: u-boot-karo-git-r0 do_mender_uboot_auto_configure: Execution of '/home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/temp/run.do_mender_uboot_auto_configure.4345' failed with exit code 2:
If at any point you get an unexpanded variable, there is probably an argument
you haven't given.
+ SUB_X=-x
+ set -u
+ rm -rf /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/tmp-src
++ dirname /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/tmp-src
+ mkdir -p /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0
+ cp -r /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/git /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/tmp-src
+ cd /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/tmp-src
+ make 'HOSTCC=gcc -DMENDER_AUTO_PROBING' 'CC=arm-poky-linux-gnueabi-gcc -DMENDER_AUTO_PROBING' tx6ul-8013_config
  HOSTCC scripts/basic/fixdep
  HOSTCC scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC scripts/kconfig/zconf.tab.o
  HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
+ grep -q '^tools-all: *env\b' Makefile
+ ENV_TARGET=env
+ grep -q '^tools-all: *envtools\b' Makefile
+ '[' -z env ']'
+ bash -x /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/uboot_auto_patch.sh --patch-config-file
+ UBI=0
+++ dirname /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/uboot_auto_patch.sh
++ readlink -f /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0
+ SCRIPT_DIR=/home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0
+ '[' -z --patch-config-file ']'
+ '[' --patch-config-file = -h ']'
+ '[' --patch-config-file = --help ']'
+ set -e
+ '[' --patch-config-file = --patch-config-file ']'
+ '[' 1 -gt 1 ']'
+ sed -i -e 's/^[\t]*#[\t]*define[\t]*CONFIG_FILE\b.*/#define CONFIG_FILE "fw_env.config"/' tools/env/fw_env.h
+ exit 0
+ make 'HOSTCC=gcc -DMENDER_AUTO_PROBING' 'CC=gcc -DMENDER_AUTO_PROBING' env
scripts/kconfig/conf --silentoldconfig Kconfig
  CHK include/config.h
  UPD include/config.h
  GEN include/autoconf.mk
  GEN include/autoconf.mk.dep
  LD tools/env/built-in.o
  HOSTCC tools/env/aes.o
  HOSTCC tools/env/crc32.o
  HOSTCC tools/env/ctype.o
  HOSTCC tools/env/env_attr.o
  HOSTCC tools/env/env_flags.o
  HOSTCC tools/env/fw_env.o
  HOSTCC tools/env/linux_string.o
  AR tools/env/lib.a
  HOSTCC tools/env/fw_env_main.o
  HOSTLD tools/env/fw_printenv
  STRIP tools/env/fw_printenv
arm-poky-linux-gnueabi-strip:tools/env/fw_printenv: file format not recognized
++ printf %d 0x20000
+ dd if=/dev/zero of=fake-env.txt count=1 bs=131072
1+0 records in
1+0 records out
131072 bytes (131 kB, 128 KiB) copied, 0.000251128 s, 522 MB/s
+ cat
+ mkdir -p fw_printenv.lock
+ ret=0
+ tools/env/fw_printenv -l fw_printenv.lock
Warning: Bad CRC, using default environment
+ rm -rf fw_printenv.lock
+ '[' 0 -ne 0 ']'
+ make 'HOSTCC=gcc -DMENDER_AUTO_PROBING' 'CC=arm-poky-linux-gnueabi-gcc -DMENDER_AUTO_PROBING' cmd/version.o
make: *** No rule to make target 'cmd/version.o'. Stop.
WARNING: exit code 2 from a shell command.

ERROR: Logfile of failure stored in: /home/safian99ali/karo-bsp/build-txul-8013/tmp/work/txul_8013-poky-linux-gnueabi/u-boot-karo/git-r0/temp/log.do_mender_uboot_auto_configure.4345

```

Any ideas?

---

<div class="post-metadata">

**Author:** ![rlaybourn](https://avatars.discourse-cdn.com/v4/letter/r/43a26b/32.png) [@rlaybourn](https://hub.mender.io/u/rlaybourn)\
**Post date:** [May 14, 2021, 11:56am UTC](https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402/9 "2021-05-14T11:56:08Z")

</div>

Sorry to jump in here but the link you gave no longer seems go have any reference to the file format not recognised problem , do you know if this has been moved ? I am having what appears to be a very similar problem on a txul-5011 unit from karo

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [May 14, 2021, 12:16pm UTC](https://hub.mender.io/t/fw-printenv-file-format-not-recognized-error-when-trying-to-integrate-mender-with-u-boot-on-karo-txul-8013-board/2402/10 "2021-05-14T12:16:43Z")

</div>

Hi @rlaybourn I found that reference in an [older version](https://docs.mender.io/2.4/troubleshooting/yocto-project-build#i-get-a-build-error-fw_printenv-file-format-not-recognized) of our docs.

Hope that helps.  
Drew
