From: "Pali Rohár" <pali@kernel.org>
To: "Stefan Roese" <sr@denx.de>, "Marek Behún" <marek.behun@nic.cz>,
"Chris Packham" <judge.packham@gmail.com>
Cc: u-boot@lists.denx.de
Subject: [PATCH u-boot-marvell v2 11/20] arm: mvebu: Correctly set LOAD_ADDRESS for U-Boot SPL binary in kwbimage
Date: Wed, 12 Jan 2022 18:20:45 +0100 [thread overview]
Message-ID: <20220112172054.5961-12-pali@kernel.org> (raw)
In-Reply-To: <20220112172054.5961-1-pali@kernel.org>
U-Boot SPL for mvebu platform is not compiled as position independent.
Therefore it is required to instruct BootROM to load U-Boot SPL at the
correct address. Loading of kwbimage binary code at specific address can be
now achieved by the new LOAD_ADDRESS token as part of BINARY command in
kwbimage config file.
Update mvebu Makefile to put value of $(CONFIG_SPL_TEXT_BASE) into
LOAD_ADDRESS token when generating kwbimage.cfg from kwbimage.cfg.in.
It is required to update regex for sed to find replacement tokens at any
position on a line in kwbimage config file and not only at the beginning of
the line. This is because LOAD_ADDRESS is specified at the end of line
containing the BINARY command.
It looks like all Armada boards set CONFIG_SPL_TEXT_BASE to value
0x40004030 or 0x40000030. Why this value? It is because main kwbimage
header is at address 0x40004030 or 0x40000000 and it is 32 bytes long.
After the main header there is the binary header, which consist of 1 byte
for type, 3 bytes for size, 1 byte for number of arguments, 3 reserved
bytes and then 4 bytes for each argument. After these arguments comes the
executable code.
So arguments start at address 0x40004028 or 0x40000028. Before commit
e6571f38c943 ("arm: mvebu: Remove dummy BIN header arguments for SPL
binary") there were two (dummy) arguments, which resulted in load address
of 0x40004030 or 0x40000030, always. After that commit (which removed dummy
arguments), load address stayed same due to the 128-bit alignment done by
mkimage.
This patch now reflects the dependency between $(CONFIG_SPL_TEXT_BASE),
load address and dummy kwbimage arguments, and allows the user to adjust
$(CONFIG_SPL_TEXT_BASE) config option to some other value.
For unsupported values, when mkimage/kwbimage cannot set chosen load address
as specified by $(CONFIG_SPL_TEXT_BASE), the build process now fails,
instead of silently generating non-working kwbimage.
Removal of this alignment between $(CONFIG_SPL_TEXT_BASE) and LOAD_ADDRESS
can only be done by compiling U-Boot SPL as position independent. But this
currently is not possible for 32-bit ARM version of U-Boot SPL.
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
---
arch/arm/mach-mvebu/Makefile | 5 ++++-
arch/arm/mach-mvebu/kwbimage.cfg.in | 4 ++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile
index 17006c9df9b0..9ace049c9d7c 100644
--- a/arch/arm/mach-mvebu/Makefile
+++ b/arch/arm/mach-mvebu/Makefile
@@ -38,6 +38,9 @@ else ifneq ($(CONFIG_ARMADA_375)$(CONFIG_ARMADA_38X)$(CONFIG_ARMADA_39X),)
KWB_CFG_CPU = A9
endif
+KWB_REPLACE += LOAD_ADDRESS
+KWB_CFG_LOAD_ADDRESS = $(CONFIG_SPL_TEXT_BASE)
+
KWB_REPLACE += BOOT_FROM
ifneq ($(CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI),)
KWB_CFG_BOOT_FROM=spi
@@ -67,7 +70,7 @@ KWB_CFG_SEC_FUSE_DUMP = a38x
endif
quiet_cmd_kwbcfg = KWBCFG $@
-cmd_kwbcfg = sed -ne '$(foreach V,$(KWB_REPLACE),s/^\#@$(V)/$(V) $(KWB_CFG_$(V))/;)p' \
+cmd_kwbcfg = sed -ne '$(foreach V,$(KWB_REPLACE),s/\#@$(V)/$(V) $(KWB_CFG_$(V))/;)p' \
<$< >$(dir $@)$(@F)
$(obj)/kwbimage.cfg: $(src)/kwbimage.cfg.in include/autoconf.mk \
diff --git a/arch/arm/mach-mvebu/kwbimage.cfg.in b/arch/arm/mach-mvebu/kwbimage.cfg.in
index 8e720daf4820..603e8863450c 100644
--- a/arch/arm/mach-mvebu/kwbimage.cfg.in
+++ b/arch/arm/mach-mvebu/kwbimage.cfg.in
@@ -11,5 +11,5 @@ VERSION 1
# Boot Media configurations
#@BOOT_FROM
-# Binary Header (bin_hdr) with DDR3 training code
-BINARY spl/u-boot-spl.bin
+# Include U-Boot SPL with DDR3 training code into Binary Header
+BINARY spl/u-boot-spl.bin #@LOAD_ADDRESS
--
2.20.1
next prev parent reply other threads:[~2022-01-12 17:24 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-21 15:54 [PATCH u-boot-marvell 00/16] tools: kwbimage: Load address fixes Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 01/16] tools: kwbimage: Mark all local functions as static Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 02/16] tools: kwbimage: Deduplicate v1 regtype header finishing Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 03/16] tools: kwbimage: Fix generating image with multiple DATA_DELAY commands Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 04/16] tools: kwbimage: Preserve order of BINARY, DATA and " Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 05/16] arm: mvebu: Generate kwbimage.cfg with $(call cmd, ...) Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 06/16] tools: kwbimage: Add support for specifying LOAD_ADDRESS for BINARY command Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 07/16] tools: kwbimage: Check the return value of image_headersz_v1() Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 08/16] arm: mvebu: Correctly set LOAD_ADDRESS for U-Boot SPL binary in kwbimage Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 09/16] arm: mvebu: Enable BootROM output on A38x Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 10/16] tools: kwbimage: Add missing check for maximal value for DATA_DELAY Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 11/16] tools: kwbimage: Show binary image address in mkimage -l, in addition to size Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 12/16] tools: kwbimage: Dump kwbimage config file on '-p -1' option Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 13/16] tools: kwbimage: Do not cast const pointers to non-const pointers Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 14/16] tools: kwbimage/kwboot: Check ext field for non-zero value Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 15/16] tools: kwbimage: Extract main data image without -p arg for dumpimage Pali Rohár
2021-12-21 15:54 ` [PATCH u-boot-marvell 16/16] tools: kwbimage: Fix mkimage/dumpimage -l argument Pali Rohár
2022-01-12 7:26 ` [PATCH u-boot-marvell 00/16] tools: kwbimage: Load address fixes Stefan Roese
2022-01-12 10:41 ` Pali Rohár
2022-01-12 10:55 ` Stefan Roese
2022-01-12 11:06 ` Stefan Roese
2022-01-12 11:34 ` Pali Rohár
2022-01-12 13:53 ` Stefan Roese
2022-01-12 14:16 ` Pali Rohár
2022-01-12 15:06 ` Stefan Roese
2022-01-12 15:09 ` Pali Rohár
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 00/20] " Pali Rohár
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 01/20] tools: kwbimage: Mark all local functions as static Pali Rohár
2022-01-13 6:30 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 02/20] tools: kwbimage: Deduplicate v1 regtype header finishing Pali Rohár
2022-01-13 6:31 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 03/20] tools: kwbimage: Fix generating image with multiple DATA_DELAY commands Pali Rohár
2022-01-13 6:31 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 04/20] tools: kwbimage: Preserve order of BINARY, DATA and " Pali Rohár
2022-01-13 6:32 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 05/20] arm: mvebu: Generate kwbimage.cfg with $(call cmd, ...) Pali Rohár
2022-01-13 6:32 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 06/20] tools: kwbimage: Add support for specifying CPU core Pali Rohár
2022-01-13 6:33 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 07/20] tools: kwbimage: Add support for specifying LOAD_ADDRESS for BINARY command Pali Rohár
2022-01-13 6:35 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 08/20] tools: kwbimage: Check the return value of image_headersz_v1() Pali Rohár
2022-01-13 6:35 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 09/20] tools: kwbimage: Check for maximal kwbimage header size Pali Rohár
2022-01-13 6:38 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 10/20] arm: mvebu: Set CPU for U-Boot SPL binary in kwbimage Pali Rohár
2022-01-13 6:39 ` Stefan Roese
2022-01-12 17:20 ` Pali Rohár [this message]
2022-01-13 6:40 ` [PATCH u-boot-marvell v2 11/20] arm: mvebu: Correctly set LOAD_ADDRESS " Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 12/20] tools: kwbimage: Enforce 128-bit boundary alignment only for Sheeva CPU Pali Rohár
2022-01-13 6:40 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 13/20] arm: mvebu: Enable BootROM output on A38x Pali Rohár
2022-01-13 6:42 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 14/20] tools: kwbimage: Add missing check for maximal value for DATA_DELAY Pali Rohár
2022-01-13 6:43 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 15/20] tools: kwbimage: Show binary image offset in mkimage -l, in addition to size Pali Rohár
2022-01-13 6:43 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 16/20] tools: kwbimage: Dump kwbimage config file on '-p -1' option Pali Rohár
2022-01-13 6:44 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 17/20] tools: kwbimage: Do not cast const pointers to non-const pointers Pali Rohár
2022-01-13 6:45 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 18/20] tools: kwbimage/kwboot: Check ext field for non-zero value Pali Rohár
2022-01-13 6:46 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 19/20] tools: kwbimage: Extract main data image without -p arg for dumpimage Pali Rohár
2022-01-13 6:46 ` Stefan Roese
2022-01-12 17:20 ` [PATCH u-boot-marvell v2 20/20] tools: kwbimage: Fix mkimage/dumpimage -l argument Pali Rohár
2022-01-13 6:46 ` Stefan Roese
2022-01-14 15:40 ` [PATCH u-boot-marvell v2 00/20] tools: kwbimage: Load address fixes Stefan Roese
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220112172054.5961-12-pali@kernel.org \
--to=pali@kernel.org \
--cc=judge.packham@gmail.com \
--cc=marek.behun@nic.cz \
--cc=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox