]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
examples/api: improve determination of LOAD_ADDR
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 27 Jan 2025 06:49:36 +0000 (07:49 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 4 Feb 2025 17:57:36 +0000 (11:57 -0600)
The current load address for the 'demo' binary does not work for
qemu_arm_defconfig.

The suitability of an address to load an ELF binary and run it does
not only depend on the architecture but also on the memory layout of
the board.

On most boards we can assume that 8 MiB of memory is available above
$loadaddr. So $loadaddr + 0x400000 should work there.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
examples/api/Makefile

index 722c7e459045245bf4399af45b2bac0bb78eca52..be97b8015bd3351432d696dc4a67161957ea7435 100644 (file)
@@ -5,26 +5,9 @@
 # Provide symbol API_BUILD to signal that the API example is being built.
 KBUILD_CPPFLAGS += -DAPI_BUILD
 
-ifeq ($(ARCH),powerpc)
-LOAD_ADDR = 0x40000
-endif
-ifeq ($(ARCH),arm)
-ifdef CONFIG_64BIT
-LOAD_ADDR = 0x40400000
-else
-LOAD_ADDR = 0x1000000
-endif
-endif
-ifeq ($(ARCH),mips)
-ifdef CONFIG_64BIT
-LOAD_ADDR = 0xffffffff80200000
-else
-LOAD_ADDR = 0x80200000
-endif
-endif
-ifeq ($(ARCH),riscv)
-LOAD_ADDR = 0x84000000
-endif
+# Environment variable loadaddr is set from CONFIG_SYS_LOAD_ADDR.
+# Run the examples 4 MiB above this address.
+LOAD_ADDR:=${shell printf 0x%X $$(( $(CONFIG_SYS_LOAD_ADDR) + 0x400000 ))}
 
 # Resulting ELF and binary exectuables will be named demo and demo.bin
 extra-y = demo