Skip to content

Commit 1df9cbd

Browse files
xyprontrini
authored andcommitted
examples/api: improve determination of LOAD_ADDR
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>
1 parent 881f0b7 commit 1df9cbd

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

examples/api/Makefile

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,9 @@
55
# Provide symbol API_BUILD to signal that the API example is being built.
66
KBUILD_CPPFLAGS += -DAPI_BUILD
77

8-
ifeq ($(ARCH),powerpc)
9-
LOAD_ADDR = 0x40000
10-
endif
11-
ifeq ($(ARCH),arm)
12-
ifdef CONFIG_64BIT
13-
LOAD_ADDR = 0x40400000
14-
else
15-
LOAD_ADDR = 0x1000000
16-
endif
17-
endif
18-
ifeq ($(ARCH),mips)
19-
ifdef CONFIG_64BIT
20-
LOAD_ADDR = 0xffffffff80200000
21-
else
22-
LOAD_ADDR = 0x80200000
23-
endif
24-
endif
25-
ifeq ($(ARCH),riscv)
26-
LOAD_ADDR = 0x84000000
27-
endif
8+
# Environment variable loadaddr is set from CONFIG_SYS_LOAD_ADDR.
9+
# Run the examples 4 MiB above this address.
10+
LOAD_ADDR:=${shell printf 0x%X $$(( $(CONFIG_SYS_LOAD_ADDR) + 0x400000 ))}
2811

2912
# Resulting ELF and binary exectuables will be named demo and demo.bin
3013
extra-y = demo

0 commit comments

Comments
 (0)