# Error when trying to build u-boot for Raspberry Pi on Ubuntu 20.04 (scarthgap)

**URL:** <https://hub.mender.io/t/error-when-trying-to-build-u-boot-for-raspberry-pi-on-ubuntu-20-04-scarthgap/7081>\
**Category:** General Discussions\
**Created:** [August 6, 2024, 5:46am UTC](https://hub.mender.io/t/error-when-trying-to-build-u-boot-for-raspberry-pi-on-ubuntu-20-04-scarthgap/7081 "2024-08-06T05:46:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![StMartin81](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/stmartin81/32/1745_2.png) [@StMartin81](https://hub.mender.io/u/StMartin81)\
**Post date:** [August 6, 2024, 5:46am UTC](https://hub.mender.io/t/error-when-trying-to-build-u-boot-for-raspberry-pi-on-ubuntu-20-04-scarthgap/7081/1 "2024-08-06T05:46:00Z")

</div>

I get the following error message when trying to build u-boot on scarthgap:

> | gcc: error: unrecognized command line option ‘-fcanon-prefix-map’; did you mean ‘-fmacro-prefix-map=’?  
> | make: \*\*\* [Makefile:1817: include/generated/env.in] Error 1

This is because the host compiler version on this Ubuntu version is 9.4 where this option isn’t supported.

The error stems from the following code in the Makefile in the root of the u-boot source directory:

> quiet\_cmd\_gen\_envp = ENVP $@  
> cmd\_gen\_envp =   
> if [-s “$(ENV\_FILE)”]; then   
> $(CPP) -P $(CFLAGS) -x assembler-with-cpp -D\_\_ASSEMBLY\_\_   
> -D\_\_UBOOT\_CONFIG\_\_   
> -I . -I include -I $(srctree)/include   
> -include linux/kconfig.h -include include/config.h   
> -I$(srctree)/arch/$(ARCH)/include   
> $\< -o $@;   
> else   
> rm -f $@;   
> touch $@ ;   
> fi  
> include/generated/env.in: include/generated/env.txt  
> $(call cmd,gen\_envp)

A workaround would be to add the following line to u-boot-mender.inc in line 332:

> ```
> CFLAGS="${BUILD_CFLAGS}" \
> BUILDCC="${BUILD_CC}" \
> CROSS_COMPILE="${TARGET_PREFIX}" \
> 
> ```

But I’m not sure if this this is correct. Honestly I don’t understand which steps need the host compiler toolchain and which steps should be using the cross compiler toolchain. Perhaps this is something which should be cleaned up in u-boot?

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [August 6, 2024, 9:16am UTC](https://hub.mender.io/t/error-when-trying-to-build-u-boot-for-raspberry-pi-on-ubuntu-20-04-scarthgap/7081/2 "2024-08-06T09:16:32Z")

</div>

HI @StMartin81,

That’s definitely strange, especially as building `u-boot` in a Yocto context should not rely on the host toolchain. Is this an otherwise unmodified poky+meta-raspberrypi+meta-mender build like the `kas` files we provide ([meta-mender-community/kas at scarthgap · mendersoftware/meta-mender-community · GitHub](https://github.com/mendersoftware/meta-mender-community/tree/scarthgap/kas)) do set up, or are there additional modifications which might affect the decoupling from the host?

Greets,  
Josef

---

<div class="post-metadata">

**Author:** ![sschefter](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/sschefter/32/2271_2.png) [@sschefter](https://hub.mender.io/u/sschefter)\
**Post date:** [August 23, 2024, 9:18pm UTC](https://hub.mender.io/t/error-when-trying-to-build-u-boot-for-raspberry-pi-on-ubuntu-20-04-scarthgap/7081/3 "2024-08-23T21:18:45Z")

</div>

Hi Josef.

> [@TheYoctoJester](#):
>
> That’s definitely strange, especially as building `u-boot` in a Yocto context should not rely on the host toolchain

The issue is in uboot\_auto\_configure.sh which uses the host toolchain.

poky/meta/conf/bitbake.conf includes the offending option in DEBUG\_PREFIX\_MAP  
poky/meta/recipes-bsp/u-boot/u-boot.inc includes DEBUG\_PREFIX\_MAP in EXTRA\_OEMAKE.

I resolved the issue by defining an empty DEBUG\_PREFIX\_MAP in my u-boot recipe. poky/meta/conf/bitbake.conf only sets that variable if it isn’t already set.

```
Steve

```
