0

I am trying to compile linux kernel v5.9.12 using my buildroot toolchain (2020.08.2) and I keep getting an error related to libfdt. I can't figure out how to fix this and I've been banging my head against the wall for several hours now.

username@local:~/linux-stable$ make ARCH=arm CROSS_COMPILE=arm-linux- -j64 
  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  Kernel: arch/arm/boot/Image is ready
  AS      arch/arm/boot/compressed/piggy.o
  CC      arch/arm/boot/compressed/fdt_ro.o
In file included from arch/arm/boot/compressed/../../../../lib/fdt_ro.c:2,
                 from arch/arm/boot/compressed/fdt_ro.c:2:
arch/arm/boot/compressed/../../../../lib/../scripts/dtc/libfdt/fdt_ro.c: In function ‘fdt_generate_phandle’:
arch/arm/boot/compressed/../../../../lib/../scripts/dtc/libfdt/fdt_ro.c:149:13: error: ‘FDT_MAX_PHANDLE’ undeclared (first use in this function)
  149 |  if (max == FDT_MAX_PHANDLE)
      |             ^~~~~~~~~~~~~~~
arch/arm/boot/compressed/../../../../lib/../scripts/dtc/libfdt/fdt_ro.c:149:13: note: each undeclared identifier is reported only once for each function it appears in
arch/arm/boot/compressed/../../../../lib/../scripts/dtc/libfdt/fdt_ro.c: In function ‘fdt_get_mem_rsv’:
arch/arm/boot/compressed/../../../../lib/../scripts/dtc/libfdt/fdt_ro.c:182:13: error: implicit declaration of function ‘fdt64_ld’ [-Werror=implicit-function-declaration]
  182 |  *address = fdt64_ld(&re->address);
      |             ^~~~~~~~
arch/arm/boot/compressed/../../../../lib/../scripts/dtc/libfdt/fdt_ro.c: In function ‘fdt_get_property_by_offset_’:
arch/arm/boot/compressed/../../../../lib/../scripts/dtc/libfdt/fdt_ro.c:371:11: error: implicit declaration of function ‘fdt32_ld’ [-Werror=implicit-function-declaration]
  371 |   *lenp = fdt32_ld(&prop->len);
      |           ^~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:283: arch/arm/boot/compressed/fdt_ro.o] Error 1
make[1]: *** [arch/arm/boot/Makefile:64: arch/arm/boot/compressed/vmlinux] Error 2
make: *** [arch/arm/Makefile:330: zImage] Error 2
make: *** Waiting for unfinished jobs....

I have added output/host/usr/bin to my PATH env variable so make can find the toolchain. Any ideas?

b20000
  • 995
  • 1
  • 12
  • 30

1 Answers1

0

It turns out that in arch/arm/boot/compressed there were a bunch of old libfdt related header files still hanging around, so by deleting these I was able to build the kernel. I found the files using git status.

b20000
  • 995
  • 1
  • 12
  • 30
  • 1
    You may run `git clean -xdf` which removes all stuff that is not under control system. Also it's highly recommended to use separate folder for generated (built) material. – 0andriy Dec 12 '20 at 20:53
  • Basically as per @b20000 and @0andriy, by deleting/removing the untracked directories, files forcefully. this command `git clean -xdf` will do the same. instead of removing bunch of old libfdt related files, it will remove all stuff which is not required. – shashank arora May 22 '21 at 12:47