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. Signed-off-by: Simon Glass <s...@chromium.org> Fixes: 47eda7e80ea ("boot: pxe: Use bootm_...() functions where possible") Reported-by: Svyatoslav Ryhel <clamo...@gmail.com> --- boot/bootm.c | 33 ++++++++++++++++++++++++++ cmd/bootz.c | 65 +++------------------------------------------------- 2 files changed, 36 insertions(+), 62 deletions(-) diff --git a/boot/bootm.c b/boot/bootm.c index 7807579d5e6..0e63dd4adf3 100644 --- a/boot/bootm.c +++ b/boot/bootm.c @@ -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); } diff --git a/cmd/bootz.c b/cmd/bootz.c index 787203f5bd7..acf0c92a42f 100644 --- a/cmd/bootz.c +++ b/cmd/bootz.c @@ -20,56 +20,6 @@ int __weak bootz_setup(ulong image, ulong *start, ulong *end) return -1; } -/* - * zImage booting support - */ -static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[], struct bootm_headers *images) -{ - ulong zi_start, zi_end; - struct bootm_info bmi; - int ret; - - bootm_init(&bmi); - if (argc) - bmi.addr_img = argv[0]; - if (argc > 1) - bmi.conf_ramdisk = argv[1]; - if (argc > 2) - bmi.conf_fdt = argv[2]; - /* do not set up argc and argv[] since nothing uses them */ - - ret = bootm_run_states(&bmi, BOOTM_STATE_START); - - /* Setup Linux kernel zImage entry point */ - if (!argc) { - images->ep = image_load_addr; - debug("* kernel: default image load address = 0x%08lx\n", - image_load_addr); - } else { - images->ep = hextoul(argv[0], NULL); - debug("* kernel: cmdline image address = 0x%08lx\n", - images->ep); - } - - ret = bootz_setup(images->ep, &zi_start, &zi_end); - if (ret != 0) - return 1; - - 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(image_load_addr, cmd_arg1(argc, argv), - cmd_arg2(argc, argv), images->ep, - zi_end - zi_start)) - return 1; - - return 0; -} - int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { struct bootm_info bmi; @@ -78,17 +28,6 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) /* Consume 'bootz' */ argc--; argv++; - if (bootz_start(cmdtp, flag, argc, argv, &images)) - return 1; - - /* - * We are doing the BOOTM_STATE_LOADOS state ourselves, so must - * disable interrupts ourselves - */ - bootm_disable_interrupts(); - - images.os.os = IH_OS_LINUX; - bootm_init(&bmi); if (argc) bmi.addr_img = argv[0]; @@ -99,8 +38,10 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) bmi.cmd_name = "bootz"; ret = bootz_run(&bmi); + if (ret) + return CMD_RET_FAILURE; - return ret; + return 0; } U_BOOT_LONGHELP(bootz, -- 2.43.0 base-commit: ea9e72801c4c3e3542afe40f89e7e0822cabfcf8 branch: fix-bootz