From 5b123e010954d8f6ef24dd0cb1a8cbe1d7d53851 Mon Sep 17 00:00:00 2001 From: Vesa Jääskeläinen Date: Sun, 16 Jun 2019 20:53:38 +0300 Subject: lib: rsa: add support to other openssl engine types than pkcs11 There are multiple other openssl engines used by HSMs that can be used to sign FIT images instead of forcing users to use pkcs11 type of service. Relax engine selection so that other openssl engines can be specified and use generic key id definition formula. Signed-off-by: Vesa Jääskeläinen Cc: Tom Rini --- doc/uImage.FIT/signature.txt | 37 +++++++++++++++++++++++++++++++++---- lib/rsa/rsa-sign.c | 18 ++++++++++++++++++ tools/mkimage.c | 2 +- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/doc/uImage.FIT/signature.txt b/doc/uImage.FIT/signature.txt index 78b59e7203f..c9b1802686f 100644 --- a/doc/uImage.FIT/signature.txt +++ b/doc/uImage.FIT/signature.txt @@ -388,8 +388,8 @@ Test Verified Boot Run: signed config with bad hash: OK Test passed -Hardware Signing with PKCS#11 ------------------------------ +Hardware Signing with PKCS#11 or with HSM +----------------------------------------- Securely managing private signing keys can challenging, especially when the keys are stored on the file system of a computer that is connected to the @@ -402,14 +402,43 @@ them perform the signing. PKCS#11 is standard for interfacing with these crypto device. Requirements: -Smartcard/USB token/HSM which can work with the pkcs11 engine +Smartcard/USB token/HSM which can work with some openssl engine openssl + +For pkcs11 engine usage: libp11 (provides pkcs11 engine) p11-kit (recommended to simplify setup) opensc (for smartcards and smartcard like USB devices) gnutls (recommended for key generation, p11tool) -The following examples use the Nitrokey Pro. Instructions for other devices may vary. +For generic HSMs respective openssl engine must be installed and locateable by +openssl. This may require setting up LD_LIBRARY_PATH if engine is not installed +to openssl's default search paths. + +PKCS11 engine support forms "key id" based on "keydir" and with +"key-name-hint". "key-name-hint" is used as "object" name and "keydir" if +defined is used to define (prefix for) which PKCS11 source is being used for +lookup up for the key. + +PKCS11 engine key ids: + "pkcs11:;object=;type=" +or + "pkcs11:object=;type=", + +Generic HSM engine support forms "key id" based on "keydir" and with +"key-name-hint". If "keydir" is specified for mkimage it is used as a prefix in +"key id" and is appended with "key-name-hint". + +Generic engine key ids: + "" +or + "" + +As mkimage does not at this time support prompting for passwords HSM may need +key preloading wrapper to be used when invoking mkimage. + +The following examples use the Nitrokey Pro using pkcs11 engine. Instructions +for other devices may vary. Notes on pkcs11 engine setup: diff --git a/lib/rsa/rsa-sign.c b/lib/rsa/rsa-sign.c index fb5e07b56d8..5b5905aeb5f 100644 --- a/lib/rsa/rsa-sign.c +++ b/lib/rsa/rsa-sign.c @@ -141,6 +141,15 @@ static int rsa_engine_get_pub_key(const char *keydir, const char *name, snprintf(key_id, sizeof(key_id), "pkcs11:object=%s;type=public", name); + } else if (engine_id) { + if (keydir) + snprintf(key_id, sizeof(key_id), + "%s%s", + keydir, name); + else + snprintf(key_id, sizeof(key_id), + "%s", + name); } else { fprintf(stderr, "Engine not supported\n"); return -ENOTSUP; @@ -252,6 +261,15 @@ static int rsa_engine_get_priv_key(const char *keydir, const char *name, snprintf(key_id, sizeof(key_id), "pkcs11:object=%s;type=private", name); + } else if (engine_id) { + if (keydir) + snprintf(key_id, sizeof(key_id), + "%s%s", + keydir, name); + else + snprintf(key_id, sizeof(key_id), + "%s", + name); } else { fprintf(stderr, "Engine not supported\n"); return -ENOTSUP; diff --git a/tools/mkimage.c b/tools/mkimage.c index d1e1a6743d1..42171883109 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -105,7 +105,7 @@ static void usage(const char *msg) " -F => re-sign existing FIT image\n" " -p => place external data at a static position\n" " -r => mark keys used as 'required' in dtb\n" - " -N => engine to use for signing (pkcs11)\n"); + " -N => openssl engine to use for signing\n"); #else fprintf(stderr, "Signing / verified boot not supported (CONFIG_FIT_SIGNATURE undefined)\n"); -- cgit v1.2.3 From 55f2bc7dd655b6c26cd5fd211a086406416510a6 Mon Sep 17 00:00:00 2001 From: Chuanhua Han Date: Fri, 21 Jun 2019 16:21:53 +0800 Subject: rtc: Add DM support to ds3231 Add an implementation of the ds3231 driver that uses the driver model i2c APIs. Signed-off-by: Chuanhua Han Reviewed-by: Lukasz Majewski --- drivers/rtc/ds3231.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/drivers/rtc/ds3231.c b/drivers/rtc/ds3231.c index 9352ff87a29..79b026af4b9 100644 --- a/drivers/rtc/ds3231.c +++ b/drivers/rtc/ds3231.c @@ -2,6 +2,9 @@ /* * (C) Copyright 2006 * Markus Klotzbuecher, mk@denx.de + * + * (C) Copyright 2019 NXP + * Chuanhua Han */ /* @@ -13,6 +16,7 @@ #include #include +#include #include #include @@ -50,6 +54,7 @@ #define RTC_STAT_BIT_EN32KHZ 0x8 /* Enable 32KHz Output */ +#if !CONFIG_IS_ENABLED(DM_RTC) static uchar rtc_read (uchar reg); static void rtc_write (uchar reg, uchar val); @@ -164,3 +169,105 @@ static void rtc_write (uchar reg, uchar val) { i2c_reg_write (CONFIG_SYS_I2C_RTC_ADDR, reg, val); } +#else +static int ds3231_rtc_get(struct udevice *dev, struct rtc_time *tmp) +{ + uchar sec, min, hour, mday, wday, mon_cent, year, status; + + status = dm_i2c_reg_read(dev, RTC_STAT_REG_ADDR); + sec = dm_i2c_reg_read(dev, RTC_SEC_REG_ADDR); + min = dm_i2c_reg_read(dev, RTC_MIN_REG_ADDR); + hour = dm_i2c_reg_read(dev, RTC_HR_REG_ADDR); + wday = dm_i2c_reg_read(dev, RTC_DAY_REG_ADDR); + mday = dm_i2c_reg_read(dev, RTC_DATE_REG_ADDR); + mon_cent = dm_i2c_reg_read(dev, RTC_MON_REG_ADDR); + year = dm_i2c_reg_read(dev, RTC_YR_REG_ADDR); + + if (status & RTC_STAT_BIT_OSF) { + printf("### Warning: RTC oscillator has stopped\n"); + /* clear the OSF flag */ + dm_i2c_reg_write(dev, RTC_STAT_REG_ADDR, + dm_i2c_reg_read(dev, RTC_STAT_REG_ADDR) + & ~RTC_STAT_BIT_OSF); + return -EINVAL; + } + + tmp->tm_sec = bcd2bin(sec & 0x7F); + tmp->tm_min = bcd2bin(min & 0x7F); + tmp->tm_hour = bcd2bin(hour & 0x3F); + tmp->tm_mday = bcd2bin(mday & 0x3F); + tmp->tm_mon = bcd2bin(mon_cent & 0x1F); + tmp->tm_year = bcd2bin(year) + ((mon_cent & 0x80) ? 2000 : 1900); + tmp->tm_wday = bcd2bin((wday - 1) & 0x07); + tmp->tm_yday = 0; + tmp->tm_isdst = 0; + + debug("Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", + tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, + tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + + return 0; +} + +static int ds3231_rtc_set(struct udevice *dev, const struct rtc_time *tmp) +{ + uchar century; + + debug("Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", + tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, + tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + + dm_i2c_reg_write(dev, RTC_YR_REG_ADDR, bin2bcd(tmp->tm_year % 100)); + + century = (tmp->tm_year >= 2000) ? 0x80 : 0; + dm_i2c_reg_write(dev, RTC_MON_REG_ADDR, bin2bcd(tmp->tm_mon) | century); + + dm_i2c_reg_write(dev, RTC_DAY_REG_ADDR, bin2bcd(tmp->tm_wday + 1)); + dm_i2c_reg_write(dev, RTC_DATE_REG_ADDR, bin2bcd(tmp->tm_mday)); + dm_i2c_reg_write(dev, RTC_HR_REG_ADDR, bin2bcd(tmp->tm_hour)); + dm_i2c_reg_write(dev, RTC_MIN_REG_ADDR, bin2bcd(tmp->tm_min)); + dm_i2c_reg_write(dev, RTC_SEC_REG_ADDR, bin2bcd(tmp->tm_sec)); + + return 0; +} + +static int ds3231_rtc_reset(struct udevice *dev) +{ + int ret; + + ret = dm_i2c_reg_write(dev, RTC_CTL_REG_ADDR, + RTC_CTL_BIT_RS1 | RTC_CTL_BIT_RS2); + if (ret < 0) + return ret; + + return 0; +} + +static int ds3231_probe(struct udevice *dev) +{ + i2c_set_chip_flags(dev, DM_I2C_CHIP_RD_ADDRESS | + DM_I2C_CHIP_WR_ADDRESS); + + return 0; +} + +static const struct rtc_ops ds3231_rtc_ops = { + .get = ds3231_rtc_get, + .set = ds3231_rtc_set, + .reset = ds3231_rtc_reset, +}; + +static const struct udevice_id ds3231_rtc_ids[] = { + { .compatible = "dallas,ds3231" }, + { .compatible = "dallas,ds3232" }, + { } +}; + +U_BOOT_DRIVER(rtc_ds3231) = { + .name = "rtc-ds3231", + .id = UCLASS_RTC, + .probe = ds3231_probe, + .of_match = ds3231_rtc_ids, + .ops = &ds3231_rtc_ops, +}; +#endif -- cgit v1.2.3 From 1c9f8f6412de4447c4f6fadeac1919c89de005f7 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Fri, 21 Jun 2019 15:32:51 +0200 Subject: ext4: fix calculating inode blkcount for non-512 blocksize filesystems The block count entry in the EXT4 filesystem disk structures uses standard 512-bytes units for most of the typical files. The only exception are HUGE files, which use the filesystem block size, but those are not supported by uboot's EXT4 implementation anyway. This patch fixes the EXT4 code to use proper unit count for inode block count. This fixes errors reported by fsck.ext4 on disks with non-standard (i.e. 4KiB, in case of new flash drives) PHYSICAL block size after using 'ext4write' uboot's command. Signed-off-by: Marek Szyprowski Reviewed-by: Lukasz Majewski --- fs/ext4/ext4_common.c | 2 +- fs/ext4/ext4_write.c | 2 +- include/ext_common.h | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index 464c33d0d74..8a142e2e6a1 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -570,7 +570,7 @@ restart_read: g_parent_inode->size = cpu_to_le32(new_size); new_blockcnt = le32_to_cpu(g_parent_inode->blockcnt); - new_blockcnt += fs->sect_perblk; + new_blockcnt += fs->blksz >> LOG2_SECTOR_SIZE; g_parent_inode->blockcnt = cpu_to_le32(new_blockcnt); if (ext4fs_put_metadata diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c index 504d23a8956..3368bd8c005 100644 --- a/fs/ext4/ext4_write.c +++ b/fs/ext4/ext4_write.c @@ -957,7 +957,7 @@ int ext4fs_write(const char *fname, const char *buffer, ext4fs_allocate_blocks(file_inode, blocks_remaining, &blks_reqd_for_file); file_inode->blockcnt = cpu_to_le32((blks_reqd_for_file * fs->blksz) >> - fs->dev_desc->log2blksz); + LOG2_SECTOR_SIZE); temp_ptr = zalloc(fs->blksz); if (!temp_ptr) diff --git a/include/ext_common.h b/include/ext_common.h index 17c92f1750b..1c10c504748 100644 --- a/include/ext_common.h +++ b/include/ext_common.h @@ -21,6 +21,7 @@ #define __EXT_COMMON__ #include #define SECTOR_SIZE 0x200 +#define LOG2_SECTOR_SIZE 9 /* Magic value used to identify an ext2 filesystem. */ #define EXT2_MAGIC 0xEF53 -- cgit v1.2.3 From bd8fbd8a13b8a696aed312753f46432b19b61fd6 Mon Sep 17 00:00:00 2001 From: Marek Szyprowski Date: Fri, 21 Jun 2019 15:35:35 +0200 Subject: ext4: add support for filesystems without JOURNAL JOURNAL is optional for EXT4 (and EXT3) filesystems, so add support for skipping it. This fixes corrupting EXT4 volumes without JOURNAL after using uboot's 'ext4write' command. Signed-off-by: Marek Szyprowski Reviewed-by: Lukasz Majewski --- fs/ext4/ext4_journal.c | 4 ++++ fs/ext4/ext4_journal.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/fs/ext4/ext4_journal.c b/fs/ext4/ext4_journal.c index 6adbab93a68..3559daf11d2 100644 --- a/fs/ext4/ext4_journal.c +++ b/fs/ext4/ext4_journal.c @@ -645,6 +645,10 @@ void ext4fs_update_journal(void) struct ext_filesystem *fs = get_fs(); long int blknr; int i; + + if (!(fs->sb->feature_compatibility & EXT4_FEATURE_COMPAT_HAS_JOURNAL)) + return; + ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, &inode_journal); blknr = read_allocated_block(&inode_journal, jrnl_blk_idx++, NULL); update_descriptor_block(blknr); diff --git a/fs/ext4/ext4_journal.h b/fs/ext4/ext4_journal.h index c9cf195f333..43fb8e76641 100644 --- a/fs/ext4/ext4_journal.h +++ b/fs/ext4/ext4_journal.h @@ -17,6 +17,8 @@ #ifndef __EXT4_JRNL__ #define __EXT4_JRNL__ +#define EXT4_FEATURE_COMPAT_HAS_JOURNAL 0x0004 + #define EXT2_JOURNAL_INO 8 /* Journal inode */ #define EXT2_JOURNAL_SUPERBLOCK 0 /* Journal Superblock number */ -- cgit v1.2.3 From 0c1456d571e77000a98cdf5009fad6277426aa75 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 23 Jun 2019 12:59:31 +0200 Subject: ARM: correct detection of thumb mode When a crash occurs in thumb mode the crash dump is incorrect. This is due to the usage of a non-existing configuration variable CONFIG_ARM_THUMB in the definition of macro thumb_mode(regs). Use CONFIG_IS_ENABLED(SYS_THUMB_BUILD) to detect that the code has been compiled for thumb mode. Remove ARM_THUMB from config_whitelist.txt. With the patch crash dumps indicate thumb mode correctly. On a system with thumb mode: => exception unaligned data abort pc : [<8f7a2b52>] lr : [<8f7ab1ef>] reloc pc : [<1780cb52>] lr : [<178151ef>] sp : 8ed8c3f8 ip : 8f7a2b4d fp : 00000002 r10: 8f7f8228 r9 : 8ed95ea8 r8 : 8ed99488 r7 : 8f7ab141 r6 : 00000000 r5 : 8ed8c3f9 r4 : 8f7f6390 r3 : 8ed9948c r2 : 00000001 r1 : 00000000 r0 : 8f7f6390 Flags: nzCv IRQs off FIQs off Mode SVC_32 (T) Code: 8f7e 466d f105 0501 (e9d5) 6700 The Flags line has '(T)' and in the Code line the output is in u16 groups. On a system without thumb mode: => exception breakpoint prefetch abort pc : [<7ff5a5c8>] lr : [<7ff675ec>] reloc pc : [<0000e5c8>] lr : [<0001b5ec>] sp : 7ee0ad80 ip : 7ff5a5cc fp : 7ff674cc r10: 00000002 r9 : 7ef0bed8 r8 : 7ffd6214 r7 : 7ef0e080 r6 : 00000000 r5 : 7ffd4090 r4 : 00000000 r3 : 7ef0e084 r2 : 00000001 r1 : 00000000 r0 : 7ffd4090 Flags: nzCv IRQs off FIQs off Mode SVC_32 Code: e1a0500d e2855001 e1c560d0 e3a00001 (e12fff1e) The Flags line does not show '(T)' and in the Code line the output is in u32 groups. Reported-by: Marek Vasut Signed-off-by: Heinrich Schuchardt Reviewed-by: Marek Vasut --- arch/arm/include/asm/proc-armv/ptrace.h | 2 +- scripts/config_whitelist.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/include/asm/proc-armv/ptrace.h b/arch/arm/include/asm/proc-armv/ptrace.h index 183b00a0871..e37ad8fd1fe 100644 --- a/arch/arm/include/asm/proc-armv/ptrace.h +++ b/arch/arm/include/asm/proc-armv/ptrace.h @@ -86,7 +86,7 @@ struct pt_regs { #define user_mode(regs) \ (((regs)->ARM_cpsr & 0xf) == 0) -#ifdef CONFIG_ARM_THUMB +#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD) #define thumb_mode(regs) \ (((regs)->ARM_cpsr & T_BIT)) #else diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 79872baeda0..bd167959b3f 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -61,7 +61,6 @@ CONFIG_ARM_FREQ CONFIG_ARM_GIC_BASE_ADDRESS CONFIG_ARM_PL180_MMCI_BASE CONFIG_ARM_PL180_MMCI_CLOCK_FREQ -CONFIG_ARM_THUMB CONFIG_ARP_TIMEOUT CONFIG_ASTRO_COFDMDUOS2 CONFIG_ASTRO_TWIN7S2 -- cgit v1.2.3 From 2f7a5f2682edc99daee1fa1d7dadd4b9f09e7b59 Mon Sep 17 00:00:00 2001 From: Sven Schwermer Date: Mon, 24 Jun 2019 13:03:33 +0200 Subject: regulator: Factor out common enable code In preparation of being able to enable/disable GPIO regulators, the code that will be shared among the two kinds to regulators is factored out into its own source files. Signed-off-by: Sven Schwermer Reviewed-by: Lukasz Majewski --- drivers/power/regulator/Kconfig | 10 ++++ drivers/power/regulator/Makefile | 1 + drivers/power/regulator/fixed.c | 75 +++------------------------- drivers/power/regulator/regulator_common.c | 80 ++++++++++++++++++++++++++++++ drivers/power/regulator/regulator_common.h | 27 ++++++++++ 5 files changed, 124 insertions(+), 69 deletions(-) create mode 100644 drivers/power/regulator/regulator_common.c create mode 100644 drivers/power/regulator/regulator_common.h diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index 147e68d5c96..30c0a13e859 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -92,9 +92,18 @@ config DM_REGULATOR_FAN53555 or switching the mode is not supported by this driver (at this time). +config DM_REGULATOR_COMMON + bool + depends on DM_REGULATOR + +config SPL_DM_REGULATOR_COMMON + bool + depends on DM_REGULATOR + config DM_REGULATOR_FIXED bool "Enable Driver Model for REGULATOR Fixed value" depends on DM_REGULATOR + select DM_REGULATOR_COMMON ---help--- This config enables implementation of driver-model regulator uclass features for fixed value regulators. The driver implements get/set api @@ -103,6 +112,7 @@ config DM_REGULATOR_FIXED config SPL_DM_REGULATOR_FIXED bool "Enable Driver Model for REGULATOR Fixed value in SPL" depends on DM_REGULATOR_FIXED + select SPL_DM_REGULATOR_COMMON ---help--- This config enables implementation of driver-model regulator uclass features for fixed value regulators in SPL. diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile index 8c1506c88ed..e728b73aee3 100644 --- a/drivers/power/regulator/Makefile +++ b/drivers/power/regulator/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o obj-$(CONFIG_$(SPL_)REGULATOR_PWM) += pwm_regulator.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_FAN53555) += fan53555.o +obj-$(CONFIG_$(SPL_)DM_REGULATOR_COMMON) += regulator_common.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_FIXED) += fixed.o obj-$(CONFIG_$(SPL_)DM_REGULATOR_GPIO) += gpio-regulator.o obj-$(CONFIG_REGULATOR_RK8XX) += rk8xx.o diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c index a99aa783107..763e671d54e 100644 --- a/drivers/power/regulator/fixed.c +++ b/drivers/power/regulator/fixed.c @@ -5,56 +5,26 @@ * Przemyslaw Marczak */ +#include "regulator_common.h" #include #include #include -#include -#include #include #include -struct fixed_regulator_platdata { - struct gpio_desc gpio; /* GPIO for regulator enable control */ - unsigned int startup_delay_us; - unsigned int off_on_delay_us; -}; - static int fixed_regulator_ofdata_to_platdata(struct udevice *dev) { struct dm_regulator_uclass_platdata *uc_pdata; - struct fixed_regulator_platdata *dev_pdata; - struct gpio_desc *gpio; - int flags = GPIOD_IS_OUT; - int ret; + struct regulator_common_platdata *dev_pdata; dev_pdata = dev_get_platdata(dev); uc_pdata = dev_get_uclass_platdata(dev); if (!uc_pdata) return -ENXIO; - /* Set type to fixed */ uc_pdata->type = REGULATOR_TYPE_FIXED; - if (dev_read_bool(dev, "enable-active-high")) - flags |= GPIOD_IS_OUT_ACTIVE; - - /* Get fixed regulator optional enable GPIO desc */ - gpio = &dev_pdata->gpio; - ret = gpio_request_by_name(dev, "gpio", 0, gpio, flags); - if (ret) { - debug("Fixed regulator optional enable GPIO - not found! Error: %d\n", - ret); - if (ret != -ENOENT) - return ret; - } - - /* Get optional ramp up delay */ - dev_pdata->startup_delay_us = dev_read_u32_default(dev, - "startup-delay-us", 0); - dev_pdata->off_on_delay_us = - dev_read_u32_default(dev, "u-boot,off-on-delay-us", 0); - - return 0; + return regulator_common_ofdata_to_platdata(dev, dev_pdata, "gpio"); } static int fixed_regulator_get_value(struct udevice *dev) @@ -91,45 +61,12 @@ static int fixed_regulator_get_current(struct udevice *dev) static int fixed_regulator_get_enable(struct udevice *dev) { - struct fixed_regulator_platdata *dev_pdata = dev_get_platdata(dev); - - /* Enable GPIO is optional */ - if (!dev_pdata->gpio.dev) - return true; - - return dm_gpio_get_value(&dev_pdata->gpio); + return regulator_common_get_enable(dev, dev_get_platdata(dev)); } static int fixed_regulator_set_enable(struct udevice *dev, bool enable) { - struct fixed_regulator_platdata *dev_pdata = dev_get_platdata(dev); - int ret; - - debug("%s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n", __func__, - dev->name, enable, dev_pdata->startup_delay_us, - dm_gpio_is_valid(&dev_pdata->gpio)); - /* Enable GPIO is optional */ - if (!dm_gpio_is_valid(&dev_pdata->gpio)) { - if (!enable) - return -ENOSYS; - return 0; - } - - ret = dm_gpio_set_value(&dev_pdata->gpio, enable); - if (ret) { - pr_err("Can't set regulator : %s gpio to: %d\n", dev->name, - enable); - return ret; - } - - if (enable && dev_pdata->startup_delay_us) - udelay(dev_pdata->startup_delay_us); - debug("%s: done\n", __func__); - - if (!enable && dev_pdata->off_on_delay_us) - udelay(dev_pdata->off_on_delay_us); - - return 0; + return regulator_common_set_enable(dev, dev_get_platdata(dev), enable); } static const struct dm_regulator_ops fixed_regulator_ops = { @@ -150,5 +87,5 @@ U_BOOT_DRIVER(fixed_regulator) = { .ops = &fixed_regulator_ops, .of_match = fixed_regulator_ids, .ofdata_to_platdata = fixed_regulator_ofdata_to_platdata, - .platdata_auto_alloc_size = sizeof(struct fixed_regulator_platdata), + .platdata_auto_alloc_size = sizeof(struct regulator_common_platdata), }; diff --git a/drivers/power/regulator/regulator_common.c b/drivers/power/regulator/regulator_common.c new file mode 100644 index 00000000000..3dabbe2a85a --- /dev/null +++ b/drivers/power/regulator/regulator_common.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Disruptive Technologies Research AS + * Sven Schwermer + */ + +#include "regulator_common.h" +#include +#include + +int regulator_common_ofdata_to_platdata(struct udevice *dev, + struct regulator_common_platdata *dev_pdata, const char *enable_gpio_name) +{ + struct gpio_desc *gpio; + int flags = GPIOD_IS_OUT; + int ret; + + if (dev_read_bool(dev, "enable-active-high")) + flags |= GPIOD_IS_OUT_ACTIVE; + + /* Get optional enable GPIO desc */ + gpio = &dev_pdata->gpio; + ret = gpio_request_by_name(dev, enable_gpio_name, 0, gpio, flags); + if (ret) { + debug("Regulator '%s' optional enable GPIO - not found! Error: %d\n", + dev->name, ret); + if (ret != -ENOENT) + return ret; + } + + /* Get optional ramp up delay */ + dev_pdata->startup_delay_us = dev_read_u32_default(dev, + "startup-delay-us", 0); + dev_pdata->off_on_delay_us = + dev_read_u32_default(dev, "u-boot,off-on-delay-us", 0); + + return 0; +} + +int regulator_common_get_enable(const struct udevice *dev, + struct regulator_common_platdata *dev_pdata) +{ + /* Enable GPIO is optional */ + if (!dev_pdata->gpio.dev) + return true; + + return dm_gpio_get_value(&dev_pdata->gpio); +} + +int regulator_common_set_enable(const struct udevice *dev, + struct regulator_common_platdata *dev_pdata, bool enable) +{ + int ret; + + debug("%s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n", __func__, + dev->name, enable, dev_pdata->startup_delay_us, + dm_gpio_is_valid(&dev_pdata->gpio)); + /* Enable GPIO is optional */ + if (!dm_gpio_is_valid(&dev_pdata->gpio)) { + if (!enable) + return -ENOSYS; + return 0; + } + + ret = dm_gpio_set_value(&dev_pdata->gpio, enable); + if (ret) { + pr_err("Can't set regulator : %s gpio to: %d\n", dev->name, + enable); + return ret; + } + + if (enable && dev_pdata->startup_delay_us) + udelay(dev_pdata->startup_delay_us); + debug("%s: done\n", __func__); + + if (!enable && dev_pdata->off_on_delay_us) + udelay(dev_pdata->off_on_delay_us); + + return 0; +} diff --git a/drivers/power/regulator/regulator_common.h b/drivers/power/regulator/regulator_common.h new file mode 100644 index 00000000000..18a525880a3 --- /dev/null +++ b/drivers/power/regulator/regulator_common.h @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2019 Disruptive Technologies Research AS + * Sven Schwermer + */ + +#ifndef _REGULATOR_COMMON_H +#define _REGULATOR_COMMON_H + +#include +#include +#include + +struct regulator_common_platdata { + struct gpio_desc gpio; /* GPIO for regulator enable control */ + unsigned int startup_delay_us; + unsigned int off_on_delay_us; +}; + +int regulator_common_ofdata_to_platdata(struct udevice *dev, + struct regulator_common_platdata *dev_pdata, const char *enable_gpio_name); +int regulator_common_get_enable(const struct udevice *dev, + struct regulator_common_platdata *dev_pdata); +int regulator_common_set_enable(const struct udevice *dev, + struct regulator_common_platdata *dev_pdata, bool enable); + +#endif /* _REGULATOR_COMMON_H */ -- cgit v1.2.3 From aa2067a8692ece9b4ce470a2c6c6704987bfd56c Mon Sep 17 00:00:00 2001 From: Sven Schwermer Date: Mon, 24 Jun 2019 13:03:34 +0200 Subject: regulator: Allow enabling GPIO regulator Drivers need to be able to enable regulators that may be implemented as GPIO regulators. Example: fsl_esdhc enables the vqmmc supply which is commonly implemented as a GPIO regulator in order to switch between I/O voltage levels. Signed-off-by: Sven Schwermer Reviewed-by: Lukasz Majewski --- drivers/power/regulator/Kconfig | 2 ++ drivers/power/regulator/gpio-regulator.c | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index 30c0a13e859..337e9e7471c 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -120,6 +120,7 @@ config SPL_DM_REGULATOR_FIXED config DM_REGULATOR_GPIO bool "Enable Driver Model for GPIO REGULATOR" depends on DM_REGULATOR && DM_GPIO + select DM_REGULATOR_COMMON ---help--- This config enables implementation of driver-model regulator uclass features for gpio regulators. The driver implements get/set for @@ -128,6 +129,7 @@ config DM_REGULATOR_GPIO config SPL_DM_REGULATOR_GPIO bool "Enable Driver Model for GPIO REGULATOR in SPL" depends on DM_REGULATOR_GPIO && SPL_GPIO_SUPPORT + select SPL_DM_REGULATOR_COMMON ---help--- This config enables implementation of driver-model regulator uclass features for gpio regulators in SPL. diff --git a/drivers/power/regulator/gpio-regulator.c b/drivers/power/regulator/gpio-regulator.c index d18e5d8d2ca..ec1dcb64b3d 100644 --- a/drivers/power/regulator/gpio-regulator.c +++ b/drivers/power/regulator/gpio-regulator.c @@ -4,6 +4,7 @@ * Keerthy */ +#include "regulator_common.h" #include #include #include @@ -18,6 +19,7 @@ DECLARE_GLOBAL_DATA_PTR; struct gpio_regulator_platdata { + struct regulator_common_platdata common; struct gpio_desc gpio; /* GPIO for regulator voltage control */ int states[GPIO_REGULATOR_MAX_STATES]; int voltages[GPIO_REGULATOR_MAX_STATES]; @@ -65,7 +67,7 @@ static int gpio_regulator_ofdata_to_platdata(struct udevice *dev) j++; } - return 0; + return regulator_common_ofdata_to_platdata(dev, &dev_pdata->common, "enable-gpios"); } static int gpio_regulator_get_value(struct udevice *dev) @@ -116,9 +118,23 @@ static int gpio_regulator_set_value(struct udevice *dev, int uV) return 0; } +static int gpio_regulator_get_enable(struct udevice *dev) +{ + struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev); + return regulator_common_get_enable(dev, &dev_pdata->common); +} + +static int gpio_regulator_set_enable(struct udevice *dev, bool enable) +{ + struct gpio_regulator_platdata *dev_pdata = dev_get_platdata(dev); + return regulator_common_set_enable(dev, &dev_pdata->common, enable); +} + static const struct dm_regulator_ops gpio_regulator_ops = { .get_value = gpio_regulator_get_value, .set_value = gpio_regulator_set_value, + .get_enable = gpio_regulator_get_enable, + .set_enable = gpio_regulator_set_enable, }; static const struct udevice_id gpio_regulator_ids[] = { -- cgit v1.2.3 From 4225f830c56d6a8f6e459bce8cec310a58a9df28 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Thu, 27 Jun 2019 00:17:27 +0200 Subject: common: Fix autocompletion with CONFIG_CMDLINE_PS_SUPPORT The autocompletion did not work if CONFIG_CMDLINE_PS_SUPPORT was enabled because U-Boot was comparing the prompt string with CONFIG_SYS_PROMPT . While this works if CONFIG_CMDLINE_PS_SUPPORT is disabled, this no longer works if it's enabled because user can override the PS1 . Fix this by checking prompt string against the current PS1 value. Signed-off-by: Marek Vasut Cc: Tom Rini --- common/command.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/command.c b/common/command.c index e192bb2a619..db25bf54e05 100644 --- a/common/command.c +++ b/common/command.c @@ -356,8 +356,13 @@ int cmd_auto_complete(const char *const prompt, char *buf, int *np, int *colp) int i, j, k, len, seplen, argc; int cnt; char last_char; +#ifdef CONFIG_CMDLINE_PS_SUPPORT + const char *ps_prompt = env_get("PS1"); +#else + const char *ps_prompt = CONFIG_SYS_PROMPT; +#endif - if (strcmp(prompt, CONFIG_SYS_PROMPT) != 0) + if (strcmp(prompt, ps_prompt) != 0) return 0; /* not in normal console */ cnt = strlen(buf); -- cgit v1.2.3 From cd121bdb6df3fe8dfe45ff1e34f46f86b8f060c0 Mon Sep 17 00:00:00 2001 From: Frank Wunderlich Date: Sat, 29 Jun 2019 11:36:19 +0200 Subject: env: register erase command this patch adds basic changes for adding a erase-subcommand to env with this command the environment stored on non-volatile storage written by saveenv can be cleared. Signed-off-by: Frank Wunderlich squashed fixes - start message with "Erasing" - mark erase-function as optional - env: separate eraseenv from saveenv Suggested-by: Simon Goldschmidt Reviewed-by: Simon Goldschmidt --- cmd/Kconfig | 8 ++++++++ cmd/nvedit.c | 20 ++++++++++++++++++++ env/env.c | 30 ++++++++++++++++++++++++++++++ include/environment.h | 17 +++++++++++++++++ 4 files changed, 75 insertions(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index 67284d8a5f6..ec746fe8255 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -408,6 +408,14 @@ config CMD_SAVEENV Save all environment variables into the compiled-in persistent storage. +config CMD_ERASEENV + bool "eraseenv" + default n + depends on CMD_SAVEENV + help + Erase environment variables from the compiled-in persistent + storage. + config CMD_ENV_EXISTS bool "env exists" default y diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 7e468ab39d6..46b1e60f0ad 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -767,6 +767,20 @@ U_BOOT_CMD( "save environment variables to persistent storage", "" ); + +#if defined(CONFIG_CMD_ERASEENV) +static int do_env_erase(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + return env_erase() ? 1 : 0; +} + +U_BOOT_CMD( + eraseenv, 1, 0, do_env_erase, + "erase environment variables from persistent storage", + "" +); +#endif #endif #endif /* CONFIG_SPL_BUILD */ @@ -1316,6 +1330,9 @@ static cmd_tbl_t cmd_env_sub[] = { #endif #if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE) U_BOOT_CMD_MKENT(save, 1, 0, do_env_save, "", ""), +#if defined(CONFIG_CMD_ERASEENV) + U_BOOT_CMD_MKENT(erase, 1, 0, do_env_erase, "", ""), +#endif #endif U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""), #if defined(CONFIG_CMD_ENV_EXISTS) @@ -1396,6 +1413,9 @@ static char env_help_text[] = #endif #if defined(CONFIG_CMD_SAVEENV) && defined(ENV_IS_IN_DEVICE) "env save - save environment\n" +#if defined(CONFIG_CMD_ERASEENV) + "env erase - erase environment\n" +#endif #endif #if defined(CONFIG_CMD_NVEDIT_EFI) "env set -e name [arg ...] - set UEFI variable; unset if 'arg' not specified\n" diff --git a/env/env.c b/env/env.c index 4b417b90a29..d3cbe2f9158 100644 --- a/env/env.c +++ b/env/env.c @@ -24,6 +24,8 @@ void env_fix_drivers(void) entry->load += gd->reloc_off; if (entry->save) entry->save += gd->reloc_off; + if (entry->erase) + entry->erase += gd->reloc_off; if (entry->init) entry->init += gd->reloc_off; } @@ -254,6 +256,34 @@ int env_save(void) return -ENODEV; } +int env_erase(void) +{ + struct env_driver *drv; + + drv = env_driver_lookup(ENVOP_ERASE, gd->env_load_prio); + if (drv) { + int ret; + + if (!drv->erase) + return -ENODEV; + + if (!env_has_inited(drv->location)) + return -ENODEV; + + printf("Erasing Environment on %s... ", drv->name); + ret = drv->erase(); + if (ret) + printf("Failed (%d)\n", ret); + else + printf("OK\n"); + + if (!ret) + return 0; + } + + return -ENODEV; +} + int env_init(void) { struct env_driver *drv; diff --git a/include/environment.h b/include/environment.h index cd966761416..de67cf4f0ea 100644 --- a/include/environment.h +++ b/include/environment.h @@ -200,6 +200,7 @@ enum env_operation { ENVOP_INIT, /* we want to call the init function */ ENVOP_LOAD, /* we want to call the load function */ ENVOP_SAVE, /* we want to call the save function */ + ENVOP_ERASE, /* we want to call the erase function */ }; struct env_driver { @@ -225,6 +226,15 @@ struct env_driver { */ int (*save)(void); + /** + * erase() - Erase the environment on storage + * + * This method is optional and required for 'eraseenv' to work. + * + * @return 0 if OK, -ve on error + */ + int (*erase)(void); + /** * init() - Set up the initial pre-relocation environment * @@ -303,6 +313,13 @@ int env_load(void); */ int env_save(void); +/** + * env_erase() - Erase the environment on storage + * + * @return 0 if OK, -ve on error + */ +int env_erase(void); + /** * env_fix_drivers() - Updates envdriver as per relocation */ -- cgit v1.2.3 From 3485392506decf3896b7f742c1300cbdf8b31f83 Mon Sep 17 00:00:00 2001 From: Frank Wunderlich Date: Sat, 29 Jun 2019 11:36:20 +0200 Subject: env: mmc: add erase-function this adds erase environment for mmc storage squashed fixes: - add CONFIG_CMD_ERASEENV - env: erase redundant offset if defined - changes mentioned by Simon - fix whitespaces around errmsg Suggested-by: Simon Goldschmidt Signed-off-by: Frank Wunderlich Reviewed-by: Simon Goldschmidt --- env/mmc.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/env/mmc.c b/env/mmc.c index c3cf35d01b8..b7b833f4235 100644 --- a/env/mmc.c +++ b/env/mmc.c @@ -242,6 +242,54 @@ fini: fini_mmc_for_env(mmc); return ret; } + +#if defined(CONFIG_CMD_ERASEENV) +static inline int erase_env(struct mmc *mmc, unsigned long size, + unsigned long offset) +{ + uint blk_start, blk_cnt, n; + struct blk_desc *desc = mmc_get_blk_desc(mmc); + + blk_start = ALIGN(offset, mmc->write_bl_len) / mmc->write_bl_len; + blk_cnt = ALIGN(size, mmc->write_bl_len) / mmc->write_bl_len; + + n = blk_derase(desc, blk_start, blk_cnt); + printf("%d blocks erased: %s\n", n, (n == blk_cnt) ? "OK" : "ERROR"); + + return (n == blk_cnt) ? 0 : 1; +} + +static int env_mmc_erase(void) +{ + int dev = mmc_get_env_dev(); + struct mmc *mmc = find_mmc_device(dev); + int ret, copy = 0; + u32 offset; + const char *errmsg; + + errmsg = init_mmc_for_env(mmc); + if (errmsg) { + printf("%s\n", errmsg); + return 1; + } + + if (mmc_get_env_addr(mmc, copy, &offset)) + return CMD_RET_FAILURE; + + ret = erase_env(mmc, CONFIG_ENV_SIZE, offset); + +#ifdef CONFIG_ENV_OFFSET_REDUND + copy = 1; + + if (mmc_get_env_addr(mmc, copy, &offset)) + return CMD_RET_FAILURE; + + ret |= erase_env(mmc, CONFIG_ENV_SIZE, offset); +#endif + + return ret; +} +#endif /* CONFIG_CMD_ERASEENV */ #endif /* CONFIG_CMD_SAVEENV && !CONFIG_SPL_BUILD */ static inline int read_env(struct mmc *mmc, unsigned long size, @@ -351,5 +399,8 @@ U_BOOT_ENV_LOCATION(mmc) = { .load = env_mmc_load, #ifndef CONFIG_SPL_BUILD .save = env_save_ptr(env_mmc_save), +#if defined(CONFIG_CMD_ERASEENV) + .erase = env_mmc_erase, +#endif #endif }; -- cgit v1.2.3 From bdfc9e8ad7e39060e60c04b882dfb2c023a689b4 Mon Sep 17 00:00:00 2001 From: Sam Protsenko Date: Tue, 2 Jul 2019 21:20:32 +0300 Subject: test/py: gpt: Use long options for sgdisk sgdisk 0.8.10.2 from AOSP doesn't support short options, failing with errors like this: sgdisk: invalid option -- 'U' Test fails due to that error. Let's use long options to make the test work with any sgdisk version. Signed-off-by: Sam Protsenko Acked-by: Stephen Warren --- test/py/tests/test_gpt.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py index c8edb336422..229d7eb2c21 100644 --- a/test/py/tests/test_gpt.py +++ b/test/py/tests/test_gpt.py @@ -40,16 +40,19 @@ class GptTestDiskImage(object): fd = os.open(persistent, os.O_RDWR | os.O_CREAT) os.ftruncate(fd, 4194304) os.close(fd) - cmd = ('sgdisk', '-U', '375a56f7-d6c9-4e81-b5f0-09d41ca89efe', + cmd = ('sgdisk', + '--disk-guid=375a56f7-d6c9-4e81-b5f0-09d41ca89efe', persistent) u_boot_utils.run_and_log(u_boot_console, cmd) # part1 offset 1MB size 1MB - cmd = ('sgdisk', '--new=1:2048:4095', '-c 1:part1', persistent) + cmd = ('sgdisk', '--new=1:2048:4095', '--change-name=1:part1', + persistent) # part2 offset 2MB size 1.5MB u_boot_utils.run_and_log(u_boot_console, cmd) - cmd = ('sgdisk', '--new=2:4096:7167', '-c 2:part2', persistent) + cmd = ('sgdisk', '--new=2:4096:7167', '--change-name=2:part2', + persistent) u_boot_utils.run_and_log(u_boot_console, cmd) - cmd = ('sgdisk', '-l', persistent) + cmd = ('sgdisk', '--load-backup=' + persistent) u_boot_utils.run_and_log(u_boot_console, cmd) cmd = ('cp', persistent, self.path) -- cgit v1.2.3 From 40e7b3ce74e32798e742725d743e484f11766ba4 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Sun, 30 Jun 2019 02:45:00 +0100 Subject: tools: mkenvimage: Fix reading from slow pipe It is perfectly fine for the read(2) syscall to return with less than the requested number of bytes read (short read, see the "RETURN VALUE" section of the man page). This typically happens with slow input (keyboard, network) or with complex pipes. So far mkenvimage expects the exact number of requested bytes to be read, assuming an end-of-file condition otherwise. This wrong behaviour can be easily shown with: $ (echo "foo=bar"; sleep 1; echo "bar=baz") | mkenvimage -s 256 -o out - The second line will be missing from the output. Correct this by checking for any positive, non-zero return value. This fixes a problem with a complex pipe in one of my scripts, where the environment consist of two parts. Signed-off-by: Andre Przywara Acked-by: Alexander Dahl --- tools/mkenvimage.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index 75967d0c2d5..ffaebd5565c 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -173,8 +173,7 @@ int main(int argc, char **argv) return EXIT_FAILURE; } filesize += readbytes; - } while (readbytes == readlen); - + } while (readbytes > 0); } else { txt_filename = argv[optind]; txt_fd = open(txt_filename, O_RDONLY); -- cgit v1.2.3 From 849f9bef429dd1a2eabaf93bef2bd3442b4e0829 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Sun, 30 Jun 2019 02:45:01 +0100 Subject: tools: mkenvimage: Always consider non-regular files At the moment mkenvimage has two separate read paths: One to read from a potential pipe, while dynamically increasing the buffer size, and a second one using mmap(2), using the input file's size. This is problematic for two reasons: - The "pipe" path will be chosen if the input filename is missing or "-". Any named, but non-regular file will use the other path, which typically will cause mmap() to fail: $ mkenvimage -s 256 -o out <(echo "foo=bar") - There is no reason to have *two* ways of reading a file, since the "pipe way" will always work, even for regular files. Fix this (and simplify the code on the way) by always using the method of dynamically resizing the buffer. The existing distinction between the two cases will merely be used to use the open() syscall or not. Signed-off-by: Andre Przywara --- tools/mkenvimage.c | 70 ++++++++++++++++-------------------------------------- 1 file changed, 21 insertions(+), 49 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index ffaebd5565c..a8eebab6c33 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -65,10 +65,12 @@ long int xstrtol(const char *s) exit(EXIT_FAILURE); } +#define CHUNK_SIZE 4096 + int main(int argc, char **argv) { uint32_t crc, targetendian_crc; - const char *txt_filename = NULL, *bin_filename = NULL; + const char *bin_filename = NULL; int txt_fd, bin_fd; unsigned char *dataptr, *envptr; unsigned char *filebuf = NULL; @@ -76,12 +78,11 @@ int main(int argc, char **argv) int bigendian = 0; int redundant = 0; unsigned char padbyte = 0xff; + int readbytes = 0; int option; int ret = EXIT_SUCCESS; - struct stat txt_file_stat; - int fp, ep; const char *prg; @@ -156,62 +157,33 @@ int main(int argc, char **argv) /* Open the input file ... */ if (optind >= argc || strcmp(argv[optind], "-") == 0) { - int readbytes = 0; - int readlen = sizeof(*envptr) * 4096; txt_fd = STDIN_FILENO; - - do { - filebuf = realloc(filebuf, filesize + readlen); - if (!filebuf) { - fprintf(stderr, "Can't realloc memory for the input file buffer\n"); - return EXIT_FAILURE; - } - readbytes = read(txt_fd, filebuf + filesize, readlen); - if (readbytes < 0) { - fprintf(stderr, "Error while reading stdin: %s\n", - strerror(errno)); - return EXIT_FAILURE; - } - filesize += readbytes; - } while (readbytes > 0); } else { - txt_filename = argv[optind]; - txt_fd = open(txt_filename, O_RDONLY); + txt_fd = open(argv[optind], O_RDONLY); if (txt_fd == -1) { fprintf(stderr, "Can't open \"%s\": %s\n", - txt_filename, strerror(errno)); + argv[optind], strerror(errno)); return EXIT_FAILURE; } - /* ... and check it */ - ret = fstat(txt_fd, &txt_file_stat); - if (ret == -1) { - fprintf(stderr, "Can't stat() on \"%s\": %s\n", - txt_filename, strerror(errno)); + } + + do { + filebuf = realloc(filebuf, filesize + CHUNK_SIZE); + if (!filebuf) { + fprintf(stderr, "Can't realloc memory for the input file buffer\n"); return EXIT_FAILURE; } - - filesize = txt_file_stat.st_size; - - filebuf = mmap(NULL, sizeof(*envptr) * filesize, PROT_READ, - MAP_PRIVATE, txt_fd, 0); - if (filebuf == MAP_FAILED) { - fprintf(stderr, "mmap (%zu bytes) failed: %s\n", - sizeof(*envptr) * filesize, - strerror(errno)); - fprintf(stderr, "Falling back to read()\n"); - - filebuf = malloc(sizeof(*envptr) * filesize); - ret = read(txt_fd, filebuf, sizeof(*envptr) * filesize); - if (ret != sizeof(*envptr) * filesize) { - fprintf(stderr, "Can't read the whole input file (%zu bytes): %s\n", - sizeof(*envptr) * filesize, - strerror(errno)); - - return EXIT_FAILURE; - } + readbytes = read(txt_fd, filebuf + filesize, CHUNK_SIZE); + if (readbytes < 0) { + fprintf(stderr, "Error while reading: %s\n", + strerror(errno)); + return EXIT_FAILURE; } + filesize += readbytes; + } while (readbytes > 0); + + if (txt_fd != STDIN_FILENO) ret = close(txt_fd); - } /* Parse a byte at time until reaching the file OR until the environment fills * up. Check ep against envsize - 1 to allow for extra trailing '\0'. */ -- cgit v1.2.3 From 803e1a3d3890621bf588544bc389d973ea9e6cd4 Mon Sep 17 00:00:00 2001 From: Jean-Jacques Hiblot Date: Tue, 2 Jul 2019 14:23:26 +0200 Subject: cmd: mem: Add a command to fill the memory with random data This command fills the memory with data produced by rand(). Signed-off-by: Jean-Jacques Hiblot --- cmd/Kconfig | 7 +++++++ cmd/mem.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/cmd/Kconfig b/cmd/Kconfig index ec746fe8255..175c6ad9e33 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -571,6 +571,13 @@ config CMD_MEMORY base - print or set address offset loop - initialize loop on address range +config CMD_RANDOM + bool "random" + default y + depends on CMD_MEMORY && (LIB_RAND || LIB_HW_RAND) + help + random - fill memory with random data + config CMD_MEMTEST bool "memtest" help diff --git a/cmd/mem.c b/cmd/mem.c index 392ed1756b6..c6b8038fc9d 100644 --- a/cmd/mem.c +++ b/cmd/mem.c @@ -1082,6 +1082,49 @@ static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #endif +#ifdef CONFIG_CMD_RANDOM +static int do_random(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + unsigned long addr, len; + unsigned long seed; // NOT INITIALIZED ON PURPOSE + unsigned int *buf, *start; + unsigned char *buf8; + unsigned int i; + + if (argc < 3 || argc > 4) { + printf("usage: %s []\n", argv[0]); + return 0; + } + + len = simple_strtoul(argv[2], NULL, 16); + addr = simple_strtoul(argv[1], NULL, 16); + + if (argc == 4) { + seed = simple_strtoul(argv[3], NULL, 16); + if (seed == 0) { + printf("The seed cannot be 0. Using 0xDEADBEEF.\n"); + seed = 0xDEADBEEF; + } + } else { + seed = get_timer(0) ^ rand(); + } + + srand(seed); + start = map_sysmem(addr, len); + buf = start; + for (i = 0; i < (len / 4); i++) + *buf++ = rand(); + + buf8 = (unsigned char *)buf; + for (i = 0; i < (len % 4); i++) + *buf8++ = rand() & 0xFF; + + unmap_sysmem(start); + printf("%lu bytes filled with random data\n", len); + return 1; +} +#endif + /**************************************************/ U_BOOT_CMD( md, 3, 1, do_mem_md, @@ -1250,3 +1293,12 @@ U_BOOT_CMD( "" ); #endif + +#ifdef CONFIG_CMD_RANDOM +U_BOOT_CMD( + random, 4, 0, do_random, + "fill memory with random pattern", + " []\n" + " - Fill 'len' bytes of memory starting at 'addr' with random data\n" +); +#endif -- cgit v1.2.3 From d963f64c0bd7248c190a221023fc633b46534b7e Mon Sep 17 00:00:00 2001 From: Sam Protsenko Date: Tue, 2 Jul 2019 21:14:57 +0300 Subject: doc: Move fastboot protocol doc to android dir Signed-off-by: Sam Protsenko --- doc/README.android-fastboot-protocol | 170 ----------------------------------- doc/android/fastboot-protocol.txt | 170 +++++++++++++++++++++++++++++++++++ doc/android/fastboot.txt | 4 +- 3 files changed, 172 insertions(+), 172 deletions(-) delete mode 100644 doc/README.android-fastboot-protocol create mode 100644 doc/android/fastboot-protocol.txt diff --git a/doc/README.android-fastboot-protocol b/doc/README.android-fastboot-protocol deleted file mode 100644 index e9e7166a266..00000000000 --- a/doc/README.android-fastboot-protocol +++ /dev/null @@ -1,170 +0,0 @@ -FastBoot Version 0.4 ----------------------- - -The fastboot protocol is a mechanism for communicating with bootloaders -over USB. It is designed to be very straightforward to implement, to -allow it to be used across a wide range of devices and from hosts running -Linux, Windows, or OSX. - - -Basic Requirements ------------------- - -* Two bulk endpoints (in, out) are required -* Max packet size must be 64 bytes for full-speed and 512 bytes for - high-speed USB -* The protocol is entirely host-driven and synchronous (unlike the - multi-channel, bi-directional, asynchronous ADB protocol) - - -Transport and Framing ---------------------- - -1. Host sends a command, which is an ascii string in a single - packet no greater than 64 bytes. - -2. Client response with a single packet no greater than 64 bytes. - The first four bytes of the response are "OKAY", "FAIL", "DATA", - or "INFO". Additional bytes may contain an (ascii) informative - message. - - a. INFO -> the remaining 60 bytes are an informative message - (providing progress or diagnostic messages). They should - be displayed and then step #2 repeats - - b. FAIL -> the requested command failed. The remaining 60 bytes - of the response (if present) provide a textual failure message - to present to the user. Stop. - - c. OKAY -> the requested command completed successfully. Go to #5 - - d. DATA -> the requested command is ready for the data phase. - A DATA response packet will be 12 bytes long, in the form of - DATA00000000 where the 8 digit hexidecimal number represents - the total data size to transfer. - -3. Data phase. Depending on the command, the host or client will - send the indicated amount of data. Short packets are always - acceptable and zero-length packets are ignored. This phase continues - until the client has sent or received the number of bytes indicated - in the "DATA" response above. - -4. Client responds with a single packet no greater than 64 bytes. - The first four bytes of the response are "OKAY", "FAIL", or "INFO". - Similar to #2: - - a. INFO -> display the remaining 60 bytes and return to #4 - - b. FAIL -> display the remaining 60 bytes (if present) as a failure - reason and consider the command failed. Stop. - - c. OKAY -> success. Go to #5 - -5. Success. Stop. - - -Example Session ---------------- - -Host: "getvar:version" request version variable - -Client: "OKAY0.4" return version "0.4" - -Host: "getvar:nonexistant" request some undefined variable - -Client: "OKAY" return value "" - -Host: "download:00001234" request to send 0x1234 bytes of data - -Client: "DATA00001234" ready to accept data - -Host: < 0x1234 bytes > send data - -Client: "OKAY" success - -Host: "flash:bootloader" request to flash the data to the bootloader - -Client: "INFOerasing flash" indicate status / progress - "INFOwriting flash" - "OKAY" indicate success - -Host: "powerdown" send a command - -Client: "FAILunknown command" indicate failure - - -Command Reference ------------------ - -* Command parameters are indicated by printf-style escape sequences. - -* Commands are ascii strings and sent without the quotes (which are - for illustration only here) and without a trailing 0 byte. - -* Commands that begin with a lowercase letter are reserved for this - specification. OEM-specific commands should not begin with a - lowercase letter, to prevent incompatibilities with future specs. - - "getvar:%s" Read a config/version variable from the bootloader. - The variable contents will be returned after the - OKAY response. - - "download:%08x" Write data to memory which will be later used - by "boot", "ramdisk", "flash", etc. The client - will reply with "DATA%08x" if it has enough - space in RAM or "FAIL" if not. The size of - the download is remembered. - - "verify:%08x" Send a digital signature to verify the downloaded - data. Required if the bootloader is "secure" - otherwise "flash" and "boot" will be ignored. - - "flash:%s" Write the previously downloaded image to the - named partition (if possible). - - "erase:%s" Erase the indicated partition (clear to 0xFFs) - - "boot" The previously downloaded data is a boot.img - and should be booted according to the normal - procedure for a boot.img - - "continue" Continue booting as normal (if possible) - - "reboot" Reboot the device. - - "reboot-bootloader" Reboot back into the bootloader. - Useful for upgrade processes that require upgrading - the bootloader and then upgrading other partitions - using the new bootloader. - - "powerdown" Power off the device. - - - -Client Variables ----------------- - -The "getvar:%s" command is used to read client variables which -represent various information about the device and the software -on it. - -The various currently defined names are: - - version Version of FastBoot protocol supported. - It should be "0.3" for this document. - - version-bootloader Version string for the Bootloader. - - version-baseband Version string of the Baseband Software - - product Name of the product - - serialno Product serial number - - secure If the value is "yes", this is a secure - bootloader requiring a signature before - it will install or boot images. - -Names starting with a lowercase character are reserved by this -specification. OEM-specific names should not start with lowercase -characters. diff --git a/doc/android/fastboot-protocol.txt b/doc/android/fastboot-protocol.txt new file mode 100644 index 00000000000..e9e7166a266 --- /dev/null +++ b/doc/android/fastboot-protocol.txt @@ -0,0 +1,170 @@ +FastBoot Version 0.4 +---------------------- + +The fastboot protocol is a mechanism for communicating with bootloaders +over USB. It is designed to be very straightforward to implement, to +allow it to be used across a wide range of devices and from hosts running +Linux, Windows, or OSX. + + +Basic Requirements +------------------ + +* Two bulk endpoints (in, out) are required +* Max packet size must be 64 bytes for full-speed and 512 bytes for + high-speed USB +* The protocol is entirely host-driven and synchronous (unlike the + multi-channel, bi-directional, asynchronous ADB protocol) + + +Transport and Framing +--------------------- + +1. Host sends a command, which is an ascii string in a single + packet no greater than 64 bytes. + +2. Client response with a single packet no greater than 64 bytes. + The first four bytes of the response are "OKAY", "FAIL", "DATA", + or "INFO". Additional bytes may contain an (ascii) informative + message. + + a. INFO -> the remaining 60 bytes are an informative message + (providing progress or diagnostic messages). They should + be displayed and then step #2 repeats + + b. FAIL -> the requested command failed. The remaining 60 bytes + of the response (if present) provide a textual failure message + to present to the user. Stop. + + c. OKAY -> the requested command completed successfully. Go to #5 + + d. DATA -> the requested command is ready for the data phase. + A DATA response packet will be 12 bytes long, in the form of + DATA00000000 where the 8 digit hexidecimal number represents + the total data size to transfer. + +3. Data phase. Depending on the command, the host or client will + send the indicated amount of data. Short packets are always + acceptable and zero-length packets are ignored. This phase continues + until the client has sent or received the number of bytes indicated + in the "DATA" response above. + +4. Client responds with a single packet no greater than 64 bytes. + The first four bytes of the response are "OKAY", "FAIL", or "INFO". + Similar to #2: + + a. INFO -> display the remaining 60 bytes and return to #4 + + b. FAIL -> display the remaining 60 bytes (if present) as a failure + reason and consider the command failed. Stop. + + c. OKAY -> success. Go to #5 + +5. Success. Stop. + + +Example Session +--------------- + +Host: "getvar:version" request version variable + +Client: "OKAY0.4" return version "0.4" + +Host: "getvar:nonexistant" request some undefined variable + +Client: "OKAY" return value "" + +Host: "download:00001234" request to send 0x1234 bytes of data + +Client: "DATA00001234" ready to accept data + +Host: < 0x1234 bytes > send data + +Client: "OKAY" success + +Host: "flash:bootloader" request to flash the data to the bootloader + +Client: "INFOerasing flash" indicate status / progress + "INFOwriting flash" + "OKAY" indicate success + +Host: "powerdown" send a command + +Client: "FAILunknown command" indicate failure + + +Command Reference +----------------- + +* Command parameters are indicated by printf-style escape sequences. + +* Commands are ascii strings and sent without the quotes (which are + for illustration only here) and without a trailing 0 byte. + +* Commands that begin with a lowercase letter are reserved for this + specification. OEM-specific commands should not begin with a + lowercase letter, to prevent incompatibilities with future specs. + + "getvar:%s" Read a config/version variable from the bootloader. + The variable contents will be returned after the + OKAY response. + + "download:%08x" Write data to memory which will be later used + by "boot", "ramdisk", "flash", etc. The client + will reply with "DATA%08x" if it has enough + space in RAM or "FAIL" if not. The size of + the download is remembered. + + "verify:%08x" Send a digital signature to verify the downloaded + data. Required if the bootloader is "secure" + otherwise "flash" and "boot" will be ignored. + + "flash:%s" Write the previously downloaded image to the + named partition (if possible). + + "erase:%s" Erase the indicated partition (clear to 0xFFs) + + "boot" The previously downloaded data is a boot.img + and should be booted according to the normal + procedure for a boot.img + + "continue" Continue booting as normal (if possible) + + "reboot" Reboot the device. + + "reboot-bootloader" Reboot back into the bootloader. + Useful for upgrade processes that require upgrading + the bootloader and then upgrading other partitions + using the new bootloader. + + "powerdown" Power off the device. + + + +Client Variables +---------------- + +The "getvar:%s" command is used to read client variables which +represent various information about the device and the software +on it. + +The various currently defined names are: + + version Version of FastBoot protocol supported. + It should be "0.3" for this document. + + version-bootloader Version string for the Bootloader. + + version-baseband Version string of the Baseband Software + + product Name of the product + + serialno Product serial number + + secure If the value is "yes", this is a secure + bootloader requiring a signature before + it will install or boot images. + +Names starting with a lowercase character are reserved by this +specification. OEM-specific names should not start with lowercase +characters. diff --git a/doc/android/fastboot.txt b/doc/android/fastboot.txt index 431191c473f..ea0d1da1fdc 100644 --- a/doc/android/fastboot.txt +++ b/doc/android/fastboot.txt @@ -5,8 +5,8 @@ Android Fastboot Overview ======== -The protocol that is used over USB and UDP is described in the -``README.android-fastboot-protocol`` file in the same directory. +The protocol that is used over USB and UDP is described in +``doc/android/fastboot-protocol.txt``. The current implementation supports the following standard commands: -- cgit v1.2.3 From 6324d50679b4eae7f611a41a1885ef395ac7b1b9 Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Wed, 3 Jul 2019 10:44:39 +0900 Subject: arm: move CONFIG_TFABOOT to generic Kconfig Currently, CONFIG_TFABOOT is located in armv8/fsl-layerscape Kconfig, but it will be also useful for other targets if some additional configuration are necessary. So move it to arch/arm/Kconfig. Please note that CONFIG_TFABOOT still depends on CONFIG_ARCH_SUPPORT_TFABOOT and so the menu won't come up if any target doesn't need its own customization for TF-A boot. This will maintain the compatibility. Signed-off-by: AKASHI Takahiro Cc: Rajesh Bhagat Cc: York Sun Cc: Prabhakar Kushwaha Cc: Priyanka Jain Cc: Sriram Dash Cc: Hou Zhiqiang Cc: Peng Ma Cc: Yuantian Tang Cc: Pankit Garg --- arch/arm/Kconfig | 29 +++++++++++++++++++++++++++++ arch/arm/cpu/armv8/fsl-layerscape/Kconfig | 7 ------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 05606d9722e..602d61ee3d8 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1100,6 +1100,7 @@ config TARGET_LS1088AQDS select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT select SUPPORT_SPL select FSL_DDR_INTERACTIVE if !SD_BOOT @@ -1115,6 +1116,7 @@ config TARGET_LS2080AQDS select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT select SUPPORT_SPL imply SCSI @@ -1133,6 +1135,7 @@ config TARGET_LS2080ARDB select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT select SUPPORT_SPL select FSL_DDR_BIST @@ -1165,6 +1168,7 @@ config TARGET_LX2160ARDB select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT help Support for NXP LX2160ARDB platform. @@ -1178,6 +1182,7 @@ config TARGET_LX2160AQDS select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT help Support for NXP LX2160AQDS platform. @@ -1218,6 +1223,7 @@ config TARGET_LS1012AQDS bool "Support ls1012aqds" select ARCH_LS1012A select ARM64 + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT help Support for Freescale LS1012AQDS platform. @@ -1229,6 +1235,7 @@ config TARGET_LS1012ARDB bool "Support ls1012ardb" select ARCH_LS1012A select ARM64 + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT imply SCSI imply SCSI_AHCI @@ -1242,6 +1249,7 @@ config TARGET_LS1012A2G5RDB bool "Support ls1012a2g5rdb" select ARCH_LS1012A select ARM64 + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT imply SCSI help @@ -1254,6 +1262,7 @@ config TARGET_LS1012AFRWY bool "Support ls1012afrwy" select ARCH_LS1012A select ARM64 + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT imply SCSI imply SCSI_AHCI @@ -1267,6 +1276,7 @@ config TARGET_LS1012AFRDM bool "Support ls1012afrdm" select ARCH_LS1012A select ARM64 + select ARCH_SUPPORT_TFABOOT help Support for Freescale LS1012AFRDM platform. The LS1012A Freedom board (FRDM) is a high-performance @@ -1278,6 +1288,7 @@ config TARGET_LS1028AQDS select ARCH_LS1028A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT help Support for Freescale LS1028AQDS platform The LS1028A Development System (QDS) is a high-performance @@ -1289,6 +1300,7 @@ config TARGET_LS1028ARDB select ARCH_LS1028A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT help Support for Freescale LS1028ARDB platform The LS1028A Development System (RDB) is a high-performance @@ -1301,6 +1313,7 @@ config TARGET_LS1088ARDB select ARCH_MISC_INIT select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_LATE_INIT select SUPPORT_SPL select FSL_DDR_INTERACTIVE if !SD_BOOT @@ -1359,6 +1372,7 @@ config TARGET_LS1043AQDS select ARCH_LS1043A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_EARLY_INIT_F select BOARD_LATE_INIT select SUPPORT_SPL @@ -1373,6 +1387,7 @@ config TARGET_LS1043ARDB select ARCH_LS1043A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_EARLY_INIT_F select BOARD_LATE_INIT select SUPPORT_SPL @@ -1384,6 +1399,7 @@ config TARGET_LS1046AQDS select ARCH_LS1046A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_EARLY_INIT_F select BOARD_LATE_INIT select DM_SPI_FLASH if DM_SPI @@ -1403,6 +1419,7 @@ config TARGET_LS1046ARDB select ARCH_LS1046A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_EARLY_INIT_F select BOARD_LATE_INIT select DM_SPI_FLASH if DM_SPI @@ -1422,6 +1439,7 @@ config TARGET_LS1046AFRWY select ARCH_LS1046A select ARM64 select ARMV8_MULTIENTRY + select ARCH_SUPPORT_TFABOOT select BOARD_EARLY_INIT_F select BOARD_LATE_INIT select DM_SPI_FLASH if DM_SPI @@ -1565,6 +1583,17 @@ config ARCH_ASPEED endchoice +config ARCH_SUPPORT_TFABOOT + bool + +config TFABOOT + bool "Support for booting from TF-A" + depends on ARCH_SUPPORT_TFABOOT + default n + help + Enabling this will make a U-Boot binary that is capable of being + booted via TF-A. + config TI_SECURE_DEVICE bool "HS Device Type Support" depends on ARCH_KEYSTONE || ARCH_OMAP2PLUS || ARCH_K3 diff --git a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig index 3f6c983aaf4..5c32738fbf3 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/Kconfig +++ b/arch/arm/cpu/armv8/fsl-layerscape/Kconfig @@ -623,10 +623,3 @@ config HAS_FSL_XHCI_USB help For some SoC(such as LS1043A and LS1046A), USB and QE-HDLC multiplex use pins, select it when the pins are assigned to USB. - -config TFABOOT - bool "Support for booting from TFA" - default n - help - Enabling this will make a U-Boot binary that is capable of being - booted via TFA. -- cgit v1.2.3 From 70a64a070e79b657dcb4903299ccad0f5fff8267 Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Wed, 3 Jul 2019 10:44:40 +0900 Subject: arm: qemu: fix failure in flash initialization if booting from TF-A If U-Boot is loaded and started from TF-A (you need to change SYS_TEXT_BASE to 0x60000000), it will hang up at flash initialization. If secure mode is off (default, or -machine virt,secure=off) at qemu, it will provide dtb with two flash memory banks: flash@0 { bank-width = <0x4>; reg = <0x0 0x0 0x0 0x4000000 0x0 0x4000000 0x0 0x4000000>; compatible = "cfi-flash"; }; If secure mode is on, on the other hand, qemu provides dtb with 1 bank: flash@0 { bank-width = <0x4>; reg = <0x0 0x4000000 0x0 0x4000000>; compatible = "cfi-flash"; }; As a result, flash_init()/flash_get_size() will eventually fail. With this patch applied, relevant CONFIG values are modified. Signed-off-by: AKASHI Takahiro Tested-by: Heinrich Schuchardt --- arch/arm/Kconfig | 1 + include/configs/qemu-arm.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 602d61ee3d8..51d4acedac4 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -840,6 +840,7 @@ config ARCH_OWL config ARCH_QEMU bool "QEMU Virtual Platform" + select ARCH_SUPPORT_TFABOOT select DM select DM_SERIAL select OF_CONTROL diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index 65fdb1e9298..35e3c5ad7a8 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -46,8 +46,13 @@ #define CONFIG_SYS_CBSIZE 512 #define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE +#ifdef CONFIG_TFABOOT +#define CONFIG_SYS_FLASH_BASE 0x4000000 +#define CONFIG_SYS_MAX_FLASH_BANKS 1 +#else #define CONFIG_SYS_FLASH_BASE 0x0 #define CONFIG_SYS_MAX_FLASH_BANKS 2 +#endif #define CONFIG_SYS_MAX_FLASH_SECT 256 /* Sector: 256K, Bank: 64M */ #endif /* __CONFIG_H */ -- cgit v1.2.3 From 1493b140e4a9211635964cd1c0276e599405f403 Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Wed, 3 Jul 2019 15:50:44 +0300 Subject: qemu-riscv: enable VIRTIO_PCI libvirt v.5.3.0 with QEMU 4.0.0 or above uses PCI automatically and thus devices (network, storage, etc) are connected via PCI. Signed-off-by: David Abdurachmanov Reviewed-by: Bin Meng --- board/emulation/qemu-riscv/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index 7f9a74dd48e..6cc7c31dc65 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -24,6 +24,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply VIRTIO_MMIO imply VIRTIO_NET imply VIRTIO_BLK + imply VIRTIO_PCI imply CMD_PING imply CMD_FS_GENERIC imply DOS_PARTITION -- cgit v1.2.3 From 232e2f4fd9a24bf08215ddc8c53ccadffc841fb5 Mon Sep 17 00:00:00 2001 From: Paul Emge Date: Mon, 8 Jul 2019 16:37:03 -0700 Subject: CVE-2019-13103: disk: stop infinite recursion in DOS Partitions part_get_info_extended and print_partition_extended can recurse infinitely while parsing a self-referential filesystem or one with a silly number of extended partitions. This patch adds a limit to the number of recursive partitions. Signed-off-by: Paul Emge --- disk/part_dos.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/disk/part_dos.c b/disk/part_dos.c index 936cee0d36c..aae9d959063 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -23,6 +23,10 @@ #define DOS_PART_DEFAULT_SECTOR 512 +/* should this be configurable? It looks like it's not very common at all + * to use large numbers of partitions */ +#define MAX_EXT_PARTS 256 + /* Convert char[4] in little endian format to the host format integer */ static inline unsigned int le32_to_int(unsigned char *le32) @@ -126,6 +130,13 @@ static void print_partition_extended(struct blk_desc *dev_desc, dos_partition_t *pt; int i; + /* set a maximum recursion level */ + if (part_num > MAX_EXT_PARTS) + { + printf("** Nested DOS partitions detected, stopping **\n"); + return; + } + if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) { printf ("** Can't read partition table on %d:" LBAFU " **\n", dev_desc->devnum, ext_part_sector); @@ -191,6 +202,13 @@ static int part_get_info_extended(struct blk_desc *dev_desc, int i; int dos_type; + /* set a maximum recursion level */ + if (part_num > MAX_EXT_PARTS) + { + printf("** Nested DOS partitions detected, stopping **\n"); + return -1; + } + if (blk_dread(dev_desc, ext_part_sector, 1, (ulong *)buffer) != 1) { printf ("** Can't read partition table on %d:" LBAFU " **\n", dev_desc->devnum, ext_part_sector); -- cgit v1.2.3 From 6e5a79de658cb1c8012c86e0837379aa6eabd024 Mon Sep 17 00:00:00 2001 From: Paul Emge Date: Mon, 8 Jul 2019 16:37:04 -0700 Subject: CVE-2019-13105: ext4: fix double-free in ext4_cache_read ext_cache_read doesn't null cache->buf, after freeing, which results in a later function double-freeing it. This patch fixes ext_cache_read to call ext_cache_fini instead of free. Signed-off-by: Paul Emge --- fs/ext4/ext4fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index 26db677a1f1..85dc122f300 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -286,7 +286,7 @@ int ext_cache_read(struct ext_block_cache *cache, lbaint_t block, int size) if (!cache->buf) return 0; if (!ext4fs_devread(block, 0, size, cache->buf)) { - free(cache->buf); + ext_cache_fini(cache); return 0; } cache->block = block; -- cgit v1.2.3 From 878269dbe74229005dd7f27aca66c554e31dad8e Mon Sep 17 00:00:00 2001 From: Paul Emge Date: Mon, 8 Jul 2019 16:37:05 -0700 Subject: CVE-2019-13104: ext4: check for underflow in ext4fs_read_file in ext4fs_read_file, it is possible for a broken/malicious file system to cause a memcpy of a negative number of bytes, which overflows all memory. This patch fixes the issue by checking for a negative length. Signed-off-by: Paul Emge --- fs/ext4/ext4fs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index 85dc122f300..e2b740cac40 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -66,13 +66,15 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos, ext_cache_init(&cache); - if (blocksize <= 0) - return -1; - /* Adjust len so it we can't read past the end of the file. */ if (len + pos > filesize) len = (filesize - pos); + if (blocksize <= 0 || len <= 0) { + ext_cache_fini(&cache); + return -1; + } + blockcnt = lldiv(((len + pos) + blocksize - 1), blocksize); for (i = lldiv(pos, blocksize); i < blockcnt; i++) { -- cgit v1.2.3 From 084be43b751df7133c94c6bf556bc61bd6297406 Mon Sep 17 00:00:00 2001 From: Paul Emge Date: Mon, 8 Jul 2019 16:37:06 -0700 Subject: ext4: gracefully fail on divide-by-0 This patch checks for 0 in several ext4 headers and gracefully fails instead of raising a divide-by-0 exception. Signed-off-by: Paul Emge --- fs/ext4/ext4_common.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index 8a142e2e6a1..5bf78b530a9 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -1571,8 +1571,12 @@ static int ext4fs_blockgroup int log2blksz = get_fs()->dev_desc->log2blksz; int desc_size = get_fs()->gdsize; + if (desc_size == 0) + return 0; desc_per_blk = EXT2_BLOCK_SIZE(data) / desc_size; + if (desc_per_blk == 0) + return 0; blkno = le32_to_cpu(data->sblock.first_data_block) + 1 + group / desc_per_blk; blkoff = (group % desc_per_blk) * desc_size; @@ -1602,6 +1606,10 @@ int ext4fs_read_inode(struct ext2_data *data, int ino, struct ext2_inode *inode) /* It is easier to calculate if the first inode is 0. */ ino--; + if ( le32_to_cpu(sblock->inodes_per_group) == 0 || fs->inodesz == 0) { + free(blkgrp); + return 0; + } status = ext4fs_blockgroup(data, ino / le32_to_cpu (sblock->inodes_per_group), blkgrp); if (status == 0) { @@ -1610,6 +1618,10 @@ int ext4fs_read_inode(struct ext2_data *data, int ino, struct ext2_inode *inode) } inodes_per_block = EXT2_BLOCK_SIZE(data) / fs->inodesz; + if ( inodes_per_block == 0 ) { + free(blkgrp); + return 0; + } blkno = ext4fs_bg_get_inode_table_id(blkgrp, fs) + (ino % le32_to_cpu(sblock->inodes_per_group)) / inodes_per_block; blkoff = (ino % inodes_per_block) * fs->inodesz; -- cgit v1.2.3 From e205896c5383c938274262524adceb2775fb03ba Mon Sep 17 00:00:00 2001 From: Paul Emge Date: Mon, 8 Jul 2019 16:37:07 -0700 Subject: CVE-2019-13106: ext4: fix out-of-bounds memset In ext4fs_read_file in ext4fs.c, a memset can overwrite the bounds of the destination memory region. This patch adds a check to disallow this. Signed-off-by: Paul Emge --- fs/ext4/ext4fs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index e2b740cac40..37b31d9f0fc 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -61,6 +61,7 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos, lbaint_t delayed_skipfirst = 0; lbaint_t delayed_next = 0; char *delayed_buf = NULL; + char *start_buf = buf; short status; struct ext_block_cache cache; @@ -139,6 +140,7 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos, } } else { int n; + int n_left; if (previous_block_number != -1) { /* spill */ status = ext4fs_devread(delayed_start, @@ -153,8 +155,9 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos, } /* Zero no more than `len' bytes. */ n = blocksize - skipfirst; - if (n > len) - n = len; + n_left = len - ( buf - start_buf ); + if (n > n_left) + n = n_left; memset(buf, 0, n); } buf += blocksize - skipfirst; -- cgit v1.2.3 From f752e5783b7300671a13587e864468f6742576c3 Mon Sep 17 00:00:00 2001 From: Anatolij Gustschin Date: Wed, 10 Jul 2019 10:03:13 +0200 Subject: power-domain.h: Fix typo %s/ot/to/ Signed-off-by: Anatolij Gustschin --- include/power-domain.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/power-domain.h b/include/power-domain.h index 00996057b0d..07370709fe0 100644 --- a/include/power-domain.h +++ b/include/power-domain.h @@ -151,7 +151,7 @@ static inline int power_domain_on(struct power_domain *power_domain) #endif /** - * power_domain_off - Disable power ot a power domain. + * power_domain_off - Disable power to a power domain. * * @power_domain: A power domain struct that was previously successfully * requested by power_domain_get(). -- cgit v1.2.3 From ea804eb340906c7e3434310de3fa647e747d4eeb Mon Sep 17 00:00:00 2001 From: Weijie Gao Date: Wed, 10 Jul 2019 17:35:42 +0800 Subject: arm: mediatek: add missing arch timer configuration for MT7629 This patch sets CNTVOFF of ARM CP15 timer to zero to make sure the virtual counter is fully usable for linux kernel. Cc: Albert Aribaud Signed-off-by: Weijie Gao --- arch/arm/mach-mediatek/mt7629/lowlevel_init.S | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm/mach-mediatek/mt7629/lowlevel_init.S b/arch/arm/mach-mediatek/mt7629/lowlevel_init.S index 3375796b797..0a0672cbea7 100644 --- a/arch/arm/mach-mediatek/mt7629/lowlevel_init.S +++ b/arch/arm/mach-mediatek/mt7629/lowlevel_init.S @@ -4,6 +4,7 @@ */ #include +#include #define WAIT_CODE_SRAM_BASE 0x0010ff00 @@ -27,6 +28,18 @@ ENTRY(lowlevel_init) movt r0, #0x131 mcr p15, 0, r0, c14, c0, 0 + cps #MON_MODE + mrc p15, 0, r1, c1, c1, 0 @ Get Secure Config + orr r0, r1, #1 + mcr p15, 0, r0, c1, c1, 0 @ Set Non Secure bit + isb + mov r0, #0 + mcrr p15, 4, r0, r0, c14 @ CNTVOFF = 0 + isb + mcr p15, 0, r1, c1, c1, 0 @ Set Secure bit + isb + cps #SVC_MODE + /* enable SMP bit */ mrc p15, 0, r0, c1, c0, 1 orr r0, r0, #0x40 -- cgit v1.2.3 From 1b96da67a0f5c70e4096bec9ce0769925f70513f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 10 Jul 2019 11:04:13 -0600 Subject: chromium: Update docs to clone vboot_reference directly We don't need a full checkout of Chrome OS to build U-Boot with Chromium OS verified boot. Update the instructions accordingly and fix a typo which joins the output directory and defconfig. Signed-off-by: Simon Glass --- doc/README.chromium | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/README.chromium b/doc/README.chromium index 096bc4f1f7f..8f67da6c728 100644 --- a/doc/README.chromium +++ b/doc/README.chromium @@ -33,12 +33,18 @@ To obtain: cd u-boot git checkout cros-master + cd .. + git clone https://chromium.googlesource.com/chromiumos/platform/vboot_reference + cd vboot_reference + git checkout 45964294 + # futility: updater: Correct output version for Snow + To build for sandbox: UB=/tmp/b/chromeos_sandbox # U-Boot build directory - CROS=/home/sglass/cosarm # Chromium OS directory - make O=$UB/chromeos_sandbox_defconfig - make O=$UB -j20 -s VBOOT_SOURCE=$CROS/src/platform/vboot_reference \ + cd u-boot + make O=$UB chromeos_sandbox_defconfig + make O=$UB -j20 -s VBOOT_SOURCE=/path/to/vboot_reference \ MAKEFLAGS_VBOOT=DEBUG=1 QUIET=1 Replace sandbox with another supported target. -- cgit v1.2.3 From 58067b0de1e5d8a07ccb8c3a5497beaa0e043c6b Mon Sep 17 00:00:00 2001 From: Weijie Gao Date: Thu, 11 Jul 2019 14:26:24 +0800 Subject: arm: dts: MediaTek: fix clock order for timer0 node of mt7629.dtsi The timer0 node has its two clocks written in reversed order. The timer0 is used as the tick timer which causes a problem that the time a delay function used is 4 times longer. This patch reverses these two clocks to solve this issue. Signed-off-by: Weijie Gao --- arch/arm/dts/mt7629.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/dts/mt7629.dtsi b/arch/arm/dts/mt7629.dtsi index c87115e0fe4..ecbd29d7ae4 100644 --- a/arch/arm/dts/mt7629.dtsi +++ b/arch/arm/dts/mt7629.dtsi @@ -82,8 +82,8 @@ compatible = "mediatek,timer"; reg = <0x10004000 0x80>; interrupts = ; - clocks = <&topckgen CLK_TOP_10M_SEL>, - <&topckgen CLK_TOP_CLKXTAL_D4>; + clocks = <&topckgen CLK_TOP_CLKXTAL_D4>, + <&topckgen CLK_TOP_10M_SEL>; clock-names = "mux", "src"; u-boot,dm-pre-reloc; }; -- cgit v1.2.3 From e90f225f8afcafee773afd01b30801e1eb005358 Mon Sep 17 00:00:00 2001 From: Weijie Gao Date: Thu, 11 Jul 2019 14:26:25 +0800 Subject: configs: mt7629_rfb: use arm arch timer instead of mtk timer This patch changes mt7629_rfb to use ARM's generic arch timer instead of MediaTek's soc timer. Signed-off-by: Weijie Gao --- configs/mt7629_rfb_defconfig | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/configs/mt7629_rfb_defconfig b/configs/mt7629_rfb_defconfig index 0dceafdaa67..d6a7c84df35 100644 --- a/configs/mt7629_rfb_defconfig +++ b/configs/mt7629_rfb_defconfig @@ -1,4 +1,5 @@ CONFIG_ARM=y +CONFIG_SYS_ARCH_TIMER=y CONFIG_SYS_THUMB_BUILD=y CONFIG_ARCH_MEDIATEK=y CONFIG_SYS_TEXT_BASE=0x41e00000 @@ -67,9 +68,6 @@ CONFIG_MTK_QSPI=y CONFIG_SYSRESET=y CONFIG_SPL_SYSRESET=y CONFIG_SYSRESET_WATCHDOG=y -CONFIG_TIMER=y -CONFIG_SPL_TIMER=y -CONFIG_MTK_TIMER=y CONFIG_WDT_MTK=y CONFIG_LZMA=y # CONFIG_EFI_LOADER is not set -- cgit v1.2.3 From 5490d6ad3b9f38aa26df36c37a1ffccad77bff7d Mon Sep 17 00:00:00 2001 From: Weijie Gao Date: Thu, 11 Jul 2019 14:26:26 +0800 Subject: arm: dts: MediaTek: remove tick-timer from mt7629.dtsi This patch removes tick-timer as all mt7629 boards should use arch timer. Signed-off-by: Weijie Gao --- arch/arm/dts/mt7629-rfb.dts | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/dts/mt7629-rfb.dts b/arch/arm/dts/mt7629-rfb.dts index 4612218a1eb..08c3b592223 100644 --- a/arch/arm/dts/mt7629-rfb.dts +++ b/arch/arm/dts/mt7629-rfb.dts @@ -18,7 +18,6 @@ chosen { stdout-path = &uart0; - tick-timer = &timer0; }; }; -- cgit v1.2.3 From 0ebe112d09b48230ba4be833cd3504b06997d9a4 Mon Sep 17 00:00:00 2001 From: Weijie Gao Date: Thu, 11 Jul 2019 15:10:23 +0800 Subject: blk: Invalidate block cache when switching hwpart Some storage devices have multiple hw partitions and both address from zero, for example eMMC. However currently block cache invalidation only applies to block write/erase. This can cause a problem that data of current hw partition is cached before switching to another hw partition. And the following read operation of the latter hw partition will get wrong data when reading from the addresses that have been cached previously. To solve this problem, invalidate block cache after a successful select_hwpart operation. Signed-off-by: Weijie Gao --- drivers/block/blk-uclass.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/block/blk-uclass.c b/drivers/block/blk-uclass.c index baaf431e5e0..c23b6682a6c 100644 --- a/drivers/block/blk-uclass.c +++ b/drivers/block/blk-uclass.c @@ -208,7 +208,11 @@ int blk_select_hwpart_devnum(enum if_type if_type, int devnum, int hwpart) if (ret) return ret; - return blk_select_hwpart(dev, hwpart); + ret = blk_select_hwpart(dev, hwpart); + if (!ret) + blkcache_invalidate(if_type, devnum); + + return ret; } int blk_list_part(enum if_type if_type) @@ -348,7 +352,13 @@ int blk_select_hwpart(struct udevice *dev, int hwpart) int blk_dselect_hwpart(struct blk_desc *desc, int hwpart) { - return blk_select_hwpart(desc->bdev, hwpart); + int ret; + + ret = blk_select_hwpart(desc->bdev, hwpart); + if (!ret) + blkcache_invalidate(desc->if_type, desc->devnum); + + return ret; } int blk_first_device(int if_type, struct udevice **devp) -- cgit v1.2.3 From 80f485f6a4165d381ebeca9a10662b95b94151aa Mon Sep 17 00:00:00 2001 From: Oleksandr Zhadan Date: Thu, 11 Jul 2019 11:52:49 -0400 Subject: board: Arcturus: ucp1020: Removing obsoleted stuff Removed one of the defconfig(obsoleted) file and unused CONFIG_MMC_SPI definition to avoid confusion about if this board using non-DM stuff or not. uCP1020 is completely DM free board, tested and runs well. Signed-off-by: Oleksandr Zhadan Signed-off-by: Michael Durrant Reviewed-by: Bin Meng --- configs/UCP1020_SPIFLASH_defconfig | 60 -------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 configs/UCP1020_SPIFLASH_defconfig diff --git a/configs/UCP1020_SPIFLASH_defconfig b/configs/UCP1020_SPIFLASH_defconfig deleted file mode 100644 index a2d7e6622a1..00000000000 --- a/configs/UCP1020_SPIFLASH_defconfig +++ /dev/null @@ -1,60 +0,0 @@ -CONFIG_PPC=y -CONFIG_SYS_TEXT_BASE=0x11000000 -CONFIG_MPC85xx=y -CONFIG_TARGET_UCP1020=y -CONFIG_TARGET_UCP1020_SPIFLASH=y -CONFIG_FIT=y -CONFIG_FIT_VERBOSE=y -CONFIG_OF_BOARD_SETUP=y -CONFIG_OF_STDOUT_VIA_ALIAS=y -# CONFIG_MISC_INIT_R is not set -CONFIG_BOARD_EARLY_INIT_F=y -CONFIG_BOARD_EARLY_INIT_R=y -CONFIG_LAST_STAGE_INIT=y -CONFIG_HUSH_PARSER=y -# CONFIG_AUTO_COMPLETE is not set -CONFIG_AUTOBOOT_KEYED=y -CONFIG_AUTOBOOT_PROMPT="Autobooting in %d seconds, press \"\" to stop\n" -CONFIG_AUTOBOOT_STOP_STR="\x1b" -CONFIG_CMD_IMLS=y -CONFIG_CMD_GPIO=y -CONFIG_CMD_I2C=y -CONFIG_CMD_MMC=y -# CONFIG_CMD_NAND is not set -CONFIG_CMD_MMC_SPI=y -CONFIG_CMD_SF=y -CONFIG_CMD_SPI=y -CONFIG_CMD_USB=y -CONFIG_CMD_DHCP=y -CONFIG_CMD_MII=y -CONFIG_CMD_PING=y -CONFIG_CMD_DATE=y -CONFIG_MP=y -# CONFIG_CMD_HASH is not set -CONFIG_CMD_CRAMFS=y -CONFIG_CMD_EXT2=y -CONFIG_CMD_FAT=y -CONFIG_ENV_IS_IN_SPI_FLASH=y -CONFIG_FSL_ESDHC=y -CONFIG_MTD_NOR_FLASH=y -CONFIG_FLASH_CFI_DRIVER=y -CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y -CONFIG_SYS_FLASH_CFI=y -CONFIG_SPI_FLASH=y -CONFIG_SF_DEFAULT_MODE=0 -CONFIG_SF_DEFAULT_SPEED=10000000 -CONFIG_SPI_FLASH_STMICRO=y -CONFIG_SPI_FLASH_SST=y -CONFIG_SPI_FLASH_WINBOND=y -CONFIG_PHY_MARVELL=y -CONFIG_PHY_GIGE=y -CONFIG_E1000=y -CONFIG_MII=y -CONFIG_TSEC_ENET=y -CONFIG_SYS_NS16550=y -CONFIG_SPI=y -CONFIG_FSL_ESPI=y -CONFIG_USB=y -CONFIG_USB_STORAGE=y -CONFIG_FS_CRAMFS=y -CONFIG_OF_LIBFDT=y -- cgit v1.2.3 From eb18742575158a680070002cf182b0c64311c1b2 Mon Sep 17 00:00:00 2001 From: Ramon Fried Date: Mon, 15 Jul 2019 23:04:41 +0300 Subject: pci_ep: fix wrong addressing to barno barno was mistakely readed from the target structure, resulting in undefined behavious depending on the previous memory content. fix that. Fixes: bb413337826e ("pci_ep: add pci endpoint sandbox driver") Signed-off-by: Ramon Fried [trini: Drop unused bar_idx] Signed-off-by: Tom Rini --- drivers/pci_endpoint/sandbox-pci_ep.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/pci_endpoint/sandbox-pci_ep.c b/drivers/pci_endpoint/sandbox-pci_ep.c index 0258433d8f9..8e05d5ba890 100644 --- a/drivers/pci_endpoint/sandbox-pci_ep.c +++ b/drivers/pci_endpoint/sandbox-pci_ep.c @@ -83,14 +83,11 @@ static int sandbox_read_bar(struct udevice *dev, uint fn, struct pci_bar *ep_bar, enum pci_barno barno) { struct sandbox_pci_ep_priv *priv = dev_get_priv(dev); - int bar_idx; if (fn > 0) return -ENODEV; - bar_idx = ep_bar->barno; - - memcpy(ep_bar, &priv->bars[bar_idx], sizeof(*ep_bar)); + memcpy(ep_bar, &priv->bars[barno], sizeof(*ep_bar)); return 0; } -- cgit v1.2.3 From bf88d2b023063a0c46d7617a4f6897d5d561662d Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Wed, 17 Jul 2019 09:58:24 -0400 Subject: Revert "test: Disable pci_ep test for now" We now have a proper fix for this test, stop disabling it in CI. This reverts commit ae8d23a668755d804748a1cf848426b28338b3d5. Signed-off-by: Tom Rini --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c21bbbbca46..6662ca126ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -365,13 +365,11 @@ matrix: - name: "test/py sandbox" env: - TEST_PY_BD="sandbox" - TEST_PY_TEST_SPEC="not pci" BUILDMAN="^sandbox$" TOOLCHAIN="i386" - name: "test/py sandbox with clang" env: - TEST_PY_BD="sandbox" - TEST_PY_TEST_SPEC="not pci" BUILDMAN="^sandbox$" OVERRIDE="clang-7" - name: "test/py sandbox_spl" @@ -384,7 +382,6 @@ matrix: - name: "test/py sandbox_flattree" env: - TEST_PY_BD="sandbox_flattree" - TEST_PY_TEST_SPEC="not pci" BUILDMAN="^sandbox_flattree$" TOOLCHAIN="i386" - name: "test/py vexpress_ca15_tc2" -- cgit v1.2.3