Skip to contentSkip to conversation

board: samsung: e850-96: Enable Standard Boot

PATCH In review Sam Protsenko 3 participants 10 messages Jan 16, 2025 – Feb 7, 2025

lore
Share & tools
lore
#0 lore raw

cover board: samsung: e850-96: Enable Standard Boot

Make all necessary configuration and environment changes to enable Standard Boot on E850-96 board. Also rework LDFW firmware loading code to look for LDFW binary on EFI System Partition instead of dedicated 'ldfw' partition.

Pending "[RFC PATCH 1/1] efi_loader: Call efi_init_early() even earlier" patch is needed to make EFI functional on E850-96, but this series does not depend on it and can be applied independently.

[1] https://lists.denx.de/pipermail/u-boot/2025-January/577194.html

Sam Protsenko (7):
configs: e850-96: Enable options for updated env
configs: e850-96: Enable U-Boot environment on eMMC
configs: e850-96: Enable more EFI features
configs: e850-96: Enable Standard Boot
board: samsung: e850-96: Load LDFW from EFI partition
board: samsung: e850-96: Report LDFW loading failures
board: samsung: e850-96: Provide bootstd default env

 board/samsung/e850-96/e850-96.c   |  7 ++++-
 board/samsung/e850-96/e850-96.env | 37 ++++++++-----------------
 board/samsung/e850-96/fw.c        | 45 ++++++++++++++++++++++++++-----
 configs/e850-96_defconfig         | 23 +++++++++++++---
 4 files changed, 75 insertions(+), 37 deletions(-)
Signature · 1 line
2.39.5
#1 lore raw

PATCH 1/7 configs: e850-96: Enable options for updated env

The E850-96 default environment is going to be updated soon, requiring next config options to be enabled:

- CONFIG_DEFAULT_FDT_FILE: $fdtfile will use this value
- CONFIG_PARTITION_TYPE_GUID: $partitions will rely on "type" feature

---
 configs/e850-96_defconfig | 2 ++
 1 file changed, 2 insertions(+)
configs/e850-96_defconfig +2 -0
index c36196c510c5..b1b3510d691d 100644
@@ -13,6 +13,7 @@ CONFIG_SYS_LOAD_ADDR=0x80000000
 # CONFIG_PSCI_RESET is not set
 CONFIG_ANDROID_BOOT_IMAGE=y
 # CONFIG_AUTOBOOT is not set
+CONFIG_DEFAULT_FDT_FILE="exynos850-e850-96.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_HUSH_PARSER=y
 CONFIG_CMD_ABOOTIMG=y
@@ -22,6 +23,7 @@ CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_RNG=y
+CONFIG_PARTITION_TYPE_GUID=y
 CONFIG_NO_NET=y
 CONFIG_CLK_EXYNOS850=y
 CONFIG_MMC_DW=y
Signature · 1 line
2.39.5
#2 lore raw

PATCH 2/7 configs: e850-96: Enable U-Boot environment on eMMC

In reply to Sam Protsenko

Store U-Boot environment in BOOT2 HW area of eMMC (/dev/mmcblk0boot1), as it's currently unused. BOOT1 area will be probably used for storing low-level bootloaders further, so let's not touch it.

Both primary and redundant environments work fine:

=> env default -f -a
## Resetting to default environment
=> env save
Saving Environment to MMC... Writing to redundant MMC(0)... OK

---
 configs/e850-96_defconfig | 9 +++++++++
 1 file changed, 9 insertions(+)
configs/e850-96_defconfig +9 -0
index b1b3510d691d..d287018ec632 100644
@@ -8,8 +8,11 @@ CONFIG_SYS_MALLOC_F_LEN=0x4000
 CONFIG_ARCH_EXYNOS9=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xf8c00000
+CONFIG_ENV_SIZE=0x10000
+CONFIG_ENV_OFFSET=0x0
 CONFIG_DEFAULT_DEVICE_TREE="exynos/exynos850-e850-96"
 CONFIG_SYS_LOAD_ADDR=0x80000000
+CONFIG_ENV_OFFSET_REDUND=0x10000
 # CONFIG_PSCI_RESET is not set
 CONFIG_ANDROID_BOOT_IMAGE=y
 # CONFIG_AUTOBOOT is not set
@@ -24,8 +27,14 @@ CONFIG_CMD_PART=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_RNG=y
 CONFIG_PARTITION_TYPE_GUID=y
+CONFIG_ENV_OVERWRITE=y
+CONFIG_ENV_IS_IN_MMC=y
+CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
+CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_PART=2
 CONFIG_NO_NET=y
 CONFIG_CLK_EXYNOS850=y
+CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_DW=y
 CONFIG_SOC_SAMSUNG=y
 CONFIG_EXYNOS_PMU=y
Signature · 1 line
2.39.5
#3 lore raw

PATCH 3/7 configs: e850-96: Enable more EFI features

In reply to Sam Protsenko

The basic EFI support is already enabled by EFI_LOADER. Follow SystemReady IR recommendations [1,2] for U-Boot and enable support for more EFI features. That includes:

- CONFIG_CMD_BOOTEFI_SELFTEST: support for "bootefi selftest" command
- CONFIG_CMD_NVEDIT_EFI: support for "env -e" to explore EFI vars
- CONFIG_CMD_EFIDEBUG: support for "efidebug" command

Also enable RTC support:

- CONFIG_EFI_SET_TIME
- CONFIG_CMD_RTC
- CONFIG_DM_RTC
- CONFIG_RTC_EMULATION

[1] https://developer.arm.com/documentation/DUI1101/1-1/Configure-U-Boot-for-SystemReady
[2] https://developer.arm.com/documentation/DUI1101/1-1/Test-SystemReady-IR

---
 configs/e850-96_defconfig | 8 ++++++++
 1 file changed, 8 insertions(+)
configs/e850-96_defconfig +8 -0
index d287018ec632..1cae252175be 100644
@@ -14,16 +14,22 @@ CONFIG_DEFAULT_DEVICE_TREE="exynos/exynos850-e850-96"
 CONFIG_SYS_LOAD_ADDR=0x80000000
 CONFIG_ENV_OFFSET_REDUND=0x10000
 # CONFIG_PSCI_RESET is not set
+CONFIG_EFI_SET_TIME=y
 CONFIG_ANDROID_BOOT_IMAGE=y
 # CONFIG_AUTOBOOT is not set
 CONFIG_DEFAULT_FDT_FILE="exynos850-e850-96.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_HUSH_PARSER=y
+CONFIG_CMD_BOOTEFI_SELFTEST=y
 CONFIG_CMD_ABOOTIMG=y
+CONFIG_CMD_NVEDIT_EFI=y
 CONFIG_CMD_CLK=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_EFIDEBUG=y
+# CONFIG_CMD_DATE is not set
+CONFIG_CMD_RTC=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_RNG=y
 CONFIG_PARTITION_TYPE_GUID=y
@@ -36,6 +42,8 @@ CONFIG_NO_NET=y
 CONFIG_CLK_EXYNOS850=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_DW=y
+CONFIG_DM_RTC=y
+CONFIG_RTC_EMULATION=y
 CONFIG_SOC_SAMSUNG=y
 CONFIG_EXYNOS_PMU=y
 CONFIG_EXYNOS_USI=y
Signature · 1 line
2.39.5
Reviewed-by on v1 3/7
#4 lore raw

Re: [PATCH 3/7] configs: e850-96: Enable more EFI features

Hi Sam

Quoted 6 lines · Sam Protsenko

The basic EFI support is already enabled by EFI_LOADER. Follow SystemReady IR recommendations [1,2] for U-Boot and enable support for more EFI features. That includes:

- CONFIG_CMD_BOOTEFI_SELFTEST: support for "bootefi selftest" command

I know that's on the Arm docs but not really a hard requirement. The tests will pass without it.

Quoted 55 lines

- CONFIG_CMD_NVEDIT_EFI: support for "env -e" to explore EFI vars
- CONFIG_CMD_EFIDEBUG: support for "efidebug" command

Also enable RTC support:

- CONFIG_EFI_SET_TIME
- CONFIG_CMD_RTC
- CONFIG_DM_RTC
- CONFIG_RTC_EMULATION

[1] https://developer.arm.com/documentation/DUI1101/1-1/Configure-U-Boot-for-SystemReady
[2] https://developer.arm.com/documentation/DUI1101/1-1/Test-SystemReady-IR

---
 configs/e850-96_defconfig | 8 ++++++++
 1 file changed, 8 insertions(+)
configs/e850-96_defconfig +8 -1
index d287018ec632..1cae252175be 100644
@@ -14,16 +14,22 @@ CONFIG_DEFAULT_DEVICE_TREE="exynos/exynos850-e850-96"
 CONFIG_SYS_LOAD_ADDR=0x80000000
 CONFIG_ENV_OFFSET_REDUND=0x10000
 # CONFIG_PSCI_RESET is not set
+CONFIG_EFI_SET_TIME=y
 CONFIG_ANDROID_BOOT_IMAGE=y
 # CONFIG_AUTOBOOT is not set
 CONFIG_DEFAULT_FDT_FILE="exynos850-e850-96.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_HUSH_PARSER=y
+CONFIG_CMD_BOOTEFI_SELFTEST=y
 CONFIG_CMD_ABOOTIMG=y
+CONFIG_CMD_NVEDIT_EFI=y
 CONFIG_CMD_CLK=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PART=y
+CONFIG_CMD_EFIDEBUG=y
+# CONFIG_CMD_DATE is not set
+CONFIG_CMD_RTC=y
 CONFIG_CMD_TIME=y
 CONFIG_CMD_RNG=y
 CONFIG_PARTITION_TYPE_GUID=y
@@ -36,6 +42,8 @@ CONFIG_NO_NET=y
 CONFIG_CLK_EXYNOS850=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_MMC_DW=y
+CONFIG_DM_RTC=y
+CONFIG_RTC_EMULATION=y
 CONFIG_SOC_SAMSUNG=y
 CONFIG_EXYNOS_PMU=y
 CONFIG_EXYNOS_USI=y
--
Quoted 2 lines

2.39.5

Up to you, but I'd remove CONFIG_CMD_BOOTEFI_SELFTEST in any case

#5 lore raw

PATCH 4/7 configs: e850-96: Enable Standard Boot

In reply to Sam Protsenko

Enable Standard Boot on E850-96 as documented in [1]. Along with corresponding changes in the default environment and properly prepared eMMC partitions (ESP and rootfs), it makes it possible to boot Debian rootfs automatically. All boot methods were tested: efi_mgr, efi, syslinux and script. The preferred boot method is efi_mgr, which relies on the configured EFI variables (stored in /ubootefi.var file on ESP partition), which boots either GRUB from /EFI/debian/grubaa64.efi, or systemd-boot from /EFI/BOOT/BOOTAA64.EFI. Currently used boot sequence:

U-Boot -> bootcmd -> 'bootflow scan -lb' -> efi_mgr -> GRUB -> Debian

[1] doc/develop/bootstd/overview.rst

---
 configs/e850-96_defconfig | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
configs/e850-96_defconfig +1 -3
index 1cae252175be..5facd418260c 100644
@@ -16,17 +16,15 @@ CONFIG_ENV_OFFSET_REDUND=0x10000
 # CONFIG_PSCI_RESET is not set
 CONFIG_EFI_SET_TIME=y
 CONFIG_ANDROID_BOOT_IMAGE=y
-# CONFIG_AUTOBOOT is not set
+CONFIG_BOOTSTD_FULL=y
 CONFIG_DEFAULT_FDT_FILE="exynos850-e850-96.dtb"
 # CONFIG_DISPLAY_CPUINFO is not set
-CONFIG_HUSH_PARSER=y
 CONFIG_CMD_BOOTEFI_SELFTEST=y
 CONFIG_CMD_ABOOTIMG=y
 CONFIG_CMD_NVEDIT_EFI=y
 CONFIG_CMD_CLK=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
-CONFIG_CMD_PART=y
 CONFIG_CMD_EFIDEBUG=y
 # CONFIG_CMD_DATE is not set
 CONFIG_CMD_RTC=y
Signature · 1 line
2.39.5
#6 lore raw

PATCH 5/7 board: samsung: e850-96: Load LDFW from EFI partition

In reply to Sam Protsenko

In case when EFI System Partition is present it can be used to store firmware binaries, instead of keeping those on separate dedicated partitions. That simplifies the partition table and makes it more standard. Rework the firmware loader code to look for LDFW binary at /EFI/firmware/ldfw.bin on ESP first, and if either the partition or the file doesn't exist -- fallback to reading it from 'ldfw' partition. This way backward compatibility can be kept, and Android partition tables without ESP partition can be handled too.

---
 board/samsung/e850-96/fw.c | 45 ++++++++++++++++++++++++++++++++------
 1 file changed, 38 insertions(+), 7 deletions(-)
board/samsung/e850-96/fw.c +38 -7
index 82a0b224c670..8f64e759b431 100644
@@ -7,14 +7,16 @@
  */
 
 #include <part.h>
+#include <fs.h>
 #include <linux/arm-smccc.h>
 #include "fw.h"
 
 #define EMMC_IFACE		"mmc"
 #define EMMC_DEV_NUM		0
+#define LDFW_RAW_PART		"ldfw"
+#define LDFW_FAT_PART		"esp"
+#define LDFW_FAT_PATH		"/EFI/firmware/ldfw.bin"
 
-/* LDFW constants */
-#define LDFW_PART_NAME		"ldfw"
 #define LDFW_NWD_ADDR		0x88000000
 #define LDFW_MAGIC		0x10adab1e
 #define SMC_CMD_LOAD_LDFW	-0x500
@@ -36,7 +38,33 @@ struct ldfw_header {
 	char fw_name[16];
 };
 
-static int read_fw(const char *part_name, void *buf)
+/* Load LDFW binary as a file from FAT partition */
+static int read_fw_from_fat(const char *part_name, const char *path, void *buf)
+{
+	char dev_part_str[8];
+	loff_t len_read;
+	int err;
+
+	snprintf(dev_part_str, sizeof(dev_part_str), "%d#%s", EMMC_DEV_NUM,
+		 LDFW_FAT_PART);
+
+	err = fs_set_blk_dev(EMMC_IFACE, dev_part_str, FS_TYPE_FAT);
+	if (err) {
+		debug("%s: Can't set block device\n", __func__);
+		return -ENODEV;
+	}
+
+	err = fs_read(path, (ulong)buf, 0, 0, &len_read);
+	if (err) {
+		debug("%s: Can't read LDFW file\n", __func__);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+/* Load LDFW binary from raw partition on block device into RAM buffer */
+static int read_fw_from_raw(const char *part_name, void *buf)
 {
 	struct blk_desc *blk_desc;
 	struct disk_partition part;
@@ -73,10 +101,13 @@ int load_ldfw(void)
 	u64 size = 0;
 	int err, i;
 
-	/* Load LDFW from the block device partition into RAM buffer */
-	err = read_fw(LDFW_PART_NAME, buf);
-	if (err)
-		return err;
+	/* First try to read LDFW from EFI partition, then from the raw one */
+	err = read_fw_from_fat(LDFW_FAT_PART, LDFW_FAT_PATH, buf);
+	if (err) {
+		err = read_fw_from_raw(LDFW_RAW_PART, buf);
+		if (err)
+			return err;
+	}
 
 	/* Validate LDFW by magic number in its header */
 	hdr = buf;
Signature · 1 line
2.39.5
#7 lore raw

PATCH 6/7 board: samsung: e850-96: Report LDFW loading failures

In reply to Sam Protsenko

LDFW firmware loading can fail, e.g. in case if user forgot to upload the binary to the appropriate location (/EFI/firmware/ldfw.bin on ESP partition). Report such errors explicitly, so that the user can notice it early and take necessary actions. But don't return error code from board_init() in this case, as LDFW firmware is not mandatory for board operation and is only required for some features like TRNG.

---
 board/samsung/e850-96/e850-96.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
board/samsung/e850-96/e850-96.c +6 -1
index c5cef6f19d22..0bef68d2fb20 100644
@@ -19,6 +19,11 @@ int dram_init_banksize(void)
 
 int board_init(void)
 {
-	load_ldfw();
+	int err;
+
+	err = load_ldfw();
+	if (err)
+		printf("ERROR: LDFW loading failed (%d)\n", err);
+
 	return 0;
 }
Signature · 1 line
2.39.5
#8 lore raw

PATCH 7/7 board: samsung: e850-96: Provide bootstd default env

In reply to Sam Protsenko

Add default environment variables needed for Standard Boot enablement as described in [1]. Also rework the eMMC partition table for Linux boot so it only has two partitions:

1. EFI System Partition (EFI vars, GRUB efi app, firmware files)
2. rootfs partition (Debian rootfs, /boot, extlinux.conf, boot.scr)

Both partitions are made bootable so that 'bootflow' command can detect all loader files (rootfs might contain extlinux.conf and boot.scr).

'ldfw' partition is removed too, as ldfw.bin can be loaded from ESP now (from /EFI/firmware/ldfw.bin).

Android partitons will be added later, once Android boot is actually enabled for E850-96.

Notes:
- $kernel_comp_addr_r uses the same address (0x88000000) as LDFW buffer (in board/samsung/e850-96/fw.c), but that's fine, as LDFW will be copied to another RAM location (Secure World) by SMC command, so it's only used temporarily on startup
- addition assignment (+=) operation is used for $partitions to avoid spaces added by newlines, so that $partitions can be used in the shell with no quotes

Now it's possible to successfully automatically boot Debian rootfs:

=> env default -f -a
=> env save
=> gpt write mmc 0 $partitions
=> reset

[1] doc/develop/bootstd/overview.rst

---
 board/samsung/e850-96/e850-96.env | 37 +++++++++----------------------
 1 file changed, 11 insertions(+), 26 deletions(-)
board/samsung/e850-96/e850-96.env +11 -26
index f36f90be9509..5ac76bcef027 100644
@@ -1,26 +1,11 @@
-partitions=
-	uuid_disk=${uuid_gpt_disk};
-	name=efs,start=512K,size=20M,uuid=${uuid_gpt_efs};
-	name=env,size=16K,uuid=${uuid_gpt_env};
-	name=kernel,size=30M,uuid=${uuid_gpt_kernel};
-	name=ramdisk,size=26M,uuid=${uuid_gpt_ramdisk};
-	name=dtbo,size=1M,uuid=${uuid_gpt_dtbo};
-	name=ldfw,size=4016K,uuid=${uuid_gpt_ldfw};
-	name=keystorage,size=8K,uuid=${uuid_gpt_keystorage};
-	name=tzsw,size=1M,uuid=${uuid_gpt_tzsw};
-	name=harx,size=2M,uuid=${uuid_gpt_harx};
-	name=harx_rkp,size=2M,uuid=${uuid_gpt_harx_rkp};
-	name=logo,size=40M,uuid=${uuid_gpt_logo};
-	name=super,size=3600M,uuid=${uuid_gpt_super};
-	name=cache,size=300M,uuid=${uuid_gpt_cache};
-	name=modem,size=100M,uuid=${uuid_gpt_modem};
-	name=boot,size=100M,uuid=${uuid_gpt_boot};
-	name=persist,size=30M,uuid=${uuid_gpt_persist};
-	name=recovery,size=40M,uuid=${uuid_gpt_recovery};
-	name=misc,size=40M,uuid=${uuid_gpt_misc};
-	name=mnv,size=20M,uuid=${uuid_gpt_mnv};
-	name=frp,size=512K,uuid=${uuid_gpt_frp};
-	name=vbmeta,size=64K,uuid=${uuid_gpt_vbmeta};
-	name=metadata,size=16M,uuid=${uuid_gpt_metadata};
-	name=dtb,size=1M,uuid=${uuid_gpt_dtb};
-	name=userdata,size=-,uuid=${uuid_gpt_userdata}
+kernel_addr_r=0x80000000
+kernel_comp_addr_r=0x88000000
+kernel_comp_size=0x4000000
+fdt_addr_r=0x8c000000
+scriptaddr=0x8c100000
+pxefile_addr_r=0x8c200000
+ramdisk_addr_r=0x8c300000
+fdtfile=CONFIG_DEFAULT_FDT_FILE
+
+partitions=name=esp,start=512K,size=128M,bootable,type=system;
+partitions+=name=rootfs,size=-,bootable,type=linux
Signature · 1 line
2.39.5
#9 lore raw
In reply to Sam Protsenko

Hi,

Quoted 20 lines · Sam Protsenko

Make all necessary configuration and environment changes to enable Standard Boot on E850-96 board. Also rework LDFW firmware loading code to look for LDFW binary on EFI System Partition instead of dedicated 'ldfw' partition.

Pending "[RFC PATCH 1/1] efi_loader: Call efi_init_early() even earlier" patch is needed to make EFI functional on E850-96, but this series does not depend on it and can be applied independently.

[1] https://lists.denx.de/pipermail/u-boot/2025-January/577194.html

Sam Protsenko (7):
configs: e850-96: Enable options for updated env
configs: e850-96: Enable U-Boot environment on eMMC
configs: e850-96: Enable more EFI features
configs: e850-96: Enable Standard Boot
board: samsung: e850-96: Load LDFW from EFI partition
board: samsung: e850-96: Report LDFW loading failures
board: samsung: e850-96: Provide bootstd default env

Quoted 10 lines
 board/samsung/e850-96/e850-96.c   |  7 ++++-
 board/samsung/e850-96/e850-96.env | 37 ++++++++-----------------
 board/samsung/e850-96/fw.c        | 45 ++++++++++++++++++++++++++-----
 configs/e850-96_defconfig         | 23 +++++++++++++---
 4 files changed, 75 insertions(+), 37 deletions(-)

--
2.39.5

applied to u-boot-samsung.

Signature · 2 lines
Thanks,
Minkyu Kang.