[PATCH 07/10] board: samsung: e850-96: Add bootdev var to choose boot device
Sam Protsenko
semen.protsenko at linaro.org
Thu Aug 7 00:27:07 CEST 2025
Provide a way for the user to select which storage to load the LDFW
firmware from, by setting the corresponding environment variables:
- bootdev: block device interface name
- bootdevnum: block device number
- bootdevpart: partition number
This might be useful when the OS is flashed and booted from a different
storage device than eMMC (e.g. USB flash drive). In this case it should
be sufficient to just set:
=> setenv bootdev usb
=> env save
assuming that the USB drive layout follows the same partitioning scheme
as defined in $partitions.
Signed-off-by: Sam Protsenko <semen.protsenko at linaro.org>
---
board/samsung/e850-96/e850-96.c | 40 ++++++++++++++++++++++++---------
1 file changed, 30 insertions(+), 10 deletions(-)
diff --git a/board/samsung/e850-96/e850-96.c b/board/samsung/e850-96/e850-96.c
index b5f6ba23432e..3df241edde2a 100644
--- a/board/samsung/e850-96/e850-96.c
+++ b/board/samsung/e850-96/e850-96.c
@@ -9,6 +9,7 @@
#include <init.h>
#include <mapmem.h>
#include <net.h>
+#include <usb.h>
#include <asm/io.h>
#include "fw.h"
#include "pmic.h"
@@ -136,21 +137,40 @@ static void setup_ethaddr(void)
eth_env_set_enetaddr("ethaddr", mac_addr);
}
-int board_late_init(void)
+/*
+ * Call this in board_late_init() to avoid probing block devices before
+ * efi_init_early().
+ */
+void load_firmware(void)
{
+ const char *ifname;
+ ulong dev, part;
int err;
- setup_serial();
- setup_ethaddr();
-
- /*
- * Do this in board_late_init() to make sure MMC is not probed before
- * efi_init_early().
- */
- err = load_ldfw(EMMC_IFNAME, EMMC_DEV_NUM, EMMC_ESP_PART,
- LDFW_NWD_ADDR);
+ ifname = env_get("bootdev");
+ if (!ifname)
+ ifname = EMMC_IFNAME;
+ dev = env_get_ulong("bootdevnum", 10, EMMC_DEV_NUM);
+ part = env_get_ulong("bootdevpart", 10, EMMC_ESP_PART);
+
+ if (!strcmp(ifname, "usb")) {
+ printf("Starting USB (bootdev=usb)...\n");
+ err = usb_init();
+ if (err)
+ return;
+ }
+
+ printf("Loading LDFW firmware (from %s %ld)...\n", ifname, dev);
+ err = load_ldfw(ifname, dev, part, LDFW_NWD_ADDR);
if (err)
printf("ERROR: LDFW loading failed (%d)\n", err);
+}
+
+int board_late_init(void)
+{
+ setup_serial();
+ setup_ethaddr();
+ load_firmware();
return 0;
}
--
2.39.5
More information about the U-Boot
mailing list