On Xilinx MB-V there is a need to use ELF file for SPL which is placed
in BRAM (Block RAM) because tools for placing code to bitstream requires to
use ELF. That's why introduce SPL_REMAKE_ELF similar to REMAKE_ELF option
as was originally done by commit f4dc714aaa2d ("arm64: Turn u-boot.bin back
into an ELF file after relocate-rela").

There is already generic and simple linker script (arch/u-boot-elf.lds)
which can be also used without any modification.

Signed-off-by: Michal Simek <[email protected]>
---

 Makefile           | 10 ++++++++++
 common/spl/Kconfig |  7 +++++++
 2 files changed, 17 insertions(+)

diff --git a/Makefile b/Makefile
index d5ae954f3133..4d83f844ac9b 100644
--- a/Makefile
+++ b/Makefile
@@ -1231,6 +1231,7 @@ ifneq ($(CONFIG_SPL_TARGET),)
 INPUTS-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%)
 endif
 INPUTS-$(CONFIG_REMAKE_ELF) += u-boot.elf
+INPUTS-$(CONFIG_SPL_REMAKE_ELF) += spl/u-boot-spl.elf
 INPUTS-$(CONFIG_EFI_APP) += u-boot-app.efi
 INPUTS-$(CONFIG_EFI_STUB) += u-boot-payload.efi
 
@@ -2001,6 +2002,15 @@ u-boot.elf: u-boot.bin u-boot-elf.lds FORCE
        $(Q)$(OBJCOPY) -I binary $(PLATFORM_ELFFLAGS) $< u-boot-elf.o
        $(call if_changed,u-boot-elf)
 
+quiet_cmd_u-boot-spl-elf ?= LD      $@
+       cmd_u-boot-spl-elf ?= $(LD) spl/u-boot-spl-elf.o -o $@ \
+       $(if $(CONFIG_SYS_BIG_ENDIAN),-EB,-EL) \
+       -T u-boot-elf.lds 
--defsym=$(CONFIG_PLATFORM_ELFENTRY)=$(CONFIG_SPL_TEXT_BASE) \
+       -Ttext=$(CONFIG_SPL_TEXT_BASE)
+spl/u-boot-spl.elf: spl/u-boot-spl.bin u-boot-elf.lds
+       $(Q)$(OBJCOPY) -I binary $(PLATFORM_ELFFLAGS) $< spl/u-boot-spl-elf.o
+       $(call if_changed,u-boot-spl-elf)
+
 u-boot-elf.lds: arch/u-boot-elf.lds prepare FORCE
        $(call if_changed_dep,cpp_lds)
 
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 996c9b8db4f8..0ee463d29705 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -707,6 +707,13 @@ config SPL_DRIVERS_MISC
          option to build the drivers in drivers/misc as part of an SPL
          build, for those that support building in SPL (not all drivers do).
 
+config SPL_REMAKE_ELF
+       bool "Recreate an ELF image from raw SPL binary"
+       help
+         Enable this to recreate an ELF image (spl/u-boot-spl.elf) from the raw
+         SPL binary (spl/u-boot-spl.bin), which may already have been 
statically
+         relocated and may already have a device-tree appended to it.
+
 config SPL_ENV_SUPPORT
        bool "Support an environment"
        help
-- 
2.43.0

base-commit: 421159c60e64fe1ab123f0f997951670a2701a65
branch: debian-sent3

Reply via email to