diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/Kconfig | 25 | ||||
-rw-r--r-- | common/board_f.c | 6 | ||||
-rw-r--r-- | common/board_r.c | 16 | ||||
-rw-r--r-- | common/bootm_os.c | 32 | ||||
-rw-r--r-- | common/image-fdt.c | 3 | ||||
-rw-r--r-- | common/image-fit.c | 63 | ||||
-rw-r--r-- | common/image.c | 3 | ||||
-rw-r--r-- | common/log.c | 17 | ||||
-rw-r--r-- | common/memsize.c | 14 | ||||
-rw-r--r-- | common/spl/Kconfig | 52 | ||||
-rw-r--r-- | common/spl/spl.c | 10 | ||||
-rw-r--r-- | common/spl/spl_fit.c | 15 | ||||
-rw-r--r-- | common/spl/spl_mmc.c | 15 | ||||
-rw-r--r-- | common/spl/spl_ram.c | 6 |
14 files changed, 217 insertions, 60 deletions
diff --git a/common/Kconfig b/common/Kconfig index b92d0e38366..03eeeb24025 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -561,13 +561,20 @@ config DISPLAY_CPUINFO to do this. config DISPLAY_BOARDINFO - bool "Display information about the board during start up" + bool "Display information about the board during early start up" default y if ARM || M68K || MIPS || PPC || SANDBOX || XTENSA help Display information about the board that U-Boot is running on when U-Boot starts up. The board function checkboard() is called to do this. +config DISPLAY_BOARDINFO_LATE + bool "Display information about the board during late start up" + help + Display information about the board that U-Boot is running on after + the relocation phase. The board function checkboard() is called to do + this. + menu "Start-up hooks" config ARCH_EARLY_INIT_R @@ -595,6 +602,22 @@ config BOARD_EARLY_INIT_F Note that the normal serial console is not yet set up, but the debug UART will be available if enabled. +config BOARD_EARLY_INIT_R + bool "Call board-specific init after relocation" + help + Some boards need to perform initialisation as directly after + relocation. With this option, U-Boot calls board_early_init_r() + in the post-relocation init sequence. + +config LAST_STAGE_INIT + bool "Call board-specific as last setup step" + help + Some boards need to perform initialisation immediately before control + is passed to the command-line interpreter (e.g. for initializations + that depend on later phases in the init sequence). With this option, + U-Boot calls last_stage_init() before the command-line interpreter is + started. + endmenu menu "Security support" diff --git a/common/board_f.c b/common/board_f.c index c6bc53e1bf0..ae8bdb7c5c0 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -18,7 +18,6 @@ #include <fs.h> #include <i2c.h> #include <initcall.h> -#include <init_helpers.h> #include <malloc.h> #include <mapmem.h> #include <os.h> @@ -489,7 +488,7 @@ static int reserve_bootstage(void) return 0; } -int arch_reserve_stacks(void) +__weak int arch_reserve_stacks(void) { return 0; } @@ -901,7 +900,8 @@ void board_init_f(ulong boot_flags) hang(); #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \ - !defined(CONFIG_EFI_APP) && !CONFIG_IS_ENABLED(X86_64) + !defined(CONFIG_EFI_APP) && !CONFIG_IS_ENABLED(X86_64) && \ + !defined(CONFIG_ARC) /* NOTREACHED - jump_to_copy() does not return */ hang(); #endif diff --git a/common/board_r.c b/common/board_r.c index 482f5066616..0f4479a58bc 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -23,10 +23,6 @@ #include <fdtdec.h> #include <ide.h> #include <initcall.h> -#include <init_helpers.h> -#ifdef CONFIG_PS2KBD -#include <keyboard.h> -#endif #if defined(CONFIG_CMD_KGDB) #include <kgdb.h> #endif @@ -642,15 +638,6 @@ static int initr_bedbug(void) } #endif -#ifdef CONFIG_PS2KBD -static int initr_kbd(void) -{ - puts("PS/2: "); - kbd_init(); - return 0; -} -#endif - static int run_main_loop(void) { #ifdef CONFIG_SANDBOX @@ -859,9 +846,6 @@ static init_fnc_t init_sequence_r[] = { #if defined(CONFIG_PRAM) initr_mem, #endif -#ifdef CONFIG_PS2KBD - initr_kbd, -#endif run_main_loop, }; diff --git a/common/bootm_os.c b/common/bootm_os.c index 5e6b1777e48..b84a8e26d2c 100644 --- a/common/bootm_os.c +++ b/common/bootm_os.c @@ -11,6 +11,7 @@ #include <linux/libfdt.h> #include <malloc.h> #include <vxworks.h> +#include <tee/optee.h> DECLARE_GLOBAL_DATA_PTR; @@ -433,6 +434,34 @@ static int do_bootm_openrtos(int flag, int argc, char * const argv[], } #endif +#ifdef CONFIG_BOOTM_OPTEE +static int do_bootm_tee(int flag, int argc, char * const argv[], + bootm_headers_t *images) +{ + int ret; + + /* Verify OS type */ + if (images->os.os != IH_OS_TEE) { + return 1; + }; + + /* Validate OPTEE header */ + ret = optee_verify_bootm_image(images->os.image_start, + images->os.load, + images->os.image_len); + if (ret) + return ret; + + /* Locate FDT etc */ + ret = bootm_find_images(flag, argc, argv); + if (ret) + return ret; + + /* From here we can run the regular linux boot path */ + return do_bootm_linux(flag, argc, argv, images); +} +#endif + static boot_os_fn *boot_os[] = { [IH_OS_U_BOOT] = do_bootm_standalone, #ifdef CONFIG_BOOTM_LINUX @@ -466,6 +495,9 @@ static boot_os_fn *boot_os[] = { #ifdef CONFIG_BOOTM_OPENRTOS [IH_OS_OPENRTOS] = do_bootm_openrtos, #endif +#ifdef CONFIG_BOOTM_OPTEE + [IH_OS_TEE] = do_bootm_tee, +#endif }; /* Allow for arch specific config before we boot */ diff --git a/common/image-fdt.c b/common/image-fdt.c index 25103ba3b5d..3dc02a12191 100644 --- a/common/image-fdt.c +++ b/common/image-fdt.c @@ -21,6 +21,9 @@ #define CONFIG_SYS_FDT_PAD 0x3000 #endif +/* adding a ramdisk needs 0x44 bytes in version 2008.10 */ +#define FDT_RAMDISK_OVERHEAD 0x80 + DECLARE_GLOBAL_DATA_PTR; static void fdt_error(const char *msg) diff --git a/common/image-fit.c b/common/image-fit.c index f6e956ad963..030a3e579f5 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -419,7 +419,8 @@ void fit_image_print(const void *fit, int image_noffset, const char *p) printf("%s Architecture: %s\n", p, genimg_get_arch_name(arch)); } - if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_RAMDISK)) { + if ((type == IH_TYPE_KERNEL) || (type == IH_TYPE_RAMDISK) || + (type == IH_TYPE_FIRMWARE)) { fit_image_get_os(fit, image_noffset, &os); printf("%s OS: %s\n", p, genimg_get_os_name(os)); } @@ -1068,34 +1069,14 @@ static int fit_image_check_hash(const void *fit, int noffset, const void *data, return 0; } -/** - * fit_image_verify - verify data integrity - * @fit: pointer to the FIT format image header - * @image_noffset: component image node offset - * - * fit_image_verify() goes over component image hash nodes, - * re-calculates each data hash and compares with the value stored in hash - * node. - * - * returns: - * 1, if all hashes are valid - * 0, otherwise (or on error) - */ -int fit_image_verify(const void *fit, int image_noffset) +int fit_image_verify_with_data(const void *fit, int image_noffset, + const void *data, size_t size) { - const void *data; - size_t size; int noffset = 0; char *err_msg = ""; int verify_all = 1; int ret; - /* Get image data and data length */ - if (fit_image_get_data(fit, image_noffset, &data, &size)) { - err_msg = "Can't get image data/size"; - goto error; - } - /* Verify all required signatures */ if (IMAGE_ENABLE_VERIFY && fit_image_verify_required_sigs(fit, image_noffset, data, size, @@ -1153,6 +1134,38 @@ error: } /** + * fit_image_verify - verify data integrity + * @fit: pointer to the FIT format image header + * @image_noffset: component image node offset + * + * fit_image_verify() goes over component image hash nodes, + * re-calculates each data hash and compares with the value stored in hash + * node. + * + * returns: + * 1, if all hashes are valid + * 0, otherwise (or on error) + */ +int fit_image_verify(const void *fit, int image_noffset) +{ + const void *data; + size_t size; + int noffset = 0; + char *err_msg = ""; + + /* Get image data and data length */ + if (fit_image_get_data(fit, image_noffset, &data, &size)) { + err_msg = "Can't get image data/size"; + printf("error!\n%s for '%s' hash node in '%s' image node\n", + err_msg, fit_get_name(fit, noffset, NULL), + fit_get_name(fit, image_noffset, NULL)); + return 0; + } + + return fit_image_verify_with_data(fit, image_noffset, data, size); +} + +/** * fit_all_image_verify - verify data integrity for all images * @fit: pointer to the FIT format image header * @@ -1598,6 +1611,10 @@ void fit_conf_print(const void *fit, int noffset, const char *p) if (uname) printf("%s Init Ramdisk: %s\n", p, uname); + uname = fdt_getprop(fit, noffset, FIT_FIRMWARE_PROP, NULL); + if (uname) + printf("%s Firmware: %s\n", p, uname); + for (fdt_index = 0; uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP, fdt_index, NULL), uname; diff --git a/common/image.c b/common/image.c index 14be3caf973..e1c50eb25d0 100644 --- a/common/image.c +++ b/common/image.c @@ -86,6 +86,7 @@ static const table_entry_t uimage_arch[] = { { IH_ARCH_ARC, "arc", "ARC", }, { IH_ARCH_X86_64, "x86_64", "AMD x86_64", }, { IH_ARCH_XTENSA, "xtensa", "Xtensa", }, + { IH_ARCH_RISCV, "riscv", "RISC-V", }, { -1, "", "", }, }; @@ -100,6 +101,7 @@ static const table_entry_t uimage_os[] = { { IH_OS_OSE, "ose", "Enea OSE", }, { IH_OS_PLAN9, "plan9", "Plan 9", }, { IH_OS_RTEMS, "rtems", "RTEMS", }, + { IH_OS_TEE, "tee", "Trusted Execution Environment" }, { IH_OS_U_BOOT, "u-boot", "U-Boot", }, { IH_OS_VXWORKS, "vxworks", "VxWorks", }, #if defined(CONFIG_CMD_ELF) || defined(USE_HOSTCC) @@ -161,6 +163,7 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_TEE, "tee", "Trusted Execution Environment Image",}, { IH_TYPE_FIRMWARE_IVT, "firmware_ivt", "Firmware with HABv4 IVT" }, { IH_TYPE_PMMC, "pmmc", "TI Power Management Micro-Controller Firmware",}, + { IH_TYPE_STM32IMAGE, "stm32image", "STMicroelectronics STM32 Image" }, { -1, "", "", }, }; diff --git a/common/log.c b/common/log.c index 680a60f86e8..66d5e3ebf85 100644 --- a/common/log.c +++ b/common/log.c @@ -224,6 +224,7 @@ int log_add_filter(const char *drv_name, enum log_category_t cat_list[], { struct log_filter *filt; struct log_device *ldev; + int ret; int i; ldev = log_device_find_by_name(drv_name); @@ -236,8 +237,10 @@ int log_add_filter(const char *drv_name, enum log_category_t cat_list[], if (cat_list) { filt->flags |= LOGFF_HAS_CAT; for (i = 0; ; i++) { - if (i == ARRAY_SIZE(filt->cat_list)) - return -ENOSPC; + if (i == ARRAY_SIZE(filt->cat_list)) { + ret = -ENOSPC; + goto err; + } filt->cat_list[i] = cat_list[i]; if (cat_list[i] == LOGC_END) break; @@ -246,17 +249,19 @@ int log_add_filter(const char *drv_name, enum log_category_t cat_list[], filt->max_level = max_level; if (file_list) { filt->file_list = strdup(file_list); - if (!filt->file_list) - goto nomem; + if (!filt->file_list) { + ret = ENOMEM; + goto err; + } } filt->filter_num = ldev->next_filter_num++; list_add_tail(&filt->sibling_node, &ldev->filter_head); return filt->filter_num; -nomem: +err: free(filt); - return -ENOMEM; + return ret; } int log_remove_filter(const char *drv_name, int filter_num) diff --git a/common/memsize.c b/common/memsize.c index 0fb9ba57b62..c31527567c3 100644 --- a/common/memsize.c +++ b/common/memsize.c @@ -27,7 +27,8 @@ DECLARE_GLOBAL_DATA_PTR; long get_ram_size(long *base, long maxsize) { volatile long *addr; - long save[32]; + long save[31]; + long save_base; long cnt; long val; long size; @@ -43,7 +44,7 @@ long get_ram_size(long *base, long maxsize) addr = base; sync(); - save[i] = *addr; + save_base = *addr; sync(); *addr = 0; @@ -51,7 +52,7 @@ long get_ram_size(long *base, long maxsize) if ((val = *addr) != 0) { /* Restore the original data before leaving the function. */ sync(); - *addr = save[i]; + *base = save_base; for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) { addr = base + cnt; sync(); @@ -76,9 +77,16 @@ long get_ram_size(long *base, long maxsize) addr = base + cnt; *addr = save[--i]; } + /* warning: don't restore save_base in this case, + * it is already done in the loop because + * base and base+size share the same physical memory + * and *base is saved after *(base+size) modification + * in first loop + */ return (size); } } + *base = save_base; return (maxsize); } diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 9609fceea59..4d275655660 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -568,6 +568,15 @@ config SPL_POST_MEM_SUPPORT performed before booting. This enables the drivers in post/drivers as part of an SPL build. +config SPL_RESET_SUPPORT + bool "Support reset drivers" + depends on SPL + help + Enable support for reset control in SPL. + That can be useful in SPL to handle IP reset in driver, as in U-Boot, + by using the generic reset API provided by driver model. + This enables the drivers in drivers/reset as part of an SPL build. + config SPL_POWER_SUPPORT bool "Support power drivers" help @@ -634,6 +643,13 @@ config SPL_SPI_FLASH_SUPPORT lines). This enables the drivers in drivers/mtd/spi as part of an SPL build. This normally requires SPL_SPI_SUPPORT. +config SPL_SPI_LOAD + bool "Support loading from SPI flash" + depends on SPL_SPI_FLASH_SUPPORT + help + Enable support for loading next stage, U-Boot or otherwise, from + SPI NOR in U-Boot SPL. + config SPL_SPI_SUPPORT bool "Support SPI drivers" help @@ -763,6 +779,13 @@ config SPL_ATF_NO_PLATFORM_PARAM If your ATF is affected, say Y. +config SPL_AM33XX_ENABLE_RTC32K_OSC + bool "Enable the RTC32K OSC on AM33xx based platforms" + default y if AM33XX + help + Enable access to the AM33xx RTC and select the external 32kHz clock + source. + config TPL bool depends on SUPPORT_TPL @@ -887,6 +910,20 @@ config TPL_NAND_SUPPORT help Enable support for NAND in TPL. See SPL_NAND_SUPPORT for details. +config TPL_RAM_SUPPORT + bool "Support booting from RAM" + help + Enable booting of an image in RAM. The image can be preloaded or + it can be loaded by TPL directly into RAM (e.g. using USB). + +config TPL_RAM_DEVICE + bool "Support booting from preloaded image in RAM" + depends on TPL_RAM_SUPPORT + help + Enable booting of an image already loaded in RAM. The image has to + be already in memory when TPL takes over, e.g. loaded by the boot + ROM. + config TPL_SERIAL_SUPPORT bool "Support serial" help @@ -899,12 +936,27 @@ config TPL_SPI_FLASH_SUPPORT Enable support for using SPI flash in TPL. See SPL_SPI_FLASH_SUPPORT for details. +config TPL_SPI_LOAD + bool "Support loading from SPI flash" + depends on TPL_SPI_FLASH_SUPPORT + help + Enable support for loading next stage, U-Boot or otherwise, from + SPI NOR in U-Boot TPL. + config TPL_SPI_SUPPORT bool "Support SPI drivers" help Enable support for using SPI in TPL. See SPL_SPI_SUPPORT for details. +config TPL_YMODEM_SUPPORT + bool "Support loading using Ymodem" + help + While loading from serial is slow it can be a useful backup when + there is no other option. The Ymodem protocol provides a reliable + means of transmitting U-Boot over a serial line for using in TPL, + with a checksum to ensure correctness. + endif # TPL endif # SPL diff --git a/common/spl/spl.c b/common/spl/spl.c index b1ce56d0d07..61d3071324b 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -127,8 +127,14 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image) ulong u_boot_pos = binman_sym(ulong, u_boot_any, pos); spl_image->size = CONFIG_SYS_MONITOR_LEN; - if (u_boot_pos != BINMAN_SYM_MISSING) { - /* biman does not support separate entry addresses at present */ + + /* + * Binman error cases: address of the end of the previous region or the + * start of the image's entry area (usually 0) if there is no previous + * region. + */ + if (u_boot_pos && u_boot_pos != BINMAN_SYM_MISSING) { + /* Binman does not support separated entry addresses */ spl_image->entry_point = u_boot_pos; spl_image->load_addr = u_boot_pos; } else { diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index b705d030e77..9f03e2648a3 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -174,6 +174,9 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, uint8_t image_comp = -1, type = -1; const void *data; bool external_data = false; +#ifdef CONFIG_SPL_FIT_SIGNATURE + int ret; +#endif if (IS_ENABLED(CONFIG_SPL_OS_BOOT) && IS_ENABLED(CONFIG_SPL_GZIP)) { if (fit_image_get_comp(fit, node, &image_comp)) @@ -252,7 +255,16 @@ static int spl_load_fit_image(struct spl_load_info *info, ulong sector, image_info->entry_point = fdt_getprop_u32(fit, node, "entry"); } +#ifdef CONFIG_SPL_FIT_SIGNATURE + printf("## Checking hash(es) for Image %s ...\n", + fit_get_name(fit, node, NULL)); + ret = fit_image_verify_with_data(fit, node, + (const void *)load_addr, length); + printf("\n"); + return !ret; +#else return 0; +#endif } static int spl_fit_append_fdt(struct spl_image_info *spl_image, @@ -383,7 +395,8 @@ int spl_load_simple_fit(struct spl_image_info *spl_image, * - fall back to using the first 'loadables' entry */ if (node < 0) - node = spl_fit_get_image_node(fit, images, "firmware", 0); + node = spl_fit_get_image_node(fit, images, FIT_FIRMWARE_PROP, + 0); #ifdef CONFIG_SPL_OS_BOOT if (node < 0) node = spl_fit_get_image_node(fit, images, FIT_KERNEL_PROP, 0); diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 351f4edd41e..4aa0b2caf39 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -292,6 +292,14 @@ u32 __weak spl_boot_mode(const u32 boot_device) #endif } +#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION +__weak +int spl_boot_partition(const u32 boot_device) +{ + return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION; +} +#endif + int spl_mmc_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) { @@ -347,8 +355,11 @@ int spl_mmc_load_image(struct spl_image_info *spl_image, return err; } #ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION - err = mmc_load_image_raw_partition(spl_image, mmc, - CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION); + err = spl_boot_partition(bootdev->boot_device); + if (!err) + return err; + + err = mmc_load_image_raw_partition(spl_image, mmc, err); if (!err) return err; #endif diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c index d9db9f3a409..a15761e309f 100644 --- a/common/spl/spl_ram.c +++ b/common/spl/spl_ram.c @@ -36,7 +36,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image, header = (struct image_header *)CONFIG_SPL_LOAD_FIT_ADDRESS; -#if defined(CONFIG_SPL_DFU_SUPPORT) +#if CONFIG_IS_ENABLED(DFU_SUPPORT) if (bootdev->boot_device == BOOT_DEVICE_DFU) spl_dfu_cmd(0, "dfu_alt_info_ram", "ram", "0"); #endif @@ -74,10 +74,10 @@ static int spl_ram_load_image(struct spl_image_info *spl_image, return 0; } -#if defined(CONFIG_SPL_RAM_DEVICE) +#if CONFIG_IS_ENABLED(RAM_DEVICE) SPL_LOAD_IMAGE_METHOD("RAM", 0, BOOT_DEVICE_RAM, spl_ram_load_image); #endif -#if defined(CONFIG_SPL_DFU_SUPPORT) +#if CONFIG_IS_ENABLED(DFU_SUPPORT) SPL_LOAD_IMAGE_METHOD("DFU", 0, BOOT_DEVICE_DFU, spl_ram_load_image); #endif |