From: "Pali Rohár" <pali@kernel.org>
To: "Simon Glass" <sjg@chromium.org>, "Marek Behún" <kabel@kernel.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH] board_f: Add support for CONFIG_OF_BOARD_FIXUP for XIP images
Date: Sat, 27 Aug 2022 20:12:20 +0200 [thread overview]
Message-ID: <20220827181220.471-1-pali@kernel.org> (raw)
When U-Boot is running from flash memory (execute in place) then
gd->fdt_blob before relocation points to read-only flash memory.
So U-Boot calls board_fix_fdt() with read-only gd->fdt_blob pointer which
cause immediate CPU crash when callback is trying to modify gd->fdt_blob.
Fix this issue by introducing a new config option OF_INITIAL_DTB_READONLY
which moves fix_fdt callback after the reloc_fdt callback. This makes
CONFIG_OF_BOARD_FIXUP working also if U-Boot before relocation is not
running from read/write (S)RAM memory.
This is required for mpc85xx boards when booting from flash NOR.
Signed-off-by: Pali Rohár <pali@kernel.org>
---
common/board_f.c | 8 +++++++-
dts/Kconfig | 6 ++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/common/board_f.c b/common/board_f.c
index 18e2246733b0..56b4eea24885 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -911,7 +911,7 @@ static const init_fnc_t init_sequence_f[] = {
* - board info struct
*/
setup_dest_addr,
-#ifdef CONFIG_OF_BOARD_FIXUP
+#if defined(CONFIG_OF_BOARD_FIXUP) && !defined(CONFIG_OF_INITIAL_DTB_READONLY)
fix_fdt,
#endif
#ifdef CONFIG_PRAM
@@ -926,6 +926,10 @@ static const init_fnc_t init_sequence_f[] = {
reserve_board,
reserve_global_data,
reserve_fdt,
+#if defined(CONFIG_OF_BOARD_FIXUP) && defined(CONFIG_OF_INITIAL_DTB_READONLY)
+ reloc_fdt,
+ fix_fdt,
+#endif
reserve_bootstage,
reserve_bloblist,
reserve_arch,
@@ -936,7 +940,9 @@ static const init_fnc_t init_sequence_f[] = {
setup_bdinfo,
display_new_sp,
INIT_FUNC_WATCHDOG_RESET
+#if !defined(CONFIG_OF_BOARD_FIXUP) || !defined(CONFIG_OF_INITIAL_DTB_READONLY)
reloc_fdt,
+#endif
reloc_bootstage,
reloc_bloblist,
setup_reloc,
diff --git a/dts/Kconfig b/dts/Kconfig
index bc5f22029ff9..0bc3d741f8bc 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -105,6 +105,12 @@ config OF_EMBED
endchoice
+config OF_INITIAL_DTB_READONLY
+ bool "Initial DTB for DT control is read-only"
+ help
+ If initial DTB for DT control is read-only (e.g. points to
+ memory-mapped flash memory), then set this option.
+
config OF_BOARD
bool "Provided by the board (e.g a previous loader) at runtime"
default y if SANDBOX || OF_HAS_PRIOR_STAGE
--
2.20.1
next reply other threads:[~2022-08-27 18:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-27 18:12 Pali Rohár [this message]
2022-08-28 3:47 ` [PATCH] board_f: Add support for CONFIG_OF_BOARD_FIXUP for XIP images Marek Behún
2022-08-28 9:33 ` Pali Rohár
2022-08-28 15:19 ` [PATCH v2] " Marek Behún
2022-10-09 11:32 ` Pali Rohár
2022-10-10 23:48 ` Simon Glass
2022-11-01 23:23 ` Pali Rohár
2022-11-21 17:42 ` Pali Rohár
2022-11-21 17:45 ` Tom Rini
2022-11-21 18:10 ` Marek Behún
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=20220827181220.471-1-pali@kernel.org \
--to=pali@kernel.org \
--cc=kabel@kernel.org \
--cc=sjg@chromium.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.