Wednesday, January 5, 2022

[SOLVED] Cannot compile u-boot with armv8-rpi4-linux-gnueabihf-gcc

Issue

I'm facing problems while trying to build the u-boot for Raspberry Pi 4. The cross-compilation tool I use is armv8-rpi4-linux-gnueabihf-gcc. I get it by using the ng-crosstool auto toolchain generator. The steps I follow are as follows.

Firstly, inside the u-boot directory, I declare the CROSS_COMPILE and ARCH environment variables while changing the PATH also:

  • export CROSS_COMPILE=armv8-rpi4-linux-gnueabihf-
  • export ARCH=arm
  • export PATH=/home/caglayan/x-tools/armv8-rpi4-linux-gnueabihf/bin:$PATH

Secondly, I invoke the build process using a board-specific configuration file named rpi_4_defconfig.

  • make rpi_4_defconfig
  • make

Unfortunately, the build process fails. Below is the simplified terminal output for the process.

scripts/kconfig/conf  --syncconfig Kconfig
  CFG     u-boot.cfg
cc1: warning: unknown register name: x18
  GEN     include/autoconf.mk
  GEN     include/autoconf.mk.dep
cc1: warning: unknown register name: x18
  CFGCHK  u-boot.cfg
  UPD     include/generated/timestamp_autogenerated.h
  CC      lib/asm-offsets.s
cc1: warning: unknown register name: x18
  CC      arch/arm/lib/asm-offsets.s
cc1: warning: unknown register name: x18

............. *(Redundant lines removed intentionally.)*

  CC      arch/arm/cpu/armv8/cpu.o
cc1: warning: unknown register name: x18
{standard input}: Assembler messages:
{standard input}:36: Error: unexpected character `n' in type specifier
{standard input}:36: Error: bad instruction `b.ne 1b'
make[1]: *** [scripts/Makefile.build:266: arch/arm/cpu/armv8/cpu.o] Error 1
make: *** [Makefile:1784: arch/arm/cpu/armv8] Error 2

What do you think that I'm doing wrong? How should I continue to search for a proper solution?


Solution

The problem is caused by the generated toolchain. The ng-crosstool toolchain generator has many options while generating the proper toolchain you need. If you list the configuration options before invoking the ng-crosstool you will see that there are two options for the Raspberry Pi 4 development board: armv8-rpi4-linux-gnueabihf and arch64-rpi4-linux-gnu.

To list the possible configurations, type the following at your ng-crosstool directory. The output will show every possible configuration for commonly used systems.

bin/ct-ng list-samples

The proper configuration is the one with arch64- prefix. If you generate the toolchain using that option, the problem will be solved.

Special thanks to @NateEldredge, @TomRini and a guy from Linux Turkey Community for giving me some clue :)



Answered By - Caglayan DOKME