diff --git a/arch/arm/boards/vexpress/lowlevel.c b/arch/arm/boards/vexpress/lowlevel.c index 0a226b2..9fe7c83 100644 --- a/arch/arm/boards/vexpress/lowlevel.c +++ b/arch/arm/boards/vexpress/lowlevel.c @@ -9,18 +9,34 @@ #include #include #include +#include #include static inline void start_vexpress_common(void *internal_dt) { void *fdt = internal_dt - get_runtime_offset(); + unsigned long membase, memsize = SZ_512M; arm_cpu_lowlevel_init(); if (amba_is_arm_sp804(IOMEM(0x10011000))) - barebox_arm_entry(0x60000000, SZ_512M, fdt); + membase = 0x60000000; else - barebox_arm_entry(0x80000000, SZ_512M, fdt); + membase = 0x80000000; + + /* QEMU may put a DTB at the start of RAM */ + if (IS_ENABLED(CONFIG_OFDEVICE) && + get_unaligned_be32((void*)membase) == FDT_MAGIC) { + fdt = (void*)membase; + /* + * Need to move membase a bit as the PBL wants to relocate + * to the start of RAM, which would overwrite the DTB. + */ + membase += SZ_4M; + memsize -= SZ_4M; + } + + barebox_arm_entry(membase, memsize, fdt); } extern char __dtb_vexpress_v2p_ca9_start[];