From: "Sven Püschel" <s.pueschel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: "Sven Püschel" <s.pueschel@pengutronix.de>
Subject: [PATCH] scripts/make_fit: move the dtbs to the start
Date: Tue, 20 May 2025 11:12:28 +0200 [thread overview]
Message-ID: <20250520091228.119392-1-s.pueschel@pengutronix.de> (raw)
Move the dtbs to the start of the fit image to avoid u-boot overwriting
the dtb while relocating the kernel image.
Using a current u-boot master eeb5ff1a468b ("Merge tag
'efi-2025-07-rc3-2' of https://source.denx.de/u-boot/custodians/u-boot-efi")
failed to load a barebox fit image on a Pine64 Rock64 board:
=> bootm $loadaddr#conf-rk3328-rock64.dtb
Using 'conf-rk3328-rock64.dtb' configuration
Verifying Hash Integrity ... OK
Trying 'kernel' kernel subimage
Description: barebox-2025.04.0-00231-g00fd6bfa3088-dirty
Type: Kernel Image (no loading done)
Compression: uncompressed
Data Start: 0x00800968
Data Size: 737350 Bytes = 720.1 KiB
Verifying Hash Integrity ... OK
Using 'conf-rk3328-rock64.dtb' configuration
Verifying Hash Integrity ... OK
Trying 'fdt-1' fdt subimage
Description: rk3328-rock64.dtb
Type: Flat Device Tree
Compression: uncompressed
Data Start: 0x008b4a48
Data Size: 37415 Bytes = 36.5 KiB
Architecture: AArch64
Verifying Hash Integrity ... OK
Booting using the fdt blob at 0x8b4a48
Working FDT set to 8b4a48
XIP Kernel Image (no loading done) to 800968
Moving Image from 0x800968 to 0x880000, end=0x934048
ERROR: image is not a fdt - must RESET the board to recover.
FDT creation failed!
resetting ...
The culprint was the fact that u-boot relocated the barebox image to
match the alignment requirements from the Linux kernel. But the
relocation did overwrite the devicetree and therefore failed to boot it.
To prevent this error from happening, move the dtbs in the generated
barebox fit image to the start, so u-boot cannot overwrite these when
moving the kernel image to a higher address.
Signed-off-by: Sven Püschel <s.pueschel@pengutronix.de>
---
scripts/make_fit.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/scripts/make_fit.py b/scripts/make_fit.py
index 2190da4c00..4253b07e5f 100755
--- a/scripts/make_fit.py
+++ b/scripts/make_fit.py
@@ -267,12 +267,6 @@ def build_fit(args):
dtbs_seen = set()
fdts = {}
- # Handle the kernel
- with open(args.kernel, 'rb') as inf:
- comp_data = compress_data(inf, 'none')
- size += os.path.getsize(args.kernel)
- write_kernel(fsw, comp_data, args)
-
for fname in args.dtbs:
# Ignore non-DTB (*.dtb) files
if os.path.splitext(fname)[1] != '.dtb':
@@ -297,6 +291,12 @@ def build_fit(args):
entries.append([dtbname, model, compat, files_seq])
+ # Handle the kernel
+ with open(args.kernel, 'rb') as inf:
+ comp_data = compress_data(inf, 'none')
+ size += os.path.getsize(args.kernel)
+ write_kernel(fsw, comp_data, args)
+
finish_fit(fsw, entries)
# Include the kernel itself in the returned file count
--
2.49.0
next reply other threads:[~2025-05-20 9:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-20 9:12 Sven Püschel [this message]
2025-05-20 9:38 ` Ahmad Fatoum
2025-05-20 11:24 ` Sascha Hauer
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=20250520091228.119392-1-s.pueschel@pengutronix.de \
--to=s.pueschel@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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