diff options
author | Stefano Babic <sbabic@denx.de> | 2016-11-29 16:28:28 +0100 |
---|---|---|
committer | Stefano Babic <sbabic@denx.de> | 2016-11-29 16:28:28 +0100 |
commit | 2d221489df021393654805536be7effcb9d39702 (patch) | |
tree | 1b636f10b4ccde42624ec665df13288408b59b7f /common | |
parent | 45a3ad81fafe3090f7f89b458f6bd9f547a453df (diff) | |
parent | e94793c844a40606252f2e3f6428063e057b3fd2 (diff) |
Merge branch 'master' of git://git.denx.de/u-boot
Signed-off-by: Stefano Babic <sbabic@denx.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/board_info.c | 4 | ||||
-rw-r--r-- | common/image-fit.c | 19 | ||||
-rw-r--r-- | common/image-sig.c | 78 | ||||
-rw-r--r-- | common/sata.c | 8 | ||||
-rw-r--r-- | common/spl/Kconfig | 84 | ||||
-rw-r--r-- | common/spl/spl.c | 2 | ||||
-rw-r--r-- | common/spl/spl_ext.c | 8 | ||||
-rw-r--r-- | common/spl/spl_mmc.c | 4 | ||||
-rw-r--r-- | common/spl/spl_spi.c | 3 | ||||
-rw-r--r-- | common/spl/spl_ymodem.c | 1 | ||||
-rw-r--r-- | common/stdio.c | 9 | ||||
-rw-r--r-- | common/xyzModem.c | 10 |
12 files changed, 161 insertions, 69 deletions
diff --git a/common/board_info.c b/common/board_info.c index bd5dcfa066..aa45e24b34 100644 --- a/common/board_info.c +++ b/common/board_info.c @@ -15,9 +15,9 @@ int __weak checkboard(void) * If the root node of the DTB has a "model" property, show it. * Then call checkboard(). */ -int show_board_info(void) +int __weak show_board_info(void) { -#if defined(CONFIG_OF_CONTROL) && !defined(CONFIG_CUSTOM_BOARDINFO) +#ifdef CONFIG_OF_CONTROL DECLARE_GLOBAL_DATA_PTR; const char *model; diff --git a/common/image-fit.c b/common/image-fit.c index 77dc011dc3..9468e519db 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -14,6 +14,7 @@ #include <time.h> #else #include <linux/compiler.h> +#include <linux/kconfig.h> #include <common.h> #include <errno.h> #include <mapmem.h> @@ -1161,11 +1162,18 @@ int fit_image_check_os(const void *fit, int noffset, uint8_t os) int fit_image_check_arch(const void *fit, int noffset, uint8_t arch) { uint8_t image_arch; + int aarch32_support = 0; + +#ifdef CONFIG_ARM64_SUPPORT_AARCH32 + aarch32_support = 1; +#endif if (fit_image_get_arch(fit, noffset, &image_arch)) return 0; return (arch == image_arch) || - (arch == IH_ARCH_I386 && image_arch == IH_ARCH_X86_64); + (arch == IH_ARCH_I386 && image_arch == IH_ARCH_X86_64) || + (arch == IH_ARCH_ARM64 && image_arch == IH_ARCH_ARM && + aarch32_support); } /** @@ -1614,6 +1622,9 @@ int fit_image_load(bootm_headers_t *images, ulong addr, int type_ok, os_ok; ulong load, data, len; uint8_t os; +#ifndef USE_HOSTCC + uint8_t os_arch; +#endif const char *prop_name; int ret; @@ -1697,6 +1708,12 @@ int fit_image_load(bootm_headers_t *images, ulong addr, return -ENOEXEC; } #endif + +#ifndef USE_HOSTCC + fit_image_get_arch(fit, noffset, &os_arch); + images->os.arch = os_arch; +#endif + if (image_type == IH_TYPE_FLATDT && !fit_image_check_comp(fit, noffset, IH_COMP_NONE)) { puts("FDT image is compressed"); diff --git a/common/image-sig.c b/common/image-sig.c index 28f7a20cad..455f2b9629 100644 --- a/common/image-sig.c +++ b/common/image-sig.c @@ -34,68 +34,74 @@ struct checksum_algo checksum_algos[] = { { "sha1", SHA1_SUM_LEN, - RSA2048_BYTES, + SHA1_DER_LEN, + sha1_der_prefix, #if IMAGE_ENABLE_SIGN EVP_sha1, #endif hash_calculate, - padding_sha1_rsa2048, - }, - { - "sha256", - SHA256_SUM_LEN, - RSA2048_BYTES, -#if IMAGE_ENABLE_SIGN - EVP_sha256, -#endif - hash_calculate, - padding_sha256_rsa2048, }, { "sha256", SHA256_SUM_LEN, - RSA4096_BYTES, + SHA256_DER_LEN, + sha256_der_prefix, #if IMAGE_ENABLE_SIGN EVP_sha256, #endif hash_calculate, - padding_sha256_rsa4096, } }; -struct image_sig_algo image_sig_algos[] = { +struct crypto_algo crypto_algos[] = { { - "sha1,rsa2048", - rsa_sign, - rsa_add_verify_data, - rsa_verify, - &checksum_algos[0], - }, - { - "sha256,rsa2048", + "rsa2048", + RSA2048_BYTES, rsa_sign, rsa_add_verify_data, rsa_verify, - &checksum_algos[1], }, { - "sha256,rsa4096", + "rsa4096", + RSA4096_BYTES, rsa_sign, rsa_add_verify_data, rsa_verify, - &checksum_algos[2], } }; -struct image_sig_algo *image_get_sig_algo(const char *name) +struct checksum_algo *image_get_checksum_algo(const char *full_name) { int i; + const char *name; + + for (i = 0; i < ARRAY_SIZE(checksum_algos); i++) { + name = checksum_algos[i].name; + /* Make sure names match and next char is a comma */ + if (!strncmp(name, full_name, strlen(name)) && + full_name[strlen(name)] == ',') + return &checksum_algos[i]; + } + + return NULL; +} + +struct crypto_algo *image_get_crypto_algo(const char *full_name) +{ + int i; + const char *name; + + /* Move name to after the comma */ + name = strchr(full_name, ','); + if (!name) + return NULL; + name += 1; - for (i = 0; i < ARRAY_SIZE(image_sig_algos); i++) { - if (!strcmp(image_sig_algos[i].name, name)) - return &image_sig_algos[i]; + for (i = 0; i < ARRAY_SIZE(crypto_algos); i++) { + if (!strcmp(crypto_algos[i].name, name)) + return &crypto_algos[i]; } return NULL; @@ -159,12 +165,14 @@ static int fit_image_setup_verify(struct image_sign_info *info, info->keyname = fdt_getprop(fit, noffset, "key-name-hint", NULL); info->fit = (void *)fit; info->node_offset = noffset; - info->algo = image_get_sig_algo(algo_name); + info->name = algo_name; + info->checksum = image_get_checksum_algo(algo_name); + info->crypto = image_get_crypto_algo(algo_name); info->fdt_blob = gd_fdt_blob(); info->required_keynode = required_keynode; printf("%s:%s", algo_name, info->keyname); - if (!info->algo) { + if (!info->checksum || !info->crypto) { *err_msgp = "Unknown signature algorithm"; return -1; } @@ -194,7 +202,7 @@ int fit_image_check_sig(const void *fit, int noffset, const void *data, region.data = data; region.size = size; - if (info.algo->verify(&info, ®ion, 1, fit_value, fit_value_len)) { + if (info.crypto->verify(&info, ®ion, 1, fit_value, fit_value_len)) { *err_msgp = "Verification failed"; return -1; } @@ -375,8 +383,8 @@ int fit_config_check_sig(const void *fit, int noffset, int required_keynode, struct image_region region[count]; fit_region_make_list(fit, fdt_regions, count, region); - if (info.algo->verify(&info, region, count, fit_value, - fit_value_len)) { + if (info.crypto->verify(&info, region, count, fit_value, + fit_value_len)) { *err_msgp = "Verification failed"; return -1; } diff --git a/common/sata.c b/common/sata.c index 88f08c95ec..42ff5c7755 100644 --- a/common/sata.c +++ b/common/sata.c @@ -51,7 +51,7 @@ static unsigned long sata_bwrite(struct blk_desc *block_dev, lbaint_t start, int __sata_initialize(void) { - int rc; + int rc, ret = -1; int i; for (i = 0; i < CONFIG_SYS_SATA_MAX_DEVICE; i++) { @@ -71,12 +71,14 @@ int __sata_initialize(void) if (!rc) { rc = scan_sata(i); if (!rc && sata_dev_desc[i].lba > 0 && - sata_dev_desc[i].blksz > 0) + sata_dev_desc[i].blksz > 0) { part_init(&sata_dev_desc[i]); + ret = i; + } } } - return rc; + return ret; } int sata_initialize(void) __attribute__((weak, alias("__sata_initialize"))); diff --git a/common/spl/Kconfig b/common/spl/Kconfig index bb99f1fcff..cba51f5df6 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -70,6 +70,33 @@ config SPL_DISPLAY_PRINT banner ("U-Boot SPL ..."). This function should be provided by the board. +config SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR + bool "MMC raw mode: by sector" + depends on SPL + default y if ARCH_SUNXI || ARCH_DAVINCI || ARCH_UNIPHIER ||ARCH_MX6 || \ + ARCH_ROCKCHIP || ARCH_MVEBU || ARCH_SOCFPGA || \ + ARCH_AT91 || ARCH_ZYNQ || ARCH_KEYSTONE || OMAP34XX || \ + OMAP44XX || OMAP54XX || AM33XX || AM43XX + help + Use sector number for specifying U-Boot location on MMC/SD in + raw mode. + +config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR + hex "Address on the MMC to load U-Boot from" + depends on SPL && SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR + default 0x50 if ARCH_SUNXI + default 0x75 if ARCH_DAVINCI + default 0x80 if ARCH_UNIPHIER + default 0x8a if ARCH_MX6 + default 0x100 if ARCH_ROCKCHIP + default 0x140 if ARCH_MVEBU + default 0x200 if ARCH_SOCFPGA || ARCH_AT91 + default 0x300 if ARCH_ZYNQ || ARCH_KEYSTONE || OMAP34XX || OMAP44XX || \ + OMAP54XX || AM33XX || AM43XX + help + Address on the MMC to load U-Boot from, when the MMC is being used + in raw mode. Units: MMC sectors (1 sector = 512 bytes). + config TPL bool depends on SPL && SUPPORT_TPL @@ -465,17 +492,6 @@ config SPL_SPI_SUPPORT enable SPI drivers that are needed for other purposes also, such as a SPI PMIC. -config SPL_USBETH_SUPPORT - bool "Support USB Ethernet drivers" - depends on SPL - help - Enable access to the USB network subsystem and associated - drivers in SPL. This permits SPL to load U-Boot over a - USB-connected Ethernet link (such as a USB Ethernet dongle) rather - than from an onboard peripheral. Environment support is required - since the network stack uses a number of environment variables. - See also SPL_NET_SUPPORT and SPL_ETH_SUPPORT. - config SPL_USB_HOST_SUPPORT bool "Support USB host drivers" depends on SPL @@ -497,6 +513,52 @@ config SPL_USB_SUPPORT config options. This enables loading from USB using a configured device. +config SPL_USB_GADGET_SUPPORT + bool "Suppport USB Gadget drivers" + depends on SPL + help + Enable USB Gadget API which allows to enable USB device functions + in SPL. + +if SPL_USB_GADGET_SUPPORT + +config SPL_USBETH_SUPPORT + bool "Support USB Ethernet drivers" + help + Enable access to the USB network subsystem and associated + drivers in SPL. This permits SPL to load U-Boot over a + USB-connected Ethernet link (such as a USB Ethernet dongle) rather + than from an onboard peripheral. Environment support is required + since the network stack uses a number of environment variables. + See also SPL_NET_SUPPORT and SPL_ETH_SUPPORT. + +config SPL_DFU_SUPPORT + bool "Support DFU (Device Firmware Upgarde)" + select SPL_HASH_SUPPORT + help + This feature enables the DFU (Device Firmware Upgarde) in SPL with + RAM memory device support. The ROM code will load and execute + the SPL built with dfu. The user can load binaries (u-boot/kernel) to + selected device partition from host-pc using dfu-utils. + This feature is useful to flash the binaries to factory or bare-metal + boards using USB interface. + +choice + bool "DFU device selection" + depends on SPL_DFU_SUPPORT + +config SPL_DFU_RAM + bool "RAM device" + depends on SPL_DFU_SUPPORT + help + select RAM/DDR memory device for loading binary images + (u-boot/kernel) to the selected device partition using + DFU and execute the u-boot/kernel from RAM. + +endchoice + +endif + config SPL_WATCHDOG_SUPPORT bool "Support watchdog drivers" depends on SPL diff --git a/common/spl/spl.c b/common/spl/spl.c index bdb165ac28..32b9f1e95c 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -220,7 +220,9 @@ static int spl_ram_load_image(struct spl_image_info *spl_image, return 0; } +#if defined(CONFIG_SPL_RAM_DEVICE) SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_RAM, spl_ram_load_image); +#endif #if defined(CONFIG_SPL_DFU_SUPPORT) SPL_LOAD_IMAGE_METHOD(0, BOOT_DEVICE_DFU, spl_ram_load_image); #endif diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c index b93e1eacd3..1b8e15e37d 100644 --- a/common/spl/spl_ext.c +++ b/common/spl/spl_ext.c @@ -42,7 +42,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image, puts("spl: ext4fs_open failed\n"); goto end; } - err = ext4fs_read((char *)header, sizeof(struct image_header), &actlen); + err = ext4fs_read((char *)header, 0, sizeof(struct image_header), &actlen); if (err < 0) { puts("spl: ext4fs_read failed\n"); goto end; @@ -54,7 +54,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image, goto end; } - err = ext4fs_read((char *)spl_image->load_addr, filelen, &actlen); + err = ext4fs_read((char *)spl_image->load_addr, 0, filelen, &actlen); end: #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT @@ -97,7 +97,7 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image, puts("spl: ext4fs_open failed\n"); goto defaults; } - err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, filelen, &actlen); + err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, 0, filelen, &actlen); if (err < 0) { printf("spl: error reading image %s, err - %d, falling back to default\n", file, err); @@ -127,7 +127,7 @@ defaults: if (err < 0) puts("spl: ext4fs_open failed\n"); - err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, filelen, &actlen); + err = ext4fs_read((void *)CONFIG_SYS_SPL_ARGS_ADDR, 0, filelen, &actlen); if (err < 0) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT printf("%s: error reading image %s, err - %d\n", diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index c674e61cbd..0b681c23de 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -165,7 +165,7 @@ static int mmc_load_image_raw_partition(struct spl_image_info *spl_image, return -1; } -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR +#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR return mmc_load_image_raw_sector(spl_image, mmc, info.start + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); #else @@ -327,7 +327,7 @@ static int spl_mmc_load_image(struct spl_image_info *spl_image, CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION); if (!err) return err; -#if defined(CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR) +#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR err = mmc_load_image_raw_sector(spl_image, mmc, CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); if (!err) diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index a3caafbd46..78b8cd16bb 100644 --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -99,7 +99,8 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, if (err) return err; - if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) { + if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && + image_get_magic(header) == FDT_MAGIC) { struct spl_load_info load; debug("Found FIT\n"); diff --git a/common/spl/spl_ymodem.c b/common/spl/spl_ymodem.c index 13e8e51da9..957894dccb 100644 --- a/common/spl/spl_ymodem.c +++ b/common/spl/spl_ymodem.c @@ -109,7 +109,6 @@ static int spl_ymodem_load_image(struct spl_image_info *spl_image, while ((res = xyzModem_stream_read(buf, BUF_SIZE, &err)) > 0) size += res; } else { - spl_parse_image_header(spl_image, (struct image_header *)buf); ret = spl_parse_image_header(spl_image, (struct image_header *)buf); if (ret) diff --git a/common/stdio.c b/common/stdio.c index 8e4a9beef4..4d30017530 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -151,9 +151,10 @@ static int stdio_probe_device(const char *name, enum uclass_id id, *sdevp = NULL; seq = trailing_strtoln(name, NULL); if (seq == -1) + seq = 0; + ret = uclass_get_device_by_seq(id, seq, &dev); + if (ret == -ENODEV) ret = uclass_first_device_err(id, &dev); - else - ret = uclass_get_device_by_seq(id, seq, &dev); if (ret) { debug("No %s device for seq %d (%s)\n", uclass_get_name(id), seq, name); @@ -173,12 +174,12 @@ static int stdio_probe_device(const char *name, enum uclass_id id, } #endif -struct stdio_dev* stdio_get_by_name(const char *name) +struct stdio_dev *stdio_get_by_name(const char *name) { struct list_head *pos; struct stdio_dev *sdev; - if(!name) + if (!name) return NULL; list_for_each(pos, &(devs.list)) { diff --git a/common/xyzModem.c b/common/xyzModem.c index 5656aac48f..e0d87dbfec 100644 --- a/common/xyzModem.c +++ b/common/xyzModem.c @@ -71,12 +71,12 @@ typedef int cyg_int32; static int CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c) { -#define DELAY 20 - unsigned long counter = 0; - while (!tstc () && (counter < xyzModem_CHAR_TIMEOUT * 1000 / DELAY)) + + ulong now = get_timer(0); + while (!tstc ()) { - udelay (DELAY); - counter++; + if (get_timer(now) > xyzModem_CHAR_TIMEOUT) + break; } if (tstc ()) { |