summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
Diffstat (limited to 'boot')
-rw-r--r--boot/Kconfig35
-rw-r--r--boot/Makefile4
-rw-r--r--boot/bootdev-uclass.c9
-rw-r--r--boot/bootmeth-uclass.c2
-rw-r--r--boot/bootmeth_efi.c2
-rw-r--r--boot/bootmeth_extlinux.c (renamed from boot/bootmeth_distro.c)58
-rw-r--r--boot/bootmeth_pxe.c50
-rw-r--r--boot/bootmeth_qfw.c2
-rw-r--r--boot/bootmeth_sandbox.c2
9 files changed, 95 insertions, 69 deletions
diff --git a/boot/Kconfig b/boot/Kconfig
index 8c27f52ec3..eea5ed6040 100644
--- a/boot/Kconfig
+++ b/boot/Kconfig
@@ -437,6 +437,7 @@ config BOOTSTD_DEFAULTS
depends on BOOTSTD
imply USE_BOOTCOMMAND
select BOOT_DEFAULTS
+ select BOOTMETH_DISTRO
help
These are not required but are commonly needed to support a good
selection of booting methods. Enable this to improve the capability
@@ -462,30 +463,38 @@ config BOOTMETH_GLOBAL
EFI bootmgr, since they take full control over which bootdevs are
selected to boot.
-config BOOTMETH_DISTRO
- bool "Bootdev support for distro boot"
+config BOOTMETH_EXTLINUX
+ bool "Bootdev support for extlinux boot"
select PXE_UTILS
default y
help
- Enables support for distro boot using bootdevs. This makes the
+ Enables support for extlinux boot using bootdevs. This makes the
bootdevs look for a 'extlinux/extlinux.conf' on each filesystem
they scan.
+ The specification for this filed is here:
+
+ https://uapi-group.org/specifications/specs/boot_loader_specification/
+
This provides a way to try out standard boot on an existing boot flow.
-config BOOTMETH_DISTRO_PXE
- bool "Bootdev support for distro boot over network"
+config BOOTMETH_EXTLINUX_PXE
+ bool "Bootdev support for extlinux boot over network"
depends on CMD_PXE && CMD_NET && DM_ETH
default y
help
- Enables support for distro boot using bootdevs. This makes the
+ Enables support for extlinux boot using bootdevs. This makes the
bootdevs look for a 'extlinux/extlinux.conf' on the tftp server.
+ The specification for this file is here:
+
+ https://uapi-group.org/specifications/specs/boot_loader_specification/
+
This provides a way to try out standard boot on an existing boot flow.
config BOOTMETH_EFILOADER
bool "Bootdev support for EFI boot"
- depends on CMD_BOOTEFI
+ depends on EFI_LOADER
default y
help
Enables support for EFI boot using bootdevs. This makes the
@@ -515,6 +524,13 @@ config BOOTMETH_VBE
supports selection of various firmware components, seleciton of an OS to
boot as well as updating these using fwupd.
+config BOOTMETH_DISTRO
+ bool # Options needed to boot any distro
+ select BOOTMETH_SCRIPT # E.g. Armbian uses scripts
+ select BOOTMETH_EXTLINUX # E.g. Debian uses these
+ select BOOTMETH_EXTLINUX_PXE if CMD_PXE && CMD_NET && DM_ETH
+ select BOOTMETH_EFILOADER if EFI_LOADER # E.g. Ubuntu uses this
+
config SPL_BOOTMETH_VBE
bool "Bootdev support for Verified Boot for Embedded (SPL)"
depends on SPL && FIT
@@ -638,6 +654,7 @@ config BOOTMETH_SANDBOX
config BOOTMETH_SCRIPT
bool "Bootdev support for U-Boot scripts"
default y if BOOTSTD_FULL
+ select HUSH_PARSER
help
Enables support for booting a distro via a U-Boot script. This makes
the bootdevs look for a 'boot/boot.scr' file which can be used to
@@ -1553,8 +1570,8 @@ config USE_BOOTCOMMAND
config BOOTCOMMAND
string "bootcmd value"
depends on USE_BOOTCOMMAND && !USE_DEFAULT_ENV_FILE
- default "bootflow scan -lb" if BOOTSTD_BOOTCOMMAND && CMD_BOOTFLOW_FULL
- default "bootflow scan" if BOOTSTD_BOOTCOMMAND && !CMD_BOOTFLOW_FULL
+ default "bootflow scan -lb" if BOOTSTD_DEFAULTS && CMD_BOOTFLOW_FULL
+ default "bootflow scan" if BOOTSTD_DEFAULTS && !CMD_BOOTFLOW_FULL
default "run distro_bootcmd" if !BOOTSTD_BOOTCOMMAND && DISTRO_DEFAULTS
help
This is the string of commands that will be used as bootcmd and if
diff --git a/boot/Makefile b/boot/Makefile
index 88193a1b60..f94c31d922 100644
--- a/boot/Makefile
+++ b/boot/Makefile
@@ -24,8 +24,8 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow.o
obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootmeth-uclass.o
obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o
-obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) += bootmeth_distro.o
-obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO_PXE) += bootmeth_pxe.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX) += bootmeth_extlinux.o
+obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX_PXE) += bootmeth_pxe.o
obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o
obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o
obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o
diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
index 57d2944647..9660ff7567 100644
--- a/boot/bootdev-uclass.c
+++ b/boot/bootdev-uclass.c
@@ -154,8 +154,15 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,
ret = -ESHUTDOWN;
else
bflow->state = BOOTFLOWST_MEDIA;
- if (ret)
+ if (ret) {
+ /* allow partition 1 to be missing */
+ if (iter->part == 1) {
+ iter->max_part = 3;
+ ret = -ENOENT;
+ }
+
return log_msg_ret("part", ret);
+ }
/*
* Currently we don't get the number of partitions, so just
diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c
index 2aee1e0f0c..3b3e0614da 100644
--- a/boot/bootmeth-uclass.c
+++ b/boot/bootmeth-uclass.c
@@ -319,7 +319,7 @@ static int alloc_file(const char *fname, uint size, void **bufp)
return log_msg_ret("read", ret);
}
if (size != bytes_read)
- return log_msg_ret("bread", -EINVAL);
+ return log_msg_ret("bread", -EIO);
buf[size] = '\0';
*bufp = buf;
diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c
index 6f70f2229b..af31fbfc85 100644
--- a/boot/bootmeth_efi.c
+++ b/boot/bootmeth_efi.c
@@ -235,7 +235,7 @@ static int distro_efi_read_bootflow_file(struct udevice *dev,
ret = efiload_read_file(desc, bflow);
if (ret)
- return log_msg_ret("read", -EINVAL);
+ return log_msg_ret("read", ret);
fdt_addr = env_get_hex("fdt_addr_r", 0);
diff --git a/boot/bootmeth_distro.c b/boot/bootmeth_extlinux.c
index b4b73ecbf5..24be076022 100644
--- a/boot/bootmeth_distro.c
+++ b/boot/bootmeth_extlinux.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Bootmethod for distro boot (syslinux boot from a block device)
+ * Bootmethod for extlinux boot from a block device
*
* Copyright 2021 Google LLC
* Written by Simon Glass <sjg@chromium.org>
@@ -14,15 +14,15 @@
#include <bootmeth.h>
#include <bootstd.h>
#include <command.h>
-#include <distro.h>
#include <dm.h>
+#include <extlinux.h>
#include <fs.h>
#include <malloc.h>
#include <mapmem.h>
#include <mmc.h>
#include <pxe_utils.h>
-static int distro_get_state_desc(struct udevice *dev, char *buf, int maxsize)
+static int extlinux_get_state_desc(struct udevice *dev, char *buf, int maxsize)
{
if (IS_ENABLED(CONFIG_SANDBOX)) {
int len;
@@ -35,10 +35,10 @@ static int distro_get_state_desc(struct udevice *dev, char *buf, int maxsize)
return 0;
}
-static int distro_getfile(struct pxe_context *ctx, const char *file_path,
- char *file_addr, ulong *sizep)
+static int extlinux_getfile(struct pxe_context *ctx, const char *file_path,
+ char *file_addr, ulong *sizep)
{
- struct distro_info *info = ctx->userdata;
+ struct extlinux_info *info = ctx->userdata;
ulong addr;
int ret;
@@ -54,7 +54,7 @@ static int distro_getfile(struct pxe_context *ctx, const char *file_path,
return 0;
}
-static int distro_check(struct udevice *dev, struct bootflow_iter *iter)
+static int extlinux_check(struct udevice *dev, struct bootflow_iter *iter)
{
int ret;
@@ -67,12 +67,12 @@ static int distro_check(struct udevice *dev, struct bootflow_iter *iter)
}
/**
- * distro_fill_info() - Decode the extlinux file to find out distro info
+ * extlinux_fill_info() - Decode the extlinux file to find out its info
*
* @bflow: Bootflow to process
* @return 0 if OK, -ve on error
*/
-static int distro_fill_info(struct bootflow *bflow)
+static int extlinux_fill_info(struct bootflow *bflow)
{
struct membuff mb;
char line[200];
@@ -98,7 +98,7 @@ static int distro_fill_info(struct bootflow *bflow)
return 0;
}
-static int distro_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+static int extlinux_read_bootflow(struct udevice *dev, struct bootflow *bflow)
{
struct blk_desc *desc;
const char *const *prefixes;
@@ -121,7 +121,7 @@ static int distro_read_bootflow(struct udevice *dev, struct bootflow *bflow)
do {
prefix = prefixes ? prefixes[i] : NULL;
- ret = bootmeth_try_file(bflow, desc, prefix, DISTRO_FNAME);
+ ret = bootmeth_try_file(bflow, desc, prefix, EXTLINUX_FNAME);
} while (ret && prefixes && prefixes[++i]);
if (ret)
return log_msg_ret("try", ret);
@@ -131,25 +131,25 @@ static int distro_read_bootflow(struct udevice *dev, struct bootflow *bflow)
if (ret)
return log_msg_ret("read", ret);
- ret = distro_fill_info(bflow);
+ ret = extlinux_fill_info(bflow);
if (ret)
return log_msg_ret("inf", ret);
return 0;
}
-static int distro_boot(struct udevice *dev, struct bootflow *bflow)
+static int extlinux_boot(struct udevice *dev, struct bootflow *bflow)
{
struct cmd_tbl cmdtp = {}; /* dummy */
struct pxe_context ctx;
- struct distro_info info;
+ struct extlinux_info info;
ulong addr;
int ret;
addr = map_to_sysmem(bflow->buf);
info.dev = dev;
info.bflow = bflow;
- ret = pxe_setup_ctx(&ctx, &cmdtp, distro_getfile, &info, true,
+ ret = pxe_setup_ctx(&ctx, &cmdtp, extlinux_getfile, &info, true,
bflow->subdir, false);
if (ret)
return log_msg_ret("ctx", -EINVAL);
@@ -161,33 +161,33 @@ static int distro_boot(struct udevice *dev, struct bootflow *bflow)
return 0;
}
-static int distro_bootmeth_bind(struct udevice *dev)
+static int extlinux_bootmeth_bind(struct udevice *dev)
{
struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
plat->desc = IS_ENABLED(CONFIG_BOOTSTD_FULL) ?
- "Syslinux boot from a block device" : "syslinux";
+ "Extlinux boot from a block device" : "extlinux";
return 0;
}
-static struct bootmeth_ops distro_bootmeth_ops = {
- .get_state_desc = distro_get_state_desc,
- .check = distro_check,
- .read_bootflow = distro_read_bootflow,
+static struct bootmeth_ops extlinux_bootmeth_ops = {
+ .get_state_desc = extlinux_get_state_desc,
+ .check = extlinux_check,
+ .read_bootflow = extlinux_read_bootflow,
.read_file = bootmeth_common_read_file,
- .boot = distro_boot,
+ .boot = extlinux_boot,
};
-static const struct udevice_id distro_bootmeth_ids[] = {
- { .compatible = "u-boot,distro-syslinux" },
+static const struct udevice_id extlinux_bootmeth_ids[] = {
+ { .compatible = "u-boot,extlinux" },
{ }
};
-U_BOOT_DRIVER(bootmeth_distro) = {
- .name = "bootmeth_distro",
+U_BOOT_DRIVER(bootmeth_extlinux) = {
+ .name = "bootmeth_extlinux",
.id = UCLASS_BOOTMETH,
- .of_match = distro_bootmeth_ids,
- .ops = &distro_bootmeth_ops,
- .bind = distro_bootmeth_bind,
+ .of_match = extlinux_bootmeth_ids,
+ .ops = &extlinux_bootmeth_ops,
+ .bind = extlinux_bootmeth_bind,
};
diff --git a/boot/bootmeth_pxe.c b/boot/bootmeth_pxe.c
index 5a8af2bbd0..ce986bd260 100644
--- a/boot/bootmeth_pxe.c
+++ b/boot/bootmeth_pxe.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
/*
- * Bootmethod for distro boot using PXE (network boot)
+ * Bootmethod for extlinux boot using PXE (network boot)
*
* Copyright 2021 Google LLC
* Written by Simon Glass <sjg@chromium.org>
@@ -13,8 +13,8 @@
#include <bootflow.h>
#include <bootmeth.h>
#include <command.h>
-#include <distro.h>
#include <dm.h>
+#include <extlinux.h>
#include <fs.h>
#include <log.h>
#include <malloc.h>
@@ -23,10 +23,10 @@
#include <net.h>
#include <pxe_utils.h>
-static int distro_pxe_getfile(struct pxe_context *ctx, const char *file_path,
- char *file_addr, ulong *sizep)
+static int extlinux_pxe_getfile(struct pxe_context *ctx, const char *file_path,
+ char *file_addr, ulong *sizep)
{
- struct distro_info *info = ctx->userdata;
+ struct extlinux_info *info = ctx->userdata;
ulong addr;
int ret;
@@ -39,7 +39,7 @@ static int distro_pxe_getfile(struct pxe_context *ctx, const char *file_path,
return 0;
}
-static int distro_pxe_check(struct udevice *dev, struct bootflow_iter *iter)
+static int extlinux_pxe_check(struct udevice *dev, struct bootflow_iter *iter)
{
int ret;
@@ -54,7 +54,8 @@ static int distro_pxe_check(struct udevice *dev, struct bootflow_iter *iter)
return 0;
}
-static int distro_pxe_read_bootflow(struct udevice *dev, struct bootflow *bflow)
+static int extlinux_pxe_read_bootflow(struct udevice *dev,
+ struct bootflow *bflow)
{
const char *addr_str;
char fname[200];
@@ -90,7 +91,7 @@ static int distro_pxe_read_bootflow(struct udevice *dev, struct bootflow *bflow)
}
}
snprintf(fname, sizeof(fname), "%s%s",
- bflow->subdir ? bflow->subdir : "", DISTRO_FNAME);
+ bflow->subdir ? bflow->subdir : "", EXTLINUX_FNAME);
bflow->fname = strdup(fname);
if (!bflow->fname)
@@ -108,8 +109,9 @@ static int distro_pxe_read_bootflow(struct udevice *dev, struct bootflow *bflow)
return 0;
}
-static int distro_pxe_read_file(struct udevice *dev, struct bootflow *bflow,
- const char *file_path, ulong addr, ulong *sizep)
+static int extlinux_pxe_read_file(struct udevice *dev, struct bootflow *bflow,
+ const char *file_path, ulong addr,
+ ulong *sizep)
{
char *tftp_argv[] = {"tftp", NULL, NULL, NULL};
struct pxe_context *ctx = dev_get_priv(dev);
@@ -133,11 +135,11 @@ static int distro_pxe_read_file(struct udevice *dev, struct bootflow *bflow,
return 0;
}
-static int distro_pxe_boot(struct udevice *dev, struct bootflow *bflow)
+static int extlinux_pxe_boot(struct udevice *dev, struct bootflow *bflow)
{
struct pxe_context *ctx = dev_get_priv(dev);
struct cmd_tbl cmdtp = {}; /* dummy */
- struct distro_info info;
+ struct extlinux_info info;
ulong addr;
int ret;
@@ -145,7 +147,7 @@ static int distro_pxe_boot(struct udevice *dev, struct bootflow *bflow)
info.dev = dev;
info.bflow = bflow;
info.cmdtp = &cmdtp;
- ret = pxe_setup_ctx(ctx, &cmdtp, distro_pxe_getfile, &info, false,
+ ret = pxe_setup_ctx(ctx, &cmdtp, extlinux_pxe_getfile, &info, false,
bflow->subdir, false);
if (ret)
return log_msg_ret("ctx", -EINVAL);
@@ -157,7 +159,7 @@ static int distro_pxe_boot(struct udevice *dev, struct bootflow *bflow)
return 0;
}
-static int distro_bootmeth_pxe_bind(struct udevice *dev)
+static int extlinux_bootmeth_pxe_bind(struct udevice *dev)
{
struct bootmeth_uc_plat *plat = dev_get_uclass_plat(dev);
@@ -167,23 +169,23 @@ static int distro_bootmeth_pxe_bind(struct udevice *dev)
return 0;
}
-static struct bootmeth_ops distro_bootmeth_pxe_ops = {
- .check = distro_pxe_check,
- .read_bootflow = distro_pxe_read_bootflow,
- .read_file = distro_pxe_read_file,
- .boot = distro_pxe_boot,
+static struct bootmeth_ops extlinux_bootmeth_pxe_ops = {
+ .check = extlinux_pxe_check,
+ .read_bootflow = extlinux_pxe_read_bootflow,
+ .read_file = extlinux_pxe_read_file,
+ .boot = extlinux_pxe_boot,
};
-static const struct udevice_id distro_bootmeth_pxe_ids[] = {
- { .compatible = "u-boot,distro-pxe" },
+static const struct udevice_id extlinux_bootmeth_pxe_ids[] = {
+ { .compatible = "u-boot,extlinux-pxe" },
{ }
};
U_BOOT_DRIVER(bootmeth_pxe) = {
.name = "bootmeth_pxe",
.id = UCLASS_BOOTMETH,
- .of_match = distro_bootmeth_pxe_ids,
- .ops = &distro_bootmeth_pxe_ops,
- .bind = distro_bootmeth_pxe_bind,
+ .of_match = extlinux_bootmeth_pxe_ids,
+ .ops = &extlinux_bootmeth_pxe_ops,
+ .bind = extlinux_bootmeth_pxe_bind,
.priv_auto = sizeof(struct pxe_context),
};
diff --git a/boot/bootmeth_qfw.c b/boot/bootmeth_qfw.c
index a5f95d4d0c..ecd4b082fd 100644
--- a/boot/bootmeth_qfw.c
+++ b/boot/bootmeth_qfw.c
@@ -89,7 +89,7 @@ static struct bootmeth_ops qfw_bootmeth_ops = {
};
static const struct udevice_id qfw_bootmeth_ids[] = {
- { .compatible = "u-boot,qfw-syslinux" },
+ { .compatible = "u-boot,qfw-extlinux" },
{ }
};
diff --git a/boot/bootmeth_sandbox.c b/boot/bootmeth_sandbox.c
index 13ec5e95e6..aabc57e635 100644
--- a/boot/bootmeth_sandbox.c
+++ b/boot/bootmeth_sandbox.c
@@ -56,7 +56,7 @@ static struct bootmeth_ops sandbox_bootmeth_ops = {
};
static const struct udevice_id sandbox_bootmeth_ids[] = {
- { .compatible = "u-boot,sandbox-syslinux" },
+ { .compatible = "u-boot,sandbox-extlinux" },
{ }
};