diff options
author | Tom Rini <trini@konsulko.com> | 2021-07-22 11:15:52 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-07-22 11:15:52 -0400 |
commit | a15fa1ba67d7b3c8061b515e7713f733fa328018 (patch) | |
tree | f7746e2e7a3410043e9ea3f3f7c0a97e2c5e6dbb /common | |
parent | 806734f41b25931798fdf667b5a2ae830229c13f (diff) | |
parent | 1b098b3e655451572054ce933a87231ee16f7133 (diff) |
Merge tag 'dm-pull-21jul21' of https://gitlab.denx.de/u-boot/custodians/u-boot-dm
dtoc improvements to show better warnings
minor test build fixes
sandbox fixes for SDL2 and running TPL
bloblist resize feature
binman multithreading
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig | 10 | ||||
-rw-r--r-- | common/bloblist.c | 73 | ||||
-rw-r--r-- | common/image-fit.c | 2 | ||||
-rw-r--r-- | common/log_console.c | 2 | ||||
-rw-r--r-- | common/spl/Kconfig | 10 | ||||
-rw-r--r-- | common/spl/spl.c | 48 |
6 files changed, 123 insertions, 22 deletions
diff --git a/common/Kconfig b/common/Kconfig index 26496f9a2e..2ab20a6c85 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -322,6 +322,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 @@ -724,7 +732,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/common/bloblist.c b/common/bloblist.c index eab63e9ca5..1290fff850 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); @@ -109,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); @@ -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/common/image-fit.c b/common/image-fit.c index 8e23d51cf2..28bd8e78c7 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1377,7 +1377,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 diff --git a/common/log_console.c b/common/log_console.c index 3f6177499e..f1dcc04b97 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/common/spl/Kconfig b/common/spl/Kconfig index 2df3e5d869..c0183521d2 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -91,6 +91,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 eba77cace6..3b96f2fc31 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -593,32 +593,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) @@ -710,9 +720,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(); } |