[Buildroot] Using u-boot tools

Thomas De Schampheleire patrickdepinguin at gmail.com
Tue Sep 30 09:58:41 UTC 2014

Hi Kantanu,

On Tue, Sep 30, 2014 at 11:33 AM, Kantanu Kumar Mohapatra
<kantanukumar at gmail.com> wrote:

> Thanks a lot Thomas for your reply. Sorry for the typo, please consider the
> new version as buildroot-2014.02.
> Let me explain all in detail.
> old br2:
> ========
> version: 2010.05
> uboot: 2010.03(customized)
> uboot-tools: 2010.03 (used from uboot src)
> New br2 (which I am upgrading to):
> ===========================
> version: 2014.02
> uboot: 2010.03(customized, same should be across tools too)
> uboot-tools: 2014.01 ( should be same as uboot-2010.03)

While I can understand that you do not want to update u-boot itself,
what is the problem to use the most recent version of u-boot-tools ?
In the cases I have seen, there was no conflict when using the most
recent u-boot-tools with images of an older u-boot.

> In br2-14, I am getting the uboot image(.bin) properly, which I customized
> to get a .rom with my headers added to it, done in boot/uboot/uboot.mk
> Here the problem which I faced is "fw_printenv" executable, which is built
> in tools, for br2-2014.02. fw_printenv is created, when getting the uboot
> image in br2-2010.03 (target/uboot/Makefile.in).
> In br2-2014.02,
> Tools should be taken from the source, which went into
> output/build/uboot-2010.03, But instead it creates another
> uboot-tools-2014.01 inside output/build/ and places source there.
> How to build that fw_printenv, in old way like br2-10, seen as below?
> $(TARGET_DIR)/usr/sbin/fw_printenv: $(U_BOOT_DIR)/$(U_BOOT_BIN)
>     mkdir -p $(@D)
>     $(TARGET_CC) -I$(U_BOOT_DIR)/include -I$(LINUX_HEADERS_DIR)/include \
>         -D_custom_flag \
>         -DUSE_HOSTCC -o $@ \
>         $(U_BOOT_DIR)/tools/env/*.c $(U_BOOT_DIR)/lib_generic/crc32.c

This is no longer used. In buildroot 2010.05, the rules to build
fw_printenv were indeed part of buildroot explicitly, as shown above.
In buildroot 2014.02, we are using the u-boot makefiles to define how
to build these tools. So you cannot simply use the same way as you did
for buildroot-2010.05.

> I want to use another "-D_custom_flag" to build "fw_printenv", in br2-14.
> Please suggest me the changes to be done. If I change   UBOOT_TOOLS_VERSION
> = 2010.03, in  uboot-tools.mk, getting compilation error, as it has
> dependency on host-tools.

I think you have two options:

1. add a patch for u-boot itself, adding your custom -D flag in the
appropriate u-boot makefile (probably in tools/env/Makefile, but I
don't know if this was already the case in u-boot-2010.03, I haven't

2. In package/uboot-tools/uboot-tools.mk, there is this code:

    $(MAKE) -C $(@D)             \
        CFLAGS="$(TARGET_CFLAGS)"    \
        LDFLAGS="$(TARGET_LDFLAGS)"    \
        CROSS_BUILD_TOOLS=y        \
    $(MAKE) -C $(@D)             \
        CFLAGS="$(TARGET_CFLAGS)"    \
        LDFLAGS="$(TARGET_LDFLAGS)"    \
        env no-dot-config-targets=env

The second make command is (as far as I can see) responsible for
building the fw_printenv tool. If your custom flag can safely be
passed to other tools inside the tools/env directory of u-boot, then
you could consider adding your custom flag here too, something like:
    $(MAKE) -C $(@D)             \
        CFLAGS="$(TARGET_CFLAGS) -Dcustom_flag"    \
        LDFLAGS="$(TARGET_LDFLAGS)"    \
        env no-dot-config-targets=env

Note that I have not tested this explicitly.

Hope this helps,

More information about the buildroot mailing list