Cannot build u-boot for CycloneV on DE10 Nano


I’m having trouble building a baremetal u-boot (ie. the preloader) for the Cyclone V on an DE10 Nano development board from a Windows10 PC. I’ve followed the instructions at []

I have the following installed:
Soc EDS v20.1 standard
Cygwin: x86_64
Linaro baremetal toochain: gcc-linaro-7.5.0-2019.12-i686-mingw32_arm-eabi

The instructions for building u-boot on the RocketBoards page are:
export CROSS_COMPILE=arm-eabi-
make socfpga_cyclone5_defconfig
make -j 24

However this fails after building scripts/basic/fixdep. It doesn’t seem to like the command:
$(call if_changed_dep,host-csingle) in scripts/

Attempting to build U-boot results in the following:

I’m not sure what the problem is - an issue with the version of gcc compiler or perhaps the wrong CROSS_COMPILE arguments are provided (despite the instructions)?

I’ve managed to resolve the issue above by making the following changes to the makefile and adding a missing directory:

  1. In makefile in the u-boot-socfpga directory, change -ansi to -std=gnu11
    ifeq ($(HOSTOS),cygwin)
    KBUILD_HOSTCFLAGS += -std=gnu11

  2. Add .exe to $(CC) here:
    export CC_VERSION_TEXT := $(shell $(CC).exe --version | head -n 1)

  3. The include file u-boot-socfpga\inlude\configs\socfpga_cyclone5_socdk.h tries to include the file baseaddr_ac5.h* from u-boot-socfpga\arch\arm\include\asm\arch, which does not exist. Create the directory u-boot-socfpga\arch\arm\include\asm\arch-socfpga and copy the file base_addr_ac5.h from u-boot-socfpga\arch\arm\mach-socfpga\include\mach into this new directory.

  4. To ensure find.exe is called from the Cygwin binary path (c:\intelfpga\20.1\host_tools\cygwin\bin) rather than the from C:\windows\system32, add the definition: HOST_TOOLCHAIN_DIR := $(dir $(shell which $(HOSTCC))) in makefile below the definition of HOSTCC. Next, change find in the line:
    autoconf_is_old := $(shell find . -path ./$(KCONFIG_CONFIG) -newer
    to: $(HOST_TOOLCHAIN_DIR)find

This allows “make socfpga_cyclone5_defconfig” to execute correctly.
The next part (make -j 24) now fails, as shown below:

scripts/kconfig/conf  --syncconfig Kconfig
  CFG     u-boot.cfg
  GEN     include/
  CFG     spl/u-boot.cfg
  GEN     include/
  GEN     spl/include/
  UPD     include/generated/timestamp_autogenerated.h
===================== WARNING ======================
This board does not use CONFIG_WDT (DM watchdog support).
Please update the board to use CONFIG_WDT before the
v2019.10 release.
Failure to update by the deadline may result in board removal.
See doc/driver-model/migration.rst for more info.
  CC      lib/asm-offsets.s
  CC      arch/arm/lib/asm-offsets.s
  CFGCHK  u-boot.cfg
: No such file or directory
: No such file or directory
make[1]: *** [scripts/ lib/asm-offsets.s] Error 2
make[1]: *** Deleting file 'lib/asm-offsets.s'
comm: file 1 is not in sorted order
make: *** [Makefile:1049: .binman_stamp] Error 1
make: *** Deleting file '.binman_stamp'
make: *** Waiting for unfinished jobs....
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [scripts/ arch/arm/lib/asm-offsets.s] Error 2
make[1]: *** Deleting file 'arch/arm/lib/asm-offsets.s'
make: *** [Makefile:1837: prepare0] Error 2

Any ideas?

The issue is now resolved, as I’ve been able to build the preloader successfully using Ubuntu over WSL after reinstalling Linaro and the Intel Embedded Development Suite in the Ubuntu environment.

The failure to build the preloader and u-boot under Cygwin is ultimately due to 2 issues:

  • the Windows environment uses carriage return, linefeed as end of line characters while the Linux environment uses only linefeed.
  • scripts running under Windows need executable files to be called with the file extension included.

Most of the build errors due to the above issues can be resolved (as I’ve indicated in my earlier posts).
Some of the line ending issues can be resolved by adding checks for CR LF. For example to build include\generated\version_autogenerated.h correctly, the definition filechk_version.h in makefile in the root directory needs to be modified:

define filechk_version.h
echo #define U_BOOT_VERSION "U-Boot " PLAIN_VERSION;
echo #define CC_VERSION_STRING “$$(LC_ALL=C $(CC) --version | head -n 1 | sed s/\r//)”;
echo #define LD_VERSION_STRING “$$(LC_ALL=C $(LD) --version | head -n 1 | sed s/\r//)”; )

The tools\scripts\define2mk.sed also needed the line s/\r//; added before the last line to remove carriage returns.
The build still failed due to CONFIG_LMB not being added to include/generated/autoconf.h. There is no ‘1’ placed after #define CONFIG_LMB in u-boot.cfg, which was related to empty quotation marks being added after CONFIG_LMB in include\ (CONFIG_LMB=""). This was somehow another symptom of the different line endings used in Windows, but I was not able to fix this in the scripts that build

I guess if someone really wants to build u-boot from Cygwin this would be something to look into.