summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig10
-rw-r--r--common/Makefile6
-rw-r--r--common/autoboot.c2
-rw-r--r--common/avb_verify.c4
-rw-r--r--common/board_r.c9
-rw-r--r--common/button_cmd.c2
-rw-r--r--common/cli_readline.c4
-rw-r--r--common/log_syslog.c1
-rw-r--r--common/menu.c44
-rw-r--r--common/spl/Kconfig19
-rw-r--r--common/spl/spl.c18
-rw-r--r--common/spl/spl_fat.c1
-rw-r--r--common/spl/spl_fit.c58
-rw-r--r--common/spl/spl_imx_container.c4
-rw-r--r--common/usb.c1
15 files changed, 145 insertions, 38 deletions
diff --git a/common/Kconfig b/common/Kconfig
index be517b80eb5..a2f653f7e72 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -704,8 +704,9 @@ config ARCH_EARLY_INIT_R
enabled. This can be used to set up architecture-specific devices.
config ARCH_MISC_INIT
- bool "Call arch-specific init after relocation, when console is ready"
+ bool
help
+ Call arch-specific init after relocation, when console is ready.
With this option U-Boot will call arch_misc_init() after
relocation to allow miscellaneous arch-dependent initialisation
to be performed. This function should be defined by the board
@@ -727,6 +728,13 @@ config BOARD_EARLY_INIT_R
relocation. With this option, U-Boot calls board_early_init_r()
in the post-relocation init sequence.
+config BOARD_INIT
+ bool "Call board-specific init board_init() during init-calls"
+ default y if ARM || RISCV || SANDBOX
+ help
+ Some boards need an board_init() function called during the initcall
+ phase of startup.
+
config BOARD_POSTCLK_INIT
bool "Call board_postclk_init"
help
diff --git a/common/Makefile b/common/Makefile
index 35991562a12..d62ea34599e 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -19,6 +19,12 @@ obj-y += version.o
# # boards
obj-y += board_f.o
obj-y += board_r.o
+ifdef CONFIG_$(PHASE_)SYS_THUMB_BUILD
+ifneq ($(CONFIG_SYS_ARM_ARCH),7)
+CFLAGS_REMOVE_board_f.o := $(LTO_CFLAGS)
+CFLAGS_REMOVE_board_r.o := $(LTO_CFLAGS)
+endif
+endif
obj-$(CONFIG_DISPLAY_BOARDINFO) += board_info.o
obj-$(CONFIG_DISPLAY_BOARDINFO_LATE) += board_info.o
diff --git a/common/autoboot.c b/common/autoboot.c
index 0a254498d40..e39f4a32f95 100644
--- a/common/autoboot.c
+++ b/common/autoboot.c
@@ -410,7 +410,7 @@ static int abortboot_single_key(int bootdelay)
udelay(10000);
} while (!abort && get_timer(ts) < 1000);
- printf("\b\b\b%2d ", bootdelay);
+ printf("\rHit any key to stop autoboot: %1d\033[K", bootdelay);
}
putc('\n');
diff --git a/common/avb_verify.c b/common/avb_verify.c
index cff9117d92f..29a3272579c 100644
--- a/common/avb_verify.c
+++ b/common/avb_verify.c
@@ -320,7 +320,7 @@ static unsigned long mmc_read_and_flush(struct mmc_part *part,
}
if ((start + sectors) > (part->info.start + part->info.size)) {
sectors = part->info.start + part->info.size - start;
- printf("%s: read sector aligned to partition bounds (%ld)\n",
+ printf("%s: read sector aligned to partition bounds (" LBAF ")\n",
__func__, sectors);
}
@@ -363,7 +363,7 @@ static unsigned long mmc_write(struct mmc_part *part, lbaint_t start,
}
if ((start + sectors) > (part->info.start + part->info.size)) {
sectors = part->info.start + part->info.size - start;
- printf("%s: sector aligned to partition bounds (%ld)\n",
+ printf("%s: sector aligned to partition bounds (" LBAF ")\n",
__func__, sectors);
}
if (unaligned) {
diff --git a/common/board_r.c b/common/board_r.c
index 41c8dec8d49..143d51d0633 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -36,7 +36,6 @@
#include <env.h>
#include <env_internal.h>
#include <fdtdec.h>
-#include <ide.h>
#include <init.h>
#include <initcall.h>
#include <kgdb.h>
@@ -145,7 +144,7 @@ static int initr_reloc_global_data(void)
*/
fixup_cpu();
#endif
-#ifdef CONFIG_SYS_RELOC_GD_ENV_ADDR
+#ifdef CONFIG_ENV_RELOC_GD_ENV_ADDR
/*
* Relocate the early env_addr pointer unless we know it is not inside
* the binary. Some systems need this and for the rest, it doesn't hurt.
@@ -443,9 +442,6 @@ static int should_load_env(void)
if (IS_ENABLED(CONFIG_OF_CONTROL))
return ofnode_conf_read_int("load-environment", 1);
- if (IS_ENABLED(CONFIG_DELAY_ENVIRONMENT))
- return 0;
-
return 1;
}
@@ -649,8 +645,7 @@ static void initcall_run_r(void)
#if CONFIG_IS_ENABLED(ADDR_MAP)
INITCALL(init_addr_map);
#endif
-#if CONFIG_IS_ENABLED(ARM) || CONFIG_IS_ENABLED(RISCV) || \
- CONFIG_IS_ENABLED(SANDBOX)
+#if CONFIG_IS_ENABLED(BOARD_INIT)
INITCALL(board_init); /* Setup chipselects */
#endif
/*
diff --git a/common/button_cmd.c b/common/button_cmd.c
index 72dac1f9ef6..a6c437d7a34 100644
--- a/common/button_cmd.c
+++ b/common/button_cmd.c
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (c) 2023 Linaro Ltd.
- * Author: Caleb Connolly <caleb.connolly@linaro.org>
+ * Author: Casey Connolly <casey.connolly@linaro.org>
*/
#include <button.h>
diff --git a/common/cli_readline.c b/common/cli_readline.c
index 4e6797a1944..0cb43e62000 100644
--- a/common/cli_readline.c
+++ b/common/cli_readline.c
@@ -332,8 +332,8 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar)
if (cls->num) {
uint base, wlen;
- for (base = cls->num - 1;
- base >= 0 && buf[base] == ' ';)
+ for (base = cls->num;
+ base > 0 && buf[base - 1] == ' ';)
base--;
for (; base > 0 && buf[base - 1] != ' ';)
base--;
diff --git a/common/log_syslog.c b/common/log_syslog.c
index 0dcb5f7cdea..73bd3aca07e 100644
--- a/common/log_syslog.c
+++ b/common/log_syslog.c
@@ -5,6 +5,7 @@
* Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
*/
+#include <env.h>
#include <log.h>
#include <net.h>
#include <asm/global_data.h>
diff --git a/common/menu.c b/common/menu.c
index 5a2126aa01a..ae5afa14766 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -8,6 +8,7 @@
#include <cli.h>
#include <malloc.h>
#include <errno.h>
+#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/list.h>
#include <watchdog.h>
@@ -436,6 +437,29 @@ int menu_destroy(struct menu *m)
return 1;
}
+static int bootmenu_conv_shortcut_key(struct bootmenu_data *menu, int ichar)
+{
+ int shortcut_key;
+
+ ichar = tolower(ichar);
+ switch (ichar) {
+ /* a-z for bootmenu entry > 9 */
+ case 'a' ... 'z':
+ shortcut_key = ichar - 'a' + 9;
+ break;
+ /* 1-9 for bootmenu entry <= 9 */
+ case '1' ... '9':
+ shortcut_key = ichar - '1';
+ break;
+ /* Reserve 0 for last option (aka Exit) */
+ case '0':
+ default:
+ return -1;
+ }
+
+ return shortcut_key;
+}
+
enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
struct cli_ch_state *cch)
{
@@ -443,12 +467,12 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
int i, c;
while (menu->delay > 0) {
+ int ichar;
+
if (ansi)
printf(ANSI_CURSOR_POSITION, menu->count + 5, 3);
printf("Hit any key to stop autoboot: %d ", menu->delay);
for (i = 0; i < 100; ++i) {
- int ichar;
-
if (!tstc()) {
schedule();
mdelay(10);
@@ -470,6 +494,11 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
case 0x3: /* ^C */
key = BKEY_QUIT;
break;
+ case 'A' ... 'Z':
+ case 'a' ... 'z':
+ case '0' ... '9':
+ key = BKEY_SHORTCUT;
+ break;
default:
key = BKEY_NONE;
break;
@@ -477,6 +506,9 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
break;
}
+ if (key == BKEY_SHORTCUT)
+ cch->shortcut_key = bootmenu_conv_shortcut_key(menu, ichar);
+
if (menu->delay < 0)
break;
@@ -524,6 +556,11 @@ enum bootmenu_key bootmenu_conv_key(int ichar)
case ' ':
key = BKEY_SPACE;
break;
+ case 'A' ... 'Z':
+ case 'a' ... 'z':
+ case '0' ... '9':
+ key = BKEY_SHORTCUT;
+ break;
default:
key = BKEY_NONE;
break;
@@ -554,5 +591,8 @@ enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
key = bootmenu_conv_key(c);
+ if (key == BKEY_SHORTCUT)
+ cch->shortcut_key = bootmenu_conv_shortcut_key(menu, c);
+
return key;
}
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 77cf04d38ed..ab05536bd02 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -80,7 +80,7 @@ config SPL_MAX_SIZE
default 0x1b000 if AM33XX && !TI_SECURE_DEVICE
default 0xec00 if OMAP34XX
default 0x10000 if ARCH_MX6 && !MX6_OCRAM_256KB
- default 0xbfa0 if MACH_SUN50I_H616
+ default 0xbfa0 if MACH_SUN50I_H616 || MACH_SUN50I_A133 || MACH_SUN55I_A523
default 0x7000 if RCAR_GEN3
default 0x5fa0 if SUNXI_SRAM_ADDRESS = 0x0
default 0x7fa0 if ARCH_SUNXI
@@ -132,6 +132,7 @@ config SPL_BSS_START_ADDR
choice
prompt "Enforce SPL BSS limit"
depends on !PPC
+ default SPL_NO_BSS_LIMIT if COMPILE_TEST
default SPL_BSS_LIMIT
help
In some platforms we only want to enforce a limit on the size of the
@@ -277,6 +278,7 @@ config SPL_TEXT_BASE
default 0x00912000 if ARCH_MX7
default 0x40301350 if OMAP54XX
default 0x10060 if MACH_SUN50I || MACH_SUN50I_H5 || MACH_SUN9I
+ default 0x44060 if MACH_SUN55I_A523
default 0x20060 if SUN50I_GEN_H6 || SUNXI_GEN_NCAT2
default 0x00060 if ARCH_SUNXI
default 0xfffc0000 if ARCH_ZYNQMP
@@ -370,6 +372,13 @@ config SPL_IMX_CONTAINER_USE_TRAMPOLINE
help
Enable SPL load reader to load data to a trampoline buffer.
+config IMX_PQC_SUPPORT
+ bool "Enable to support i.MX ROM PQC Container"
+ depends on SPL && SPL_LOAD_IMX_CONTAINER
+ help
+ Support i.MX ROM new PQC container format. If your chip does not use
+ PQC container, say 'n'.
+
config IMX_CONTAINER_CFG
string "i.MX8 Container config file"
depends on SPL && SPL_LOAD_IMX_CONTAINER
@@ -423,7 +432,8 @@ config SPL_STACK
default 0x91ffb8 if ARCH_MX6 && !MX6_OCRAM_256KB
default 0x118000 if MACH_SUN50I_H6
default 0x52a00 if MACH_SUN50I_H616
- default 0x40000 if MACH_SUN8I_R528
+ default 0x40000 if MACH_SUN8I_R528 || MACH_SUN50I_A133
+ default 0x44000 if MACH_SUN55I_A523
default 0x54000 if MACH_SUN50I || MACH_SUN50I_H5
default 0x18000 if MACH_SUN9I
default 0x8000 if ARCH_SUNXI
@@ -488,7 +498,7 @@ config SPL_CUSTOM_SYS_MALLOC_ADDR
config SPL_SYS_MALLOC_SIZE
hex "Size of the SPL malloc pool"
depends on SPL_SYS_MALLOC
- default 0x180000 if BIOSEMU && RISCV
+ default 0x800000 if RISCV
default 0x100000
config SPL_READ_ONLY
@@ -1138,6 +1148,7 @@ config SPL_DM_SPI_FLASH
config SPL_NET
bool "Support networking"
depends on !NET_LWIP
+ select SPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF
help
Enable support for network devices (such as Ethernet) in SPL.
This permits SPL to load U-Boot over a network link rather than
@@ -1597,7 +1608,7 @@ config SPL_OPENSBI_SCRATCH_OPTIONS
config SPL_TARGET
string "Addtional build targets for 'make'"
default "spl/u-boot-spl.srec" if RCAR_GEN2
- default "spl/u-boot-spl.scif" if RCAR_GEN3
+ default "spl/u-boot-spl.scif" if RCAR_64
default ""
help
On some platforms we need to have 'make' run additional build target
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 76fd56dfe4b..ed443c645a7 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -392,7 +392,7 @@ int spl_load(struct spl_image_info *spl_image,
}
#endif
-__weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
+__weak void __noreturn jump_to_image(struct spl_image_info *spl_image)
{
typedef void __noreturn (*image_entry_noargs_t)(void);
@@ -634,7 +634,7 @@ static int boot_from_devices(struct spl_image_info *spl_image,
if (CONFIG_IS_ENABLED(SHOW_ERRORS))
ret = -ENXIO;
for (loader = drv; loader != drv + n_ents; loader++) {
- if (bootdev != loader->boot_device)
+ if (loader && bootdev != loader->boot_device)
continue;
if (!CONFIG_IS_ENABLED(SILENT_CONSOLE)) {
if (loader)
@@ -689,7 +689,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
BOOT_DEVICE_NONE,
BOOT_DEVICE_NONE,
};
- spl_jump_to_image_t jump_to_image = &jump_to_image_no_args;
+ spl_jump_to_image_t jumper = &jump_to_image;
struct spl_image_info spl_image;
int ret, os;
@@ -783,20 +783,20 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
} else if (CONFIG_IS_ENABLED(ATF) && os == IH_OS_ARM_TRUSTED_FIRMWARE) {
debug("Jumping to U-Boot via ARM Trusted Firmware\n");
spl_fixup_fdt(spl_image_fdt_addr(&spl_image));
- jump_to_image = &spl_invoke_atf;
+ jumper = &spl_invoke_atf;
} else if (CONFIG_IS_ENABLED(OPTEE_IMAGE) && os == IH_OS_TEE) {
debug("Jumping to U-Boot via OP-TEE\n");
spl_board_prepare_for_optee(spl_image_fdt_addr(&spl_image));
- jump_to_image = &jump_to_image_optee;
+ jumper = &jump_to_image_optee;
} else if (CONFIG_IS_ENABLED(OPENSBI) && os == IH_OS_OPENSBI) {
debug("Jumping to U-Boot via RISC-V OpenSBI\n");
- jump_to_image = &spl_invoke_opensbi;
+ jumper = &spl_invoke_opensbi;
} else if (CONFIG_IS_ENABLED(OS_BOOT) && os == IH_OS_LINUX) {
debug("Jumping to Linux\n");
if (IS_ENABLED(CONFIG_SPL_OS_BOOT))
spl_fixup_fdt((void *)SPL_PAYLOAD_ARGS_ADDR);
spl_board_prepare_for_linux();
- jump_to_image = &jump_to_image_linux;
+ jumper = &jump_to_image_linux;
} else {
debug("Unsupported OS image.. Jumping nevertheless..\n");
}
@@ -848,7 +848,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
if (CONFIG_IS_ENABLED(RELOC_LOADER)) {
int ret;
- ret = spl_reloc_jump(&spl_image, jump_to_image);
+ ret = spl_reloc_jump(&spl_image, jumper);
if (ret) {
if (xpl_phase() == PHASE_VPL)
printf("jump failed %d\n", ret);
@@ -856,7 +856,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
}
}
- jump_to_image(&spl_image);
+ jumper(&spl_image);
}
/*
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index f426a068ff9..8b7cafa7291 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -16,6 +16,7 @@
#include <errno.h>
#include <image.h>
#include <linux/libfdt.h>
+#include <asm/cache.h>
static int fat_registered;
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 86506d6905c..25f3c822a49 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -73,7 +73,7 @@ static int spl_fit_get_image_name(const struct spl_fit_info *ctx,
const char **outname)
{
struct udevice *sysinfo;
- const char *name, *str;
+ const char *name, *str, *end;
__maybe_unused int node;
int len, i;
bool found = true;
@@ -83,11 +83,17 @@ static int spl_fit_get_image_name(const struct spl_fit_info *ctx,
debug("cannot find property '%s': %d\n", type, len);
return -EINVAL;
}
+ /* A string property should be NUL terminated */
+ end = name + len - 1;
+ if (!len || *end) {
+ debug("malformed property '%s'\n", type);
+ return -EINVAL;
+ }
str = name;
for (i = 0; i < index; i++) {
str = strchr(str, '\0') + 1;
- if (!str || (str - name >= len)) {
+ if (str > end) {
found = false;
break;
}
@@ -199,7 +205,7 @@ static int get_aligned_image_size(struct spl_load_info *info, int data_size,
* the image gets loaded to the address pointed to by the
* load_addr member in this struct, if load_addr is not 0
*
- * Return: 0 on success, -EPERM if this image is not the correct phase
+ * Return: 0 on success, -EBADSLT if this image is not the correct phase
* (for CONFIG_BOOTMETH_VBE_SIMPLE_FW), or another negative error number on
* other error.
*/
@@ -235,7 +241,7 @@ static int load_simple_fit(struct spl_load_info *info, ulong fit_offset,
return ret;
} else {
log_debug("- phase mismatch, skipping this image\n");
- return -EPERM;
+ return -EBADSLT;
}
}
@@ -474,7 +480,7 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
image_info.load_addr = (ulong)tmpbuffer;
ret = load_simple_fit(info, offset, ctx, node,
&image_info);
- if (ret == -EPERM)
+ if (ret == -EBADSLT)
continue;
else if (ret < 0)
break;
@@ -702,13 +708,51 @@ static int spl_simple_fit_read(struct spl_fit_info *ctx,
*/
size = get_aligned_image_size(info, size, 0);
buf = board_spl_fit_buffer_addr(size, size, 1);
+ if (!buf) {
+ /*
+ * We assume that none of the board will ever use 0x0 as a
+ * valid load address. Theoretically some board could use it,
+ * but this is extremely unlikely.
+ */
+ return -EIO;
+ }
count = info->read(info, offset, size, buf);
+ if (!count) {
+ /*
+ * FIT could not be read. This means we should free the
+ * memory allocated by board_spl_fit_buffer_addr().
+ * Unfortunately, we don't know what memory allocation
+ * mechanism was used:
+ * - For the SPL_SYS_MALLOC_SIMPLE case nothing could
+ * be done. The memory just could not be freed.
+ * - For statically allocated memory buffer we can try
+ * to reuse previously allocated memory (example:
+ * board_spl_fit_buffer_addr() function from the
+ * file test/image/spl_load.c).
+ * - For normall malloc() -- memory leak can't be easily
+ * avoided. To somehow reduce memory consumption the
+ * next calls of board_spl_fit_buffer_addr() could
+ * reallocate previously allocated buffer and use
+ * them again. This is somethat similar to the approach
+ * used for statically allocated buffer.
+ *
+ * Please note:
+ * - FIT images with data placed outside of the FIT
+ * structure will cause small memory leak (several
+ * kilobytes),
+ * - FIT images with data placed inside to the FIT
+ * structure may cause huge memory leak (up to
+ * several megabytes). Do NOT use such images!
+ */
+ return -EIO;
+ }
+
ctx->fit = buf;
debug("fit read offset %lx, size=%lu, dst=%p, count=%lu\n",
offset, size, buf, count);
- return (count == 0) ? -EIO : 0;
+ return 0;
}
static int spl_simple_fit_parse(struct spl_fit_info *ctx)
@@ -834,7 +878,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
image_info.load_addr = 0;
ret = load_simple_fit(info, offset, &ctx, node, &image_info);
- if (ret < 0 && ret != -EPERM) {
+ if (ret < 0 && ret != -EBADSLT) {
printf("%s: can't load image loadables index %d (ret = %d)\n",
__func__, index, ret);
return ret;
diff --git a/common/spl/spl_imx_container.c b/common/spl/spl_imx_container.c
index b3565efb225..79d021f81dc 100644
--- a/common/spl/spl_imx_container.c
+++ b/common/spl/spl_imx_container.c
@@ -31,7 +31,7 @@ static struct boot_img_t *read_auth_image(struct spl_image_info *spl_image,
ulong container_offset)
{
struct boot_img_t *images;
- ulong offset, overhead, size;
+ ulong offset, size;
void *buf, *trampoline;
if (image_index > container->num_images) {
@@ -54,7 +54,7 @@ static struct boot_img_t *read_auth_image(struct spl_image_info *spl_image,
debug("%s: container: %p offset: %lu size: %lu\n", __func__,
container, offset, size);
- buf = map_sysmem(images[image_index].dst - overhead, images[image_index].size);
+ buf = map_sysmem(images[image_index].dst, images[image_index].size);
if (IS_ENABLED(CONFIG_SPL_IMX_CONTAINER_USE_TRAMPOLINE) &&
arch_check_dst_in_secure(buf, size)) {
trampoline = arch_get_container_trampoline();
diff --git a/common/usb.c b/common/usb.c
index 7a8435296c6..6a4ad346f4b 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -28,6 +28,7 @@
#include <command.h>
#include <dm.h>
#include <dm/device_compat.h>
+#include <env.h>
#include <log.h>
#include <malloc.h>
#include <memalign.h>