Skip to contentSkip to conversation

Bug-fixes for a few boards

PATCH Superseded Simon Glass 3 participants 23 messages Jun 26, 2024 – Jun 27, 2024

Subsystems (2)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover Bug-fixes for a few boards

This series includes fixes to get some rockchip and nvidia boards working again. It also drops the broken Beaglebone Black config and provides a devicetree fix for coral (x86).

Note that since this series fixes bugs, it is targeted at -master

Changes in v5:
- Move setting of pmugrf into the probe() function

Changes in v4:
- Drop Fixes tag
- Add new patch to set a board-size limit for chromebook_link
- Fix 'stating' typo
- Move Binman size feature to a separate series

Changes in v3:
- Use BLOBLIST instead of OF_BLOBLIST
- Cut the patch down to bare bones
- Split out the refactoring into a separate patch

Changes in v2:
- Put the conditions under EFI_TCG2_PROTOCOL
- Consider MEASURED_BOOT too
- Remove the superfluous if() and drop the debug() as well
- Use 'phase' instead of 'stage'
- Add new patch to correct memory size in SPL
- Drop patch "regulator: rk8xx: Fix incorrect parameter"
- Rewrite boneblack patch to onstead drop the target and update docs

Simon Glass (16):
mkeficapsule: Add a --version argument
binman: Collect the version number for mkeficapsule
binman: Deal with mkeficapsule being missing
binman: Return failure when a usage() message is generated
binman: Keep the efi_capsule input file
nvidia: nyan-big: Disable debug UART
tpm: Avoid code bloat when not using EFI_TCG2_PROTOCOL
x86: Set a board-size limit for chromebook_link
rockchip: veyron: Add logging for power init
power: regulator: Handle autoset in regulators_enable_boot_on()
fdt: Correct condition for bloblist existing
spl: Allow ATF to work when dcache is disabled
rockchip: Ensure memory size is available in RK3399 SPL
rockchip: Avoid #ifdefs in RK3399 SPL
rockchip: bob: kevin: Disable dcache in SPL
Drop the special am335x_boneblack_vboot target

 board/google/veyron/veyron.c               | 30 +++----
 board/ti/am335x/MAINTAINERS                |  1 -
 boot/Kconfig                               |  4 +
 common/spl/spl_atf.c                       |  3 +-
 configs/am335x_boneblack_vboot_defconfig   | 94 ----------------------
 configs/am335x_evm_defconfig               |  3 +-
 configs/chromebook_bob_defconfig           |  1 +
 configs/chromebook_kevin_defconfig         |  1 +
 configs/chromebook_link_defconfig          |  2 +
 configs/nyan-big_defconfig                 |  1 -
 doc/mkeficapsule.1                         |  4 +
 doc/usage/fit/beaglebone_vboot.rst         | 21 +++--
 drivers/power/regulator/regulator-uclass.c |  2 +-
 drivers/ram/rockchip/sdram_rk3399.c        | 35 ++++----
 lib/Kconfig                                |  4 -
 lib/fdtdec.c                               | 12 ++-
 tools/binman/btool/mkeficapsule.py         |  3 +-
 tools/binman/etype/efi_capsule.py          |  5 +-
 tools/mkeficapsule.c                       | 10 ++-
 19 files changed, 80 insertions(+), 156 deletions(-)
 delete mode 100644 configs/am335x_boneblack_vboot_defconfig
Signature · 1 line
2.34.1
#1 lore raw

PATCH v5 1/16 mkeficapsule: Add a --version argument

Tools should have an option to obtain the version, so add this to the mkeficapsule tool.

---

(no changes since v1)

 doc/mkeficapsule.1   | 4 ++++
 tools/mkeficapsule.c | 8 +++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
doc/mkeficapsule.1 +4 -0
index c4c2057d5c7..c3d0f21488a 100644
@@ -87,6 +87,10 @@ Generate a firmware revert empty capsule
 .BI "-o\fR,\fB --capoemflag "
 Capsule OEM flag, value between 0x0000 to 0xffff
 
+.TP
+.BR -V ", " --version
+Print version information and exit.
+
 .TP
 .BR -h ", " --help
 Print a help message
tools/mkeficapsule.c +7 -1
index 6a261ff549d..c112ae2de8d 100644
@@ -21,6 +21,8 @@
 #include <gnutls/pkcs7.h>
 #include <gnutls/abstract.h>
 
+#include <version.h>
+
 #include "eficapsule.h"
 
 static const char *tool_name = "mkeficapsule";
@@ -28,7 +30,7 @@ static const char *tool_name = "mkeficapsule";
 efi_guid_t efi_guid_fm_capsule = EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID;
 efi_guid_t efi_guid_cert_type_pkcs7 = EFI_CERT_TYPE_PKCS7_GUID;
 
-static const char *opts_short = "g:i:I:v:p:c:m:o:dhARD";
+static const char *opts_short = "g:i:I:v:p:c:m:o:dhARDV";
 
 enum {
 	CAPSULE_NORMAL_BLOB = 0,
@@ -70,6 +72,7 @@ static void print_usage(void)
 		"\t-R, --fw-revert  firmware revert capsule, takes no GUID, no image blob\n"
 		"\t-o, --capoemflag Capsule OEM Flag, an integer between 0x0000 and 0xffff\n"
 		"\t-D, --dump-capsule          dump the contents of the capsule headers\n"
+		"\t-V, --version               show version number\n"
 		"\t-h, --help                  print a help message\n",
 		tool_name);
 }
@@ -969,6 +972,9 @@ int main(int argc, char **argv)
 		case 'D':
 			capsule_dump = true;
 			break;
+		case 'V':
+			printf("mkeficapsule version %s\n", PLAIN_VERSION);
+			exit(EXIT_SUCCESS);
 		default:
 			print_usage();
 			exit(EXIT_SUCCESS);
Signature · 1 line
2.34.1
#2 lore raw

PATCH v5 2/16 binman: Collect the version number for mkeficapsule

In reply to Simon Glass

Now that this tool has a version number, collect it.

---

(no changes since v1)

 tools/binman/btool/mkeficapsule.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/binman/btool/mkeficapsule.py +2 -1
index ef1da638df1..f7e5a886849 100644
@@ -33,7 +33,8 @@ class Bintoolmkeficapsule(bintool.Bintool):
     commandline, or through a config file.
     """
     def __init__(self, name):
-        super().__init__(name, 'mkeficapsule tool for generating capsules')
+        super().__init__(name, 'mkeficapsule tool for generating capsules',
+                         r'mkeficapsule version (.*)')
 
     def generate_capsule(self, image_index, image_guid, hardware_instance,
                          payload, output_fname, priv_key, pub_key,
Signature · 1 line
2.34.1
#3 lore raw

PATCH v5 3/16 binman: Deal with mkeficapsule being missing

In reply to Simon Glass

Tools cannot be assumed to be present. Add a check for this with the mkeficpasule tool.

Fixes b617611b27a ("binman: capsule: Add support for generating...")

---

(no changes since v1)

 tools/binman/etype/efi_capsule.py | 4 ++++
 1 file changed, 4 insertions(+)
tools/binman/etype/efi_capsule.py +4 -0
index e3203717822..47da5da324b 100644
@@ -150,6 +150,10 @@ class Entry_efi_capsule(Entry_section):
         if ret is not None:
             os.remove(payload)
             return tools.read_file(capsule_fname)
+        else:
+            # Bintool is missing; just use the input data as the output
+            self.record_missing_bintool(self.mkeficapsule)
+            return data
 
     def AddBintools(self, btools):
         self.mkeficapsule = self.AddBintool(btools, 'mkeficapsule')
Signature · 1 line
2.34.1
#4 lore raw

PATCH v5 4/16 binman: Return failure when a usage() message is generated

In reply to Simon Glass

The tool must return an error code when invalid arguments are provided, otherwise binman has no way of knowing that anything went wrong.

Correct this.

Fixes fab430be2f4 ("tools: add mkeficapsule command for UEFI...")

---

(no changes since v1)

 tools/mkeficapsule.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/mkeficapsule.c +1 -1
index c112ae2de8d..f28008a0829 100644
@@ -977,7 +977,7 @@ int main(int argc, char **argv)
 			exit(EXIT_SUCCESS);
 		default:
 			print_usage();
-			exit(EXIT_SUCCESS);
+			exit(EXIT_FAILURE);
 		}
 	}
 
Signature · 1 line
2.34.1
#5 lore raw

PATCH v5 5/16 binman: Keep the efi_capsule input file

In reply to Simon Glass

There is no need to remove input files. It makes it harder to diagnose failures. Keep the payload file.

There is no test for this condition, but one could be added.

---

(no changes since v4)

Changes in v4:
- Drop Fixes tag

 tools/binman/etype/efi_capsule.py | 1 -
 1 file changed, 1 deletion(-)
tools/binman/etype/efi_capsule.py +0 -1
index 47da5da324b..03e55cbc4d9 100644
@@ -148,7 +148,6 @@ class Entry_efi_capsule(Entry_section):
                                                  self.fw_version,
                                                  self.oem_flags)
         if ret is not None:
-            os.remove(payload)
             return tools.read_file(capsule_fname)
         else:
             # Bintool is missing; just use the input data as the output
Signature · 1 line
2.34.1
#6 lore raw

PATCH v5 6/16 nvidia: nyan-big: Disable debug UART

In reply to Simon Glass

This cannot be enabled early in boot since some other init is needed. At this point it is unclear exactly what init is needed, so disable the debug UART to avoid a hang.

---

(no changes since v1)

 configs/nyan-big_defconfig | 1 -
 1 file changed, 1 deletion(-)
configs/nyan-big_defconfig +0 -1
index 1483d17d975..4dec710cf8d 100644
@@ -17,7 +17,6 @@ CONFIG_TEGRA124=y
 CONFIG_TARGET_NYAN_BIG=y
 CONFIG_TEGRA_GPU=y
 CONFIG_SYS_LOAD_ADDR=0x82408000
-CONFIG_DEBUG_UART=y
 CONFIG_FIT=y
 CONFIG_FIT_BEST_MATCH=y
 CONFIG_BOOTSTAGE=y
Signature · 1 line
2.34.1
#7 lore raw

PATCH v5 7/16 tpm: Avoid code bloat when not using EFI_TCG2_PROTOCOL

In reply to Simon Glass

It does not make sense to enable all SHA algorithms unless they are needed. It bloats the code and in this case, causes chromebook_link to fail to build. That board does use the TPM, but not with measured boot, nor EFI.

Since EFI_TCG2_PROTOCOL already selects these options, we just need to add them to MEASURED_BOOT as well.

Note that the original commit combines refactoring and new features, which makes it hard to see what is going on.

Fixes 97707f12fda tpm: Support boot measurements

---

(no changes since v2)

Changes in v2:
- Put the conditions under EFI_TCG2_PROTOCOL
- Consider MEASURED_BOOT too

 boot/Kconfig | 4 ++++
 lib/Kconfig  | 4 ----
 2 files changed, 4 insertions(+), 4 deletions(-)
boot/Kconfig +4 -0
index 36bdc83b957..4c9d2c0f79a 100644
@@ -734,6 +734,10 @@ config LEGACY_IMAGE_FORMAT
 config MEASURED_BOOT
 	bool "Measure boot images and configuration when booting without EFI"
 	depends on HASH && TPM_V2
+	select SHA1
+	select SHA256
+	select SHA384
+	select SHA512
 	help
 	  This option enables measurement of the boot process when booting
 	  without UEFI . Measurement involves creating cryptographic hashes
lib/Kconfig +0 -4
index 189e6eb31aa..568892fce44 100644
@@ -438,10 +438,6 @@ config TPM
 	bool "Trusted Platform Module (TPM) Support"
 	depends on DM
 	imply DM_RNG
-	select SHA1
-	select SHA256
-	select SHA384
-	select SHA512
 	help
 	  This enables support for TPMs which can be used to provide security
 	  features for your board. The TPM can be connected via LPC or I2C
Signature · 1 line
2.34.1
#8 lore raw

PATCH v5 8/16 x86: Set a board-size limit for chromebook_link

In reply to Simon Glass

Set a size limit for this board so that we get a build error if it grows too much.

Note that the limit is approximately, since it does not include the FDT, microcode and fdtmap, which can change in size. However this board is fairly stable, so overflowing this limit will likely result in the image not fitting in the ROM space available for U-Boot.

---

(no changes since v4)

Changes in v4:
- Add new patch to set a board-size limit for chromebook_link

 configs/chromebook_link_defconfig | 2 ++
 1 file changed, 2 insertions(+)
configs/chromebook_link_defconfig +2 -0
index a9f91dd9b26..1a72fd178a8 100644
@@ -15,6 +15,8 @@ CONFIG_DEBUG_UART=y
 CONFIG_HAVE_MRC=y
 CONFIG_SMP=y
 CONFIG_HAVE_VGA_BIOS=y
+CONFIG_HAS_BOARD_SIZE_LIMIT=y
+CONFIG_BOARD_SIZE_LIMIT=630000
 CONFIG_FIT=y
 CONFIG_BOOTSTAGE=y
 CONFIG_BOOTSTAGE_REPORT=y
Signature · 1 line
2.34.1
#9 lore raw

PATCH v5 9/16 rockchip: veyron: Add logging for power init

In reply to Simon Glass

Add better logging for power init so that CONFIG_LOG_ERROR_RETURN can be enabled.

---

(no changes since v2)

Changes in v2:
- Remove the superfluous if() and drop the debug() as well

 board/google/veyron/veyron.c | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)
board/google/veyron/veyron.c +12 -18
index 32dbcdc4d10..6d4c9debdee 100644
@@ -29,44 +29,38 @@ static int veyron_init(void)
 	int ret;
 
 	ret = regulator_get_by_platname("vdd_arm", &dev);
-	if (ret) {
-		debug("Cannot set regulator name\n");
-		return ret;
-	}
+	if (ret)
+		return log_msg_ret("vdd", ret);
 
 	/* Slowly raise to max CPU voltage to prevent overshoot */
 	ret = regulator_set_value(dev, 1200000);
 	if (ret)
-		return ret;
+		return log_msg_ret("s12", ret);
 	udelay(175); /* Must wait for voltage to stabilize, 2mV/us */
 	ret = regulator_set_value(dev, 1400000);
 	if (ret)
-		return ret;
+		return log_msg_ret("s14", ret);
 	udelay(100); /* Must wait for voltage to stabilize, 2mV/us */
 
 	ret = rockchip_get_clk(&clk.dev);
 	if (ret)
-		return ret;
+		return log_msg_ret("clk", ret);
 	clk.id = PLL_APLL;
 	ret = clk_set_rate(&clk, 1800000000);
 	if (IS_ERR_VALUE(ret))
-		return ret;
+		return log_msg_ret("s18", ret);
 
 	ret = regulator_get_by_platname("vcc33_sd", &dev);
-	if (ret) {
-		debug("Cannot get regulator name\n");
-		return ret;
-	}
+	if (ret)
+		return log_msg_ret("vcc", ret);
 
 	ret = regulator_set_value(dev, 3300000);
 	if (ret)
-		return ret;
+		return log_msg_ret("s33", ret);
 
 	ret = regulators_enable_boot_on(false);
-	if (ret) {
-		debug("%s: Cannot enable boot on regulators\n", __func__);
-		return ret;
-	}
+	if (ret)
+		return log_msg_ret("boo", ret);
 
 	return 0;
 }
@@ -81,7 +75,7 @@ int board_early_init_r(void)
 	if (!fdt_node_check_compatible(gd->fdt_blob, 0, "google,veyron")) {
 		ret = veyron_init();
 		if (ret)
-			return ret;
+			return log_msg_ret("vey", ret);
 	}
 #endif
 	/*
Signature · 1 line
2.34.1
#10 lore raw

PATCH v5 10/16 power: regulator: Handle autoset in regulators_enable_boot_on()

In reply to Simon Glass

With a recent change, regulators_enable_boot_on() returns an error if a regulator is already set. Check for and handle this situation.

Fixes d99fb64a98a power: regulator: Only run autoset once for each regulator

---

(no changes since v1)

 drivers/power/regulator/regulator-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/regulator/regulator-uclass.c +1 -1
index 77d101f262e..d9e1fb68295 100644
@@ -518,7 +518,7 @@ int regulators_enable_boot_on(bool verbose)
 	     dev;
 	     uclass_next_device(&dev)) {
 		ret = regulator_autoset(dev);
-		if (ret == -EMEDIUMTYPE) {
+		if (ret == -EMEDIUMTYPE || ret == -EALREADY) {
 			ret = 0;
 			continue;
 		}
Signature · 1 line
2.34.1
#11 lore raw

PATCH v5 11/16 fdt: Correct condition for bloblist existing

In reply to Simon Glass

On some boards, the bloblist is created in SPL once SDRAM is ready. It cannot be accessed until that point, so is not available early in SPL.

Add a condition to avoid a hang in this case.

This fixes a hang in chromebook_coral

Fixes 70fe2385943 ("fdt: Allow the devicetree to come from a bloblist")

---

(no changes since v3)

Changes in v3:
- Use BLOBLIST instead of OF_BLOBLIST

Changes in v2:
- Use 'phase' instead of 'stage'

 lib/fdtdec.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
lib/fdtdec.c +10 -2
index b2c59ab3818..e16d1819449 100644
@@ -1669,8 +1669,16 @@ int fdtdec_setup(void)
 {
 	int ret = -ENOENT;
 
-	/* If allowing a bloblist, check that first */
-	if (CONFIG_IS_ENABLED(BLOBLIST)) {
+	/*
+	 * If allowing a bloblist, check that first. This would be better
+	 * handled with an OF_BLOBLIST Kconfig, but that caused far too much
+	 * argument, so add a hack here, used e.g. by chromebook_coral
+	 * The necessary test is whether the previous phase passed a bloblist,
+	 * not whether this phase creates one.
+	 */
+	if (CONFIG_IS_ENABLED(BLOBLIST) &&
+	    (spl_prev_phase() != PHASE_TPL ||
+	     !IS_ENABLED(CONFIG_TPL_BLOBLIST))) {
 		ret = bloblist_maybe_init();
 		if (!ret) {
 			gd->fdt_blob = bloblist_find(BLOBLISTT_CONTROL_FDT, 0);
Signature · 1 line
2.34.1
#12 lore raw

PATCH v5 12/16 spl: Allow ATF to work when dcache is disabled

In reply to Simon Glass

The dcache may not be enabled in SPL. Add a check to avoid trying to use an undefined function.

---

(no changes since v1)

 common/spl/spl_atf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
common/spl/spl_atf.c +2 -1
index 3bdd013a35f..9afe6456bc4 100644
@@ -204,7 +204,8 @@ static void __noreturn bl31_entry(uintptr_t bl31_entry, uintptr_t bl32_entry,
 						       fdt_addr);
 
 	raw_write_daif(SPSR_EXCEPTION_MASK);
-	dcache_disable();
+	if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
+		dcache_disable();
 
 	atf_entry(bl31_params, (void *)fdt_addr);
 }
Signature · 1 line
2.34.1
#13 lore raw

PATCH v5 13/16 rockchip: Ensure memory size is available in RK3399 SPL

In reply to Simon Glass

At present gd->ram_size is 0 in SPL, meaning that it is not possible to enable the cache. Correct this by always populating the RAM size correctly.

This increases code size by about 500 bytes in SPL, since it must call the rather large rockchip_sdram_size() function.

---

(no changes since v3)

Changes in v3:
- Cut the patch down to bare bones

Changes in v2:
- Add new patch to correct memory size in SPL

 drivers/ram/rockchip/sdram_rk3399.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/ram/rockchip/sdram_rk3399.c +4 -4
index 02cc4a38cf0..3c4e20f4e80 100644
@@ -3142,19 +3142,19 @@ static int rk3399_dmc_init(struct udevice *dev)
 
 static int rk3399_dmc_probe(struct udevice *dev)
 {
+	struct dram_info *priv = dev_get_priv(dev);
+
 #if defined(CONFIG_TPL_BUILD) || \
 	(!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD))
 	if (rk3399_dmc_init(dev))
 		return 0;
-#else
-	struct dram_info *priv = dev_get_priv(dev);
-
+#endif
 	priv->pmugrf = syscon_get_first_range(ROCKCHIP_SYSCON_PMUGRF);
 	debug("%s: pmugrf = %p\n", __func__, priv->pmugrf);
 	priv->info.base = CFG_SYS_SDRAM_BASE;
 	priv->info.size =
 		rockchip_sdram_size((phys_addr_t)&priv->pmugrf->os_reg2);
-#endif
+
 	return 0;
 }
 
Signature · 1 line
2.34.1
#14 lore raw

PATCH v5 14/16 rockchip: Avoid #ifdefs in RK3399 SPL

In reply to Simon Glass

The code here is confusing due to large blocks which are #ifdefed out. Add a function phase_sdram_init() which returns whether SDRAM init should happen in the current phase, using that as needed to control the code flow.

This increases code size by about 500 bytes in SPL when the cache is on, since it must call the rather large rockchip_sdram_size() function.

- Drop the non-dcache optimisation, since the cache should normally be on

---

Changes in v5:
- Move setting of pmugrf into the probe() function

Changes in v3:
- Split out the refactoring into a separate patch

 drivers/ram/rockchip/sdram_rk3399.c | 33 ++++++++++++++---------------
 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/ram/rockchip/sdram_rk3399.c +16 -17
index 3c4e20f4e80..b259e8e3dd6 100644
@@ -13,6 +13,7 @@
 #include <log.h>
 #include <ram.h>
 #include <regmap.h>
+#include <spl.h>
 #include <syscon.h>
 #include <asm/arch-rockchip/clock.h>
 #include <asm/arch-rockchip/cru.h>
@@ -63,8 +64,6 @@ struct chan_info {
 };
 
 struct dram_info {
-#if defined(CONFIG_TPL_BUILD) || \
-	(!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD))
 	u32 pwrup_srefresh_exit[2];
 	struct chan_info chan[2];
 	struct clk ddr_clk;
@@ -75,7 +74,6 @@ struct dram_info {
 	struct rk3399_pmusgrf_regs *pmusgrf;
 	struct rk3399_ddr_cic_regs *cic;
 	const struct sdram_rk3399_ops *ops;
-#endif
 	struct ram_info info;
 	struct rk3399_pmugrf_regs *pmugrf;
 };
@@ -92,9 +90,6 @@ struct sdram_rk3399_ops {
 					struct rk3399_sdram_params *params);
 };
 
-#if defined(CONFIG_TPL_BUILD) || \
-	(!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD))
-
 struct rockchip_dmc_plat {
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
 	struct dtd_rockchip_rk3399_dmc dtplat;
@@ -191,6 +186,17 @@ struct io_setting {
 	},
 };
 
+/**
+ * phase_sdram_init() - Check if this is the phase where SDRAM init happens
+ *
+ * Returns: true to do SDRAM init in this phase, false to not
+ */
+static bool phase_sdram_init(void)
+{
+	return spl_phase() == PHASE_TPL ||
+	    (!IS_ENABLED(CONFIG_TPL) && !spl_in_proper());
+}
+
 static struct io_setting *
 lpddr4_get_io_settings(const struct rk3399_sdram_params *params, u32 mr5)
 {
@@ -3024,7 +3030,7 @@ static int rk3399_dmc_of_to_plat(struct udevice *dev)
 	struct rockchip_dmc_plat *plat = dev_get_plat(dev);
 	int ret;
 
-	if (!CONFIG_IS_ENABLED(OF_REAL))
+	if (!CONFIG_IS_ENABLED(OF_REAL) || !phase_sdram_init())
 		return 0;
 
 	ret = dev_read_u32_array(dev, "rockchip,sdram-params",
@@ -3093,7 +3099,6 @@ static int rk3399_dmc_init(struct udevice *dev)
 	priv->cic = syscon_get_first_range(ROCKCHIP_SYSCON_CIC);
 	priv->grf = syscon_get_first_range(ROCKCHIP_SYSCON_GRF);
 	priv->pmu = syscon_get_first_range(ROCKCHIP_SYSCON_PMU);
-	priv->pmugrf = syscon_get_first_range(ROCKCHIP_SYSCON_PMUGRF);
 	priv->pmusgrf = syscon_get_first_range(ROCKCHIP_SYSCON_PMUSGRF);
 	priv->pmucru = rockchip_get_pmucru();
 	priv->cru = rockchip_get_cru();
@@ -3138,19 +3143,16 @@ static int rk3399_dmc_init(struct udevice *dev)
 
 	return 0;
 }
-#endif
 
 static int rk3399_dmc_probe(struct udevice *dev)
 {
 	struct dram_info *priv = dev_get_priv(dev);
 
-#if defined(CONFIG_TPL_BUILD) || \
-	(!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD))
-	if (rk3399_dmc_init(dev))
-		return 0;
-#endif
 	priv->pmugrf = syscon_get_first_range(ROCKCHIP_SYSCON_PMUGRF);
 	debug("%s: pmugrf = %p\n", __func__, priv->pmugrf);
+	if (phase_sdram_init() && rk3399_dmc_init(dev))
+		return 0;
+
 	priv->info.base = CFG_SYS_SDRAM_BASE;
 	priv->info.size =
 		rockchip_sdram_size((phys_addr_t)&priv->pmugrf->os_reg2);
@@ -3181,10 +3183,7 @@ U_BOOT_DRIVER(dmc_rk3399) = {
 	.id = UCLASS_RAM,
 	.of_match = rk3399_dmc_ids,
 	.ops = &rk3399_dmc_ops,
-#if defined(CONFIG_TPL_BUILD) || \
-	(!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD))
 	.of_to_plat = rk3399_dmc_of_to_plat,
-#endif
 	.probe = rk3399_dmc_probe,
 	.priv_auto	= sizeof(struct dram_info),
 #if defined(CONFIG_TPL_BUILD) || \
Signature · 1 line
2.34.1
#15 lore raw

Re: [PATCH v5 14/16] rockchip: Avoid #ifdefs in RK3399 SPL

Hi Simon,

Quoted 26 lines · Simon Glass

The code here is confusing due to large blocks which are #ifdefed out. Add a function phase_sdram_init() which returns whether SDRAM init should happen in the current phase, using that as needed to control the code flow.

This increases code size by about 500 bytes in SPL when the cache is on, since it must call the rather large rockchip_sdram_size() function.

- Drop the non-dcache optimisation, since the cache should normally be on

---

Changes in v5:
- Move setting of pmugrf into the probe() function

Changes in v3:
- Split out the refactoring into a separate patch

 drivers/ram/rockchip/sdram_rk3399.c | 33 ++++++++++++++---------------
 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/ram/rockchip/sdram_rk3399.c +0 -0
index 3c4e20f4e80..b259e8e3dd6 100644

[snip]

drivers/ram/rockchip/sdram_rk3399.c struct io_setting { · line 197

Quoted 9 lines
drivers/ram/rockchip/sdram_rk3399.c +9 -0
+/**
+ * phase_sdram_init() - Check if this is the phase where SDRAM init happens
+ *
+ * Returns: true to do SDRAM init in this phase, false to not
+ */
+static bool phase_sdram_init(void)
+{
+	return spl_phase() == PHASE_TPL ||
+	    (!IS_ENABLED(CONFIG_TPL) && !spl_in_proper());

This still need to check for !IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL) to be correct, else you must build with both CONFIG_TPL and CONFIG_ROCKCHIP_EXTERNAL_TPL or the generated SPL will incorrectly try to initialize DRAM.

DRAM should only be initialized in TPL or ROCKCHIP_EXTERNAL_TPL, or if none of them are defined in SPL. All other phases should just read and report dram size.

Regards,
Jonas

Quoted 2 lines
drivers/ram/rockchip/sdram_rk3399.c +2 -0
+}
+

[snip]

#16 lore raw

Re: [PATCH v5 14/16] rockchip: Avoid #ifdefs in RK3399 SPL

Hi Jonas,

Quoted 48 lines · Jonas Karlman

Hi Simon,

Quoted 26 lines · Simon Glass

The code here is confusing due to large blocks which are #ifdefed out. Add a function phase_sdram_init() which returns whether SDRAM init should happen in the current phase, using that as needed to control the code flow.

This increases code size by about 500 bytes in SPL when the cache is on, since it must call the rather large rockchip_sdram_size() function.

- Drop the non-dcache optimisation, since the cache should normally be on

---

Changes in v5:
- Move setting of pmugrf into the probe() function

Changes in v3:
- Split out the refactoring into a separate patch

 drivers/ram/rockchip/sdram_rk3399.c | 33 ++++++++++++++---------------
 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/ram/rockchip/sdram_rk3399.c +0 -0
index 3c4e20f4e80..b259e8e3dd6 100644

[snip]

drivers/ram/rockchip/sdram_rk3399.c struct io_setting { · line 197

Quoted 9 lines
drivers/ram/rockchip/sdram_rk3399.c +9 -0
+/**
+ * phase_sdram_init() - Check if this is the phase where SDRAM init happens
+ *
+ * Returns: true to do SDRAM init in this phase, false to not
+ */
+static bool phase_sdram_init(void)
+{
+     return spl_phase() == PHASE_TPL ||
+         (!IS_ENABLED(CONFIG_TPL) && !spl_in_proper());

This still need to check for !IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL) to be correct, else you must build with both CONFIG_TPL and CONFIG_ROCKCHIP_EXTERNAL_TPL or the generated SPL will incorrectly try to initialize DRAM.

Quoted 3 lines

DRAM should only be initialized in TPL or ROCKCHIP_EXTERNAL_TPL, or if none of them are defined in SPL. All other phases should just read and report dram size.

Thanks for the info.

The reason I am finding this hard to understand is that ROCKCHIP_EXTERNAL_TPL does not appear in the code as it is. So I cannot figure out why it needs to be added. Is there a bug in the current code, or does my patch introduce a bug, or...?

Regards,
Simon

#17 lore raw

Re: [PATCH v5 14/16] rockchip: Avoid #ifdefs in RK3399 SPL

Hi Simon,

Quoted 55 lines · Simon Glass

Hi Jonas,

Quoted 48 lines · Jonas Karlman

Hi Simon,

Quoted 26 lines · Simon Glass

The code here is confusing due to large blocks which are #ifdefed out. Add a function phase_sdram_init() which returns whether SDRAM init should happen in the current phase, using that as needed to control the code flow.

This increases code size by about 500 bytes in SPL when the cache is on, since it must call the rather large rockchip_sdram_size() function.

- Drop the non-dcache optimisation, since the cache should normally be on

---

Changes in v5:
- Move setting of pmugrf into the probe() function

Changes in v3:
- Split out the refactoring into a separate patch

 drivers/ram/rockchip/sdram_rk3399.c | 33 ++++++++++++++---------------
 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/ram/rockchip/sdram_rk3399.c +0 -0
index 3c4e20f4e80..b259e8e3dd6 100644

[snip]

drivers/ram/rockchip/sdram_rk3399.c struct io_setting { · line 197

Quoted 9 lines
drivers/ram/rockchip/sdram_rk3399.c +9 -0
+/**
+ * phase_sdram_init() - Check if this is the phase where SDRAM init happens
+ *
+ * Returns: true to do SDRAM init in this phase, false to not
+ */
+static bool phase_sdram_init(void)
+{
+     return spl_phase() == PHASE_TPL ||
+         (!IS_ENABLED(CONFIG_TPL) && !spl_in_proper());

This still need to check for !IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL) to be correct, else you must build with both CONFIG_TPL and CONFIG_ROCKCHIP_EXTERNAL_TPL or the generated SPL will incorrectly try to initialize DRAM.

Quoted 3 lines

DRAM should only be initialized in TPL or ROCKCHIP_EXTERNAL_TPL, or if none of them are defined in SPL. All other phases should just read and report dram size.

Quoted 6 lines

Thanks for the info.

The reason I am finding this hard to understand is that ROCKCHIP_EXTERNAL_TPL does not appear in the code as it is. So I cannot figure out why it needs to be added. Is there a bug in the current code, or does my patch introduce a bug, or...?

The current code does not handle ROCKCHIP_EXTERNAL_TPL and TPL must be built to later be replaced with the external TPL blob.

This adds a new helper that states "Check if this is the phase where SDRAM init happens", and for this statement to be true it should also consider ROCKCHIP_EXTERNAL_TPL or a bugfix patch is later needed for this newly added helper.

Adding !IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL) should make this statement be valid for the foreseeable combinations.

	return spl_phase() == PHASE_TPL ||
	       (!IS_ENABLED(CONFIG_TPL) &&
		!IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL) &&
		!spl_in_proper());

With that it should be possible to have TPL=n and ROCKCHIP_EXTERNAL_TPL=y and produce a working SPL.

Regards,
Jonas

Quoted 3 lines

Regards,
Simon

#18 lore raw

Re: [PATCH v5 14/16] rockchip: Avoid #ifdefs in RK3399 SPL

Hi Jonas,

Quoted 77 lines · Jonas Karlman

Hi Simon,

Quoted 55 lines · Simon Glass

Hi Jonas,

Quoted 48 lines · Jonas Karlman

Hi Simon,

Quoted 26 lines · Simon Glass

The code here is confusing due to large blocks which are #ifdefed out. Add a function phase_sdram_init() which returns whether SDRAM init should happen in the current phase, using that as needed to control the code flow.

This increases code size by about 500 bytes in SPL when the cache is on, since it must call the rather large rockchip_sdram_size() function.

- Drop the non-dcache optimisation, since the cache should normally be on

---

Changes in v5:
- Move setting of pmugrf into the probe() function

Changes in v3:
- Split out the refactoring into a separate patch

 drivers/ram/rockchip/sdram_rk3399.c | 33 ++++++++++++++---------------
 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/ram/rockchip/sdram_rk3399.c +0 -0
index 3c4e20f4e80..b259e8e3dd6 100644

[snip]

drivers/ram/rockchip/sdram_rk3399.c struct io_setting { · line 197

Quoted 9 lines
drivers/ram/rockchip/sdram_rk3399.c +9 -0
+/**
+ * phase_sdram_init() - Check if this is the phase where SDRAM init happens
+ *
+ * Returns: true to do SDRAM init in this phase, false to not
+ */
+static bool phase_sdram_init(void)
+{
+     return spl_phase() == PHASE_TPL ||
+         (!IS_ENABLED(CONFIG_TPL) && !spl_in_proper());

This still need to check for !IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL) to be correct, else you must build with both CONFIG_TPL and CONFIG_ROCKCHIP_EXTERNAL_TPL or the generated SPL will incorrectly try to initialize DRAM.

Quoted 3 lines

DRAM should only be initialized in TPL or ROCKCHIP_EXTERNAL_TPL, or if none of them are defined in SPL. All other phases should just read and report dram size.

Quoted 6 lines

Thanks for the info.

The reason I am finding this hard to understand is that ROCKCHIP_EXTERNAL_TPL does not appear in the code as it is. So I cannot figure out why it needs to be added. Is there a bug in the current code, or does my patch introduce a bug, or...?

The current code does not handle ROCKCHIP_EXTERNAL_TPL and TPL must be built to later be replaced with the external TPL blob.

This adds a new helper that states "Check if this is the phase where SDRAM init happens", and for this statement to be true it should also consider ROCKCHIP_EXTERNAL_TPL or a bugfix patch is later needed for this newly added helper.

Adding !IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL) should make this statement be valid for the foreseeable combinations.

Quoted 7 lines
        return spl_phase() == PHASE_TPL ||
               (!IS_ENABLED(CONFIG_TPL) &&
                !IS_ENABLED(CONFIG_ROCKCHIP_EXTERNAL_TPL) &&
                !spl_in_proper());

With that it should be possible to have TPL=n and ROCKCHIP_EXTERNAL_TPL=y and produce a working SPL.

Thanks very much, I understand it now.

Regards,
Simon

#19 lore raw

PATCH v5 15/16 rockchip: bob: kevin: Disable dcache in SPL

In reply to Simon Glass

This causes a hang, so disable it. Unfortunately the RAM-size fix does not resolve the problem and I am unsure what is wrong. As soon as the cache is enabled the board appears to hang.

Fixes 6d8cdfd1536 ("rockchip: spl: Enable caches to speed up checksum validation")

---

(no changes since v1)

 configs/chromebook_bob_defconfig   | 1 +
 configs/chromebook_kevin_defconfig | 1 +
 2 files changed, 2 insertions(+)
configs/chromebook_bob_defconfig +1 -0
index acfe3934104..b2ecfa6050c 100644
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_SPL_SYS_DCACHE_OFF=y
 CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
 CONFIG_TEXT_BASE=0x00200000
configs/chromebook_kevin_defconfig +1 -0
index 95fdb418d82..da748e4f022 100644
@@ -2,6 +2,7 @@ CONFIG_ARM=y
 CONFIG_SKIP_LOWLEVEL_INIT=y
 CONFIG_COUNTER_FREQUENCY=24000000
 CONFIG_ARCH_ROCKCHIP=y
+CONFIG_SPL_SYS_DCACHE_OFF=y
 CONFIG_TEXT_BASE=0x00200000
 CONFIG_SPL_GPIO=y
 CONFIG_NR_DRAM_BANKS=1
Signature · 1 line
2.34.1
#20 lore raw

PATCH v5 16/16 Drop the special am335x_boneblack_vboot target

In reply to Simon Glass

Now that am335x_evm boots OK on the Beaglebone black, drop the latter and update the docs to cover the change.

Also add a few updates about 'make fit' and drop the note about the security review, as U-Boot's verified boot has had quite extensive review now.

---

(no changes since v4)

Changes in v4:
- Fix 'stating' typo
- Move Binman size feature to a separate series

Changes in v2:
- Drop patch "regulator: rk8xx: Fix incorrect parameter"
- Rewrite boneblack patch to onstead drop the target and update docs

 board/ti/am335x/MAINTAINERS              |  1 -
 configs/am335x_boneblack_vboot_defconfig | 94 ------------------------
 configs/am335x_evm_defconfig             |  3 +-
 doc/usage/fit/beaglebone_vboot.rst       | 21 +++---
 4 files changed, 12 insertions(+), 107 deletions(-)
 delete mode 100644 configs/am335x_boneblack_vboot_defconfig
board/ti/am335x/MAINTAINERS +0 -1
index 219c8715bf1..ed8800a2663 100644
@@ -3,6 +3,5 @@ M:	Tom Rini <[email protected]>
 S:	Maintained
 F:	board/ti/am335x/
 F:	include/configs/am335x_evm.h
-F:	configs/am335x_boneblack_vboot_defconfig
 F:	configs/am335x_evm_defconfig
 F:	configs/am335x_evm_spiboot_defconfig
configs/am335x_boneblack_vboot_defconfig deleted +0 -94

94 lines not on this page · raw message

configs/am335x_evm_defconfig +2 -1
index d243cb16e72..cabc181460a 100644
@@ -13,6 +13,8 @@ CONFIG_AM335X_USB0_PERIPHERAL=y
 CONFIG_AM335X_USB1=y
 CONFIG_SPL=y
 CONFIG_TIMESTAMP=y
+CONFIG_FIT_SIGNATURE=y
+CONFIG_FIT_VERBOSE=y
 CONFIG_SPL_LOAD_FIT=y
 CONFIG_SYS_BOOTM_LEN=0x1000000
 CONFIG_DISTRO_DEFAULTS=y
@@ -119,5 +121,4 @@ CONFIG_SPL_USB_ETHER=y
 CONFIG_WDT=y
 # CONFIG_SPL_WDT is not set
 CONFIG_DYNAMIC_CRC_TABLE=y
-CONFIG_RSA=y
 CONFIG_LZO=y
doc/usage/fit/beaglebone_vboot.rst +10 -11
index cd6bb141910..1298ba1ae08 100644
@@ -67,18 +67,20 @@ a. Set up the environment variable to point to your toolchain. You will need
 
        export CROSS_COMPILE=arm-linux-gnueabi-
 
-b. Configure and build U-Boot with verified boot enabled::
+b. Configure and build U-Boot with verified boot enabled. Note that we use the
+am335x_evm target since it covers all boards based on the AM335x evaluation
+board::
 
     export UBOOT=/path/to/u-boot
     cd $UBOOT
     # You can add -j10 if you have 10 CPUs to make it faster
-    make O=b/am335x_boneblack_vboot am335x_boneblack_vboot_config all
-    export UOUT=$UBOOT/b/am335x_boneblack_vboot
+    make O=b/am335x_evm am335x_evm_config all
+    export UOUT=$UBOOT/b/am335x_evm
 
 c. You will now have a U-Boot image::
 
-    file b/am335x_boneblack_vboot/u-boot-dtb.img
-    b/am335x_boneblack_vboot/u-boot-dtb.img: u-boot legacy uImage,
+    file b/am335x_evm/u-boot-dtb.img
+    b/am335x_evm/u-boot-dtb.img: u-boot legacy uImage,
       U-Boot 2014.07-rc2-00065-g2f69f8, Firmware/ARM, Firmware Image
       (Not compressed), 395375 bytes, Sat May 31 16:19:04 2014,
       Load Address: 0x80800000, Entry Point: 0x00000000,
@@ -466,7 +468,7 @@ the private key that you signed with so that it can verify any kernels that
 you sign::
 
     cd $UBOOT
-    make O=b/am335x_boneblack_vboot EXT_DTB=${WORK}/am335x-boneblack-pubkey.dtb
+    make O=b/am335x_evm EXT_DTB=${WORK}/am335x-boneblack-pubkey.dtb
 
 Here we are overriding the normal device tree file with our one, which
 contains the public key.
@@ -597,14 +599,11 @@ Further Improvements
 
 Several of the steps here can be easily automated. In particular it would be
 capital if signing and packaging a kernel were easy, perhaps a simple make
-target in the kernel.
+target in the kernel. A starting point for this is the 'make image.fit' target
+for ARM64 in Linux from v6.9 onwards.
 
 Some mention of how to use multiple .dtb files in a FIT might be useful.
 
-U-Boot's verified boot mechanism has not had a robust and independent security
-review. Such a review should look at the implementation and its resistance to
-attacks.
-
 Perhaps the verified boot feature could be integrated into the Amstrom
 distribution.
 
Signature · 1 line
2.34.1
#21 lore raw
In reply to Simon Glass
Quoted 5 lines · Simon Glass

This series includes fixes to get some rockchip and nvidia boards working again. It also drops the broken Beaglebone Black config and provides a devicetree fix for coral (x86).

Note that since this series fixes bugs, it is targeted at -master

[snip]

Quoted 6 lines

Simon Glass (16):
mkeficapsule: Add a --version argument
binman: Collect the version number for mkeficapsule
binman: Deal with mkeficapsule being missing
binman: Return failure when a usage() message is generated
binman: Keep the efi_capsule input file

Can you please split these out from this series? At this point in the cycle I just want obvious regression fixes.

Quoted 1 line

nvidia: nyan-big: Disable debug UART

This is fine.

Quoted 2 lines

tpm: Avoid code bloat when not using EFI_TCG2_PROTOCOL
x86: Set a board-size limit for chromebook_link

These two combined are fine.

Quoted 2 lines

rockchip: veyron: Add logging for power init
power: regulator: Handle autoset in regulators_enable_boot_on()

These have acks and are fine.

Quoted 1 line

fdt: Correct condition for bloblist existing

I'm waiting for review tags on this one.

Quoted 1 line

spl: Allow ATF to work when dcache is disabled

This is fine.

Quoted 3 lines

rockchip: Ensure memory size is available in RK3399 SPL
rockchip: Avoid #ifdefs in RK3399 SPL
rockchip: bob: kevin: Disable dcache in SPL

These keep being iterated on?

Quoted 1 line

Drop the special am335x_boneblack_vboot target

This is fine.

It might be best for right now to split out the patches that I've listed as fine above, to one series that I'll pick up today after my current queue of next testing is done, another of the binman/mkeficapsule changes, and another of the remaining fixes. Thanks.

Signature · 1 line
Tom
#22 lore raw

Hi Tom,

Quoted 39 lines · Tom Rini
Quoted 5 lines · Simon Glass

This series includes fixes to get some rockchip and nvidia boards working again. It also drops the broken Beaglebone Black config and provides a devicetree fix for coral (x86).

Note that since this series fixes bugs, it is targeted at -master

[snip]

Quoted 6 lines

Simon Glass (16):
mkeficapsule: Add a --version argument
binman: Collect the version number for mkeficapsule
binman: Deal with mkeficapsule being missing
binman: Return failure when a usage() message is generated
binman: Keep the efi_capsule input file

Can you please split these out from this series? At this point in the cycle I just want obvious regression fixes.

Quoted 1 line

nvidia: nyan-big: Disable debug UART

This is fine.

Quoted 2 lines

tpm: Avoid code bloat when not using EFI_TCG2_PROTOCOL
x86: Set a board-size limit for chromebook_link

These two combined are fine.

Quoted 2 lines

rockchip: veyron: Add logging for power init
power: regulator: Handle autoset in regulators_enable_boot_on()

These have acks and are fine.

Quoted 1 line

fdt: Correct condition for bloblist existing

I'm waiting for review tags on this one.

Quoted 1 line

spl: Allow ATF to work when dcache is disabled

Quoted 7 lines

This is fine.

Quoted 3 lines

rockchip: Ensure memory size is available in RK3399 SPL
rockchip: Avoid #ifdefs in RK3399 SPL
rockchip: bob: kevin: Disable dcache in SPL

These keep being iterated on?

I believe the last one is OK...the other two don't help my boards anyway, but I'll continue trying to figure out what is needed.

Quoted 9 lines
Quoted 2 lines

Drop the special am335x_boneblack_vboot target

This is fine.

It might be best for right now to split out the patches that I've listed as fine above, to one series that I'll pick up today after my current queue of next testing is done, another of the binman/mkeficapsule changes, and another of the remaining fixes. Thanks.

OK done, except I added the 'Disable dcache in SPL' patch.

As noted in the series, I would like the FDT bloblist thing sorted out / applied, even if it is a stopgap in -master.

Regards,
Simon