All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/22] Various fixes and enhancements
@ 2021-07-05 22:32 Simon Glass
  2021-07-05 22:32 ` [PATCH 01/22] dm: core: Add logging for DM_SEQ_ALIAS Simon Glass
                   ` (41 more replies)
  0 siblings, 42 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, AKASHI Takahiro, Adam Ford, Alexandru Gagniuc,
	Alper Nebi Yasak, Anastasiia Lukianenko, Andre Przywara,
	Andrii Anisov, Andy Shevchenko, Bin Meng, Claudiu Manoil,
	Dario Binacchi, Etienne Carriere, Faiz Abbas, Harald Seiler,
	Heinrich Schuchardt, Igor Opaniuk, Jaehoon Chung,
	Jean-Jacques Hiblot, Joe Hershberger, Joel Peshkin, Joel Stanley,
	Lokesh Vutla, Marek Behún, Marek Vasut, Mark Kettenis,
	Masahiro Yamada, Masahiro Yamada, Michael Walle, Michal Simek,
	Oleksandr Andrushchenko, Otavio Salvador, Ovidiu Panait,
	Patrick Delaunay, Pavel Herrmann, Peng Fan, Philippe Reynes,
	Pratyush Yadav, Roger Pau Monne, Samuel Holland, Sean Anderson,
	Sebastian Reichel, Stefan Roese, Usama Arif, Walter Lozano,
	Wolfgang Wallner

This series includes a number of fixes and enhancements related to
enabling verified boot on Chromium OS:

- bloblist support for resizing and a few minor fixes
- iteration through block devices
- a few cros_ec improvements
- sandbox SDL2 fixes and support for launching the VPL executable
- minor test and dm fixes
- show boot error when SPL fails to find next phase

It is based on the VPL series:

   http://patchwork.ozlabs.org/project/uboot/list/?series=242761


Simon Glass (22):
  dm: core: Add logging for DM_SEQ_ALIAS
  dm: Support lzma in the flashmap
  test: Allow CONFIG_SPL_LOAD_FIT to be disabled
  test: Add DM_DMA to be disabled
  test: Avoid a build error with SPL
  Makefile: Avoid rebuilding .dtb files each time
  sandbox: Support executables for more phases
  sandbox: Add work-around for SDL2 display
  sandbox: Use hinting with the display
  sandbox: Adjust the bloblist default address
  cros_ec: Allow reading the battery-charge state
  cros_ec: Drop cros_ec_entering_mode()
  cros_ec: Support the full-size vboot context
  cros_ec: Use standard calls for recovery-request checking
  bloblist: Support resizing a blob
  bloblist: Tidy up a few API comments
  bloblist: Correct condition in bloblist_addrec()
  image: Allow @ in node names when not using signatures
  spl: Provide more information on boot failure
  sandbox: mmc: Support fixed MMC devices
  blk: Support iteration
  log: Allow padding of the function name

 arch/sandbox/cpu/os.c          |  63 +++++-----
 arch/sandbox/cpu/sdl.c         |  26 +++-
 arch/sandbox/cpu/spl.c         |  18 ++-
 arch/sandbox/dts/test.dts      |   1 +
 arch/sandbox/include/asm/spl.h |  13 ++
 common/Kconfig                 |  10 +-
 common/bloblist.c              |  73 ++++++++++-
 common/image-fit.c             |   2 +-
 common/log_console.c           |   2 +-
 common/spl/Kconfig             |  10 ++
 common/spl/spl.c               |  48 +++++---
 doc/arch/sandbox.rst           |   2 +-
 drivers/block/blk-uclass.c     |  49 ++++++++
 drivers/core/device.c          |   4 +-
 drivers/core/of_extra.c        |   2 +
 drivers/misc/cros_ec.c         |  28 +++--
 drivers/misc/cros_ec_sandbox.c |  29 +++--
 drivers/mmc/sandbox_mmc.c      |  24 +++-
 include/blk.h                  |  56 +++++++++
 include/bloblist.h             |  23 +++-
 include/cros_ec.h              |  17 ++-
 include/os.h                   |   5 +-
 include/spl.h                  |  33 +++++
 scripts/Makefile.lib           |   2 +-
 test/Makefile                  |   2 +
 test/bloblist.c                | 215 +++++++++++++++++++++++++++++++++
 test/dm/blk.c                  |  55 +++++++++
 test/dm/core.c                 |   2 +
 test/image/spl_load.c          |   6 +-
 test/log/log_test.c            |  16 +--
 test/test-main.c               |   2 +-
 31 files changed, 724 insertions(+), 114 deletions(-)

-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply	[flat|nested] 50+ messages in thread

* [PATCH 01/22] dm: core: Add logging for DM_SEQ_ALIAS
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 02/22] dm: Support lzma in the flashmap Simon Glass
                   ` (40 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Marek Vasut, Pavel Herrmann

It is sometimes helpful to see which sequence is assigned to a device.
Add debugging info for that.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 9f1400768de..29668f6fb30 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -87,8 +87,10 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
 		if (CONFIG_IS_ENABLED(OF_CONTROL) &&
 		    !CONFIG_IS_ENABLED(OF_PLATDATA)) {
 			if (uc->uc_drv->name && ofnode_valid(node)) {
-				if (!dev_read_alias_seq(dev, &dev->seq_))
+				if (!dev_read_alias_seq(dev, &dev->seq_)) {
 					auto_seq = false;
+					log_debug("   - seq=%d\n", dev->seq_);
+					}
 			}
 		}
 	}
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 02/22] dm: Support lzma in the flashmap
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
  2021-07-05 22:32 ` [PATCH 01/22] dm: core: Add logging for DM_SEQ_ALIAS Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 03/22] test: Allow CONFIG_SPL_LOAD_FIT to be disabled Simon Glass
                   ` (39 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Marek Vasut, Pavel Herrmann

Allow lzma compression as well as lz4.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/of_extra.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/core/of_extra.c b/drivers/core/of_extra.c
index 7702beff97b..632a1c2210e 100644
--- a/drivers/core/of_extra.c
+++ b/drivers/core/of_extra.c
@@ -31,6 +31,8 @@ int ofnode_read_fmap_entry(ofnode node, struct fmap_entry *entry)
 	if (prop) {
 		if (!strcmp(prop, "lz4"))
 			entry->compress_algo = FMAP_COMPRESS_LZ4;
+		else if (!strcmp(prop, "lzma"))
+			entry->compress_algo = FMAP_COMPRESS_LZMA;
 		else
 			return log_msg_ret("compression algo", -EINVAL);
 	} else {
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 03/22] test: Allow CONFIG_SPL_LOAD_FIT to be disabled
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
  2021-07-05 22:32 ` [PATCH 01/22] dm: core: Add logging for DM_SEQ_ALIAS Simon Glass
  2021-07-05 22:32 ` [PATCH 02/22] dm: Support lzma in the flashmap Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 04/22] test: Add DM_DMA " Simon Glass
                   ` (38 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Heinrich Schuchardt

At present if this is not enabled on a sandbox build, the build fails. Add
a condition to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test/Makefile b/test/Makefile
index a26e915e050..117839e5847 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -3,7 +3,9 @@
 # (C) Copyright 2012 The Chromium Authors
 
 obj-y += test-main.o
+ifdef CONFIG_SPL_LOAD_FIT
 obj-$(CONFIG_SANDBOX) += image/
+endif
 
 ifneq ($(CONFIG_$(SPL_)BLOBLIST),)
 obj-$(CONFIG_$(SPL_)CMDLINE) += bloblist.o
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 04/22] test: Add DM_DMA to be disabled
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (2 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 03/22] test: Allow CONFIG_SPL_LOAD_FIT to be disabled Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 05/22] test: Avoid a build error with SPL Simon Glass
                   ` (37 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass

At present if DM_DMA is disabled on a sandbox build, the build fails.
Make the test conditional.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/dm/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test/dm/core.c b/test/dm/core.c
index 2210345dd14..0492698997c 100644
--- a/test/dm/core.c
+++ b/test/dm/core.c
@@ -1171,6 +1171,7 @@ static int dm_test_all_have_seq(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_all_have_seq, UT_TESTF_SCAN_PDATA);
 
+#if CONFIG_IS_ENABLED(DM_DMA)
 static int dm_test_dma_offset(struct unit_test_state *uts)
 {
        struct udevice *dev;
@@ -1200,3 +1201,4 @@ static int dm_test_dma_offset(struct unit_test_state *uts)
        return 0;
 }
 DM_TEST(dm_test_dma_offset, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+#endif
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 05/22] test: Avoid a build error with SPL
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (3 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 04/22] test: Add DM_DMA " Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time Simon Glass
                   ` (36 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Andy Shevchenko

At present this fails to build chromeos_sandbox due to a rebase error
in dm_test_pre_run(). Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/test-main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/test-main.c b/test/test-main.c
index 7afe8741cf9..3cdf6849c57 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -45,7 +45,7 @@ static int dm_test_pre_run(struct unit_test_state *uts)
 	uts->force_fail_alloc = false;
 	uts->skip_post_probe = false;
 	gd->dm_root = NULL;
-	if (IS_ENABLED(CONFIG_UT_DM) && !CONFIG_IS_ENABLED(OF_PLATDATA))
+	if (CONFIG_IS_ENABLED(UT_DM) && !CONFIG_IS_ENABLED(OF_PLATDATA))
 		memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count));
 	arch_reset_for_test();
 
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (4 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 05/22] test: Avoid a build error with SPL Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 07/22] sandbox: Support executables for more phases Simon Glass
                   ` (35 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Heinrich Schuchardt, Marek Behún,
	Masahiro Yamada, Michal Simek, Roger Pau Monne

Drop the FORCE from the rule that builds .dtb files and let the normal
dependency checking do its work. This should work correctly, at least
for .dts files that don't use /include/.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 scripts/Makefile.lib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 78bbebe7e93..03b348c8df8 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -328,7 +328,7 @@ cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
 		; \
 	sed "s:$(pre-tmp):$(<):" $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
 
-$(obj)/%.dtb: $(src)/%.dts FORCE
+$(obj)/%.dtb: $(src)/%.dts
 	$(call if_changed_dep,dtc)
 
 pre-tmp = $(subst $(comma),_,$(dot-target).pre.tmp)
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 07/22] sandbox: Support executables for more phases
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (5 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 08/22] sandbox: Add work-around for SDL2 display Simon Glass
                   ` (34 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Alexandru Gagniuc, Dario Binacchi, Faiz Abbas,
	Heinrich Schuchardt, Marek Behún, Michael Walle,
	Patrick Delaunay, Peng Fan

The SPL header has a function for obtaining the phase in capital letters,
e.g. 'SPL'. Add one for lower-case also, as used by sandbox.

Use this to generalise the sandbox logic for determining the filename of
the next sandbox executable. This can provide support for VPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/cpu/os.c          | 63 +++++++++++++++-------------------
 arch/sandbox/cpu/spl.c         | 18 ++++++++--
 arch/sandbox/include/asm/spl.h | 13 +++++++
 include/os.h                   |  5 ++-
 include/spl.h                  | 23 +++++++++++++
 test/image/spl_load.c          |  6 +++-
 6 files changed, 89 insertions(+), 39 deletions(-)

diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c
index 0d21827e1b7..a8aa9def27f 100644
--- a/arch/sandbox/cpu/os.c
+++ b/arch/sandbox/cpu/os.c
@@ -783,12 +783,14 @@ int os_jump_to_image(const void *dest, int size)
 	return os_jump_to_file(fname, true);
 }
 
-int os_find_u_boot(char *fname, int maxlen, bool use_img)
+int os_find_u_boot(char *fname, int maxlen, bool use_img,
+		   const char *cur_prefix, const char *next_prefix)
 {
 	struct sandbox_state *state = state_get_current();
 	const char *progname = state->argv[0];
 	int len = strlen(progname);
-	const char *suffix;
+	char subdir[10];
+	char *suffix;
 	char *p;
 	int fd;
 
@@ -798,45 +800,36 @@ int os_find_u_boot(char *fname, int maxlen, bool use_img)
 	strcpy(fname, progname);
 	suffix = fname + len - 4;
 
-	/* If we are TPL, boot to SPL */
-	if (!strcmp(suffix, "-tpl")) {
-		fname[len - 3] = 's';
-		fd = os_open(fname, O_RDONLY);
-		if (fd >= 0) {
-			close(fd);
-			return 0;
-		}
-
-		/* Look for 'u-boot-spl' in the spl/ directory */
-		p = strstr(fname, "/spl/");
-		if (p) {
-			p[1] = 's';
-			fd = os_open(fname, O_RDONLY);
-			if (fd >= 0) {
-				close(fd);
-				return 0;
-			}
-		}
-		return -ENOENT;
-	}
+	/* Change the existing suffix to the new one */
+	if (*suffix != '-')
+		return -EINVAL;
 
-	/* Look for 'u-boot' in the same directory as 'u-boot-spl' */
-	if (!strcmp(suffix, "-spl")) {
-		fname[len - 4] = '\0';
-		fd = os_open(fname, O_RDONLY);
-		if (fd >= 0) {
-			close(fd);
-			return 0;
-		}
+	if (*next_prefix)
+		strcpy(suffix + 1, next_prefix);  /* e.g. "-tpl" to "-spl" */
+	else
+		*suffix = '\0';  /* e.g. "-spl" to "" */
+	fd = os_open(fname, O_RDONLY);
+	if (fd >= 0) {
+		close(fd);
+		return 0;
 	}
 
-	/* Look for 'u-boot' in the parent directory of spl/ */
-	p = strstr(fname, "spl/");
+	/*
+	 * We didn't find it, so try looking for 'u-boot-xxx' in the xxx/
+	 * directory. Replace the old dirname with the new one.
+	 */
+	snprintf(subdir, sizeof(subdir), "/%s/", cur_prefix);
+	p = strstr(fname, subdir);
 	if (p) {
-		/* Remove the "spl" characters */
-		memmove(p, p + 4, strlen(p + 4) + 1);
+		if (*next_prefix)
+			/* e.g. ".../tpl/u-boot-spl"  to "../spl/u-boot-spl" */
+			memcpy(p + 1, next_prefix, strlen(next_prefix));
+		else
+			/* e.g. ".../spl/u-boot" to ".../u-boot" */
+			strcpy(p, p + 1 + strlen(cur_prefix));
 		if (use_img)
 			strcat(p, ".img");
+
 		fd = os_open(fname, O_RDONLY);
 		if (fd >= 0) {
 			close(fd);
diff --git a/arch/sandbox/cpu/spl.c b/arch/sandbox/cpu/spl.c
index f82b0d3de16..be86182fd85 100644
--- a/arch/sandbox/cpu/spl.c
+++ b/arch/sandbox/cpu/spl.c
@@ -17,7 +17,21 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/* SPL / TPL init function */
+int sandbox_find_next_phase(char *fname, int maxlen, bool use_img)
+{
+	const char *cur_prefix, *next_prefix;
+	int ret;
+
+	cur_prefix = spl_phase_prefix(spl_phase());
+	next_prefix = spl_phase_prefix(spl_next_phase());
+	ret = os_find_u_boot(fname, maxlen, use_img, cur_prefix, next_prefix);
+	if (ret)
+		return log_msg_ret("find", ret);
+
+	return 0;
+}
+
+/* SPL / TPL / VPL init function */
 void board_init_f(ulong flag)
 {
 	struct sandbox_state *state = state_get_current();
@@ -37,7 +51,7 @@ static int spl_board_load_image(struct spl_image_info *spl_image,
 	char fname[256];
 	int ret;
 
-	ret = os_find_u_boot(fname, sizeof(fname), false);
+	ret = sandbox_find_next_phase(fname, sizeof(fname), false);
 	if (ret) {
 		printf("(%s not found, error %d)\n", fname, ret);
 		return ret;
diff --git a/arch/sandbox/include/asm/spl.h b/arch/sandbox/include/asm/spl.h
index 51e9d95d557..d25dc7c82a0 100644
--- a/arch/sandbox/include/asm/spl.h
+++ b/arch/sandbox/include/asm/spl.h
@@ -12,4 +12,17 @@ enum {
 	BOOT_DEVICE_BOARD,
 };
 
+/**
+ * sandbox_find_next_phase() - Find the next phase of U-Boot
+ *
+ * This function is intended to be called from within sandbox SPL. It uses
+ * a few rules to find the filename of the next U-Boot phase. See also
+ * os_find_u_boot().
+ *
+ * @fname:	place to put full path to U-Boot
+ * @maxlen:	maximum size of @fname
+ * @use_img:	select the 'u-boot.img' file instead of the 'u-boot' ELF file
+ */
+int sandbox_find_next_phase(char *fname, int maxlen, bool use_img);
+
 #endif
diff --git a/include/os.h b/include/os.h
index bd1096eb8b3..7b20d606dd0 100644
--- a/include/os.h
+++ b/include/os.h
@@ -327,9 +327,12 @@ int os_jump_to_image(const void *dest, int size);
  * @fname:	place to put full path to U-Boot
  * @maxlen:	maximum size of @fname
  * @use_img:	select the 'u-boot.img' file instead of the 'u-boot' ELF file
+ * @cur_prefix:	prefix of current executable, e.g. "spl" or "tpl"
+ * @next_prefix: prefix of executable to find, e.g. "spl" or ""
  * Return:	0 if OK, -NOSPC if the filename is too large, -ENOENT if not found
  */
-int os_find_u_boot(char *fname, int maxlen, bool use_img);
+int os_find_u_boot(char *fname, int maxlen, bool use_img,
+		   const char *cur_prefix, const char *next_prefix);
 
 /**
  * os_spl_to_uboot() - Run U-Boot proper
diff --git a/include/spl.h b/include/spl.h
index d9fe4e1bfd4..cf77d379da2 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -188,6 +188,29 @@ static inline const char *spl_phase_name(enum u_boot_phase phase)
 	}
 }
 
+/**
+ * spl_phase_prefix() - Get the prefix  of the current phase
+ *
+ * @phase: Phase to look up
+ * @return phase prefix ("spl", "tpl", etc.)
+ */
+static inline const char *spl_phase_prefix(enum u_boot_phase phase)
+{
+	switch (phase) {
+	case PHASE_TPL:
+		return "tpl";
+	case PHASE_VPL:
+		return "vpl";
+	case PHASE_SPL:
+		return "spl";
+	case PHASE_BOARD_F:
+	case PHASE_BOARD_R:
+		return "";
+	default:
+		return "phase?";
+	}
+}
+
 /* A string name for SPL or TPL */
 #ifdef CONFIG_SPL_BUILD
 # ifdef CONFIG_TPL_BUILD
diff --git a/test/image/spl_load.c b/test/image/spl_load.c
index 851603ddd75..e7cabf5680c 100644
--- a/test/image/spl_load.c
+++ b/test/image/spl_load.c
@@ -56,6 +56,7 @@ struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
 
 static int spl_test_load(struct unit_test_state *uts)
 {
+	const char *cur_prefix, *next_prefix;
 	struct spl_image_info image;
 	struct image_header *header;
 	struct text_ctx text_ctx;
@@ -68,7 +69,10 @@ static int spl_test_load(struct unit_test_state *uts)
 	load.bl_len = 512;
 	load.read = read_fit_image;
 
-	ret = os_find_u_boot(fname, sizeof(fname), true);
+	cur_prefix = spl_phase_prefix(spl_phase());
+	next_prefix = spl_phase_prefix(spl_next_phase());
+	ret = os_find_u_boot(fname, sizeof(fname), true, cur_prefix,
+			     next_prefix);
 	if (ret) {
 		printf("(%s not found, error %d)\n", fname, ret);
 		return ret;
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 08/22] sandbox: Add work-around for SDL2 display
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (6 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 07/22] sandbox: Support executables for more phases Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-22  6:00   ` Heinrich Schuchardt
  2021-07-05 22:32 ` [PATCH 09/22] sandbox: Use hinting with the display Simon Glass
                   ` (33 subsequent siblings)
  41 siblings, 1 reply; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Harald Seiler, Heinrich Schuchardt

At present the display does not show on some machines, e.g. Ubunutu
20.04 but the reason is unknown. Add a work-around until this can be
determined.

Also include more error checking just in case.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/cpu/sdl.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index 8102649be3a..e2649494818 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -164,8 +164,29 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp,
 
 int sandbox_sdl_sync(void *lcd_base)
 {
+	struct SDL_Rect rect;
+	int ret;
+
+	if (!sdl.texture)
+		return 0;
+	SDL_RenderClear(sdl.renderer);
 	SDL_UpdateTexture(sdl.texture, NULL, lcd_base, sdl.pitch);
-	SDL_RenderCopy(sdl.renderer, sdl.texture, NULL, NULL);
+	ret = SDL_RenderCopy(sdl.renderer, sdl.texture, NULL, NULL);
+	if (ret) {
+		printf("SDL copy %d: %s\n", ret, SDL_GetError());
+		return -EIO;
+	}
+
+	/*
+	 * On some machines this does not appear. Draw an empty rectangle which
+	 * seems to fix that.
+	 */
+	rect.x = 0;
+	rect.y = 0;
+	rect.w = 0;
+	rect.h = 0;
+	SDL_RenderDrawRect(sdl.renderer, &rect);
+
 	SDL_RenderPresent(sdl.renderer);
 	sandbox_sdl_poll_events();
 
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 09/22] sandbox: Use hinting with the display
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (7 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 08/22] sandbox: Add work-around for SDL2 display Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 10/22] sandbox: Adjust the bloblist default address Simon Glass
                   ` (32 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Harald Seiler, Heinrich Schuchardt

SDL provides a hinting feature which provides a higher-quality image
with the double-display option (-K). Enable it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/cpu/sdl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
index e2649494818..bef5abd039d 100644
--- a/arch/sandbox/cpu/sdl.c
+++ b/arch/sandbox/cpu/sdl.c
@@ -123,6 +123,9 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp,
 		sdl.vis_height = sdl.height;
 	}
 
+	if (!SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1"))
+		printf("Unable to init hinting: %s", SDL_GetError());
+
 	sdl.depth = 1 << log2_bpp;
 	sdl.pitch = sdl.width * sdl.depth / 8;
 	SDL_Window *screen = SDL_CreateWindow("U-Boot", SDL_WINDOWPOS_UNDEFINED,
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 10/22] sandbox: Adjust the bloblist default address
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (8 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 09/22] sandbox: Use hinting with the display Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 11/22] cros_ec: Allow reading the battery-charge state Simon Glass
                   ` (31 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, AKASHI Takahiro, Heinrich Schuchardt, Igor Opaniuk,
	Joel Peshkin, Usama Arif

Move this down to provide more space for the bloblist.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/Kconfig       | 2 +-
 doc/arch/sandbox.rst | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 2a7f08af1dc..21407b547da 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -791,7 +791,7 @@ config BLOBLIST_SIZE
 config BLOBLIST_ADDR
 	hex "Address of bloblist"
 	depends on BLOBLIST
-	default 0xe000 if SANDBOX
+	default 0xc000 if SANDBOX
 	help
 	  Sets the address of the bloblist, set up by the first part of U-Boot
 	  which runs. Subsequent U-Boot stages typically use the same address.
diff --git a/doc/arch/sandbox.rst b/doc/arch/sandbox.rst
index e052b6bdb09..9e23e1618c7 100644
--- a/doc/arch/sandbox.rst
+++ b/doc/arch/sandbox.rst
@@ -510,7 +510,7 @@ that are mapped into that memory:
 Addr      Config                     Usage
 =======   ========================   ===============================
       0   CONFIG_SYS_FDT_LOAD_ADDR   Device tree
-   e000   CONFIG_BLOBLIST_ADDR       Blob list
+   c000   CONFIG_BLOBLIST_ADDR       Blob list
   10000   CONFIG_MALLOC_F_ADDR       Early memory allocation
   f0000   CONFIG_PRE_CON_BUF_ADDR    Pre-console buffer
  100000   CONFIG_TRACE_EARLY_ADDR    Early trace buffer (if enabled). Also used
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 11/22] cros_ec: Allow reading the battery-charge state
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (9 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 10/22] sandbox: Adjust the bloblist default address Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 12/22] cros_ec: Drop cros_ec_entering_mode() Simon Glass
                   ` (30 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Alper Nebi Yasak

Add a function to read this information from the EC. It is useful for
determining whether the battery has enough charge to boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec.c | 17 +++++++++++++++++
 include/cros_ec.h      |  8 ++++++++
 2 files changed, 25 insertions(+)

diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 7904d5cc72d..0818ef8ad6e 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -1661,6 +1661,23 @@ int cros_ec_get_switches(struct udevice *dev)
 	return ret;
 }
 
+int cros_ec_read_batt_charge(struct udevice *dev, uint *chargep)
+{
+	struct ec_params_charge_state req;
+	struct ec_response_charge_state resp;
+	int ret;
+
+	req.cmd = CHARGE_STATE_CMD_GET_STATE;
+	ret = ec_command(dev, EC_CMD_CHARGE_STATE, 0, &req, sizeof(req),
+			 &resp, sizeof(resp));
+	if (ret)
+		return log_msg_ret("read", ret);
+
+	*chargep = resp.get_state.batt_state_of_charge;
+
+	return 0;
+}
+
 UCLASS_DRIVER(cros_ec) = {
 	.id		= UCLASS_CROS_EC,
 	.name		= "cros-ec",
diff --git a/include/cros_ec.h b/include/cros_ec.h
index 9396b4d2466..9dab6cdf9ba 100644
--- a/include/cros_ec.h
+++ b/include/cros_ec.h
@@ -652,4 +652,12 @@ int cros_ec_vstore_read(struct udevice *dev, int slot, uint8_t *data);
 int cros_ec_vstore_write(struct udevice *dev, int slot, const uint8_t *data,
 			 size_t size);
 
+/**
+ * cros_ec_read_batt_charge() - Read the battery-charge state
+ *
+ * @dev: CROS-EC device
+ * @chargep: Return battery-charge state as a percentage
+ */
+int cros_ec_read_batt_charge(struct udevice *dev, uint *chargep);
+
 #endif
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 12/22] cros_ec: Drop cros_ec_entering_mode()
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (10 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 11/22] cros_ec: Allow reading the battery-charge state Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 13/22] cros_ec: Support the full-size vboot context Simon Glass
                   ` (29 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Alper Nebi Yasak, Andy Shevchenko,
	Heinrich Schuchardt, Walter Lozano

This function is not needed anymore. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec.c         | 11 -----------
 drivers/misc/cros_ec_sandbox.c |  3 ---
 include/cros_ec.h              |  9 ---------
 3 files changed, 23 deletions(-)

diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index 0818ef8ad6e..2a15094d20a 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -754,17 +754,6 @@ int cros_ec_flash_protect(struct udevice *dev, uint32_t set_mask,
 	return 0;
 }
 
-int cros_ec_entering_mode(struct udevice *dev, int mode)
-{
-	int rc;
-
-	rc = ec_command(dev, EC_CMD_ENTERING_MODE, 0, &mode, sizeof(mode),
-			NULL, 0);
-	if (rc)
-		return -1;
-	return 0;
-}
-
 static int cros_ec_check_version(struct udevice *dev)
 {
 	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index db5e3b0f51a..35e9f4eff44 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -494,9 +494,6 @@ static int process_cmd(struct ec_state *ec,
 	case EC_CMD_MKBP_STATE:
 		len = cros_ec_keyscan(ec, resp_data);
 		break;
-	case EC_CMD_ENTERING_MODE:
-		len = 0;
-		break;
 	case EC_CMD_GET_NEXT_EVENT: {
 		struct ec_response_get_next_event *resp = resp_data;
 
diff --git a/include/cros_ec.h b/include/cros_ec.h
index 9dab6cdf9ba..ef89deff762 100644
--- a/include/cros_ec.h
+++ b/include/cros_ec.h
@@ -198,15 +198,6 @@ int cros_ec_flash_protect(struct udevice *dev, uint32_t set_mask,
 			  uint32_t set_flags,
 			  struct ec_response_flash_protect *resp);
 
-/**
- * Notify EC of current boot mode
- *
- * @param dev		CROS-EC device
- * @param vboot_mode    Verified boot mode
- * @return 0 if ok, <0 on error
- */
-int cros_ec_entering_mode(struct udevice *dev, int mode);
-
 /**
  * Run internal tests on the cros_ec interface.
  *
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 13/22] cros_ec: Support the full-size vboot context
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (11 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 12/22] cros_ec: Drop cros_ec_entering_mode() Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 14/22] cros_ec: Use standard calls for recovery-request checking Simon Glass
                   ` (28 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Alper Nebi Yasak, Andy Shevchenko,
	Heinrich Schuchardt, Pratyush Yadav, Walter Lozano

The v2 format is 64-bytes in size. Support this and drop v1 since it is
not used anymore.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec_sandbox.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index 35e9f4eff44..6a95a9132a6 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -341,15 +341,13 @@ static int process_cmd(struct ec_state *ec,
 
 		switch (req->op) {
 		case EC_VBNV_CONTEXT_OP_READ:
-			/* TODO(sjg@chromium.org): Support full-size context */
 			memcpy(resp->block, ec->vbnv_context,
-			       EC_VBNV_BLOCK_SIZE);
-			len = 16;
+			       EC_VBNV_BLOCK_SIZE_V2);
+			len = EC_VBNV_BLOCK_SIZE_V2;
 			break;
 		case EC_VBNV_CONTEXT_OP_WRITE:
-			/* TODO(sjg@chromium.org): Support full-size context */
 			memcpy(ec->vbnv_context, req->block,
-			       EC_VBNV_BLOCK_SIZE);
+			       EC_VBNV_BLOCK_SIZE_V2);
 			len = 0;
 			break;
 		default:
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 14/22] cros_ec: Use standard calls for recovery-request checking
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (12 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 13/22] cros_ec: Support the full-size vboot context Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 15/22] bloblist: Support resizing a blob Simon Glass
                   ` (27 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Alper Nebi Yasak, Andy Shevchenko,
	Heinrich Schuchardt, Pratyush Yadav, Walter Lozano

Rather than calling directly into the sandbox SDL code, we can use the
normal U-Boot console handling for this feature. Update the code, to make
it more generic.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec_sandbox.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index 6a95a9132a6..17fca0f9f00 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -622,15 +622,19 @@ void cros_ec_check_keyboard(struct udevice *dev)
 	struct ec_state *ec = dev_get_priv(dev);
 	ulong start;
 
-	printf("Press keys for EC to detect on reset (ESC=recovery)...");
+	printf("\nPress keys for EC to detect on reset (ESC=recovery)...");
 	start = get_timer(0);
-	while (get_timer(start) < 1000)
-		;
-	putc('\n');
-	if (!sandbox_sdl_key_pressed(KEY_ESC)) {
-		ec->recovery_req = true;
-		printf("   - EC requests recovery\n");
+	while (get_timer(start) < 2000) {
+		if (tstc()) {
+			int ch = getchar();
+
+			if (ch == 0x1b) {
+				ec->recovery_req = true;
+				printf("EC requests recovery");
+			}
+		}
 	}
+	putc('\n');
 }
 
 /* Return the byte of EC switch states */
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 15/22] bloblist: Support resizing a blob
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (13 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 14/22] cros_ec: Use standard calls for recovery-request checking Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 16/22] bloblist: Tidy up a few API comments Simon Glass
                   ` (26 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Bin Meng

Sometimes a blob needs to expand, e.g. because it needs to hold more log
data. Add support for this. Note that the bloblist must have sufficient
spare space for this to work.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/bloblist.c  |  71 ++++++++++++++++-
 include/bloblist.h |  13 +++
 test/bloblist.c    | 192 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 274 insertions(+), 2 deletions(-)

diff --git a/common/bloblist.c b/common/bloblist.c
index eab63e9ca51..bb49ecab92e 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -57,13 +57,22 @@ static struct bloblist_rec *bloblist_first_blob(struct bloblist_hdr *hdr)
 	return (struct bloblist_rec *)((void *)hdr + hdr->hdr_size);
 }
 
-static struct bloblist_rec *bloblist_next_blob(struct bloblist_hdr *hdr,
-					       struct bloblist_rec *rec)
+static ulong bloblist_blob_end_ofs(struct bloblist_hdr *hdr,
+				   struct bloblist_rec *rec)
 {
 	ulong offset;
 
 	offset = (void *)rec - (void *)hdr;
 	offset += rec->hdr_size + ALIGN(rec->size, BLOBLIST_ALIGN);
+
+	return offset;
+}
+
+static struct bloblist_rec *bloblist_next_blob(struct bloblist_hdr *hdr,
+					       struct bloblist_rec *rec)
+{
+	ulong offset = bloblist_blob_end_ofs(hdr, rec);
+
 	if (offset >= hdr->alloced)
 		return NULL;
 	return (struct bloblist_rec *)((void *)hdr + offset);
@@ -215,6 +224,64 @@ int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp)
 	return 0;
 }
 
+static int bloblist_resize_rec(struct bloblist_hdr *hdr,
+			       struct bloblist_rec *rec,
+			       int new_size)
+{
+	int expand_by;	/* Number of bytes to expand by (-ve to contract) */
+	int new_alloced;	/* New value for @hdr->alloced */
+	ulong next_ofs;	/* Offset of the record after @rec */
+
+	expand_by = ALIGN(new_size - rec->size, BLOBLIST_ALIGN);
+	new_alloced = ALIGN(hdr->alloced + expand_by, BLOBLIST_ALIGN);
+	if (new_size < 0) {
+		log(LOGC_BLOBLIST, LOGL_DEBUG,
+		    "Attempt to shrink blob size below 0 (%x)\n", new_size);
+		return log_msg_ret("size", -EINVAL);
+	}
+	if (new_alloced > hdr->size) {
+		log(LOGC_BLOBLIST, LOGL_ERR,
+		    "Failed to allocate %x bytes size=%x, need size=%x\n",
+		    new_size, hdr->size, new_alloced);
+		return log_msg_ret("alloc", -ENOSPC);
+	}
+
+	/* Move the following blobs up or down, if this is not the last */
+	next_ofs = bloblist_blob_end_ofs(hdr, rec);
+	if (next_ofs != hdr->alloced) {
+		memmove((void *)hdr + next_ofs + expand_by,
+			(void *)hdr + next_ofs, new_alloced - next_ofs);
+	}
+	hdr->alloced = new_alloced;
+
+	/* Zero the new part of the blob */
+	if (expand_by > 0) {
+		memset((void *)rec + rec->hdr_size + rec->size, '\0',
+		       new_size - rec->size);
+	}
+
+	/* Update the size of this blob */
+	rec->size = new_size;
+
+	return 0;
+}
+
+int bloblist_resize(uint tag, int new_size)
+{
+	struct bloblist_hdr *hdr = gd->bloblist;
+	struct bloblist_rec *rec;
+	int ret;
+
+	rec = bloblist_findrec(tag);
+	if (!rec)
+		return log_msg_ret("find", -ENOENT);
+	ret = bloblist_resize_rec(hdr, rec, new_size);
+	if (ret)
+		return log_msg_ret("resize", ret);
+
+	return 0;
+}
+
 static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr)
 {
 	struct bloblist_rec *rec;
diff --git a/include/bloblist.h b/include/bloblist.h
index 964b974fdaf..b659d2bc93d 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -179,6 +179,19 @@ void *bloblist_ensure(uint tag, int size);
  */
 int bloblist_ensure_size_ret(uint tag, int *sizep, void **blobp);
 
+/**
+ * bloblist_resize() - resize a blob
+ *
+ * Any blobs above this one are relocated up or down. The resized blob remains
+ * in the same place.
+ *
+ * @tag:	Tag to add (enum bloblist_tag_t)
+ * @new_size:	New size of the blob (>0 to expand, <0 to contract)
+ * @return 0 if OK, -ENOSPC if the bloblist does not have enough space, -ENOENT
+ *	if the tag is not found
+ */
+int bloblist_resize(uint tag, int new_size);
+
 /**
  * bloblist_new() - Create a new, empty bloblist of a given size
  *
diff --git a/test/bloblist.c b/test/bloblist.c
index d876b639184..345eb181fff 100644
--- a/test/bloblist.c
+++ b/test/bloblist.c
@@ -33,6 +33,9 @@ enum {
 	ERASE_BYTE		= '\xff',
 };
 
+static const char test1_str[] = "the eyes are open";
+static const char test2_str[] = "the mouth moves";
+
 static struct bloblist_hdr *clear_bloblist(void)
 {
 	struct bloblist_hdr *hdr;
@@ -384,6 +387,195 @@ static int bloblist_test_reloc(struct unit_test_state *uts)
 }
 BLOBLIST_TEST(bloblist_test_reloc, 0);
 
+/* Test expansion of a blob */
+static int bloblist_test_grow(struct unit_test_state *uts)
+{
+	const uint small_size = 0x20;
+	void *blob1, *blob2, *blob1_new;
+	struct bloblist_hdr *hdr;
+	void *ptr;
+
+	ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE);
+	hdr = ptr;
+	memset(hdr, ERASE_BYTE, TEST_BLOBLIST_SIZE);
+
+	/* Create two blobs */
+	ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
+	blob1 = bloblist_add(TEST_TAG, small_size, 0);
+	ut_assertnonnull(blob1);
+	ut_assertok(check_zero(blob1, small_size));
+	strcpy(blob1, test1_str);
+
+	blob2 = bloblist_add(TEST_TAG2, small_size, 0);
+	ut_assertnonnull(blob2);
+	strcpy(blob2, test2_str);
+
+	ut_asserteq(sizeof(struct bloblist_hdr) +
+		    sizeof(struct bloblist_rec) * 2 + small_size * 2,
+		    hdr->alloced);
+
+	/* Resize the first one */
+	ut_assertok(bloblist_resize(TEST_TAG, small_size + 4));
+
+	/* The first one should not have moved, just got larger */
+	blob1_new = bloblist_find(TEST_TAG, small_size + 4);
+	ut_asserteq_ptr(blob1, blob1_new);
+
+	/* The new space should be zeroed */
+	ut_assertok(check_zero(blob1 + small_size, 4));
+
+	/* The second one should have moved */
+	blob2 = bloblist_find(TEST_TAG2, small_size);
+	ut_assertnonnull(blob2);
+	ut_asserteq_str(test2_str, blob2);
+
+	/* The header should have more bytes in use */
+	hdr = ptr;
+	ut_asserteq(sizeof(struct bloblist_hdr) +
+		    sizeof(struct bloblist_rec) * 2 + small_size * 2 +
+		    BLOBLIST_ALIGN,
+		    hdr->alloced);
+
+	return 0;
+}
+BLOBLIST_TEST(bloblist_test_grow, 0);
+
+/* Test shrinking of a blob */
+static int bloblist_test_shrink(struct unit_test_state *uts)
+{
+	const uint small_size = 0x20;
+	void *blob1, *blob2, *blob1_new;
+	struct bloblist_hdr *hdr;
+	int new_size;
+	void *ptr;
+
+	ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE);
+
+	/* Create two blobs */
+	ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
+	blob1 = bloblist_add(TEST_TAG, small_size, 0);
+	ut_assertnonnull(blob1);
+	strcpy(blob1, test1_str);
+
+	blob2 = bloblist_add(TEST_TAG2, small_size, 0);
+	ut_assertnonnull(blob2);
+	strcpy(blob2, test2_str);
+
+	hdr = ptr;
+	ut_asserteq(sizeof(struct bloblist_hdr) +
+		    sizeof(struct bloblist_rec) * 2 + small_size * 2,
+		    hdr->alloced);
+
+	/* Resize the first one */
+	new_size = small_size - BLOBLIST_ALIGN - 4;
+	ut_assertok(bloblist_resize(TEST_TAG, new_size));
+
+	/* The first one should not have moved, just got smaller */
+	blob1_new = bloblist_find(TEST_TAG, new_size);
+	ut_asserteq_ptr(blob1, blob1_new);
+
+	/* The second one should have moved */
+	blob2 = bloblist_find(TEST_TAG2, small_size);
+	ut_assertnonnull(blob2);
+	ut_asserteq_str(test2_str, blob2);
+
+	/* The header should have fewer bytes in use */
+	hdr = ptr;
+	ut_asserteq(sizeof(struct bloblist_hdr) +
+		    sizeof(struct bloblist_rec) * 2 + small_size * 2 -
+		    BLOBLIST_ALIGN,
+		    hdr->alloced);
+
+	return 0;
+}
+BLOBLIST_TEST(bloblist_test_shrink, 0);
+
+/* Test failing to adjust a blob size */
+static int bloblist_test_resize_fail(struct unit_test_state *uts)
+{
+	const uint small_size = 0x20;
+	struct bloblist_hdr *hdr;
+	void *blob1, *blob2;
+	int new_size;
+	void *ptr;
+
+	ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE);
+
+	/* Create two blobs */
+	ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
+	blob1 = bloblist_add(TEST_TAG, small_size, 0);
+	ut_assertnonnull(blob1);
+
+	blob2 = bloblist_add(TEST_TAG2, small_size, 0);
+	ut_assertnonnull(blob2);
+
+	hdr = ptr;
+	ut_asserteq(sizeof(struct bloblist_hdr) +
+		    sizeof(struct bloblist_rec) * 2 + small_size * 2,
+		    hdr->alloced);
+
+	/* Resize the first one, to check the boundary conditions */
+	ut_asserteq(-EINVAL, bloblist_resize(TEST_TAG, -1));
+
+	new_size = small_size + (hdr->size - hdr->alloced);
+	ut_asserteq(-ENOSPC, bloblist_resize(TEST_TAG, new_size + 1));
+	ut_assertok(bloblist_resize(TEST_TAG, new_size));
+
+	return 0;
+}
+BLOBLIST_TEST(bloblist_test_resize_fail, 0);
+
+/* Test expanding the last blob in a bloblist */
+static int bloblist_test_resize_last(struct unit_test_state *uts)
+{
+	const uint small_size = 0x20;
+	struct bloblist_hdr *hdr;
+	void *blob1, *blob2, *blob2_new;
+	int alloced_val;
+	void *ptr;
+
+	ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE);
+	memset(ptr, ERASE_BYTE, TEST_BLOBLIST_SIZE);
+	hdr = ptr;
+
+	/* Create two blobs */
+	ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
+	blob1 = bloblist_add(TEST_TAG, small_size, 0);
+	ut_assertnonnull(blob1);
+
+	blob2 = bloblist_add(TEST_TAG2, small_size, 0);
+	ut_assertnonnull(blob2);
+
+	/* Check the byte after the last blob */
+	alloced_val = sizeof(struct bloblist_hdr) +
+		    sizeof(struct bloblist_rec) * 2 + small_size * 2;
+	ut_asserteq(alloced_val, hdr->alloced);
+	ut_asserteq_ptr((void *)hdr + alloced_val, blob2 + small_size);
+	ut_asserteq((u8)ERASE_BYTE, *((u8 *)hdr + hdr->alloced));
+
+	/* Resize the second one, checking nothing changes */
+	ut_asserteq(0, bloblist_resize(TEST_TAG2, small_size + 4));
+
+	blob2_new = bloblist_find(TEST_TAG2, small_size + 4);
+	ut_asserteq_ptr(blob2, blob2_new);
+
+	/*
+	 * the new blob should encompass the byte we checked now, so it should
+	 * be zeroed. This zeroing should affect only the four new bytes added
+	 * to the blob.
+	 */
+	ut_asserteq(0, *((u8 *)hdr + alloced_val));
+	ut_asserteq((u8)ERASE_BYTE, *((u8 *)hdr + alloced_val + 4));
+
+	/* Check that the new top of the allocated blobs has not been touched */
+	alloced_val += BLOBLIST_ALIGN;
+	ut_asserteq(alloced_val, hdr->alloced);
+	ut_asserteq((u8)ERASE_BYTE, *((u8 *)hdr + hdr->alloced));
+
+	return 0;
+}
+BLOBLIST_TEST(bloblist_test_resize_last, 0);
+
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
 		   char *const argv[])
 {
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 16/22] bloblist: Tidy up a few API comments
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (14 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 15/22] bloblist: Support resizing a blob Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 17/22] bloblist: Correct condition in bloblist_addrec() Simon Glass
                   ` (25 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass, Bin Meng

Some comments for struct bloblist_hdr are a bit ambiguous. Update them to
clarify the meaning more precisely. Also document bloblist_get_stats()
properly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/bloblist.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/include/bloblist.h b/include/bloblist.h
index b659d2bc93d..9f007c7a94d 100644
--- a/include/bloblist.h
+++ b/include/bloblist.h
@@ -64,10 +64,10 @@ enum bloblist_tag_t {
  *	first bloblist_rec starts at this offset from the start of the header
  * @flags: Space for BLOBLISTF_... flags (none yet)
  * @magic: BLOBLIST_MAGIC
- * @size: Total size of all records (non-zero if valid) including this header.
+ * @size: Total size of the bloblist (non-zero if valid) including this header.
  *	The bloblist extends for this many bytes from the start of this header.
- * @alloced: Total size allocated for this bloblist. When adding new records,
- *	the bloblist can grow up to this size. This starts out as
+ *	When adding new records, the bloblist can grow up to this size.
+ * @alloced: Total size allocated so far for this bloblist. This starts out as
  *	sizeof(bloblist_hdr) since we need at least that much space to store a
  *	valid bloblist
  * @spare: Spare space (for future use)
@@ -230,6 +230,10 @@ int bloblist_finish(void);
  * bloblist_get_stats() - Get information about the bloblist
  *
  * This returns useful information about the bloblist
+ *
+ * @basep: Returns base address of bloblist
+ * @sizep: Returns the number of bytes used in the bloblist
+ * @allocedp: Returns the total space allocated to the bloblist
  */
 void bloblist_get_stats(ulong *basep, ulong *sizep, ulong *allocedp);
 
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 17/22] bloblist: Correct condition in bloblist_addrec()
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (15 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 16/22] bloblist: Tidy up a few API comments Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 18/22] image: Allow @ in node names when not using signatures Simon Glass
                   ` (24 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List; +Cc: Simon Glass

It is possible to add a blob that ends at the end of the bloblist, but at
present this is not supported. Fix it and add a regression test for this
case.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/bloblist.c |  2 +-
 test/bloblist.c   | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/common/bloblist.c b/common/bloblist.c
index bb49ecab92e..1290fff8504 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -118,7 +118,7 @@ static int bloblist_addrec(uint tag, int size, int align,
 	/* Calculate the new allocated total */
 	new_alloced = data_start + ALIGN(size, align);
 
-	if (new_alloced >= hdr->size) {
+	if (new_alloced > hdr->size) {
 		log(LOGC_BLOBLIST, LOGL_ERR,
 		    "Failed to allocate %x bytes size=%x, need size=%x\n",
 		    size, hdr->size, new_alloced);
diff --git a/test/bloblist.c b/test/bloblist.c
index 345eb181fff..4104e6a92f6 100644
--- a/test/bloblist.c
+++ b/test/bloblist.c
@@ -576,6 +576,29 @@ static int bloblist_test_resize_last(struct unit_test_state *uts)
 }
 BLOBLIST_TEST(bloblist_test_resize_last, 0);
 
+/* Check a completely full bloblist */
+static int bloblist_test_blob_maxsize(struct unit_test_state *uts)
+{
+	void *ptr;
+	int size;
+
+	/* At the start there should be no records */
+	clear_bloblist();
+	ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0));
+
+	/* Add a blob that takes up all space */
+	size = TEST_BLOBLIST_SIZE - sizeof(struct bloblist_hdr) -
+		sizeof(struct bloblist_rec);
+	ptr = bloblist_add(TEST_TAG, size, 0);
+	ut_assertnonnull(ptr);
+
+	ptr = bloblist_add(TEST_TAG, size + 1, 0);
+	ut_assertnull(ptr);
+
+	return 0;
+}
+BLOBLIST_TEST(bloblist_test_blob_maxsize, 0);
+
 int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc,
 		   char *const argv[])
 {
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 18/22] image: Allow @ in node names when not using signatures
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (16 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 17/22] bloblist: Correct condition in bloblist_addrec() Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-17 20:40   ` Simon Glass
  2021-07-05 22:32 ` [PATCH 19/22] spl: Provide more information on boot failure Simon Glass
                   ` (23 subsequent siblings)
  41 siblings, 1 reply; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Alexandru Gagniuc, Joe Hershberger, Joel Stanley,
	Lokesh Vutla, Marek Vasut, Mark Kettenis, Michal Simek,
	Sebastian Reichel

If signature verification is not in use we don't need to worry about
the risk of using @ in node names. Update fit_image_verify() to allow
it if the function is not enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/image-fit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/image-fit.c b/common/image-fit.c
index 0c5a05948d1..617375bfe1d 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1376,7 +1376,7 @@ int fit_image_verify(const void *fit, int image_noffset)
 	size_t		size;
 	char		*err_msg = "";
 
-	if (strchr(name, '@')) {
+	if (IS_ENABLED(CONFIG_FIT_SIGNATURE) && strchr(name, '@')) {
 		/*
 		 * We don't support this since libfdt considers names with the
 		 * name root but different @ suffix to be equal
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 19/22] spl: Provide more information on boot failure
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (17 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 18/22] image: Allow @ in node names when not using signatures Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:32 ` [PATCH 20/22] sandbox: mmc: Support fixed MMC devices Simon Glass
                   ` (22 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Adam Ford, Alexandru Gagniuc, Andre Przywara,
	Dario Binacchi, Faiz Abbas, Masahiro Yamada, Michael Walle,
	Michal Simek, Otavio Salvador, Ovidiu Panait, Peng Fan,
	Philippe Reynes, Samuel Holland, Stefan Roese

If SPL fails to boot, try to provide an error code to indicate what is
wrong. For example, if a uclass is missing, this can return -EPFNOSUPPORT
(-96) which provides useful information.

Add a helper for accessing the image-loader name so we can drop the use
of #ifdefs in this code.

Put this feature behind a CONFIG_SHOW_ERRORS option to avoid increasing
the code size.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/spl/Kconfig | 10 ++++++++++
 common/spl/spl.c   | 48 ++++++++++++++++++++++++++++++----------------
 include/spl.h      | 10 ++++++++++
 3 files changed, 52 insertions(+), 16 deletions(-)

diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 1de9b912c3f..26c0ab58531 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -94,6 +94,16 @@ config SPL_SYS_REPORT_STACK_F_USAGE
 	  occurrence of non 0xaa bytes.
 	  This default implementation works for stacks growing down only.
 
+config SPL_SHOW_ERRORS
+	bool "Show more information when something goes wrong"
+	help
+	  This enabled more verbose error messages and checking when something
+	  goes wrong in SPL. For example, it shows the error code when U-Boot
+	  cannot be located. This can help to diagnose the problem and figure
+	  out a fix, particularly during development.
+
+	  This adds a small amount to SPL code size, perhaps 100 bytes.
+
 menu "PowerPC and LayerScape SPL Boot options"
 
 config SPL_NAND_BOOT
diff --git a/common/spl/spl.c b/common/spl/spl.c
index cd428c1cbc9..6fe6483f7f4 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -610,32 +610,42 @@ static int spl_load_image(struct spl_image_info *spl_image,
  * @spl_image: Place to put the image details if successful
  * @spl_boot_list: List of boot devices to try
  * @count: Number of elements in spl_boot_list
- * @return 0 if OK, -ve on error
+ * @return 0 if OK, -ENODEV if there were no boot devices
+ *	if CONFIG_SHOW_ERRORS is enabled, returns -ENXIO if there were
+ *	devices but none worked
  */
 static int boot_from_devices(struct spl_image_info *spl_image,
 			     u32 spl_boot_list[], int count)
 {
+	int ret = -ENODEV;
 	int i;
 
 	for (i = 0; i < count && spl_boot_list[i] != BOOT_DEVICE_NONE; i++) {
 		struct spl_image_loader *loader;
-
-		loader = spl_ll_find_loader(spl_boot_list[i]);
-#if defined(CONFIG_SPL_SERIAL_SUPPORT) \
-    && defined(CONFIG_SPL_LIBCOMMON_SUPPORT)    \
-    && !defined(CONFIG_SILENT_CONSOLE)
-		if (loader)
-			printf("Trying to boot from %s\n", loader->name);
-		else
-			puts(SPL_TPL_PROMPT "Unsupported Boot Device!\n");
-#endif
+		int bootdev = spl_boot_list[i];
+
+		if (CONFIG_IS_ENABLED(SHOW_ERRORS))
+			ret = -ENXIO;
+		loader = spl_ll_find_loader(bootdev);
+		if (CONFIG_IS_ENABLED(SERIAL_SUPPORT) &&
+		    CONFIG_IS_ENABLED(LIBCOMMON_SUPPORT) &&
+		    !IS_ENABLED(CONFIG_SILENT_CONSOLE)) {
+			if (loader)
+				printf("Trying to boot from %s\n",
+				       spl_loader_name(loader));
+			else if (CONFIG_IS_ENABLED(SHOW_ERRORS))
+				printf(SPL_TPL_PROMPT
+				       "Unsupported Boot Device %d\n", bootdev);
+			else
+				puts(SPL_TPL_PROMPT "Unsupported Boot Device!\n");
+		}
 		if (loader && !spl_load_image(spl_image, loader)) {
-			spl_image->boot_device = spl_boot_list[i];
+			spl_image->boot_device = bootdev;
 			return 0;
 		}
 	}
 
-	return -ENODEV;
+	return ret;
 }
 
 #if defined(CONFIG_SPL_FRAMEWORK_BOARD_INIT_F)
@@ -727,9 +737,15 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 	spl_image.boot_device = BOOT_DEVICE_NONE;
 	board_boot_order(spl_boot_list);
 
-	if (boot_from_devices(&spl_image, spl_boot_list,
-			      ARRAY_SIZE(spl_boot_list))) {
-		puts(SPL_TPL_PROMPT "failed to boot from all boot devices\n");
+	ret = boot_from_devices(&spl_image, spl_boot_list,
+				ARRAY_SIZE(spl_boot_list));
+	if (ret) {
+		if (CONFIG_IS_ENABLED(SHOW_ERRORS) &&
+		    CONFIG_IS_ENABLED(LIBCOMMON_SUPPORT))
+			printf(SPL_TPL_PROMPT "failed to boot from all boot devices (err=%d)\n",
+			       ret);
+		else
+			puts(SPL_TPL_PROMPT "failed to boot from all boot devices\n");
 		hang();
 	}
 
diff --git a/include/spl.h b/include/spl.h
index cf77d379da2..8359dffd212 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -498,6 +498,16 @@ struct spl_image_loader {
 			  struct spl_boot_device *bootdev);
 };
 
+/* Helper function for accessing the name */
+static inline const char *spl_loader_name(const struct spl_image_loader *loader)
+{
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+	return loader->name;
+#else
+	return NULL;
+#endif
+}
+
 /* Declare an SPL image loader */
 #define SPL_LOAD_IMAGE(__name)					\
 	ll_entry_declare(struct spl_image_loader, __name, spl_image_loader)
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 20/22] sandbox: mmc: Support fixed MMC devices
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (18 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 19/22] spl: Provide more information on boot failure Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-06  1:12   ` Jaehoon Chung
  2021-07-17 20:39   ` Simon Glass
  2021-07-05 22:32 ` [PATCH 21/22] blk: Support iteration Simon Glass
                   ` (21 subsequent siblings)
  41 siblings, 2 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Bin Meng, Claudiu Manoil, Dario Binacchi,
	Etienne Carriere, Jaehoon Chung, Jean-Jacques Hiblot,
	Michael Walle, Peng Fan, Sean Anderson, Wolfgang Wallner

Add support for reading devicetree flags for MMC devices. With this we
can distinguish between fixed and removable drives. Note that this
information is only available when the device is probed, not when it is
bound, since it is read in the of_to_plat() method. This could be changed
if needed later.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/dts/test.dts |  1 +
 drivers/mmc/sandbox_mmc.c | 24 +++++++++++++++++++++---
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
index d85bb46ceba..0cee15a0ea2 100644
--- a/arch/sandbox/dts/test.dts
+++ b/arch/sandbox/dts/test.dts
@@ -819,6 +819,7 @@
 
 	mmc2 {
 		compatible = "sandbox,mmc";
+		non-removable;
 	};
 
 	mmc1 {
diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c
index 18ba020aacc..895fbffecfc 100644
--- a/drivers/mmc/sandbox_mmc.c
+++ b/drivers/mmc/sandbox_mmc.c
@@ -136,14 +136,31 @@ static const struct dm_mmc_ops sandbox_mmc_ops = {
 	.get_cd = sandbox_mmc_get_cd,
 };
 
-int sandbox_mmc_probe(struct udevice *dev)
+static int sandbox_mmc_of_to_plat(struct udevice *dev)
+{
+	struct sandbox_mmc_plat *plat = dev_get_plat(dev);
+	struct mmc_config *cfg = &plat->cfg;
+	struct blk_desc *blk;
+	int ret;
+
+	ret = mmc_of_parse(dev, cfg);
+	if (ret)
+		return ret;
+	blk = mmc_get_blk_desc(&plat->mmc);
+	if (blk)
+		blk->removable = !(cfg->host_caps & MMC_CAP_NONREMOVABLE);
+
+	return 0;
+}
+
+static int sandbox_mmc_probe(struct udevice *dev)
 {
 	struct sandbox_mmc_plat *plat = dev_get_plat(dev);
 
 	return mmc_init(&plat->mmc);
 }
 
-int sandbox_mmc_bind(struct udevice *dev)
+static int sandbox_mmc_bind(struct udevice *dev)
 {
 	struct sandbox_mmc_plat *plat = dev_get_plat(dev);
 	struct mmc_config *cfg = &plat->cfg;
@@ -158,7 +175,7 @@ int sandbox_mmc_bind(struct udevice *dev)
 	return mmc_bind(dev, &plat->mmc, cfg);
 }
 
-int sandbox_mmc_unbind(struct udevice *dev)
+static int sandbox_mmc_unbind(struct udevice *dev)
 {
 	mmc_unbind(dev);
 
@@ -177,6 +194,7 @@ U_BOOT_DRIVER(mmc_sandbox) = {
 	.ops		= &sandbox_mmc_ops,
 	.bind		= sandbox_mmc_bind,
 	.unbind		= sandbox_mmc_unbind,
+	.of_to_plat	= sandbox_mmc_of_to_plat,
 	.probe		= sandbox_mmc_probe,
 	.priv_auto = sizeof(struct sandbox_mmc_priv),
 	.plat_auto = sizeof(struct sandbox_mmc_plat),
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 21/22] blk: Support iteration
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (19 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 20/22] sandbox: mmc: Support fixed MMC devices Simon Glass
@ 2021-07-05 22:32 ` Simon Glass
  2021-07-05 22:33 ` [PATCH 22/22] log: Allow padding of the function name Simon Glass
                   ` (20 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:32 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, Anastasiia Lukianenko, Andrii Anisov,
	Oleksandr Andrushchenko, Ovidiu Panait, Patrick Delaunay

It is useful to be able to iterate over block devices. Typically there
are fixed and removable devices. For security reasons it is sometimes
useful to ignore removable devices since they are under user control.

Add iterators which support selecting the block-device type.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/block/blk-uclass.c | 49 +++++++++++++++++++++++++++++++++
 include/blk.h              | 56 ++++++++++++++++++++++++++++++++++++++
 test/dm/blk.c              | 55 +++++++++++++++++++++++++++++++++++++
 3 files changed, 160 insertions(+)

diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c
index dfc0d469702..83682dcc181 100644
--- a/drivers/block/blk-uclass.c
+++ b/drivers/block/blk-uclass.c
@@ -540,6 +540,55 @@ int blk_next_free_devnum(enum if_type if_type)
 	return ret + 1;
 }
 
+static int blk_flags_check(struct udevice *dev, enum blk_flag_t req_flags)
+{
+	const struct blk_desc *desc = dev_get_uclass_plat(dev);
+	enum blk_flag_t flags;
+
+	flags = desc->removable ? BLKF_REMOVABLE : BLKF_FIXED;
+
+	return flags & req_flags ? 0 : 1;
+}
+
+int blk_first_device_err(enum blk_flag_t flags, struct udevice **devp)
+{
+	int ret;
+
+	for (ret = uclass_first_device_err(UCLASS_BLK, devp);
+	     !ret;
+	     ret = uclass_next_device_err(devp)) {
+		if (!blk_flags_check(*devp, flags))
+			return 0;
+	}
+
+	return -ENODEV;
+}
+
+int blk_next_device_err(enum blk_flag_t flags, struct udevice **devp)
+{
+	int ret;
+
+	for (ret = uclass_next_device_err(devp);
+	     !ret;
+	     ret = uclass_next_device_err(devp)) {
+		if (!blk_flags_check(*devp, flags))
+			return 0;
+	}
+
+	return -ENODEV;
+}
+
+int blk_count_devices(enum blk_flag_t flag)
+{
+	struct udevice *dev;
+	int count = 0;
+
+	blk_foreach_probe(flag, dev)
+		count++;
+
+	return count;
+}
+
 static int blk_claim_devnum(enum if_type if_type, int devnum)
 {
 	struct udevice *dev;
diff --git a/include/blk.h b/include/blk.h
index c4401b00253..19bab081c2c 100644
--- a/include/blk.h
+++ b/include/blk.h
@@ -19,6 +19,8 @@ typedef ulong lbaint_t;
 #define LBAF "%" LBAFlength "x"
 #define LBAFU "%" LBAFlength "u"
 
+struct udevice;
+
 /* Interface types: */
 enum if_type {
 	IF_TYPE_UNKNOWN = 0,
@@ -683,4 +685,58 @@ const char *blk_get_if_type_name(enum if_type if_type);
 int blk_common_cmd(int argc, char *const argv[], enum if_type if_type,
 		   int *cur_devnump);
 
+enum blk_flag_t {
+	BLKF_FIXED	= 1 << 0,
+	BLKF_REMOVABLE	= 1 << 1,
+	BLKF_BOTH	= BLKF_FIXED | BLKF_REMOVABLE,
+};
+
+/**
+ * blk_first_device_err() - Get the first block device
+ *
+ * The device returned is probed if necessary, and ready for use
+ *
+ * @flags: Indicates type of device to return
+ * @devp: Returns pointer to the first device in that uclass, or NULL if none
+ * @return 0 if found, -ENODEV if not found, other -ve on error
+ */
+int blk_first_device_err(enum blk_flag_t flags, struct udevice **devp);
+
+/**
+ * blk_next_device_err() - Get the next block device
+ *
+ * The device returned is probed if necessary, and ready for use
+ *
+ * @flags: Indicates type of device to return
+ * @devp: On entry, pointer to device to lookup. On exit, returns pointer
+ * to the next device in the uclass if no error occurred, or -ENODEV if
+ * there is no next device.
+ * @return 0 if found, -ENODEV if not found, other -ve on error
+ */
+int blk_next_device_err(enum blk_flag_t flags, struct udevice **devp);
+
+/**
+ * blk_foreach_probe() - Helper function to iteration through block devices
+ *
+ * This creates a for() loop which works through the available devices in
+ * a uclass in order from start to end. Devices are probed if necessary,
+ * and ready for use.
+ *
+ * @flags: Indicates type of device to return
+ * @dev: struct udevice * to hold the current device. Set to NULL when there
+ * are no more devices.
+ */
+#define blk_foreach_probe(flags, pos)	\
+	for (int _ret = blk_first_device_err(flags, &(pos)); \
+	     !_ret && pos; \
+	     _ret = blk_next_device_err(flags, &(pos)))
+
+/**
+ * blk_count_devices() - count the number of devices of a particular type
+ *
+ * @flags: Indicates type of device to find
+ * @return number of devices matching those flags
+ */
+int blk_count_devices(enum blk_flag_t flag);
+
 #endif
diff --git a/test/dm/blk.c b/test/dm/blk.c
index b7f4304e9e9..deccf05289b 100644
--- a/test/dm/blk.c
+++ b/test/dm/blk.c
@@ -162,3 +162,58 @@ static int dm_test_blk_get_from_parent(struct unit_test_state *uts)
 	return 0;
 }
 DM_TEST(dm_test_blk_get_from_parent, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
+
+/* Test iteration through block devices */
+static int dm_test_blk_iter(struct unit_test_state *uts)
+{
+	struct udevice *dev;
+	int i;
+
+	/*
+	 * See sandbox test.dts - it has:
+	 *
+	 *   mmc0 - removable
+	 *   mmc1 - removable
+	 *   mmc2 - fixed
+	 */
+	ut_assertok(blk_first_device_err(BLKF_FIXED, &dev));
+	ut_asserteq_str("mmc2.blk", dev->name);
+	ut_asserteq(-ENODEV, blk_next_device_err(BLKF_FIXED, &dev));
+
+	ut_assertok(blk_first_device_err(BLKF_REMOVABLE, &dev));
+	ut_asserteq_str("mmc1.blk", dev->name);
+	ut_assertok(blk_next_device_err(BLKF_REMOVABLE, &dev));
+	ut_asserteq_str("mmc0.blk", dev->name);
+	ut_asserteq(-ENODEV, blk_next_device_err(BLKF_REMOVABLE, &dev));
+
+	ut_assertok(blk_first_device_err(BLKF_BOTH, &dev));
+	ut_asserteq_str("mmc2.blk", dev->name);
+	ut_assertok(blk_next_device_err(BLKF_BOTH, &dev));
+	ut_asserteq_str("mmc1.blk", dev->name);
+	ut_assertok(blk_next_device_err(BLKF_BOTH, &dev));
+	ut_asserteq_str("mmc0.blk", dev->name);
+	ut_asserteq(-ENODEV, blk_next_device_err(BLKF_FIXED, &dev));
+
+	ut_asserteq(1, blk_count_devices(BLKF_FIXED));
+	ut_asserteq(2, blk_count_devices(BLKF_REMOVABLE));
+	ut_asserteq(3, blk_count_devices(BLKF_BOTH));
+
+	i = 0;
+	blk_foreach_probe(BLKF_FIXED, dev)
+		ut_asserteq_str((i++, "mmc2.blk"), dev->name);
+	ut_asserteq(1, i);
+
+	i = 0;
+	blk_foreach_probe(BLKF_REMOVABLE, dev)
+		ut_asserteq_str(i++ ? "mmc0.blk" : "mmc1.blk", dev->name);
+	ut_asserteq(2, i);
+
+	i = 0;
+	blk_foreach_probe(BLKF_BOTH, dev)
+		ut_asserteq_str((++i == 1 ? "mmc2.blk" : i == 2 ?
+			"mmc1.blk" : "mmc0.blk"), dev->name);
+	ut_asserteq(3, i);
+
+	return 0;
+}
+DM_TEST(dm_test_blk_iter, UT_TESTF_SCAN_PDATA | UT_TESTF_SCAN_FDT);
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* [PATCH 22/22] log: Allow padding of the function name
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (20 preceding siblings ...)
  2021-07-05 22:32 ` [PATCH 21/22] blk: Support iteration Simon Glass
@ 2021-07-05 22:33 ` Simon Glass
  2021-07-17 20:39 ` Simon Glass
                   ` (19 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-05 22:33 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Simon Glass, AKASHI Takahiro, Heinrich Schuchardt, Igor Opaniuk,
	Joel Peshkin, Usama Arif

At present when function names are logged, the output is a little hard to
read since every function is a different length. Add a way to pad the
names so that the log messages line up vertically. This doesn't work if
the function name is very long, but it makes a big difference in most
cases.

Use 20 characters as a default since this covers the vast majority of
functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/Kconfig       |  8 ++++++++
 common/log_console.c |  2 +-
 test/log/log_test.c  | 16 +++++++++-------
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/common/Kconfig b/common/Kconfig
index 21407b547da..b77e17b5cbd 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -340,6 +340,14 @@ config LOGF_FUNC
 	  Show the function name in log messages by default. This value can
 	  be overridden using the 'log format' command.
 
+config LOGF_FUNC_PAD
+	int "Number of characters to use for function"
+	default 20
+	help
+	  Sets the field width to use when showing the function. Set this to
+	  a larger value if you have lots of long function names, and want
+	  things to line up.
+
 config LOG_SYSLOG
 	bool "Log output to syslog server"
 	depends on NET
diff --git a/common/log_console.c b/common/log_console.c
index 3f6177499ef..f1dcc04b97c 100644
--- a/common/log_console.c
+++ b/common/log_console.c
@@ -38,7 +38,7 @@ static int log_console_emit(struct log_device *ldev, struct log_rec *rec)
 		if (fmt & BIT(LOGF_LINE))
 			printf("%d-", rec->line);
 		if (fmt & BIT(LOGF_FUNC))
-			printf("%s()", rec->func);
+			printf("%*s()", CONFIG_LOGF_FUNC_PAD, rec->func);
 	}
 	if (fmt & BIT(LOGF_MSG))
 		printf("%s%s", add_space ? " " : "", rec->msg);
diff --git a/test/log/log_test.c b/test/log/log_test.c
index f1e67509c17..db7170f3042 100644
--- a/test/log/log_test.c
+++ b/test/log/log_test.c
@@ -62,9 +62,9 @@ static int do_check_log_entries(struct unit_test_state *uts, int flags, int min,
 
 	for (i = min; i <= max; i++) {
 		if (flags & EXPECT_LOG)
-			ut_assert_nextline("do_log_run() log %d", i);
+			ut_assert_nextline("          do_log_run() log %d", i);
 		if (flags & EXPECT_DIRECT)
-			ut_assert_nextline("func() _log %d", i);
+			ut_assert_nextline("                func() _log %d", i);
 		if (flags & EXPECT_DEBUG) {
 			ut_assert_nextline("log %d", i);
 			ut_assert_nextline("_log %d", i);
@@ -72,11 +72,12 @@ static int do_check_log_entries(struct unit_test_state *uts, int flags, int min,
 	}
 	if (flags & EXPECT_EXTRA)
 		for (; i <= LOGL_MAX ; i++)
-			ut_assert_nextline("func() _log %d", i);
+			ut_assert_nextline("                func() _log %d", i);
 
 	for (i = LOGL_FIRST; i < LOGL_COUNT; i++) {
 		if (flags & EXPECT_FORCE)
-			ut_assert_nextline("func() _log force %d", i);
+			ut_assert_nextline("                func() _log force %d",
+					   i);
 		if (flags & EXPECT_DEBUG)
 			ut_assert_nextline("_log force %d", i);
 	}
@@ -277,7 +278,8 @@ int do_log_test_helpers(struct unit_test_state *uts)
 	log_io("level %d\n", LOGL_DEBUG_IO);
 
 	for (i = LOGL_EMERG; i <= _LOG_MAX_LEVEL; i++)
-		ut_assert_nextline("%s() level %d", __func__, i);
+		ut_assert_nextline("%*s() level %d", CONFIG_LOGF_FUNC_PAD,
+				   __func__, i);
 	ut_assert_console_end();
 	return 0;
 }
@@ -297,14 +299,14 @@ int do_log_test_disable(struct unit_test_state *uts)
 {
 	ut_assertok(console_record_reset_enable());
 	log_err("default\n");
-	ut_assert_nextline("%s() default", __func__);
+	ut_assert_nextline("%*s() default", CONFIG_LOGF_FUNC_PAD, __func__);
 
 	ut_assertok(log_device_set_enable(LOG_GET_DRIVER(console), false));
 	log_err("disabled\n");
 
 	ut_assertok(log_device_set_enable(LOG_GET_DRIVER(console), true));
 	log_err("enabled\n");
-	ut_assert_nextline("%s() enabled", __func__);
+	ut_assert_nextline("%*s() enabled", CONFIG_LOGF_FUNC_PAD, __func__);
 	ut_assert_console_end();
 	return 0;
 }
-- 
2.32.0.93.g670b81a890-goog


^ permalink raw reply related	[flat|nested] 50+ messages in thread

* Re: [PATCH 20/22] sandbox: mmc: Support fixed MMC devices
  2021-07-05 22:32 ` [PATCH 20/22] sandbox: mmc: Support fixed MMC devices Simon Glass
@ 2021-07-06  1:12   ` Jaehoon Chung
  2021-07-17 20:39   ` Simon Glass
  1 sibling, 0 replies; 50+ messages in thread
From: Jaehoon Chung @ 2021-07-06  1:12 UTC (permalink / raw)
  To: Simon Glass, U-Boot Mailing List
  Cc: Bin Meng, Claudiu Manoil, Dario Binacchi, Etienne Carriere,
	Jean-Jacques Hiblot, Michael Walle, Peng Fan, Sean Anderson,
	Wolfgang Wallner

On 7/6/21 7:32 AM, Simon Glass wrote:
> Add support for reading devicetree flags for MMC devices. With this we
> can distinguish between fixed and removable drives. Note that this
> information is only available when the device is probed, not when it is
> bound, since it is read in the of_to_plat() method. This could be changed
> if needed later.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>

Best Regards,
Jaehoon Chung

> ---
> 
>  arch/sandbox/dts/test.dts |  1 +
>  drivers/mmc/sandbox_mmc.c | 24 +++++++++++++++++++++---
>  2 files changed, 22 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts
> index d85bb46ceba..0cee15a0ea2 100644
> --- a/arch/sandbox/dts/test.dts
> +++ b/arch/sandbox/dts/test.dts
> @@ -819,6 +819,7 @@
>  
>  	mmc2 {
>  		compatible = "sandbox,mmc";
> +		non-removable;
>  	};
>  
>  	mmc1 {
> diff --git a/drivers/mmc/sandbox_mmc.c b/drivers/mmc/sandbox_mmc.c
> index 18ba020aacc..895fbffecfc 100644
> --- a/drivers/mmc/sandbox_mmc.c
> +++ b/drivers/mmc/sandbox_mmc.c
> @@ -136,14 +136,31 @@ static const struct dm_mmc_ops sandbox_mmc_ops = {
>  	.get_cd = sandbox_mmc_get_cd,
>  };
>  
> -int sandbox_mmc_probe(struct udevice *dev)
> +static int sandbox_mmc_of_to_plat(struct udevice *dev)
> +{
> +	struct sandbox_mmc_plat *plat = dev_get_plat(dev);
> +	struct mmc_config *cfg = &plat->cfg;
> +	struct blk_desc *blk;
> +	int ret;
> +
> +	ret = mmc_of_parse(dev, cfg);
> +	if (ret)
> +		return ret;
> +	blk = mmc_get_blk_desc(&plat->mmc);
> +	if (blk)
> +		blk->removable = !(cfg->host_caps & MMC_CAP_NONREMOVABLE);
> +
> +	return 0;
> +}
> +
> +static int sandbox_mmc_probe(struct udevice *dev)
>  {
>  	struct sandbox_mmc_plat *plat = dev_get_plat(dev);
>  
>  	return mmc_init(&plat->mmc);
>  }
>  
> -int sandbox_mmc_bind(struct udevice *dev)
> +static int sandbox_mmc_bind(struct udevice *dev)
>  {
>  	struct sandbox_mmc_plat *plat = dev_get_plat(dev);
>  	struct mmc_config *cfg = &plat->cfg;
> @@ -158,7 +175,7 @@ int sandbox_mmc_bind(struct udevice *dev)
>  	return mmc_bind(dev, &plat->mmc, cfg);
>  }
>  
> -int sandbox_mmc_unbind(struct udevice *dev)
> +static int sandbox_mmc_unbind(struct udevice *dev)
>  {
>  	mmc_unbind(dev);
>  
> @@ -177,6 +194,7 @@ U_BOOT_DRIVER(mmc_sandbox) = {
>  	.ops		= &sandbox_mmc_ops,
>  	.bind		= sandbox_mmc_bind,
>  	.unbind		= sandbox_mmc_unbind,
> +	.of_to_plat	= sandbox_mmc_of_to_plat,
>  	.probe		= sandbox_mmc_probe,
>  	.priv_auto = sizeof(struct sandbox_mmc_priv),
>  	.plat_auto = sizeof(struct sandbox_mmc_plat),
> 


^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 22/22] log: Allow padding of the function name
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (21 preceding siblings ...)
  2021-07-05 22:33 ` [PATCH 22/22] log: Allow padding of the function name Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 21/22] blk: Support iteration Simon Glass
                   ` (18 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass
  Cc: AKASHI Takahiro, Heinrich Schuchardt, Igor Opaniuk, Joel Peshkin,
	Usama Arif, U-Boot Mailing List

At present when function names are logged, the output is a little hard to
read since every function is a different length. Add a way to pad the
names so that the log messages line up vertically. This doesn't work if
the function name is very long, but it makes a big difference in most
cases.

Use 20 characters as a default since this covers the vast majority of
functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/Kconfig       |  8 ++++++++
 common/log_console.c |  2 +-
 test/log/log_test.c  | 16 +++++++++-------
 3 files changed, 18 insertions(+), 8 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 21/22] blk: Support iteration
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (22 preceding siblings ...)
  2021-07-17 20:39 ` Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 19/22] spl: Provide more information on boot failure Simon Glass
                   ` (17 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass
  Cc: Anastasiia Lukianenko, Andrii Anisov, Oleksandr Andrushchenko,
	Ovidiu Panait, Patrick Delaunay, U-Boot Mailing List

It is useful to be able to iterate over block devices. Typically there
are fixed and removable devices. For security reasons it is sometimes
useful to ignore removable devices since they are under user control.

Add iterators which support selecting the block-device type.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/block/blk-uclass.c | 49 +++++++++++++++++++++++++++++++++
 include/blk.h              | 56 ++++++++++++++++++++++++++++++++++++++
 test/dm/blk.c              | 55 +++++++++++++++++++++++++++++++++++++
 3 files changed, 160 insertions(+)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 20/22] sandbox: mmc: Support fixed MMC devices
  2021-07-05 22:32 ` [PATCH 20/22] sandbox: mmc: Support fixed MMC devices Simon Glass
  2021-07-06  1:12   ` Jaehoon Chung
@ 2021-07-17 20:39   ` Simon Glass
  1 sibling, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Jaehoon Chung
  Cc: Bin Meng, Claudiu Manoil, Dario Binacchi, Etienne Carriere,
	Jean-Jacques Hiblot, Michael Walle, Peng Fan, Sean Anderson,
	Wolfgang Wallner, Simon Glass, U-Boot Mailing List

On 7/6/21 7:32 AM, Simon Glass wrote:
> Add support for reading devicetree flags for MMC devices. With this we
> can distinguish between fixed and removable drives. Note that this
> information is only available when the device is probed, not when it is
> bound, since it is read in the of_to_plat() method. This could be changed
> if needed later.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>

Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>

Best Regards,
Jaehoon Chung

> ---
>
>  arch/sandbox/dts/test.dts |  1 +
>  drivers/mmc/sandbox_mmc.c | 24 +++++++++++++++++++++---
>  2 files changed, 22 insertions(+), 3 deletions(-)
>
Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 19/22] spl: Provide more information on boot failure
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (23 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 21/22] blk: Support iteration Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 17/22] bloblist: Correct condition in bloblist_addrec() Simon Glass
                   ` (16 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass
  Cc: Adam Ford, Alexandru Gagniuc, Andre Przywara, Dario Binacchi,
	Faiz Abbas, Masahiro Yamada, Michael Walle, Michal Simek,
	Otavio Salvador, Ovidiu Panait, Peng Fan, Philippe Reynes,
	Samuel Holland, Stefan Roese, U-Boot Mailing List

If SPL fails to boot, try to provide an error code to indicate what is
wrong. For example, if a uclass is missing, this can return -EPFNOSUPPORT
(-96) which provides useful information.

Add a helper for accessing the image-loader name so we can drop the use
of #ifdefs in this code.

Put this feature behind a CONFIG_SHOW_ERRORS option to avoid increasing
the code size.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/spl/Kconfig | 10 ++++++++++
 common/spl/spl.c   | 48 ++++++++++++++++++++++++++++++----------------
 include/spl.h      | 10 ++++++++++
 3 files changed, 52 insertions(+), 16 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 17/22] bloblist: Correct condition in bloblist_addrec()
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (24 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 19/22] spl: Provide more information on boot failure Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 16/22] bloblist: Tidy up a few API comments Simon Glass
                   ` (15 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List

It is possible to add a blob that ends at the end of the bloblist, but at
present this is not supported. Fix it and add a regression test for this
case.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/bloblist.c |  2 +-
 test/bloblist.c   | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 16/22] bloblist: Tidy up a few API comments
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (25 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 17/22] bloblist: Correct condition in bloblist_addrec() Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 15/22] bloblist: Support resizing a blob Simon Glass
                   ` (14 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: Bin Meng, U-Boot Mailing List

Some comments for struct bloblist_hdr are a bit ambiguous. Update them to
clarify the meaning more precisely. Also document bloblist_get_stats()
properly.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/bloblist.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 15/22] bloblist: Support resizing a blob
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (26 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 16/22] bloblist: Tidy up a few API comments Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 14/22] cros_ec: Use standard calls for recovery-request checking Simon Glass
                   ` (13 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: Bin Meng, U-Boot Mailing List

Sometimes a blob needs to expand, e.g. because it needs to hold more log
data. Add support for this. Note that the bloblist must have sufficient
spare space for this to work.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/bloblist.c  |  71 ++++++++++++++++-
 include/bloblist.h |  13 +++
 test/bloblist.c    | 192 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 274 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 14/22] cros_ec: Use standard calls for recovery-request checking
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (27 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 15/22] bloblist: Support resizing a blob Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 13/22] cros_ec: Support the full-size vboot context Simon Glass
                   ` (12 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass
  Cc: Alper Nebi Yasak, Andy Shevchenko, Heinrich Schuchardt,
	Pratyush Yadav, Walter Lozano, U-Boot Mailing List

Rather than calling directly into the sandbox SDL code, we can use the
normal U-Boot console handling for this feature. Update the code, to make
it more generic.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec_sandbox.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 13/22] cros_ec: Support the full-size vboot context
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (28 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 14/22] cros_ec: Use standard calls for recovery-request checking Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 12/22] cros_ec: Drop cros_ec_entering_mode() Simon Glass
                   ` (11 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass
  Cc: Alper Nebi Yasak, Andy Shevchenko, Heinrich Schuchardt,
	Pratyush Yadav, Walter Lozano, U-Boot Mailing List

The v2 format is 64-bytes in size. Support this and drop v1 since it is
not used anymore.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec_sandbox.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 12/22] cros_ec: Drop cros_ec_entering_mode()
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (29 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 13/22] cros_ec: Support the full-size vboot context Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 11/22] cros_ec: Allow reading the battery-charge state Simon Glass
                   ` (10 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass
  Cc: Alper Nebi Yasak, Andy Shevchenko, Heinrich Schuchardt,
	Walter Lozano, U-Boot Mailing List

This function is not needed anymore. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec.c         | 11 -----------
 drivers/misc/cros_ec_sandbox.c |  3 ---
 include/cros_ec.h              |  9 ---------
 3 files changed, 23 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 11/22] cros_ec: Allow reading the battery-charge state
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (30 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 12/22] cros_ec: Drop cros_ec_entering_mode() Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 10/22] sandbox: Adjust the bloblist default address Simon Glass
                   ` (9 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: Alper Nebi Yasak, U-Boot Mailing List

Add a function to read this information from the EC. It is useful for
determining whether the battery has enough charge to boot.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/misc/cros_ec.c | 17 +++++++++++++++++
 include/cros_ec.h      |  8 ++++++++
 2 files changed, 25 insertions(+)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 10/22] sandbox: Adjust the bloblist default address
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (31 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 11/22] cros_ec: Allow reading the battery-charge state Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 09/22] sandbox: Use hinting with the display Simon Glass
                   ` (8 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass
  Cc: AKASHI Takahiro, Heinrich Schuchardt, Igor Opaniuk, Joel Peshkin,
	Usama Arif, U-Boot Mailing List

Move this down to provide more space for the bloblist.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 common/Kconfig       | 2 +-
 doc/arch/sandbox.rst | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 09/22] sandbox: Use hinting with the display
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (32 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 10/22] sandbox: Adjust the bloblist default address Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 08/22] sandbox: Add work-around for SDL2 display Simon Glass
                   ` (7 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: Harald Seiler, Heinrich Schuchardt, U-Boot Mailing List

SDL provides a hinting feature which provides a higher-quality image
with the double-display option (-K). Enable it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/cpu/sdl.c | 3 +++
 1 file changed, 3 insertions(+)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 08/22] sandbox: Add work-around for SDL2 display
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (33 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 09/22] sandbox: Use hinting with the display Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 07/22] sandbox: Support executables for more phases Simon Glass
                   ` (6 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: Harald Seiler, Heinrich Schuchardt, U-Boot Mailing List

At present the display does not show on some machines, e.g. Ubunutu
20.04 but the reason is unknown. Add a work-around until this can be
determined.

Also include more error checking just in case.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/cpu/sdl.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 07/22] sandbox: Support executables for more phases
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (34 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 08/22] sandbox: Add work-around for SDL2 display Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time Simon Glass
                   ` (5 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass
  Cc: Alexandru Gagniuc, Dario Binacchi, Faiz Abbas,
	Heinrich Schuchardt, Marek Behún, Michael Walle,
	Patrick Delaunay, Peng Fan, U-Boot Mailing List

The SPL header has a function for obtaining the phase in capital letters,
e.g. 'SPL'. Add one for lower-case also, as used by sandbox.

Use this to generalise the sandbox logic for determining the filename of
the next sandbox executable. This can provide support for VPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 arch/sandbox/cpu/os.c          | 63 +++++++++++++++-------------------
 arch/sandbox/cpu/spl.c         | 18 ++++++++--
 arch/sandbox/include/asm/spl.h | 13 +++++++
 include/os.h                   |  5 ++-
 include/spl.h                  | 23 +++++++++++++
 test/image/spl_load.c          |  6 +++-
 6 files changed, 89 insertions(+), 39 deletions(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (35 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 07/22] sandbox: Support executables for more phases Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-18 13:34   ` Masahiro Yamada
  2021-07-17 20:39 ` [PATCH 05/22] test: Avoid a build error with SPL Simon Glass
                   ` (4 subsequent siblings)
  41 siblings, 1 reply; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass
  Cc: Heinrich Schuchardt, Marek Behún, Masahiro Yamada,
	Michal Simek, Roger Pau Monne, U-Boot Mailing List

Drop the FORCE from the rule that builds .dtb files and let the normal
dependency checking do its work. This should work correctly, at least
for .dts files that don't use /include/.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 scripts/Makefile.lib | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 05/22] test: Avoid a build error with SPL
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (36 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 04/22] test: Add DM_DMA to be disabled Simon Glass
                   ` (3 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: Andy Shevchenko, U-Boot Mailing List

At present this fails to build chromeos_sandbox due to a rebase error
in dm_test_pre_run(). Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/test-main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 04/22] test: Add DM_DMA to be disabled
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (37 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 05/22] test: Avoid a build error with SPL Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 03/22] test: Allow CONFIG_SPL_LOAD_FIT " Simon Glass
                   ` (2 subsequent siblings)
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: U-Boot Mailing List

At present if DM_DMA is disabled on a sandbox build, the build fails.
Make the test conditional.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/dm/core.c | 2 ++
 1 file changed, 2 insertions(+)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 03/22] test: Allow CONFIG_SPL_LOAD_FIT to be disabled
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (38 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 04/22] test: Add DM_DMA to be disabled Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 02/22] dm: Support lzma in the flashmap Simon Glass
  2021-07-17 20:39 ` [PATCH 01/22] dm: core: Add logging for DM_SEQ_ALIAS Simon Glass
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: Heinrich Schuchardt, U-Boot Mailing List

At present if this is not enabled on a sandbox build, the build fails. Add
a condition to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/Makefile | 2 ++
 1 file changed, 2 insertions(+)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 02/22] dm: Support lzma in the flashmap
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (39 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 03/22] test: Allow CONFIG_SPL_LOAD_FIT " Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  2021-07-17 20:39 ` [PATCH 01/22] dm: core: Add logging for DM_SEQ_ALIAS Simon Glass
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: Marek Vasut, Pavel Herrmann, U-Boot Mailing List

Allow lzma compression as well as lz4.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/of_extra.c | 2 ++
 1 file changed, 2 insertions(+)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 01/22] dm: core: Add logging for DM_SEQ_ALIAS
  2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
                   ` (40 preceding siblings ...)
  2021-07-17 20:39 ` [PATCH 02/22] dm: Support lzma in the flashmap Simon Glass
@ 2021-07-17 20:39 ` Simon Glass
  41 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:39 UTC (permalink / raw)
  To: Simon Glass; +Cc: Marek Vasut, Pavel Herrmann, U-Boot Mailing List

It is sometimes helpful to see which sequence is assigned to a device.
Add debugging info for that.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/device.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 18/22] image: Allow @ in node names when not using signatures
  2021-07-05 22:32 ` [PATCH 18/22] image: Allow @ in node names when not using signatures Simon Glass
@ 2021-07-17 20:40   ` Simon Glass
  0 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-17 20:40 UTC (permalink / raw)
  To: U-Boot Mailing List
  Cc: Alexandru Gagniuc, Joe Hershberger, Joel Stanley, Lokesh Vutla,
	Marek Vasut, Mark Kettenis, Michal Simek, Sebastian Reichel

On Mon, 5 Jul 2021 at 16:33, Simon Glass <sjg@chromium.org> wrote:
>
> If signature verification is not in use we don't need to worry about
> the risk of using @ in node names. Update fit_image_verify() to allow
> it if the function is not enabled.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  common/image-fit.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-dm, thanks!

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time
  2021-07-17 20:39 ` [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time Simon Glass
@ 2021-07-18 13:34   ` Masahiro Yamada
  2021-07-22  2:13     ` Simon Glass
  0 siblings, 1 reply; 50+ messages in thread
From: Masahiro Yamada @ 2021-07-18 13:34 UTC (permalink / raw)
  To: Simon Glass
  Cc: Heinrich Schuchardt, Marek Behún, Michal Simek,
	Roger Pau Monne, U-Boot Mailing List

On Sun, Jul 18, 2021 at 5:41 AM Simon Glass <sjg@chromium.org> wrote:
>
> Drop the FORCE from the rule that builds .dtb files and let the normal
> dependency checking do its work. This should work correctly, at least
> for .dts files that don't use /include/.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  scripts/Makefile.lib | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Applied to u-boot-dm, thanks!


I am no longer working on U-Boot,
but this patch is obviously wrong.

if_changed_dep must always have FORCE
as the prerequisite.

If it is not working, you may miss adding
the objects to the 'targets'.

Somebody had broken the build system?


--
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time
  2021-07-18 13:34   ` Masahiro Yamada
@ 2021-07-22  2:13     ` Simon Glass
  0 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-22  2:13 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Heinrich Schuchardt, Marek Behún, Michal Simek,
	Roger Pau Monne, U-Boot Mailing List

Hi Masahiro,

On Sun, 18 Jul 2021 at 07:36, Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> On Sun, Jul 18, 2021 at 5:41 AM Simon Glass <sjg@chromium.org> wrote:
> >
> > Drop the FORCE from the rule that builds .dtb files and let the normal
> > dependency checking do its work. This should work correctly, at least
> > for .dts files that don't use /include/.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> >  scripts/Makefile.lib | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > Applied to u-boot-dm, thanks!
>
>
> I am no longer working on U-Boot,
> but this patch is obviously wrong.
>
> if_changed_dep must always have FORCE
> as the prerequisite.

Thanks for the email.

OK I found the documentation about this in Linux so will add it to U-Boot.

>
> If it is not working, you may miss adding
> the objects to the 'targets'.
>
> Somebody had broken the build system?

I'm not sure, but let's drop this patch for now.

Regards,
Simon

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 08/22] sandbox: Add work-around for SDL2 display
  2021-07-05 22:32 ` [PATCH 08/22] sandbox: Add work-around for SDL2 display Simon Glass
@ 2021-07-22  6:00   ` Heinrich Schuchardt
  2021-07-22 13:28     ` Simon Glass
  0 siblings, 1 reply; 50+ messages in thread
From: Heinrich Schuchardt @ 2021-07-22  6:00 UTC (permalink / raw)
  To: Simon Glass, U-Boot Mailing List; +Cc: Harald Seiler



On 7/6/21 12:32 AM, Simon Glass wrote:
> At present the display does not show on some machines, e.g. Ubunutu
> 20.04 but the reason is unknown. Add a work-around until this can be
> determined.

I am running Ubuntu 20.04 and

     ./u-boot -T -l

shows the graphical console for sandbox_defconfig.

Please, provide more detail on how to reproduce the issue on Ubuntu Hirsute.

Best regards

Heinrich

>
> Also include more error checking just in case.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>   arch/sandbox/cpu/sdl.c | 23 ++++++++++++++++++++++-
>   1 file changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/arch/sandbox/cpu/sdl.c b/arch/sandbox/cpu/sdl.c
> index 8102649be3a..e2649494818 100644
> --- a/arch/sandbox/cpu/sdl.c
> +++ b/arch/sandbox/cpu/sdl.c
> @@ -164,8 +164,29 @@ int sandbox_sdl_init_display(int width, int height, int log2_bpp,
>
>   int sandbox_sdl_sync(void *lcd_base)
>   {
> +	struct SDL_Rect rect;
> +	int ret;
> +
> +	if (!sdl.texture)
> +		return 0;
> +	SDL_RenderClear(sdl.renderer);
>   	SDL_UpdateTexture(sdl.texture, NULL, lcd_base, sdl.pitch);
> -	SDL_RenderCopy(sdl.renderer, sdl.texture, NULL, NULL);
> +	ret = SDL_RenderCopy(sdl.renderer, sdl.texture, NULL, NULL);
> +	if (ret) {
> +		printf("SDL copy %d: %s\n", ret, SDL_GetError());
> +		return -EIO;
> +	}
> +
> +	/*
> +	 * On some machines this does not appear. Draw an empty rectangle which
> +	 * seems to fix that.
> +	 */
> +	rect.x = 0;
> +	rect.y = 0;
> +	rect.w = 0;
> +	rect.h = 0;
> +	SDL_RenderDrawRect(sdl.renderer, &rect);
> +
>   	SDL_RenderPresent(sdl.renderer);
>   	sandbox_sdl_poll_events();
>
>

^ permalink raw reply	[flat|nested] 50+ messages in thread

* Re: [PATCH 08/22] sandbox: Add work-around for SDL2 display
  2021-07-22  6:00   ` Heinrich Schuchardt
@ 2021-07-22 13:28     ` Simon Glass
  0 siblings, 0 replies; 50+ messages in thread
From: Simon Glass @ 2021-07-22 13:28 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: U-Boot Mailing List, Harald Seiler

Hi Heinrich,

On Thu, 22 Jul 2021 at 00:00, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
>
>
> On 7/6/21 12:32 AM, Simon Glass wrote:
> > At present the display does not show on some machines, e.g. Ubunutu
> > 20.04 but the reason is unknown. Add a work-around until this can be
> > determined.
>
> I am running Ubuntu 20.04 and
>
>      ./u-boot -T -l
>
> shows the graphical console for sandbox_defconfig.
>
> Please, provide more detail on how to reproduce the issue on Ubuntu Hirsute.

I am really not sure. I noticed the problem a while back but have
never been able to figure out why it happens or what is going on. I am
pleased it does not happen for you. I'll try it on a later Ubuntu at
some point, but I'm assuming people will continue to use 20.04 for a
while.

Regards,
Simon

^ permalink raw reply	[flat|nested] 50+ messages in thread

end of thread, other threads:[~2021-07-22 13:29 UTC | newest]

Thread overview: 50+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 22:32 [PATCH 00/22] Various fixes and enhancements Simon Glass
2021-07-05 22:32 ` [PATCH 01/22] dm: core: Add logging for DM_SEQ_ALIAS Simon Glass
2021-07-05 22:32 ` [PATCH 02/22] dm: Support lzma in the flashmap Simon Glass
2021-07-05 22:32 ` [PATCH 03/22] test: Allow CONFIG_SPL_LOAD_FIT to be disabled Simon Glass
2021-07-05 22:32 ` [PATCH 04/22] test: Add DM_DMA " Simon Glass
2021-07-05 22:32 ` [PATCH 05/22] test: Avoid a build error with SPL Simon Glass
2021-07-05 22:32 ` [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time Simon Glass
2021-07-05 22:32 ` [PATCH 07/22] sandbox: Support executables for more phases Simon Glass
2021-07-05 22:32 ` [PATCH 08/22] sandbox: Add work-around for SDL2 display Simon Glass
2021-07-22  6:00   ` Heinrich Schuchardt
2021-07-22 13:28     ` Simon Glass
2021-07-05 22:32 ` [PATCH 09/22] sandbox: Use hinting with the display Simon Glass
2021-07-05 22:32 ` [PATCH 10/22] sandbox: Adjust the bloblist default address Simon Glass
2021-07-05 22:32 ` [PATCH 11/22] cros_ec: Allow reading the battery-charge state Simon Glass
2021-07-05 22:32 ` [PATCH 12/22] cros_ec: Drop cros_ec_entering_mode() Simon Glass
2021-07-05 22:32 ` [PATCH 13/22] cros_ec: Support the full-size vboot context Simon Glass
2021-07-05 22:32 ` [PATCH 14/22] cros_ec: Use standard calls for recovery-request checking Simon Glass
2021-07-05 22:32 ` [PATCH 15/22] bloblist: Support resizing a blob Simon Glass
2021-07-05 22:32 ` [PATCH 16/22] bloblist: Tidy up a few API comments Simon Glass
2021-07-05 22:32 ` [PATCH 17/22] bloblist: Correct condition in bloblist_addrec() Simon Glass
2021-07-05 22:32 ` [PATCH 18/22] image: Allow @ in node names when not using signatures Simon Glass
2021-07-17 20:40   ` Simon Glass
2021-07-05 22:32 ` [PATCH 19/22] spl: Provide more information on boot failure Simon Glass
2021-07-05 22:32 ` [PATCH 20/22] sandbox: mmc: Support fixed MMC devices Simon Glass
2021-07-06  1:12   ` Jaehoon Chung
2021-07-17 20:39   ` Simon Glass
2021-07-05 22:32 ` [PATCH 21/22] blk: Support iteration Simon Glass
2021-07-05 22:33 ` [PATCH 22/22] log: Allow padding of the function name Simon Glass
2021-07-17 20:39 ` Simon Glass
2021-07-17 20:39 ` [PATCH 21/22] blk: Support iteration Simon Glass
2021-07-17 20:39 ` [PATCH 19/22] spl: Provide more information on boot failure Simon Glass
2021-07-17 20:39 ` [PATCH 17/22] bloblist: Correct condition in bloblist_addrec() Simon Glass
2021-07-17 20:39 ` [PATCH 16/22] bloblist: Tidy up a few API comments Simon Glass
2021-07-17 20:39 ` [PATCH 15/22] bloblist: Support resizing a blob Simon Glass
2021-07-17 20:39 ` [PATCH 14/22] cros_ec: Use standard calls for recovery-request checking Simon Glass
2021-07-17 20:39 ` [PATCH 13/22] cros_ec: Support the full-size vboot context Simon Glass
2021-07-17 20:39 ` [PATCH 12/22] cros_ec: Drop cros_ec_entering_mode() Simon Glass
2021-07-17 20:39 ` [PATCH 11/22] cros_ec: Allow reading the battery-charge state Simon Glass
2021-07-17 20:39 ` [PATCH 10/22] sandbox: Adjust the bloblist default address Simon Glass
2021-07-17 20:39 ` [PATCH 09/22] sandbox: Use hinting with the display Simon Glass
2021-07-17 20:39 ` [PATCH 08/22] sandbox: Add work-around for SDL2 display Simon Glass
2021-07-17 20:39 ` [PATCH 07/22] sandbox: Support executables for more phases Simon Glass
2021-07-17 20:39 ` [PATCH 06/22] Makefile: Avoid rebuilding .dtb files each time Simon Glass
2021-07-18 13:34   ` Masahiro Yamada
2021-07-22  2:13     ` Simon Glass
2021-07-17 20:39 ` [PATCH 05/22] test: Avoid a build error with SPL Simon Glass
2021-07-17 20:39 ` [PATCH 04/22] test: Add DM_DMA to be disabled Simon Glass
2021-07-17 20:39 ` [PATCH 03/22] test: Allow CONFIG_SPL_LOAD_FIT " Simon Glass
2021-07-17 20:39 ` [PATCH 02/22] dm: Support lzma in the flashmap Simon Glass
2021-07-17 20:39 ` [PATCH 01/22] dm: core: Add logging for DM_SEQ_ALIAS Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.