[PATCH 1/3] pxe: Add debugging for booting

Show which boot protocol is being used.
Signed-off-by: Simon Glass sjg@chromium.org ---
boot/pxe_utils.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 4b22bb6f525..53ddb16be73 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -4,6 +4,8 @@ * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved. */
+#define LOG_CATEGORY LOGC_BOOT + #include <command.h> #include <dm.h> #include <env.h> @@ -762,17 +764,22 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
/* Try bootm for legacy and FIT format image */ if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID && - IS_ENABLED(CONFIG_CMD_BOOTM)) + IS_ENABLED(CONFIG_CMD_BOOTM)) { + log_debug("using bootm\n"); do_bootm(ctx->cmdtp, 0, bootm_argc, bootm_argv); /* Try booting an AArch64 Linux kernel image */ - else if (IS_ENABLED(CONFIG_CMD_BOOTI)) + } else if (IS_ENABLED(CONFIG_CMD_BOOTI)) { + log_debug("using booti\n"); do_booti(ctx->cmdtp, 0, bootm_argc, bootm_argv); /* Try booting a Image */ - else if (IS_ENABLED(CONFIG_CMD_BOOTZ)) + } else if (IS_ENABLED(CONFIG_CMD_BOOTZ)) { + log_debug("using bootz\n"); do_bootz(ctx->cmdtp, 0, bootm_argc, bootm_argv); /* Try booting an x86_64 Linux kernel image */ - else if (IS_ENABLED(CONFIG_CMD_ZBOOT)) + } else if (IS_ENABLED(CONFIG_CMD_ZBOOT)) { + log_debug("using zboot\n"); do_zboot_parent(ctx->cmdtp, 0, zboot_argc, zboot_argv, NULL); + }
unmap_sysmem(buf);

Show the boot arguments and the state mask, to aid debugging.
Signed-off-by: Simon Glass sjg@chromium.org ---
cmd/x86/zboot.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/cmd/x86/zboot.c b/cmd/x86/zboot.c index addf28cb4aa..c14219f19e9 100644 --- a/cmd/x86/zboot.c +++ b/cmd/x86/zboot.c @@ -5,6 +5,8 @@ * Daniel Engström, Omicron Ceti AB, daniel@omicron.se */
+#define LOG_CATEGORY LOGC_BOOT + #include <command.h> #include <mapmem.h> #include <vsprintf.h> @@ -14,8 +16,14 @@ static int do_zboot_start(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { ulong bzimage_addr = 0, bzimage_size, initrd_addr, initrd_size; - ulong base_addr; const char *s, *cmdline; + ulong base_addr; + int i; + + log_debug("argc %d:", argc); + for (i = 0; i < argc; i++) + log_debug(" %s", argv[i]); + log_debug("\n");
/* argv[1] holds the address of the bzImage */ s = cmd_arg1(argc, argv) ? : env_get("fileaddr"); @@ -116,6 +124,7 @@ int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc, { int ret;
+ log_debug("state_mask %x\n", state_mask); if (flag & ZBOOT_STATE_START) ret = do_zboot_start(cmdtp, flag, argc, argv); if (!ret && (flag & ZBOOT_STATE_LOAD))

There is confusion in this function between the flag and state_mask parameters, which prevents the boot from actually happening. Correct this by using state_mask instead of flag for deciding which states to go through.
This fixes booting of some 32-bit Debian kernels.
Note: Some sort of CI for this is in the works.
Fixes: 228c6722d44 ("x86: zboot: Avoid iteration in do_zboot_states()")
Signed-off-by: Simon Glass sjg@chromium.org ---
cmd/x86/zboot.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/cmd/x86/zboot.c b/cmd/x86/zboot.c index c14219f19e9..94e602b8a5b 100644 --- a/cmd/x86/zboot.c +++ b/cmd/x86/zboot.c @@ -122,18 +122,18 @@ U_BOOT_SUBCMDS(zboot, int do_zboot_states(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[], int state_mask) { - int ret; + int ret = 0;
log_debug("state_mask %x\n", state_mask); - if (flag & ZBOOT_STATE_START) + if (state_mask & ZBOOT_STATE_START) ret = do_zboot_start(cmdtp, flag, argc, argv); - if (!ret && (flag & ZBOOT_STATE_LOAD)) + if (!ret && (state_mask & ZBOOT_STATE_LOAD)) ret = do_zboot_load(cmdtp, flag, argc, argv); - if (!ret && (flag & ZBOOT_STATE_SETUP)) + if (!ret && (state_mask & ZBOOT_STATE_SETUP)) ret = do_zboot_setup(cmdtp, flag, argc, argv); - if (!ret && (flag & ZBOOT_STATE_INFO)) + if (!ret && (state_mask & ZBOOT_STATE_INFO)) ret = do_zboot_info(cmdtp, flag, argc, argv); - if (!ret && (flag & ZBOOT_STATE_GO)) + if (!ret && (state_mask & ZBOOT_STATE_GO)) ret = do_zboot_go(cmdtp, flag, argc, argv); if (ret) return ret;

Hi
On Wed, Jun 19, 2024 at 2:34 PM Simon Glass sjg@chromium.org wrote:
Show which boot protocol is being used.
Signed-off-by: Simon Glass sjg@chromium.org
boot/pxe_utils.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index 4b22bb6f525..53ddb16be73 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -4,6 +4,8 @@
- Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
*/
+#define LOG_CATEGORY LOGC_BOOT
#include <command.h> #include <dm.h> #include <env.h> @@ -762,17 +764,22 @@ static int label_boot(struct pxe_context *ctx, struct pxe_label *label)
/* Try bootm for legacy and FIT format image */ if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID &&
IS_ENABLED(CONFIG_CMD_BOOTM))
IS_ENABLED(CONFIG_CMD_BOOTM)) {
log_debug("using bootm\n"); do_bootm(ctx->cmdtp, 0, bootm_argc, bootm_argv); /* Try booting an AArch64 Linux kernel image */
else if (IS_ENABLED(CONFIG_CMD_BOOTI))
} else if (IS_ENABLED(CONFIG_CMD_BOOTI)) {
log_debug("using booti\n"); do_booti(ctx->cmdtp, 0, bootm_argc, bootm_argv); /* Try booting a Image */
else if (IS_ENABLED(CONFIG_CMD_BOOTZ))
} else if (IS_ENABLED(CONFIG_CMD_BOOTZ)) {
log_debug("using bootz\n"); do_bootz(ctx->cmdtp, 0, bootm_argc, bootm_argv); /* Try booting an x86_64 Linux kernel image */
else if (IS_ENABLED(CONFIG_CMD_ZBOOT))
} else if (IS_ENABLED(CONFIG_CMD_ZBOOT)) {
log_debug("using zboot\n"); do_zboot_parent(ctx->cmdtp, 0, zboot_argc, zboot_argv, NULL);
} unmap_sysmem(buf);
-- 2.34.1
Reviewed-by: Michael Trimarchi michael@amarulasolutions.com

Hi Tom,
On Thu, 27 Jun 2024 at 02:19, Tom Rini trini@konsulko.com wrote:
On Wed, 19 Jun 2024 06:34:50 -0600, Simon Glass wrote:
Show which boot protocol is being used.
Applied to u-boot/next, thanks!
I wonder if this could go to -master since it is an important bugfix?
https://patchwork.ozlabs.org/project/uboot/list/?series=411595&state=*
Regards, Simon

On Sat, Jun 29, 2024 at 07:56:00AM +0100, Simon Glass wrote:
Hi Tom,
On Thu, 27 Jun 2024 at 02:19, Tom Rini trini@konsulko.com wrote:
On Wed, 19 Jun 2024 06:34:50 -0600, Simon Glass wrote:
Show which boot protocol is being used.
Applied to u-boot/next, thanks!
I wonder if this could go to -master since it is an important bugfix?
https://patchwork.ozlabs.org/project/uboot/list/?series=411595&state=*
It doesn't apply to master and v2024.04 was also seemingly broken. I think it's clear enough that it can be cherry-picked in places as needed.

Hi Tom,
On Sun, 30 Jun 2024 at 15:57, Tom Rini trini@konsulko.com wrote:
On Sat, Jun 29, 2024 at 07:56:00AM +0100, Simon Glass wrote:
Hi Tom,
On Thu, 27 Jun 2024 at 02:19, Tom Rini trini@konsulko.com wrote:
On Wed, 19 Jun 2024 06:34:50 -0600, Simon Glass wrote:
Show which boot protocol is being used.
Applied to u-boot/next, thanks!
I wonder if this could go to -master since it is an important bugfix?
https://patchwork.ozlabs.org/project/uboot/list/?series=411595&state=*
It doesn't apply to master and v2024.04 was also seemingly broken. I think it's clear enough that it can be cherry-picked in places as needed.
OK, yes it was broken in the last release too. I'd be happy to rebase it if you do want it in.
Regards, Simon
participants (3)
-
Michael Nazzareno Trimarchi
-
Simon Glass
-
Tom Rini