[PATCH 00/17] Various minor clean-ups and improvements

This series includes a collection of things noticed while bringing up verified boot on Coral.
It includes support for relocating the bloblist.
Simon Glass (17): doc: Correct documentation for uclass_root spl: Add functions for next and previous phase bloblist: Support relocating to a larger space bloblist: Add missing tag names x86: tsc_timer: Correct overflow in __udelay() video: Allow syncing the entire framebuffer to the copy net: Use CONFIG_IS_ENABLED() in eth_dev_get_mac_address() fdtdec: Update the missing-devicetree message fdtdec: Use CONFIG_IS_ENABLED in board_fdt_blob_setup() display_options: Use USE_TINY_PRINTF for SPL check uuid: Add a comment for UUID_STR_LEN mmc: pci_mmc: Only generate ACPI code for the SD card x86: coral: Add a devicetree node for eMMC mmc: pci_mmc: Set the removable flag crc32: Exclude crc32 from TPL binman: Move selection of the binman node into a function binman: Allow reading entries from a subnode
arch/x86/dts/chromebook_coral.dts | 6 +++ common/Kconfig | 10 +++++ common/bloblist.c | 17 +++++++++ common/board_f.c | 10 +++-- common/spl/spl.c | 2 +- drivers/mmc/pci_mmc.c | 19 +++++++++- drivers/timer/tsc_timer.c | 2 +- drivers/video/video-uclass.c | 10 +++++ include/asm-generic/global_data.h | 4 +- include/binman.h | 14 +++++++ include/bloblist.h | 10 +++++ include/spl.h | 53 +++++++++++++++++++++++++++ include/uuid.h | 1 + include/video.h | 14 +++++++ lib/Makefile | 2 + lib/binman.c | 61 ++++++++++++++++++++++++++----- lib/display_options.c | 9 ++--- lib/fdtdec.c | 5 ++- net/eth-uclass.c | 2 +- test/bloblist.c | 36 ++++++++++++++++++ 20 files changed, 260 insertions(+), 27 deletions(-)

The comments are swapped at present so this produces an error with 'make htmldocs'. Fix it.
Signed-off-by: Simon Glass sjg@chromium.org ---
include/asm-generic/global_data.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/asm-generic/global_data.h b/include/asm-generic/global_data.h index aa6bba8645d..63bcf109d40 100644 --- a/include/asm-generic/global_data.h +++ b/include/asm-generic/global_data.h @@ -192,12 +192,12 @@ struct global_data { */ struct udevice *dm_root_f; /** - * @uclass_root: head of core tree + * @uclass_root_s: head of core tree */ struct list_head uclass_root_s; /** * @uclass_root: pointer to head of core tree, if uclasses are in - * read-only memory and cannot be adjusted to use @uclass_root as a + * read-only memory and cannot be adjusted to use @uclass_root_s as a * list head. */ struct list_head *uclass_root;

It is useful to be able to figure out which phase we are loading next and which phase we came from. Add some functions to handle this as well as returning the name of a phase. This allows messages like "Booting to x" where x is the next phase.
At present, TPL says 'Jumping to U-Boot' at the end, when in fact it is jumping to SPL. This is confusing, so use the new functions to correct this.
Tests for this will come with an upcoming minor SPL test refactor.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/spl/spl.c | 2 +- include/spl.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c index 835c53deaa8..d375dcbb2ed 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -734,7 +734,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2) debug("Failed to stash bootstage: err=%d\n", ret); #endif
- debug("loaded - jumping to U-Boot...\n"); + debug("loaded - jumping to %s...\n", spl_phase_name(spl_next_phase())); spl_board_prepare_for_boot(); jump_to_image_no_args(&spl_image); } diff --git a/include/spl.h b/include/spl.h index a7648787b74..faffeb519ac 100644 --- a/include/spl.h +++ b/include/spl.h @@ -58,6 +58,7 @@ static inline bool u_boot_first_phase(void) }
enum u_boot_phase { + PHASE_NONE, /* Invalid phase, signifying before U-Boot */ PHASE_TPL, /* Running in TPL */ PHASE_SPL, /* Running in SPL */ PHASE_BOARD_F, /* Running in U-Boot before relocation */ @@ -123,6 +124,58 @@ static inline enum u_boot_phase spl_phase(void) #endif }
+/** + * spl_prev_phase() - Figure out the previous U-Boot phase + * + * @return the previous phase from this one, e.g. if called in SPL this returns + * PHASE_TPL, if TPL is enabled + */ +static inline enum u_boot_phase spl_prev_phase(void) +{ +#ifdef CONFIG_TPL_BUILD + return PHASE_NONE; +#elif defined(CONFIG_SPL_BUILD) + return IS_ENABLED(CONFIG_TPL) ? PHASE_TPL : PHASE_NONE; +#else + return IS_ENABLED(CONFIG_SPL) ? PHASE_SPL : PHASE_NONE; +#endif +} + +/** + * spl_next_phase() - Figure out the next U-Boot phase + * + * @return the next phase from this one, e.g. if called in TPL this returns + * PHASE_SPL + */ +static inline enum u_boot_phase spl_next_phase(void) +{ +#ifdef CONFIG_TPL_BUILD + return PHASE_SPL; +#else + return PHASE_BOARD_F; +#endif +} + +/** + * spl_phase_name() - Get the name of the current phase + * + * @return phase name + */ +static inline const char *spl_phase_name(enum u_boot_phase phase) +{ + switch (phase) { + case PHASE_TPL: + return "TPL"; + case PHASE_SPL: + return "SPL"; + case PHASE_BOARD_F: + case PHASE_BOARD_R: + return "U-Boot"; + default: + return "phase?"; + } +} + /* A string name for SPL or TPL */ #ifdef CONFIG_SPL_BUILD # ifdef CONFIG_TPL_BUILD

On Wed, Jan 13, 2021 at 08:29:42PM -0700, Simon Glass wrote:
It is useful to be able to figure out which phase we are loading next and which phase we came from. Add some functions to handle this as well as returning the name of a phase. This allows messages like "Booting to x" where x is the next phase.
At present, TPL says 'Jumping to U-Boot' at the end, when in fact it is jumping to SPL. This is confusing, so use the new functions to correct this.
Tests for this will come with an upcoming minor SPL test refactor.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

Typically in TPL/SPL the bloblist is quite small. But U-Boot proper may want to add a lot more to it, such as ACPI tables.
Add a way to expand the bloblist by relocating it in U-Boot proper, along with the other relocation activities.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/Kconfig | 10 ++++++++++ common/bloblist.c | 11 +++++++++++ common/board_f.c | 10 ++++++---- include/bloblist.h | 10 ++++++++++ test/bloblist.c | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 73 insertions(+), 4 deletions(-)
diff --git a/common/Kconfig b/common/Kconfig index 2bce8c9ba1b..f5fe3701626 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -689,6 +689,16 @@ config BLOBLIST_ADDR 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.
+config BLOBLIST_SIZE_RELOC + hex "Size of bloblist after relocation" + depends on BLOBLIST + default BLOBLIST_SIZE + help + Sets the size of the bloblist in bytes after relocation. Since U-Boot + has a lot more memory available then, it is possible to use a larger + size than the one set up by SPL. This bloblist is set up during the + relocation process. + endmenu
source "common/spl/Kconfig" diff --git a/common/bloblist.c b/common/bloblist.c index 33b58623807..e32f551e27e 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -317,6 +317,15 @@ void bloblist_show_list(void) } }
+void bloblist_reloc(void *to, uint to_size, void *from, uint from_size) +{ + struct bloblist_hdr *hdr; + + memcpy(to, from, from_size); + hdr = to; + hdr->size = to_size; +} + int bloblist_init(void) { bool expected; @@ -327,6 +336,8 @@ int bloblist_init(void) * that runs */ expected = !u_boot_first_phase(); + if (spl_prev_phase() == PHASE_TPL && !IS_ENABLED(CONFIG_TPL_BLOBLIST)) + expected = false; if (expected) ret = bloblist_check(CONFIG_BLOBLIST_ADDR, CONFIG_BLOBLIST_SIZE); diff --git a/common/board_f.c b/common/board_f.c index 9f441c44f17..2aa5e728dbb 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -576,9 +576,10 @@ static int reserve_bloblist(void) { #ifdef CONFIG_BLOBLIST /* Align to a 4KB boundary for easier reading of addresses */ - gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp - CONFIG_BLOBLIST_SIZE, - 0x1000); - gd->new_bloblist = map_sysmem(gd->start_addr_sp, CONFIG_BLOBLIST_SIZE); + gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp - + CONFIG_BLOBLIST_SIZE_RELOC, 0x1000); + gd->new_bloblist = map_sysmem(gd->start_addr_sp, + CONFIG_BLOBLIST_SIZE_RELOC); #endif
return 0; @@ -661,7 +662,8 @@ static int reloc_bloblist(void)
debug("Copying bloblist from %p to %p, size %x\n", gd->bloblist, gd->new_bloblist, size); - memcpy(gd->new_bloblist, gd->bloblist, size); + bloblist_reloc(gd->new_bloblist, CONFIG_BLOBLIST_SIZE_RELOC, + gd->bloblist, size); gd->bloblist = gd->new_bloblist; } #endif diff --git a/include/bloblist.h b/include/bloblist.h index 8cdce61187a..964b974fdaf 100644 --- a/include/bloblist.h +++ b/include/bloblist.h @@ -242,6 +242,16 @@ void bloblist_show_list(void); */ const char *bloblist_tag_name(enum bloblist_tag_t tag);
+/** + * bloblist_reloc() - Relocate the bloblist and optionally resize it + * + * @to: Pointer to new bloblist location (must not overlap old location) + * @to:size: New size for bloblist (must be larger than from_size) + * @from: Pointer to bloblist to relocate + * @from_size: Size of bloblist to relocate + */ +void bloblist_reloc(void *to, uint to_size, void *from, uint from_size); + /** * bloblist_init() - Init the bloblist system with a single bloblist * diff --git a/test/bloblist.c b/test/bloblist.c index 0bb9e2d81e7..adf437ff0b1 100644 --- a/test/bloblist.c +++ b/test/bloblist.c @@ -352,6 +352,42 @@ static int bloblist_test_align(struct unit_test_state *uts) } BLOBLIST_TEST(bloblist_test_align, 0);
+/* Test relocation of a bloblist */ +static int bloblist_test_reloc(struct unit_test_state *uts) +{ + const uint large_size = TEST_BLOBLIST_SIZE; + const uint small_size = 0x20; + void *old_ptr, *new_ptr; + void *blob1, *blob2; + ulong new_addr; + ulong new_size; + + ut_assertok(bloblist_new(TEST_ADDR, TEST_BLOBLIST_SIZE, 0)); + old_ptr = map_sysmem(TEST_ADDR, TEST_BLOBLIST_SIZE); + + /* Add one blob and then one that won't fit */ + blob1 = bloblist_add(TEST_TAG, small_size, 0); + ut_assertnonnull(blob1); + blob2 = bloblist_add(TEST_TAG2, large_size, 0); + ut_assertnull(blob2); + + /* Relocate the bloblist somewhere else, a bit larger */ + new_addr = TEST_ADDR + TEST_BLOBLIST_SIZE; + new_size = TEST_BLOBLIST_SIZE + 0x100; + new_ptr = map_sysmem(new_addr, TEST_BLOBLIST_SIZE); + bloblist_reloc(new_ptr, new_size, old_ptr, TEST_BLOBLIST_SIZE); + gd->bloblist = new_ptr; + + /* Check the old blob is there and that we can now add the bigger one */ + ut_assertnonnull(bloblist_find(TEST_TAG, small_size)); + ut_assertnull(bloblist_find(TEST_TAG2, small_size)); + blob2 = bloblist_add(TEST_TAG2, large_size, 0); + ut_assertnonnull(blob2); + + return 0; +} +BLOBLIST_TEST(bloblist_test_reloc, 0); + int do_ut_bloblist(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) {

On Wed, Jan 13, 2021 at 08:29:43PM -0700, Simon Glass wrote:
Typically in TPL/SPL the bloblist is quite small. But U-Boot proper may want to add a lot more to it, such as ACPI tables.
Add a way to expand the bloblist by relocating it in U-Boot proper, along with the other relocation activities.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

Add tag names for recently added types.
Fixes: d2cb7a22da0 (x86: Allow putting some tables in the bloblist) Signed-off-by: Simon Glass sjg@chromium.org ---
common/bloblist.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/common/bloblist.c b/common/bloblist.c index e32f551e27e..0e6448becbc 100644 --- a/common/bloblist.c +++ b/common/bloblist.c @@ -33,6 +33,12 @@ static const char *const tag_name[] = { [BLOBLISTT_SPL_HANDOFF] = "SPL hand-off", [BLOBLISTT_VBOOT_CTX] = "Chrome OS vboot context", [BLOBLISTT_VBOOT_HANDOFF] = "Chrome OS vboot hand-off", + [BLOBLISTT_ACPI_GNVS] = "ACPI GNVS", + [BLOBLISTT_INTEL_VBT] = "Intel Video-BIOS table", + [BLOBLISTT_TPM2_TCG_LOG] = "TPM v2 log space", + [BLOBLISTT_TCPA_LOG] = "TPM log space", + [BLOBLISTT_ACPI_TABLES] = "ACPI tables for x86", + [BLOBLISTT_SMBIOS_TABLES] = "SMBIOS tables for x86", };
const char *bloblist_tag_name(enum bloblist_tag_t tag)

On Wed, Jan 13, 2021 at 08:29:44PM -0700, Simon Glass wrote:
Add tag names for recently added types.
Fixes: d2cb7a22da0 (x86: Allow putting some tables in the bloblist) Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

At present long delays such as msleep(2000) can cause an overflow in this function. There is no need for this, since it already uses a 64-bit int.
Add a cast to correct this.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/timer/tsc_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/timer/tsc_timer.c b/drivers/timer/tsc_timer.c index 706d52b830a..7d0fc66cc75 100644 --- a/drivers/timer/tsc_timer.c +++ b/drivers/timer/tsc_timer.c @@ -372,7 +372,7 @@ void __udelay(unsigned long usec) u64 now = get_ticks(); u64 stop;
- stop = now + usec * get_tbclk_mhz(); + stop = now + (u64)usec * get_tbclk_mhz();
while ((int64_t)(stop - get_ticks()) > 0) #if defined(CONFIG_QEMU) && defined(CONFIG_SMP)

On Thu, Jan 14, 2021 at 11:30 AM Simon Glass sjg@chromium.org wrote:
At present long delays such as msleep(2000) can cause an overflow in this function. There is no need for this, since it already uses a 64-bit int.
Add a cast to correct this.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/timer/tsc_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com

On Mon, Feb 1, 2021 at 2:10 PM Bin Meng bmeng.cn@gmail.com wrote:
On Thu, Jan 14, 2021 at 11:30 AM Simon Glass sjg@chromium.org wrote:
At present long delays such as msleep(2000) can cause an overflow in this function. There is no need for this, since it already uses a 64-bit int.
Add a cast to correct this.
Signed-off-by: Simon Glass sjg@chromium.org
drivers/timer/tsc_timer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Bin Meng bmeng.cn@gmail.com
applied to u-boot-x86, thanks!

In some cases so much of the framebuffer is updated that it is not worth copying the changes piece by piece to the copy framebuffer. Add a function to copy the whole thing.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/video/video-uclass.c | 10 ++++++++++ include/video.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+)
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c index 8883e290357..8a832aef01a 100644 --- a/drivers/video/video-uclass.c +++ b/drivers/video/video-uclass.c @@ -275,6 +275,16 @@ int video_sync_copy(struct udevice *dev, void *from, void *to)
return 0; } + +int video_sync_copy_all(struct udevice *dev) +{ + struct video_priv *priv = dev_get_uclass_priv(dev); + + video_sync_copy(dev, priv->fb, priv->fb + priv->fb_size); + + return 0; +} + #endif
/* Set up the colour map */ diff --git a/include/video.h b/include/video.h index 7b7f62a8277..a63dbbd7df9 100644 --- a/include/video.h +++ b/include/video.h @@ -236,11 +236,25 @@ void video_set_default_colors(struct udevice *dev, bool invert); * frame buffer start */ int video_sync_copy(struct udevice *dev, void *from, void *to); + +/** + * video_sync_copy_all() - Sync the entire framebuffer to the copy + * + * @dev: Vidconsole device being updated + * @return 0 (always) + */ +int video_sync_copy_all(struct udevice *dev); #else static inline int video_sync_copy(struct udevice *dev, void *from, void *to) { return 0; } + +static inline int video_sync_copy_all(struct udevice *dev) +{ + return 0; +} + #endif
#ifndef CONFIG_DM_VIDEO

On Wed, Jan 13, 2021 at 08:29:46PM -0700, Simon Glass wrote:
In some cases so much of the framebuffer is updated that it is not worth copying the changes piece by piece to the copy framebuffer. Add a function to copy the whole thing.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

This function may be used in SPL where devicetree is not available. Use the correct macro so that the function does not try to read it.
Signed-off-by: Simon Glass sjg@chromium.org ---
net/eth-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/eth-uclass.c b/net/eth-uclass.c index 0156324032b..cb3f8a9095f 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -482,7 +482,7 @@ static int eth_pre_unbind(struct udevice *dev)
static bool eth_dev_get_mac_address(struct udevice *dev, u8 mac[ARP_HLEN]) { -#if IS_ENABLED(CONFIG_OF_CONTROL) +#if CONFIG_IS_ENABLED(OF_CONTROL) const uint8_t *p;
p = dev_read_u8_array_ptr(dev, "mac-address", ARP_HLEN);

On Wed, Jan 13, 2021 at 08:29:47PM -0700, Simon Glass wrote:
This function may be used in SPL where devicetree is not available. Use the correct macro so that the function does not try to read it.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

This includes information about sandbox which is not relevant for most boards. Drop it.
Also add the address to help figure out the problem.
Signed-off-by: Simon Glass sjg@chromium.org ---
lib/fdtdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 0ab7105fef0..54f7a1fe477 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -600,7 +600,8 @@ int fdtdec_prepare_fdt(void) #ifdef CONFIG_SPL_BUILD puts("Missing DTB\n"); #else - puts("No valid device tree binary found - please append one to U-Boot binary, use u-boot-dtb.bin or define CONFIG_OF_EMBED. For sandbox, use -d <file.dtb>\n"); + printf("No valid device tree binary found at %p\n", + gd->fdt_blob); # ifdef DEBUG if (gd->fdt_blob) { printf("fdt_blob=%p\n", gd->fdt_blob);

On Wed, Jan 13, 2021 at 08:29:48PM -0700, Simon Glass wrote:
This includes information about sandbox which is not relevant for most boards. Drop it.
Also add the address to help figure out the problem.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

This setting may be different in SPL and TPL. Update the code to check the correct setting.
Signed-off-by: Simon Glass sjg@chromium.org ---
lib/fdtdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 54f7a1fe477..a2d2fb4e1fe 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -1253,7 +1253,7 @@ __weak void *board_fdt_blob_setup(void) void *fdt_blob = NULL; #ifdef CONFIG_SPL_BUILD /* FDT is at end of BSS unless it is in a different memory region */ - if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS)) + if (CONFIG_IS_ENABLED(SEPARATE_BSS)) fdt_blob = (ulong *)&_image_binary_end; else fdt_blob = (ulong *)&__bss_end;

On Wed, Jan 13, 2021 at 08:29:49PM -0700, Simon Glass wrote:
This setting may be different in SPL and TPL. Update the code to check the correct setting.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

Hi Simon,
On Thu, Jan 28, 2021 at 11:59 PM Tom Rini trini@konsulko.com wrote:
On Wed, Jan 13, 2021 at 08:29:49PM -0700, Simon Glass wrote:
This setting may be different in SPL and TPL. Update the code to check the correct setting.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
This breaks booting on at least rk3399 based devices for me with the following error:
U-Boot TPL 2021.04-rc1 (Feb 01 2021 - 00:00:00) Missing DTB ### ERROR ### Please RESET the board ###

On 14.02.2021 19.50, Peter Robinson wrote:
Hi Simon,
On Thu, Jan 28, 2021 at 11:59 PM Tom Rini trini@konsulko.com wrote:
On Wed, Jan 13, 2021 at 08:29:49PM -0700, Simon Glass wrote:
This setting may be different in SPL and TPL. Update the code to check the correct setting.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
This breaks booting on at least rk3399 based devices for me with the following error:
U-Boot TPL 2021.04-rc1 (Feb 01 2021 - 00:00:00) Missing DTB ### ERROR ### Please RESET the board ###
Also see https://lists.denx.de/pipermail/u-boot/2021-February/440263.html

On Sun, Feb 14, 2021 at 08:05:33PM +0100, Jesper Schmitz Mouridsen wrote:
On 14.02.2021 19.50, Peter Robinson wrote:
Hi Simon,
On Thu, Jan 28, 2021 at 11:59 PM Tom Rini trini@konsulko.com wrote:
On Wed, Jan 13, 2021 at 08:29:49PM -0700, Simon Glass wrote:
This setting may be different in SPL and TPL. Update the code to check the correct setting.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
This breaks booting on at least rk3399 based devices for me with the following error:
U-Boot TPL 2021.04-rc1 (Feb 01 2021 - 00:00:00) Missing DTB ### ERROR ### Please RESET the board ###
Also see https://lists.denx.de/pipermail/u-boot/2021-February/440263.html
So we have two forms of bug. sunxi (your link above Jesper) needs SPL_SEPARATE_BSS to be set I think. Peter's problem is that there is no TPL_SEPARATE_BSS which is a harder problem to solve quickly. I'll post a revert with you both Reported-by shortly, thanks.

On Sun, Feb 14, 2021 at 02:08:08PM -0500, Tom Rini wrote:
On Sun, Feb 14, 2021 at 08:05:33PM +0100, Jesper Schmitz Mouridsen wrote:
On 14.02.2021 19.50, Peter Robinson wrote:
Hi Simon,
On Thu, Jan 28, 2021 at 11:59 PM Tom Rini trini@konsulko.com wrote:
On Wed, Jan 13, 2021 at 08:29:49PM -0700, Simon Glass wrote:
This setting may be different in SPL and TPL. Update the code to check the correct setting.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
This breaks booting on at least rk3399 based devices for me with the following error:
U-Boot TPL 2021.04-rc1 (Feb 01 2021 - 00:00:00) Missing DTB ### ERROR ### Please RESET the board ###
Also see https://lists.denx.de/pipermail/u-boot/2021-February/440263.html
So we have two forms of bug. sunxi (your link above Jesper) needs SPL_SEPARATE_BSS to be set I think. Peter's problem is that there is no TPL_SEPARATE_BSS which is a harder problem to solve quickly. I'll post a revert with you both Reported-by shortly, thanks.
Er, wait. I'm a bit less clear on the why on sunxi at least. I'm going to post the revert shortly all the same.

On Sun, Feb 14, 2021 at 7:10 PM Tom Rini trini@konsulko.com wrote:
On Sun, Feb 14, 2021 at 02:08:08PM -0500, Tom Rini wrote:
On Sun, Feb 14, 2021 at 08:05:33PM +0100, Jesper Schmitz Mouridsen wrote:
On 14.02.2021 19.50, Peter Robinson wrote:
Hi Simon,
On Thu, Jan 28, 2021 at 11:59 PM Tom Rini trini@konsulko.com wrote:
On Wed, Jan 13, 2021 at 08:29:49PM -0700, Simon Glass wrote:
This setting may be different in SPL and TPL. Update the code to check the correct setting.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
This breaks booting on at least rk3399 based devices for me with the following error:
U-Boot TPL 2021.04-rc1 (Feb 01 2021 - 00:00:00) Missing DTB ### ERROR ### Please RESET the board ###
Also see https://lists.denx.de/pipermail/u-boot/2021-February/440263.html
So we have two forms of bug. sunxi (your link above Jesper) needs SPL_SEPARATE_BSS to be set I think. Peter's problem is that there is no TPL_SEPARATE_BSS which is a harder problem to solve quickly. I'll post a revert with you both Reported-by shortly, thanks.
Er, wait. I'm a bit less clear on the why on sunxi at least. I'm going to post the revert shortly all the same.
The sunxi bits seem OK with 2021.04-rc1 from my testing, at least for this problem, to now in my testing it's only been the rockchip stuff that's had issues but I'm still getting through all my devices.
Peter

On Sun, Feb 14, 2021 at 07:20:45PM +0000, Peter Robinson wrote:
On Sun, Feb 14, 2021 at 7:10 PM Tom Rini trini@konsulko.com wrote:
On Sun, Feb 14, 2021 at 02:08:08PM -0500, Tom Rini wrote:
On Sun, Feb 14, 2021 at 08:05:33PM +0100, Jesper Schmitz Mouridsen wrote:
On 14.02.2021 19.50, Peter Robinson wrote:
Hi Simon,
On Thu, Jan 28, 2021 at 11:59 PM Tom Rini trini@konsulko.com wrote:
On Wed, Jan 13, 2021 at 08:29:49PM -0700, Simon Glass wrote:
> This setting may be different in SPL and TPL. Update the code to check > the correct setting. > > Signed-off-by: Simon Glass sjg@chromium.org Applied to u-boot/master, thanks!
This breaks booting on at least rk3399 based devices for me with the following error:
U-Boot TPL 2021.04-rc1 (Feb 01 2021 - 00:00:00) Missing DTB ### ERROR ### Please RESET the board ###
Also see https://lists.denx.de/pipermail/u-boot/2021-February/440263.html
So we have two forms of bug. sunxi (your link above Jesper) needs SPL_SEPARATE_BSS to be set I think. Peter's problem is that there is no TPL_SEPARATE_BSS which is a harder problem to solve quickly. I'll post a revert with you both Reported-by shortly, thanks.
Er, wait. I'm a bit less clear on the why on sunxi at least. I'm going to post the revert shortly all the same.
The sunxi bits seem OK with 2021.04-rc1 from my testing, at least for this problem, to now in my testing it's only been the rockchip stuff that's had issues but I'm still getting through all my devices.
Yup. I need to fix my mental map of "pine* == sunxi", that was the confusion I had.

At present this code uses a simple printf() format if running in SPL. But SPL can use the full printf. Use USE_TINY_PRINTF instead.
Signed-off-by: Simon Glass sjg@chromium.org ---
lib/display_options.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/lib/display_options.c b/lib/display_options.c index b2025eeb5cf..cd48998b6d4 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -169,11 +169,10 @@ int print_buffer(ulong addr, const void *data, uint width, uint count, x = lb.us[i] = *(volatile uint16_t *)data; else x = lb.uc[i] = *(volatile uint8_t *)data; -#if defined(CONFIG_SPL_BUILD) - printf(" %x", (uint)x); -#else - printf(" %0*lx", width * 2, x); -#endif + if (CONFIG_IS_ENABLED(USE_TINY_PRINTF)) + printf(" %x", (uint)x); + else + printf(" %0*lx", width * 2, x); data += width; }

On Wed, Jan 13, 2021 at 08:29:50PM -0700, Simon Glass wrote:
At present this code uses a simple printf() format if running in SPL. But SPL can use the full printf. Use USE_TINY_PRINTF instead.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

This macro is the length of the string but excludes the terminator. Users must add 1 when declaring a large-enough string. Add a comment to make this clear.
Signed-off-by: Simon Glass sjg@chromium.org ---
include/uuid.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/uuid.h b/include/uuid.h index 73c5a89ec7c..f82f6dc5eff 100644 --- a/include/uuid.h +++ b/include/uuid.h @@ -23,6 +23,7 @@ struct uuid { #define UUID_STR_FORMAT_GUID BIT(0) #define UUID_STR_UPPER_CASE BIT(1)
+/* Use UUID_STR_LEN + 1 for string space */ #define UUID_STR_LEN 36 #define UUID_BIN_LEN sizeof(struct uuid)

On Wed, Jan 13, 2021 at 08:29:51PM -0700, Simon Glass wrote:
This macro is the length of the string but excludes the terminator. Users must add 1 when declaring a large-enough string. Add a comment to make this clear.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

At present if an eMMC part is in the system, the ACPI table generated will include information about that, as well as the SD card. We only need to include the SD card, since it has a card-detect GPIO. Use a different compatible string for each option, and add code only for the SD card.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/mmc/pci_mmc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c index c71c495d581..6517d8268b2 100644 --- a/drivers/mmc/pci_mmc.c +++ b/drivers/mmc/pci_mmc.c @@ -17,6 +17,12 @@ #include <asm-generic/gpio.h> #include <dm/acpi.h>
+/* Type of MMC device */ +enum { + TYPE_SD, + TYPE_EMMC, +}; + struct pci_mmc_plat { struct mmc_config cfg; struct mmc mmc; @@ -77,6 +83,8 @@ static int pci_mmc_acpi_fill_ssdt(const struct udevice *dev,
if (!dev_has_ofnode(dev)) return 0; + if (dev_get_driver_data(dev) == TYPE_EMMC) + return 0;
ret = gpio_get_acpi(&priv->cd_gpio, &gpio); if (ret) @@ -120,7 +128,8 @@ struct acpi_ops pci_mmc_acpi_ops = { };
static const struct udevice_id pci_mmc_match[] = { - { .compatible = "intel,apl-sd" }, + { .compatible = "intel,apl-sd", .data = TYPE_SD }, + { .compatible = "intel,apl-emmc", .data = TYPE_EMMC }, { } };

On 1/14/21 12:29 PM, Simon Glass wrote:
At present if an eMMC part is in the system, the ACPI table generated will include information about that, as well as the SD card. We only need to include the SD card, since it has a card-detect GPIO. Use a different compatible string for each option, and add code only for the SD card.
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Jaehoon Chung jh80.chung@samsung.com
Best Regards, Jaehoon Chung
drivers/mmc/pci_mmc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c index c71c495d581..6517d8268b2 100644 --- a/drivers/mmc/pci_mmc.c +++ b/drivers/mmc/pci_mmc.c @@ -17,6 +17,12 @@ #include <asm-generic/gpio.h> #include <dm/acpi.h>
+/* Type of MMC device */ +enum {
- TYPE_SD,
- TYPE_EMMC,
+};
struct pci_mmc_plat { struct mmc_config cfg; struct mmc mmc; @@ -77,6 +83,8 @@ static int pci_mmc_acpi_fill_ssdt(const struct udevice *dev,
if (!dev_has_ofnode(dev)) return 0;
if (dev_get_driver_data(dev) == TYPE_EMMC)
return 0;
ret = gpio_get_acpi(&priv->cd_gpio, &gpio); if (ret)
@@ -120,7 +128,8 @@ struct acpi_ops pci_mmc_acpi_ops = { };
static const struct udevice_id pci_mmc_match[] = {
- { .compatible = "intel,apl-sd" },
- { .compatible = "intel,apl-sd", .data = TYPE_SD },
- { .compatible = "intel,apl-emmc", .data = TYPE_EMMC }, { }
};

On Wed, Jan 13, 2021 at 08:29:52PM -0700, Simon Glass wrote:
At present if an eMMC part is in the system, the ACPI table generated will include information about that, as well as the SD card. We only need to include the SD card, since it has a card-detect GPIO. Use a different compatible string for each option, and add code only for the SD card.
Signed-off-by: Simon Glass sjg@chromium.org Reviewed-by: Jaehoon Chung jh80.chung@samsung.com
Applied to u-boot/master, thanks!

Add a node for this so we can indicate that it is does not require any ACPI code.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/x86/dts/chromebook_coral.dts | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/arch/x86/dts/chromebook_coral.dts b/arch/x86/dts/chromebook_coral.dts index 965f59276af..bfbdd517d1f 100644 --- a/arch/x86/dts/chromebook_coral.dts +++ b/arch/x86/dts/chromebook_coral.dts @@ -569,6 +569,12 @@ acpi,name = "SDCD"; };
+ emmc: emmc@1c,0 { + reg = <0x0000e000 0 0 0 0>; + compatible = "intel,apl-emmc"; + non-removable; + }; + pch: pch@1f,0 { reg = <0x0000f800 0 0 0 0>; compatible = "intel,apl-pch";

On 1/14/21 12:29 PM, Simon Glass wrote:
Add a node for this so we can indicate that it is does not require any ACPI code.
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Jaehoon Chung jh80.chung@samsung.com
Best Regards, Jaehoon Chung
arch/x86/dts/chromebook_coral.dts | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/arch/x86/dts/chromebook_coral.dts b/arch/x86/dts/chromebook_coral.dts index 965f59276af..bfbdd517d1f 100644 --- a/arch/x86/dts/chromebook_coral.dts +++ b/arch/x86/dts/chromebook_coral.dts @@ -569,6 +569,12 @@ acpi,name = "SDCD"; };
emmc: emmc@1c,0 {
reg = <0x0000e000 0 0 0 0>;
compatible = "intel,apl-emmc";
non-removable;
};
- pch: pch@1f,0 { reg = <0x0000f800 0 0 0 0>; compatible = "intel,apl-pch";

On Thu, Jan 14, 2021 at 11:30 AM Simon Glass sjg@chromium.org wrote:
Add a node for this so we can indicate that it is does not require any ACPI code.
Signed-off-by: Simon Glass sjg@chromium.org
arch/x86/dts/chromebook_coral.dts | 6 ++++++ 1 file changed, 6 insertions(+)
Reviewed-by: Bin Meng bmeng.cn@gmail.com

On Mon, Feb 1, 2021 at 2:11 PM Bin Meng bmeng.cn@gmail.com wrote:
On Thu, Jan 14, 2021 at 11:30 AM Simon Glass sjg@chromium.org wrote:
Add a node for this so we can indicate that it is does not require any ACPI code.
Signed-off-by: Simon Glass sjg@chromium.org
arch/x86/dts/chromebook_coral.dts | 6 ++++++ 1 file changed, 6 insertions(+)
Reviewed-by: Bin Meng bmeng.cn@gmail.com
applied to u-boot-x86, thanks!

Set this flag so that it is available to those looking at the device. For non-removable devices there is no need to check for insertion/removable since the media can never change.
Signed-off-by: Simon Glass sjg@chromium.org ---
drivers/mmc/pci_mmc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c index 6517d8268b2..e2389d1644a 100644 --- a/drivers/mmc/pci_mmc.c +++ b/drivers/mmc/pci_mmc.c @@ -10,6 +10,7 @@ #include <log.h> #include <malloc.h> #include <mapmem.h> +#include <mmc.h> #include <sdhci.h> #include <acpi/acpigen.h> #include <acpi/acpi_device.h> @@ -40,8 +41,15 @@ static int pci_mmc_probe(struct udevice *dev) struct pci_mmc_plat *plat = dev_get_plat(dev); struct pci_mmc_priv *priv = dev_get_priv(dev); struct sdhci_host *host = &priv->host; + struct blk_desc *desc; int ret;
+ ret = mmc_of_parse(dev, &plat->cfg); + if (ret) + return ret; + desc = mmc_get_blk_desc(&plat->mmc); + desc->removable = !(plat->cfg.host_caps & MMC_CAP_NONREMOVABLE); + host->ioaddr = (void *)dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM); host->name = dev->name;

On 1/14/21 12:29 PM, Simon Glass wrote:
Set this flag so that it is available to those looking at the device. For non-removable devices there is no need to check for insertion/removable since the media can never change.
Signed-off-by: Simon Glass sjg@chromium.org
Reviewed-by: Jaehoon Chung jh80.chung@samsung.com
Best Regards, Jaehoon Chung
drivers/mmc/pci_mmc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/drivers/mmc/pci_mmc.c b/drivers/mmc/pci_mmc.c index 6517d8268b2..e2389d1644a 100644 --- a/drivers/mmc/pci_mmc.c +++ b/drivers/mmc/pci_mmc.c @@ -10,6 +10,7 @@ #include <log.h> #include <malloc.h> #include <mapmem.h> +#include <mmc.h> #include <sdhci.h> #include <acpi/acpigen.h> #include <acpi/acpi_device.h> @@ -40,8 +41,15 @@ static int pci_mmc_probe(struct udevice *dev) struct pci_mmc_plat *plat = dev_get_plat(dev); struct pci_mmc_priv *priv = dev_get_priv(dev); struct sdhci_host *host = &priv->host;
struct blk_desc *desc; int ret;
ret = mmc_of_parse(dev, &plat->cfg);
if (ret)
return ret;
desc = mmc_get_blk_desc(&plat->mmc);
desc->removable = !(plat->cfg.host_caps & MMC_CAP_NONREMOVABLE);
host->ioaddr = (void *)dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM); host->name = dev->name;

On Wed, Jan 13, 2021 at 08:29:54PM -0700, Simon Glass wrote:
Set this flag so that it is available to those looking at the device. For non-removable devices there is no need to check for insertion/removable since the media can never change.
Signed-off-by: Simon Glass sjg@chromium.org Reviewed-by: Jaehoon Chung jh80.chung@samsung.com
Applied to u-boot/master, thanks!

Unfortunately the toolchain often brings in the crc32 table even if the function is not actually used. For now, exclude it from the TPL build, which is very sensitive to size.
Signed-off-by: Simon Glass sjg@chromium.org ---
lib/Makefile | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/lib/Makefile b/lib/Makefile index 851a80ef3bf..edc1c3dd4f9 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -92,7 +92,9 @@ obj-y += display_options.o CFLAGS_display_options.o := $(if $(BUILD_TAG),-DBUILD_TAG='"$(BUILD_TAG)"') obj-$(CONFIG_BCH) += bch.o obj-$(CONFIG_MMC_SPI) += crc7.o +#ifndef CONFIG_TPL_BUILD obj-y += crc32.o +#endif obj-$(CONFIG_CRC32C) += crc32c.o obj-y += ctype.o obj-y += div64.o

On Wed, Jan 13, 2021 at 08:29:55PM -0700, Simon Glass wrote:
Unfortunately the toolchain often brings in the crc32 table even if the function is not actually used. For now, exclude it from the TPL build, which is very sensitive to size.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

Move this logic out of the main init function so it is available for other purpose.
Use a different error when multiple-images is in use but no subnode is available. This makes it easier to determine what is wrong.
Signed-off-by: Simon Glass sjg@chromium.org ---
lib/binman.c | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-)
diff --git a/lib/binman.c b/lib/binman.c index f027d1b3042..b6d9dff5b7c 100644 --- a/lib/binman.c +++ b/lib/binman.c @@ -30,6 +30,34 @@ struct binman_info {
static struct binman_info *binman;
+/** + * find_image_node() - Find the top-level binman node + * + * Finds the binman node which can be used to load entries. The correct node + * depends on whether multiple-images is in use. + * + * @nodep: Returns the node found, on success + * @return 0 if OK, , -EINVAL if there is no /binman node, -ECHILD if multiple + * images are being used but the first image is not available + */ +static int find_image_node(ofnode *nodep) +{ + ofnode node; + + node = ofnode_path("/binman"); + if (!ofnode_valid(node)) + return log_msg_ret("binman node", -EINVAL); + if (ofnode_read_bool(node, "multiple-images")) { + node = ofnode_first_subnode(node); + + if (!ofnode_valid(node)) + return log_msg_ret("first image", -ECHILD); + } + *nodep = node; + + return 0; +} + static int binman_entry_find_internal(ofnode node, const char *name, struct binman_entry *entry) { @@ -90,19 +118,14 @@ int binman_get_rom_offset(void)
int binman_init(void) { + int ret; + binman = malloc(sizeof(struct binman_info)); if (!binman) return log_msg_ret("space for binman", -ENOMEM); - binman->image = ofnode_path("/binman"); - if (!ofnode_valid(binman->image)) - return log_msg_ret("binman node", -EINVAL); - if (ofnode_read_bool(binman->image, "multiple-images")) { - ofnode node = ofnode_first_subnode(binman->image); - - if (!ofnode_valid(node)) - return log_msg_ret("first image", -ENOENT); - binman->image = node; - } + ret = find_image_node(&binman->image); + if (ret) + return log_msg_ret("node", -ENOENT); binman_set_rom_offset(ROM_OFFSET_NONE);
return 0;

On Wed, Jan 13, 2021 at 08:29:56PM -0700, Simon Glass wrote:
Move this logic out of the main init function so it is available for other purpose.
Use a different error when multiple-images is in use but no subnode is available. This makes it easier to determine what is wrong.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

Some images may have multiple copies of the same thing, e.g. two versions of the read/write U-Boots. It is necessary to read data from one or other of these under selection of the verified-boot logic. Add a function to select the subnode to use.
Signed-off-by: Simon Glass sjg@chromium.org ---
include/binman.h | 14 ++++++++++++++ lib/binman.c | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+)
diff --git a/include/binman.h b/include/binman.h index 8b89a9666d5..5958dfb4485 100644 --- a/include/binman.h +++ b/include/binman.h @@ -70,6 +70,20 @@ int binman_entry_find(const char *name, struct binman_entry *entry); */ ofnode binman_section_find_node(const char *name);
+/** + * binman_select_subnode() - Select a subnode to use to find entries + * + * Normally binman selects the top-level node for future entry requests, such as + * binman_entry_find(). This function allows a subnode to be chosen instead. + * + * @name: Name of subnode, typically a section. This must be in the top-level + * binman node + * @return 0 if OK, -EINVAL if there is no /binman node, -ECHILD if multiple + * images are being used but the first image is not available, -ENOENT if + * the requested subnode cannot be found + */ +int binman_select_subnode(const char *name); + /** * binman_init() - Set up the binman symbol information * diff --git a/lib/binman.c b/lib/binman.c index b6d9dff5b7c..f415df30545 100644 --- a/lib/binman.c +++ b/lib/binman.c @@ -116,6 +116,24 @@ int binman_get_rom_offset(void) return binman->rom_offset; }
+int binman_select_subnode(const char *name) +{ + ofnode node; + int ret; + + ret = find_image_node(&node); + if (ret) + return log_msg_ret("main", -ENOENT); + node = ofnode_find_subnode(node, name); + if (!ofnode_valid(node)) + return log_msg_ret("node", -ENOENT); + binman->image = node; + log_debug("binman: Selected image subnode '%s'\n", + ofnode_get_name(binman->image)); + + return 0; +} + int binman_init(void) { int ret;

On Wed, Jan 13, 2021 at 08:29:57PM -0700, Simon Glass wrote:
Some images may have multiple copies of the same thing, e.g. two versions of the read/write U-Boots. It is necessary to read data from one or other of these under selection of the verified-boot logic. Add a function to select the subnode to use.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
participants (6)
-
Bin Meng
-
Jaehoon Chung
-
Jesper Schmitz Mouridsen
-
Peter Robinson
-
Simon Glass
-
Tom Rini