aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass2024-07-17 09:31:00 +0100
committerHeinrich Schuchardt2024-07-19 13:57:50 +0200
commit60b180fdba1bf7bbd6181c1eef804a20fa485427 (patch)
treecbee58345bb3c29853439cebbe6c64a581e11614
parentcfed2219e36946902e3bd57d5c647ab8f10f6397 (diff)
bootstd: Correct handling of script from network
When reading a script from a network, no block device is available. Update the implementation to support this correctly, avoiding setting environment variables which relate only to block devices. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
-rw-r--r--boot/bootmeth_script.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c
index 24da47c7259..c5cbf18c2e6 100644
--- a/boot/bootmeth_script.c
+++ b/boot/bootmeth_script.c
@@ -185,31 +185,42 @@ static int script_set_bootflow(struct udevice *dev, struct bootflow *bflow,
static int script_boot(struct udevice *dev, struct bootflow *bflow)
{
- struct blk_desc *desc = dev_get_uclass_plat(bflow->blk);
+ struct blk_desc *desc;
ulong addr;
int ret = 0;
- if (desc->uclass_id == UCLASS_USB) {
- ret = env_set("devtype", "usb");
+ if (bflow->blk) {
+ desc = dev_get_uclass_plat(bflow->blk);
+ if (desc->uclass_id == UCLASS_USB) {
+ ret = env_set("devtype", "usb");
+ } else {
+ /*
+ * If the uclass is AHCI, but the driver is ATA
+ * (not scsi), set devtype to sata
+ */
+ if (IS_ENABLED(CONFIG_SATA) &&
+ desc->uclass_id == UCLASS_AHCI)
+ ret = env_set("devtype", "sata");
+ else
+ ret = env_set("devtype", blk_get_devtype(bflow->blk));
+ }
+ if (!ret)
+ ret = env_set_hex("devnum", desc->devnum);
+ if (!ret)
+ ret = env_set_hex("distro_bootpart", bflow->part);
+ if (!ret)
+ ret = env_set("prefix", bflow->subdir);
+ if (!ret && IS_ENABLED(CONFIG_ARCH_SUNXI) &&
+ !strcmp("mmc", blk_get_devtype(bflow->blk)))
+ ret = env_set_hex("mmc_bootdev", desc->devnum);
} else {
- /* If the uclass is AHCI, but the driver is ATA
- * (not scsi), set devtype to sata
- */
- if (IS_ENABLED(CONFIG_SATA) &&
- desc->uclass_id == UCLASS_AHCI)
- ret = env_set("devtype", "sata");
- else
- ret = env_set("devtype", blk_get_devtype(bflow->blk));
+ const struct udevice *media = dev_get_parent(bflow->dev);
+
+ ret = env_set("devtype",
+ uclass_get_name(device_get_uclass_id(media)));
+ if (!ret)
+ ret = env_set_hex("devnum", dev_seq(media));
}
- if (!ret)
- ret = env_set_hex("devnum", desc->devnum);
- if (!ret)
- ret = env_set_hex("distro_bootpart", bflow->part);
- if (!ret)
- ret = env_set("prefix", bflow->subdir);
- if (!ret && IS_ENABLED(CONFIG_ARCH_SUNXI) &&
- !strcmp("mmc", blk_get_devtype(bflow->blk)))
- ret = env_set_hex("mmc_bootdev", desc->devnum);
if (ret)
return log_msg_ret("env", ret);