Skip to contentSkip to conversation

build error "undefined reference to `fdtdec_setup_memory_banksize'" (running u-boot and linux on qemu arm64 machine using SPL BOOT from RAM mode)

Question Chan Kim 1 participant 1 message May 3, 2023

lore
Share & tools
lore

Chan Kim

author
#0 lore raw

I soon found how to fix it..
From internet search, I found my old post on stackexchange :
https://stackoverflow.com/questions/70017750/undefined-reference-to-memcpy-d
uring-u-boot-spl-build-how-can-i-use-the-archt
So after adding 'select SPL_LIBCOMMON_SUPPORT' to 'config ARCH_QEMU' in arch/arm/Kconfig, those errors are gone.
Thank you.
Chan Kim

Quoted 8 lines

-----Original Message-----
From: Chan Kim <[email protected]>
Sent: Wednesday, May 3, 2023 6:08 PM
To: U-Boot Mailing List <[email protected]>
Subject: [Question] build error "undefined reference to `fdtdec_setup_memory_banksize'" (running u-boot and linux on qemu arm64 machine using SPL BOOT from RAM mode)

Quoted 5 lines

Hello u-boot experts,

I tried running u-boot on qemu arm64 machine and wanted to make u-boot-spl automatically switch to linux.
(I asked this question on qemu-discuss email, but no answer yet, so I ask

it

Quoted 4 lines

here with some update).

I used u-boot v2022.07 and I wanted to use SPL mode and 'Boot from RAM'

mode.

Quoted 1 line

So when calling qemu, I give option so that linux kernel image is at

certain

Quoted 111 lines

DRAM address already, and I wish u-boot will switch to the kernel address. Originally, the qemu-arm64 board doesn't support SPL so I added/fixed some things.

I added in arch/arm/Kconfig, under config ARCH_QEMU,
select SPL
select RAM
select SPL_DM
select SUPPORT_SPL
select SPL_RAM_SUPPORT
select SPL_RAM_DEVICE
select SPL_OS_BOOT
select SPL_OF_LIBFDT
select OF_LIBFDT
select SPL_LIBGENERIC_SUPPORT

To make some errors in the link script, I added in include/configs/qemu- arm.h,(in the qemu machine, DRAM seemd to start at 0x40000000 and it said dtb is placed at the first 2MB)

#define CONFIG_SYS_INIT_RAM_ADDR 0x40200000 #define CONFIG_SPL_MAX_SIZE 0x400000 #define CONFIG_SPL_BSS_START_ADDR 0x40800000 #define CONFIG_SPL_BSS_MAX_SIZE 0x100000

and I added this function at board/emulation/qemu-arm/qemu-arm.c to avoid compile error(undefined ref for spl_boot_device).

#include <asm/spl.h>
u32 spl_boot_device(void)

{
   return BOOT_DEVICE_NONE;
}

This is how I compile u-boot-spl.

$ make CROSS_COMPILE=aarch64_none_elf- qemu_arm64_defconfig $ make
CROSS_COMPILE=aarch64_none_elf- -j28

But I see this compile errors (see at the bottom).

ENVC include/generated/env.txt

 UPD     include/generated/timestamp_autogenerated.h
 CFGCHK  u-boot.cfg
 ENVP    include/generated/env.in
 ENVT    include/generated/environment.h
 OFCHK   .config
 CC      cmd/version.o
 CC      env/common.o
 AR      cmd/built-in.o
 CC      lib/efi_loader/dtbdump.o
 CC      lib/efi_loader/initrddump.o
 CC      lib/efi_selftest/efi_selftest_miniapp_exception.o
 CC      lib/efi_selftest/efi_selftest_miniapp_exit.o
 CC      lib/efi_selftest/efi_selftest_miniapp_return.o
 LD      lib/efi_selftest/efi_selftest_miniapp_return_efi.so

aarch64-none-elf-ld.bfd LD lib/efi_selftest/efi_selftest_miniapp_exception_efi.so : warning: -z norelro ignored aarch64-none-elf-ld.bfd: warning: -z norelro ignored
OBJCOPY lib/efi_selftest/efi_selftest_miniapp_return.efi
lib/efi_selftest/../../tools/file2include lib/efi_selftest/efi_selftest_miniapp_return.efi > \ lib/efi_selftest/efi_miniapp_file_image_return.h
OBJCOPY lib/efi_selftest/efi_selftest_miniapp_exception.efi
lib/efi_selftest/../../tools/file2include lib/efi_selftest/efi_selftest_miniapp_exception.efi > \ lib/efi_selftest/efi_miniapp_file_image_exception.h

 AR      env/built-in.o
 CC      lib/efi_selftest/efi_selftest_startimage_return.o
 CC      lib/efi_selftest/efi_selftest_exception.o
 LD      lib/efi_selftest/efi_selftest_miniapp_exit_efi.so

aarch64-none-elf-ld.bfd: warning: -z norelro ignored
OBJCOPY lib/efi_selftest/efi_selftest_miniapp_exit.efi
lib/efi_selftest/../../tools/file2include lib/efi_selftest/efi_selftest_miniapp_exit.efi > \ lib/efi_selftest/efi_miniapp_file_image_exit.h

 CC      lib/efi_selftest/efi_selftest_load_file.o
 CC      lib/efi_selftest/efi_selftest_loadimage.o
 CC      lib/efi_selftest/efi_selftest_startimage_exit.o
 LD      lib/efi_loader/initrddump_efi.so

aarch64-none-elf-ld.bfd: warning: -z norelro ignored
OBJCOPY lib/efi_loader/initrddump.efi
LD lib/efi_loader/dtbdump_efi.so
aarch64-none-elf-ld.bfd: warning: -z norelro ignored
OBJCOPY lib/efi_loader/dtbdump.efi

 CC      spl/common/spl/spl.o
 AR      lib/efi_selftest/built-in.o
 AR      lib/built-in.o
 AR      spl/common/spl/built-in.o
 LD      spl/u-boot-spl

aarch64-none-elf-ld.bfd: drivers/core/device.o: in function `alloc_priv':
/home/ckim/SuperCom/U-BOOT/temp/u-boot.v2022.07/drivers/core/device.c:308:
undefined reference to `memalign'
aarch64-none-elf-ld.bfd: /home/ckim/SuperCom/U-BOOT/temp/u- boot.v2022.07/drivers/core/device.c:340: undefined reference to calloc' aarch64-none-elf-ld.bfd: drivers/core/device.o: in function device_bind_common':
/home/ckim/SuperCom/U-BOOT/temp/u-boot.v2022.07/drivers/core/device.c:64:
undefined reference to `calloc'
aarch64-none-elf-ld.bfd: /home/ckim/SuperCom/U-BOOT/temp/u- boot.v2022.07/drivers/core/device.c:118: undefined reference to calloc' aarch64-none-elf-ld.bfd: /home/ckim/SuperCom/U-BOOT/temp/u- boot.v2022.07/drivers/core/device.c:137: undefined reference to calloc' aarch64-none-elf-ld.bfd: /home/ckim/SuperCom/U-BOOT/temp/u- boot.v2022.07/drivers/core/device.c:151: undefined reference to calloc' aarch64-none-elf-ld.bfd: /home/ckim/SuperCom/U-BOOT/temp/u- boot.v2022.07/drivers/core/device.c:234: undefined reference to free' aarch64-none-elf-ld.bfd: drivers/core/uclass.o: in function `uclass_add':
/home/ckim/SuperCom/U-BOOT/temp/u-boot.v2022.07/drivers/core/uclass.c:72:
undefined reference to `calloc'

Quoted 8 lines

aarch64-none-elf-ld.bfd: /home/ckim/SuperCom/U-BOOT/temp/u- boot.v2022.07/drivers/core/uclass.c:78: undefined reference to calloc' aarch64-none-elf-ld.bfd: /home/ckim/SuperCom/U-BOOT/temp/u- boot.v2022.07/drivers/core/uclass.c:101: undefined reference to free' aarch64-none-elf-ld.bfd: /home/ckim/SuperCom/U-BOOT/temp/u- boot.v2022.07/drivers/core/uclass.c:106: undefined reference to free' aarch64-none-elf-ld.bfd: drivers/firmware/psci.o: in function psci_bind':
/home/ckim/SuperCom/U-BOOT/temp/u-boot.v2022.07/drivers/firmware/psci.c:101

:

Quoted 15 lines

undefined reference to device_is_compatible' aarch64-none-elf-ld.bfd: /home/ckim/SuperCom/U-BOOT/temp/u- boot.v2022.07/drivers/firmware/psci.c:102: undefined reference to device_is_compatible'
aarch64-none-elf-ld.bfd: u-boot-spl: hidden symbol `calloc' isn't defined aarch64-none-elf-ld.bfd: final link failed: bad value make[1]: *** [scripts/Makefile.spl:525: spl/u-boot-spl] Error 1
make: *** [Makefile:2106: spl/u-boot-spl] Error 2

How can I remove this kind of errors?
If someone could provide me an anser or hind, I will be very grateful. Thank you!

Chan Kim