Skip to contentSkip to conversation

Fix booting kernels with ATAGS and extlinux

PATCH In review Svyatoslav Ryhel 2 participants 5 messages Jan 25, 2024 – Mar 4, 2024

lore
Share & tools
lore
#0 lore raw

v2 cover Fix booting kernels with ATAGS and extlinux

Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass - in the fdt extlinux field as a signal that no tree should be used.

Tested with 3.4 legacy kernel and mainline 6.7 kernel on P895 (lg_x3 board).

---
Changes form v1
- Added CONFIG guards
- Clarified documentation
---

Svyatoslav Ryhel (1):
boot: pxe_utils: skip fdt setup in case legacy kernel is booted

 boot/pxe_utils.c       | 27 ++++++++++++++++++++++-----
 doc/develop/distro.rst |  6 ++++++
 2 files changed, 28 insertions(+), 5 deletions(-)
Signature · 1 line
2.40.1
#1 lore raw

PATCH v2 1/1 boot: pxe_utils: skip fdt setup in case legacy kernel is booted

Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass - in the fdt extlinux field as a signal that no tree should be used.

---
 boot/pxe_utils.c       | 27 ++++++++++++++++++++++-----
 doc/develop/distro.rst |  6 ++++++
 2 files changed, 28 insertions(+), 5 deletions(-)
boot/pxe_utils.c +22 -5
index 83bc167785..9620562675 100644
@@ -634,7 +634,12 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
 		char *fdtfilefree = NULL;
 
 		if (label->fdt) {
-			fdtfile = label->fdt;
+			if (IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS)) {
+				if (strcmp("-", label->fdt))
+					fdtfile = label->fdt;
+			} else {
+				fdtfile = label->fdt;
+			}
 		} else if (label->fdtdir) {
 			char *f1, *f2, *f3, *f4, *slash;
 
@@ -731,14 +736,26 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
 		zboot_argc = 5;
 	}
 
-	if (!bootm_argv[3])
-		bootm_argv[3] = env_get("fdt_addr");
+	if (!bootm_argv[3]) {
+		if (IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS)) {
+			if (strcmp("-", label->fdt))
+				bootm_argv[3] = env_get("fdt_addr");
+		} else {
+			bootm_argv[3] = env_get("fdt_addr");
+		}
+	}
 
 	kernel_addr_r = genimg_get_kernel_addr(kernel_addr);
 	buf = map_sysmem(kernel_addr_r, 0);
 
-	if (!bootm_argv[3] && genimg_get_format(buf) != IMAGE_FORMAT_FIT)
-		bootm_argv[3] = env_get("fdtcontroladdr");
+	if (!bootm_argv[3] && genimg_get_format(buf) != IMAGE_FORMAT_FIT) {
+		if (IS_ENABLED(CONFIG_SUPPORT_PASSING_ATAGS)) {
+			if (strcmp("-", label->fdt))
+				bootm_argv[3] = env_get("fdtcontroladdr");
+		} else {
+			bootm_argv[3] = env_get("fdtcontroladdr");
+		}
+	}
 
 	if (bootm_argv[3]) {
 		if (!bootm_argv[2])
doc/develop/distro.rst +6 -0
index 8016acad09..9e715b23eb 100644
@@ -81,6 +81,12 @@ as specified at `Boot Loader Specification`_:
 * Does not document the fdtdir option, which automatically selects the DTB to
   pass to the kernel.
 
+* If no fdt/fdtdir is provided, the U-Boot will pass its own currently used
+  device tree.
+
+* If ``-`` is passed as fdt argument and ``CONFIG_SUPPORT_PASSING_ATAGS`` is
+  enabled, then no device tree will be used (legacy booting / pre-dtb kernel).
+
 See also doc/README.pxe under 'pxe file format'.
 
 One example extlinux.conf generated by the Fedora installer is::
Signature · 1 line
2.40.1
#2 lore raw

Re: [PATCH v2 1/1] boot: pxe_utils: skip fdt setup in case legacy kernel is booted

Quoted 10 lines · Svyatoslav Ryhel

Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass - in the fdt extlinux field as a signal that no tree should be used.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
#3 lore raw
In reply to Svyatoslav Ryhel

чт, 25 січ. 2024 р. о 22:17 Svyatoslav Ryhel <[email protected]> пише:

Quoted 20 lines

Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass - in the fdt extlinux field as a signal that no tree should be used.

Tested with 3.4 legacy kernel and mainline 6.7 kernel on P895 (lg_x3 board).

---
Changes form v1
- Added CONFIG guards
- Clarified documentation
---

Svyatoslav Ryhel (1):
boot: pxe_utils: skip fdt setup in case legacy kernel is booted

Quoted 7 lines
 boot/pxe_utils.c       | 27 ++++++++++++++++++++++-----
 doc/develop/distro.rst |  6 ++++++
 2 files changed, 28 insertions(+), 5 deletions(-)

--
2.40.1

Hello, Tom! A month passed since v2 was pushed without any actions, should I re-send it or maybe some adjustments are needed?

#4 lore raw
Quoted 25 lines · Svyatoslav Ryhel

чт, 25 січ. 2024 р. о 22:17 Svyatoslav Ryhel <[email protected]> пише:

Quoted 24 lines

Currently, if boot with extlinux.conf and do not set the fdt U-Boot will provide its own device tree. This behavior is beneficial if the U-Boot device tree is in sync with Linux, but it totally halts the booting of pre-dtb kernels (3.4 for example) since it uses ATAGs. To fix this, pass - in the fdt extlinux field as a signal that no tree should be used.

Tested with 3.4 legacy kernel and mainline 6.7 kernel on P895 (lg_x3 board).

---
Changes form v1
- Added CONFIG guards
- Clarified documentation
---

Svyatoslav Ryhel (1):
boot: pxe_utils: skip fdt setup in case legacy kernel is booted

 boot/pxe_utils.c       | 27 ++++++++++++++++++++++-----
 doc/develop/distro.rst |  6 ++++++
 2 files changed, 28 insertions(+), 5 deletions(-)
Quoted 6 lines
Quoted 3 lines

--
2.40.1

Hello, Tom! A month passed since v2 was pushed without any actions, should I re-send it or maybe some adjustments are needed?

I should pick it up at some point for -next, thanks.

Signature · 1 line
Tom