mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Alexander Dahl <ada@thorsis.com>
To: ptxdist@pengutronix.de
Cc: AVazquez <avazquez.dev@gmail.com>,
	Enrico Jorns <ejo@pengutronix.de>,
	Roland Hieber <rhi@pengutronix.de>,
	Bastian Krause <bst@pengutronix.de>
Subject: [ptxdist] [PATCH 2/5] kernel-fit: Allow using 'kernel_noload' as sub-image type
Date: Fri,  2 Feb 2024 16:12:06 +0100	[thread overview]
Message-ID: <20240202151209.2535721-3-ada@thorsis.com> (raw)
In-Reply-To: <20240202151209.2535721-1-ada@thorsis.com>

Multi platform kernels built by the kernel-fit rule before are not
usable in U-Boot, which adheres more strictly to the Flat Image Tree
(FIT) spec than barebox does.  For image sub-type 'kernel' U-Boot
expects valid 'load' and 'entry' addresses.  Setting those addresses to
a generic value is impossible however for generic kernels, e.g. the
DistroKit v7a kernel needs different addresses on at91 SAMA5 than
on i.MX6.  barebox circumvents this by ignoring missing 'load' and
'entry' addresses and finding a suitable address by itself.  For using
generic kernels in U-Boot you need sub-image type 'kernel_noload' and
dummy addresses, which is also supported in barebox from v2024.01.0
release onwards.

Link: https://github.com/open-source-firmware/flat-image-tree/releases/download/v0.8/fit-specification-v0.8.pdf
Link: https://lore.barebox.org/barebox/20231129203106.2417486-1-a.fatoum@pengutronix.de/
Signed-off-by: Alexander Dahl <ada@thorsis.com>
---
 platforms/kernel-fit.in            | 17 +++++++++++++++++
 scripts/lib/ptxd_make_fit_image.sh | 20 +++++++++++++++-----
 2 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/platforms/kernel-fit.in b/platforms/kernel-fit.in
index 0e82889b9..5b160c57d 100644
--- a/platforms/kernel-fit.in
+++ b/platforms/kernel-fit.in
@@ -17,14 +17,31 @@ menuconfig KERNEL_FIT
 
 if KERNEL_FIT
 
+config KERNEL_FIT_NOLOAD
+	bool
+	prompt "Sub-image type 'kernel_noload'"
+	help
+	  Use 'kernel_noload' as sub-image type for the kernel, setting
+	  the load address and entry address to dummy values as required
+	  by the FIT image specification.
+	  Useful for booting kernels supporting multiple boards with
+	  U-Boot, e.g. the platform-v7a kernel of DistroKit.
+	  U-Boot supports this since release v2011.12.
+
+	  Note: barebox added support with release v2024.01.0.
+	  You can leave this option disabled if you only use barebox.
+	  You should not enable this if you use older barebox versions.
+
 config KERNEL_FIT_LOAD
 	string
+	depends on !KERNEL_FIT_NOLOAD
 	prompt "Kernel load address (optional)"
 	help
 	  Required by most bootloaders. Optional for Barebox.
 
 config KERNEL_FIT_ENTRY
 	string
+	depends on !KERNEL_FIT_NOLOAD
 	prompt "Kernel entry address (optional)"
 	help
 	  Required by most bootloaders. Optional for Barebox.
diff --git a/scripts/lib/ptxd_make_fit_image.sh b/scripts/lib/ptxd_make_fit_image.sh
index dd0f63b7b..4b99e6fbf 100644
--- a/scripts/lib/ptxd_make_fit_image.sh
+++ b/scripts/lib/ptxd_make_fit_image.sh
@@ -19,20 +19,30 @@ ptxd_make_image_fit_its() {
 		kernel {
 			description = "kernel";
 			data = /incbin/("${image_kernel}");
-			type = "kernel";
 			arch = "$(ptxd_get_ptxconf PTXCONF_ARCH_STRING)";
 			os = "linux";
 			compression = "none";
 EOF
-    if [ -n "$(ptxd_get_ptxconf PTXCONF_KERNEL_FIT_LOAD)" ]; then
+    if [ -n "$(ptxd_get_ptxconf PTXCONF_KERNEL_FIT_NOLOAD)" ]; then
         cat << EOF
+			type = "kernel_noload";
+			load = <0x00000000>;
+			entry = <0x00000000>;
+EOF
+    else
+        cat << EOF
+			type = "kernel";
+EOF
+        if [ -n "$(ptxd_get_ptxconf PTXCONF_KERNEL_FIT_LOAD)" ]; then
+            cat << EOF
 			load = <$(ptxd_get_ptxconf PTXCONF_KERNEL_FIT_LOAD)>;
 EOF
-    fi
-    if [ -n "$(ptxd_get_ptxconf PTXCONF_KERNEL_FIT_ENTRY)" ]; then
-        cat << EOF
+        fi
+        if [ -n "$(ptxd_get_ptxconf PTXCONF_KERNEL_FIT_ENTRY)" ]; then
+            cat << EOF
 			entry = <$(ptxd_get_ptxconf PTXCONF_KERNEL_FIT_ENTRY)>;
 EOF
+        fi
     fi
     cat << EOF
 			hash-1 {
-- 
2.39.2




  parent reply	other threads:[~2024-02-02 15:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-02 15:12 [ptxdist] [PATCH 0/5] FIT images with U-Boot and barebox on recent DistroKit Alexander Dahl
2024-02-02 15:12 ` [ptxdist] [PATCH 1/5] kernel-fit: Review help text Alexander Dahl
2024-02-08 16:03   ` [ptxdist] [APPLIED] " Michael Olbrich
2024-02-02 15:12 ` Alexander Dahl [this message]
2024-02-08 16:03   ` [ptxdist] [APPLIED] kernel-fit: Allow using 'kernel_noload' as sub-image type Michael Olbrich
2024-02-02 15:12 ` [ptxdist] [PATCH 3/5] blspec-entry: Fix kernel entry for FIT image Alexander Dahl
2024-02-08 16:03   ` [ptxdist] [APPLIED] " Michael Olbrich
2024-02-02 15:12 ` [ptxdist] [PATCH 4/5] u-boot: Avoid hooking oldconfig if kconfig is not selected Alexander Dahl
2024-02-08 16:03   ` [ptxdist] [APPLIED] " Michael Olbrich
2024-02-02 15:12 ` [ptxdist] [PATCH 5/5] image-rauc: Fix quotation marks / whitespace handling Alexander Dahl
2024-02-06 11:41   ` Roland Hieber
2024-02-08 16:03   ` [ptxdist] [APPLIED] " Michael Olbrich

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=20240202151209.2535721-3-ada@thorsis.com \
    --to=ada@thorsis.com \
    --cc=avazquez.dev@gmail.com \
    --cc=bst@pengutronix.de \
    --cc=ejo@pengutronix.de \
    --cc=ptxdist@pengutronix.de \
    --cc=rhi@pengutronix.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