Skip to contentSkip to conversation

boot: Add missing code for bootz_run()

PATCH In review Simon Glass 2 participants 3 messages Apr 9, 2025 – May 1, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 boot: Add missing code for bootz_run()

The bootz method is special in that it uses its own implementation of several of the bootm states.

The existing do_bootz() function calls bootz_run() but first does a few other things. These are missing in the direct call to bootz_run(). I probably missed this because bootz_start() sets up its own struct bootm_info so I assumed it was independent. While the struct itself is independent, changes to the images member (which is a pointer) persist.

Move the required code into bootz_run()

This change was manually tested on an rpi2 with postmarketOS added, using standard boot and also the 'bootz' command.

Fixes 47eda7e80ea ("boot: pxe: Use bootm_...() functions where possible")

---

 boot/bootm.c | 33 ++++++++++++++++++++++++++
 cmd/bootz.c  | 65 +++-------------------------------------------------
 2 files changed, 36 insertions(+), 62 deletions(-)
boot/bootm.c +33 -0
index 7807579d5e6..0e63dd4adf3 100644
@@ -1185,6 +1185,39 @@ int bootm_run(struct bootm_info *bmi)
 
 int bootz_run(struct bootm_info *bmi)
 {
+	struct bootm_headers *images = bmi->images;
+	ulong zi_start, zi_end;
+	int ret;
+
+	ret = bootm_run_states(bmi, BOOTM_STATE_START);
+	if (ret)
+		return ret;
+
+	images->ep = bmi->addr_img ? hextoul(bmi->addr_img, NULL) :
+		image_load_addr;
+
+	ret = bootz_setup(images->ep, &zi_start, &zi_end);
+	if (ret)
+		return ret;
+
+	lmb_reserve(images->ep, zi_end - zi_start);
+
+	/*
+	 * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
+	 * have a header that provide this informaiton.
+	 */
+	if (bootm_find_images(images->ep, bmi->conf_ramdisk, bmi->conf_fdt,
+			      images->ep, zi_end - zi_start))
+		return -EINVAL;
+
+	/*
+	 * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
+	 * disable interrupts ourselves
+	 */
+	bootm_disable_interrupts();
+
+	images->os.os = IH_OS_LINUX;
+
 	return boot_run(bmi, "bootz", 0);
 }
 
cmd/bootz.c +3 -62

84 lines not on this page · raw message

Signature · 4 lines
2.43.0

base-commit: ea9e72801c4c3e3542afe40f89e7e0822cabfcf8
branch: fix-bootz
Tested-by on v1 1/1
#1 lore raw

ср, 9 квіт. 2025 р. о 18:57 Simon Glass <[email protected]> пише:

Quoted 13 lines

The bootz method is special in that it uses its own implementation of several of the bootm states.

The existing do_bootz() function calls bootz_run() but first does a few other things. These are missing in the direct call to bootz_run(). I probably missed this because bootz_start() sets up its own struct bootm_info so I assumed it was independent. While the struct itself is independent, changes to the images member (which is a pointer) persist.

Move the required code into bootz_run()

Quoted 8 lines

This change was manually tested on an rpi2 with postmarketOS added, using standard boot and also the 'bootz' command.

Fixes 47eda7e80ea ("boot: pxe: Use bootm_...() functions where possible")

---

It is not cleanly applicable to current u-boot/next with your pxe changes present, but overall it fixes booting on my devices. Thank you.

author Tested-by Svyatoslav Ryhel Applied
#2 lore raw

ср, 9 квіт. 2025 р. о 18:57 Simon Glass <[email protected]> пише:

Quoted 13 lines

The bootz method is special in that it uses its own implementation of several of the bootm states.

The existing do_bootz() function calls bootz_run() but first does a few other things. These are missing in the direct call to bootz_run(). I probably missed this because bootz_start() sets up its own struct bootm_info so I assumed it was independent. While the struct itself is independent, changes to the images member (which is a pointer) persist.

Move the required code into bootz_run()

Quoted 8 lines

This change was manually tested on an rpi2 with postmarketOS added, using standard boot and also the 'bootz' command.

Fixes 47eda7e80ea ("boot: pxe: Use bootm_...() functions where possible")

---

It is not cleanly applicable to current u-boot/next with your pxe changes present, but overall it fixes booting on my devices. Thank you.

Applied to sjg/master, thanks!