Compiling out of tree U-Boot

I have been trying to compile U-Boot on AMD64 laptop for ASUS Tinkerboard2. It uses a custom tree.
I also need to compile Raxda tree but I started with the Asus TinkerBoard2

mkdir -r /usr/ports/sysutils/u-boot-tinkerboard2
cd /usr/ports/sysutils/u-boot-tinkerboard2
git clone https://github.com/TinkerBoard2/u-boot.git
cd /usr/ports/sysutils/u-boot-tinkerboard2/u-boot

OK now what? I stared at 4 different setups none FreeBSD.

Where I am stuck is that I am a compiling novice. All these examples use make.
I have only been partially successful with gmake. Going through the configs was educational.
I have built plenty of 'in-ports' u-boot. So I know the stages some.
There is a step in u-boot port building that makes symlinks to compilers.
I think I am missing steps.

Here is my futile attempt:
Code:
gmake tinker2_defconfig
gmake config
gmake savedefconfig
gmake ARCH=arm DESTDIR=/usr/ports/sysutils/u-boot-tinker2/u-boot tinker2_defconfig

Please help me compile u-boot from a manufacturers u-boot source tree.
 
Getting closer:
gmake SED=gsed HOSTCC=cc CROSS_COMPILE=aarch64-none-elf- tinker2_defconfig
gmake SED=gsed HOSTCC=cc CROSS_COMPILE=aarch64-none-elf-

Code:
/bin/sh: Syntax error: end of file unexpected (expecting ")")
gmake: *** [Makefile:1410: include/generated/version_autogenerated.h] Error
 
Where I am stuck is that I am a compiling novice. All these examples use make.
I have only been partially successful with gmake.
On GNU/Linux systems, make is (usually) GNU make. Hence using devel/gmake is indeed the correct thing to do on FreeBSD.

gmake SED=gsed HOSTCC=cc CROSS_COMPILE=aarch64-none-elf- tinker2_defconfig
gmake SED=gsed HOSTCC=cc CROSS_COMPILE=aarch64-none-elf-
Shouldn't those variable definitions go in front of the call to gmake?
 
I used the long form I converted from another build from ports tree.

/usr/bin/env MAKE=gmake PYTHON="/usr/local/bin/python3.9" PKG_CONFIG=pkgconf XDG_DATA_HOME=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot XDG_CONFIG_HOME=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot XDG_CACHE_HOME=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot/.cache HOME=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot PATH=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin PKG_CONFIG_LIBDIR=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig SHELL=/bin/sh CONFIG_SHELL=/bin/sh V=1 CROSS_COMPILE=aarch64-none-elf- PYTHON=/usr/local/bin/python3.9 CC=clang BL31=/usr/local/share/atf-rk3399/bl31.elf XDG_DATA_HOME=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot XDG_CONFIG_HOME=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot XDG_CACHE_HOME=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot/.cache HOME=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot PATH=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin PKG_CONFIG_LIBDIR=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local LOCALBASE=/usr/local CC="cc" CFLAGS="-O2 -pipe -fno-strict-aliasing " CPP="cpp" CPPFLAGS="" LDFLAGS=" " LIBS="" CXX="c++" CXXFLAGS="-O2 -pipe -fno-strict-aliasing " MANPREFIX="/usr/local" BSD_INSTALL_PROGRAM="install -s -m 555" BSD_INSTALL_LIB="install -s -m 0644" BSD_INSTALL_SCRIPT="install -m 555" BSD_INSTALL_DATA="install -m 0644" BSD_INSTALL_MAN="install -m 444" gmake ARCH=arm DESTDIR=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot/stage tinkerboard2_defconfig

And yet the error seems to be very similar. (When running gmake after the config stage)

Code:
DESTDIR=/usr/ports/sysutils/u-boot-tinkerboard2/u-boot/stage
scripts/kconfig/conf  --silentoldconfig Kconfig
  CHK     include/config.h
  UPD     include/config.h
  CFG     u-boot.cfg
  GEN     include/autoconf.mk
  GEN     include/autoconf.mk.dep
  CFG     spl/u-boot.cfg
  GEN     spl/include/autoconf.mk
  CFG     tpl/u-boot.cfg
  GEN     tpl/include/autoconf.mk
  CHK     include/config/uboot.release
  UPD     include/config/uboot.release
/bin/sh: Syntax error: end of file unexpected (expecting ")")
gmake: *** [Makefile:1410: include/generated/version_autogenerated.h] Error 2
 
I deleted this file just in case it wasn't being cleaned with gmake mrproper
/include/generated/version_autogenerated.h
No luck.
Have to see what Makefile is doing at line 1410
 
On GNU/Linux systems, make is (usually) GNU make. Hence using devel/gmake is indeed the correct thing to do on FreeBSD.


Shouldn't those variable definitions go in front of the call to gmake?

If placed in front of the gmake then the symbols are processed as shell environment symbols. If they appear as command line params then they simply override the variable name within the makefile.

See gnu gmake manual, section 9.5
 
FYI: to OP...try executing your build under bash instead of under the traditional bourne shell. You are undoubtedly using makefiles that someone created on a platform other than BSD, and while it's been a while, I vaguely remember the u-boot build doing some explicit shell calls in the makefiles.
 
Something else I just thought of, that has never been a problem for me becaue my uboot builds are always under embedded linux:

Check to see if any part of the uboot build is looking for kernel configuration headers such as exist when folks build kernel modules under linux. If that's the case, then the uboot build may be subtly incompatible with BSD unless you do some mods.
 
When I looked at include/config/uboot.release (last build item) I saw some weird characters.

I did notice another file in /include/generated. It has zero bit length. Very suspicious.
autoksyms.h
symbols.h
hmmmm...

Maybe compiler error message is lagging? Sending me in wrong direction?
 
This builds u.boot.release
2017.09"" #root

A normal u.boot.release
2023.01

I changed it to no avail.
 
These are some of the warnings from compiling the defconfig:
Code:
undefined                        fprintf(stderr, _("\n*** Error during update of the configuration.\n\n"));
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
                ^~~~~~~~~~~~~
scripts/kconfig/conf.c:698:20: note: treat the string as an argument to avoid this
                        fprintf(stderr, _("\n*** Error during update of the configuration.\n\n"));
                                        ^
                                        "%s",
scripts/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
                ^
scripts/kconfig/conf.c:709:20: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
                        fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scripts/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
                ^~~~~~~~~~~~~
scripts/kconfig/conf.c:709:20: note: treat the string as an argument to avoid this
                        fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
                                        ^
                                        "%s",
scripts/kconfig/lkc.h:34:17: note: expanded from macro '_'
#define _(text) gettext(text)
                ^
10 warnings generated.

Something about symbol.h I thought I saw somewhere...
 
When a u-boot port on FreeBSD is built a directory ends up in the root directory.
/.bin

This contains symbolic link to tools needed for the build like python.
Just copying over this directory from another build did not help.
How do I link the tools and create this .bin directory?

Code:
OSS_COMPILE=aarch64-none-elf-
  UPD     include/generated/timestamp_autogenerated.h
  ENVC    include/generated/env.txt
  ENVP    include/generated/env.in
  ENVT    include/generated/environment.h
  PYMOD   rebuild

/bin/sh: python3: not found

gmake[2]: *** [scripts/dtc/pylibfdt/Makefile:33: rebuild] Error 127
gmake[1]: *** [scripts/Makefile.build:397: scripts/dtc/pylibfdt] Error 2
gmake: *** [Makefile:2009: scripts_dtc] Error 2
 
Sorry that was the short form.
Once I compiled with long form like ports it finally built.
/usr/bin/env MAKE=gmake PYTHON="/usr/local/bin/python3.9" PKG_CONFIG=pkgconf XDG_DATA_HOME=/usr/ports/sysutils/u-boot-rock3/u-boot XDG_CONFIG_HOME=/usr/ports/sysutils/u-boot-rock3/u-boot XDG_CACHE_HOME=/usr/ports/sysutils/u-boot-rock3/u-boot/.cache HOME=/usr/ports/sysutils/u-boot-rock3/u-boot PATH=/usr/ports/sysutils/u-boot-rock3/u-boot/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin PKG_CONFIG_LIBDIR=/usr/ports/sysutils/u-boot-rock3/u-boot/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig SHELL=/bin/sh CONFIG_SHELL=/bin/sh V=1 CROSS_COMPILE=aarch64-none-elf- PYTHON=/usr/local/bin/python3.9 CC=clang BL31=/usr/local/share/atf-rk3399/bl31.elf XDG_DATA_HOME=/usr/ports/sysutils/u-boot-rock3/u-boot XDG_CONFIG_HOME=/usr/ports/sysutils/u-boot-rock3/u-boot XDG_CACHE_HOME=/usr/ports/sysutils/u-boot-rock3/u-boot/.cache HOME=/usr/ports/sysutils/u-boot-rock3/u-boot PATH=/usr/ports/sysutils/u-boot-rock3/u-boot/.bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin PKG_CONFIG_LIBDIR=/usr/ports/sysutils/u-boot-rock3/u-boot/.pkgconfig:/usr/local/libdata/pkgconfig:/usr/local/share/pkgconfig:/usr/libdata/pkgconfig MK_DEBUG_FILES=no MK_KERNEL_SYMBOLS=no SHELL=/bin/sh NO_LINT=YES PREFIX=/usr/local LOCALBASE=/usr/local CC="cc" CFLAGS="-O2 -pipe -fno-strict-aliasing " CPP="cpp" CPPFLAGS="" LDFLAGS=" " LIBS="" CXX="c++" CXXFLAGS="-O2 -pipe -fno-strict-aliasing " MANPREFIX="/usr/local" BSD_INSTALL_PROGRAM="install -s -m 555" BSD_INSTALL_LIB="install -s -m 0644" BSD_INSTALL_SCRIPT="install -m 555" BSD_INSTALL_DATA="install -m 0644" BSD_INSTALL_MAN="install -m 444" gmake ARCH=arm DESTDIR=/usr/ports/sysutils/u-boot-rock3/u-boot rock-3a-rk3568_defconfig

Getting closer. Switched to Rock3A build.

That dang BINMAN
Code:
  OBJCOPY spl/u-boot-spl-nodtb.bin
mkdir -p spl/dts/
  FDTGREP spl/dts/dt-spl.dtb
  COPY    spl/u-boot-spl.dtb
  CAT     spl/u-boot-spl-dtb.bin
  COPY    spl/u-boot-spl.bin
  SYM     spl/u-boot-spl.sym
  MKIMAGE u-boot.img
  COPY    u-boot.dtb
  MKIMAGE u-boot-dtb.img
  BINMAN  .binman_stamp
binman: Filename 'rockchip-tpl' not found in input path (.,.,./board/rockchip/evb_rk3568,arch/arm/dts) (cwd='/usr/ports/sysutils/u-boot-rock3/u-boot')
gmake: *** [Makefile:1111: .binman_stamp] Error 1
 
Just for information sake I am compiling u-boot tree directly from U-Boot github repo.

Our ports tree version is at 01.2023 and Rock-3a-rk3568 just went in the u-boot tree within the last month.

So I built a custom rock3 uboot from current source. Thusly making it out of tree. FreeBSD's tree.

Anybody have any tips for BINMAN and the missing rockchip-tpl file?
Is that part of building ATF ?
 
Back
Top