From 8b1312662b3b1748c3d5f8a30bc6f9ca72879c7a Mon Sep 17 00:00:00 2001 From: Igor Opaniuk Date: Tue, 4 Dec 2018 14:37:19 +0200 Subject: [PATCH 01/10] tee: change return code for REE FS supplicant cmd If OP-TEE core is compiled with support of REE FS and RPMB at the same time (CFG_RPMB_FS ?= y; CFG_RPMB_FS ?= y), and persistent storage API is used with TEE_STORAGE_PRIVATE storage id, it will lead to TA panic. E/TC:? 0 TA panicked with code 0xffff0009 ..... E/TC:? 0 Call stack: E/TC:? 0 0x000000004002f2f8 TEE_OpenPersistentObject at lib/libutee/tee_api_objects.c:422 In this particular case TEE_ERROR_STORAGE_NOT_AVAILABLE is more suitable than TEE_ERROR_NOT_IMPLEMENTED, as it provides to a TA a possibility to handle this error code [1]. >From GPD TEE Internal Core specification [2]: TEE_ERROR_STORAGE_NOT_AVAILABLE - if the persistent object is stored in a storage area which is currently inaccessible. It may be associated with the device but unplugged, busy, or inaccessible for some other reason. [1]: https://github.com/OP-TEE/optee_os/blob/94db01ef448d1e552161c2d861d57a5f8bda0cc0/lib/libutee/tee_api_objects.c#L419 [2]: https://globalplatform.org/wp-content/uploads/2018/06/GPD_TEE_Internal_Core_API_Specification_v1.1.2.50_PublicReview.pdf Signed-off-by: Igor Opaniuk Reviewed-by: Jens Wiklander --- drivers/tee/optee/supplicant.c | 4 ++-- include/tee.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/tee/optee/supplicant.c b/drivers/tee/optee/supplicant.c index b1ea65bdb2..c5726ecb91 100644 --- a/drivers/tee/optee/supplicant.c +++ b/drivers/tee/optee/supplicant.c @@ -82,8 +82,8 @@ void optee_suppl_cmd(struct udevice *dev, struct tee_shm *shm_arg, cmd_shm_free(arg); break; case OPTEE_MSG_RPC_CMD_FS: - debug("OPTEE_MSG_RPC_CMD_FS not implemented\n"); - arg->ret = TEE_ERROR_NOT_IMPLEMENTED; + debug("REE FS storage isn't available\n"); + arg->ret = TEE_ERROR_STORAGE_NOT_AVAILABLE; break; case OPTEE_MSG_RPC_CMD_RPMB: optee_suppl_cmd_rpmb(dev, arg); diff --git a/include/tee.h b/include/tee.h index 98b1c9cc69..edd9f9b0c9 100644 --- a/include/tee.h +++ b/include/tee.h @@ -34,6 +34,7 @@ * struct tee_version_data::gen_caps */ #define TEE_SUCCESS 0x00000000 +#define TEE_ERROR_STORAGE_NOT_AVAILABLE 0xf0100003 #define TEE_ERROR_GENERIC 0xffff0000 #define TEE_ERROR_BAD_PARAMETERS 0xffff0006 #define TEE_ERROR_ITEM_NOT_FOUND 0xffff0008 From 4bca32497c09ef53ad669dfa4c413c00321ad7ca Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Fri, 14 Dec 2018 18:42:51 +0900 Subject: [PATCH 02/10] hashtable: fix length calculation in hexport_r The commit below incorrectly fixed hexport_r(); > size = totlen + 1; One extra byte is necessary to NULL-terminate a whole buffer, "resp." Fixes: f1b20acb4a03 ("hashtable: Fix length calculation in hexport_r") Signed-off-by: AKASHI Takahiro --- lib/hashtable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hashtable.c b/lib/hashtable.c index 1c48692b69..93028ed83b 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -662,7 +662,7 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep, int flag, return (-1); } } else { - size = totlen; + size = totlen + 1; } /* Check if the user provided a buffer */ From 6df41b1cf3f22c8baa3e2919d7607f96c5385c57 Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 7 Dec 2018 19:00:39 -0500 Subject: [PATCH 03/10] cmd: Move the "dm" command from test/dm/ to cmd/ The "dm" command under CONFIG_CMD_DM should live under cmd/ rather than test/dm/ so move it. Signed-off-by: Tom Rini --- cmd/Makefile | 1 + test/dm/cmd_dm.c => cmd/dm.c | 0 test/dm/Makefile | 1 - 3 files changed, 1 insertion(+), 1 deletion(-) rename test/dm/cmd_dm.c => cmd/dm.c (100%) diff --git a/cmd/Makefile b/cmd/Makefile index 49986437ba..15ae4d250f 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -40,6 +40,7 @@ obj-$(CONFIG_CMD_CPU) += cpu.o obj-$(CONFIG_DATAFLASH_MMC_SELECT) += dataflash_mmc_mux.o obj-$(CONFIG_CMD_DATE) += date.o obj-$(CONFIG_CMD_DEMO) += demo.o +obj-$(CONFIG_CMD_DM) += dm.o obj-$(CONFIG_CMD_SOUND) += sound.o ifdef CONFIG_POST obj-$(CONFIG_CMD_DIAG) += diag.o diff --git a/test/dm/cmd_dm.c b/cmd/dm.c similarity index 100% rename from test/dm/cmd_dm.c rename to cmd/dm.c diff --git a/test/dm/Makefile b/test/dm/Makefile index 6b451060d8..7dc80be25e 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -2,7 +2,6 @@ # # Copyright (c) 2013 Google, Inc -obj-$(CONFIG_CMD_DM) += cmd_dm.o obj-$(CONFIG_UT_DM) += bus.o obj-$(CONFIG_UT_DM) += test-driver.o obj-$(CONFIG_UT_DM) += test-fdt.o From 79ffe8c63af3f6b411bf8e1a034c110a7408824d Mon Sep 17 00:00:00 2001 From: Tom Rini Date: Fri, 7 Dec 2018 19:00:40 -0500 Subject: [PATCH 04/10] test: Only descend into test/ when CONFIG_UNIT_TEST is enabled The contents of the test subdirectories only make sense when we have CONFIG_UNIT_TEST set. We will otherwise attempt to build code on for example sandbox that needs CONFIG_UNIT_TEST otherwise and rather than complicate the Makefiles simply leave them out when we can. Signed-off-by: Tom Rini --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 5683714947..f69aa06169 100644 --- a/Makefile +++ b/Makefile @@ -724,8 +724,7 @@ libs-y += common/ libs-y += env/ libs-$(CONFIG_API) += api/ libs-$(CONFIG_HAS_POST) += post/ -libs-y += test/ -libs-y += test/dm/ +libs-$(CONFIG_UNIT_TEST) += test/ test/dm/ libs-$(CONFIG_UT_ENV) += test/env/ libs-$(CONFIG_UT_OVERLAY) += test/overlay/ From 80870e2a664e277df0b6c0604bc4c5591aebde67 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Fri, 7 Dec 2018 19:00:41 -0500 Subject: [PATCH 05/10] tools: add a generic config for native tools building The motivation for this is to allow distributions to distribute all possible tools in a generic way, avoiding the need of specific tools building for each machine. Especially on OpenEmbedded / Yocto Project ecosystem, it is very common each BSP to end providing their specific tools when they need to generate images for some SoC (e.g MX23 / MX28 in meta-freescale case). Using this, we can package the tools doing: $: make tools-only_defconfig $: make tools-only Signed-off-by: Otavio Salvador [trini: Add MAINTAINERS entry for myself, add to .travis.yml, make U-Boot itself buildable to not trip up other frameworks] Signed-off-by: Tom Rini --- .travis.yml | 4 ++++ MAINTAINERS | 1 + configs/tools-only_defconfig | 24 ++++++++++++++++++++++++ tools/Makefile | 2 +- 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 configs/tools-only_defconfig diff --git a/.travis.yml b/.travis.yml index fe2dfce9bf..321fd793a7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -336,6 +336,10 @@ matrix: - name: "Check for configs without MAINTAINERS entry" script: - if [ `./tools/genboardscfg.py -f 2>&1 | wc -l` -ne 0 ]; then exit 1; fi + # Ensure host tools build + - name: "Build tools-only" + script: + - make tools-only_config tools-only -j$(nproc) # test/py - name: "test/py sandbox" diff --git a/MAINTAINERS b/MAINTAINERS index 0cec39c542..0fb089807c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -719,5 +719,6 @@ L: u-boot@lists.denx.de Q: http://patchwork.ozlabs.org/project/uboot/list/ S: Maintained T: git git://git.denx.de/u-boot.git +F: configs/tools-only_defconfig F: * F: */ diff --git a/configs/tools-only_defconfig b/configs/tools-only_defconfig new file mode 100644 index 0000000000..fb06076785 --- /dev/null +++ b/configs/tools-only_defconfig @@ -0,0 +1,24 @@ +CONFIG_SYS_TEXT_BASE=0 +CONFIG_ANDROID_BOOT_IMAGE=y +CONFIG_FIT=y +CONFIG_FIT_SIGNATURE=y +# CONFIG_CMD_BOOTD is not set +# CONFIG_CMD_BOOTM is not set +# CONFIG_CMD_ELF is not set +# CONFIG_CMD_DATE is not set +CONFIG_OF_CONTROL=y +CONFIG_OF_HOSTFILE=y +CONFIG_DEFAULT_DEVICE_TREE="sandbox" +# CONFIG_UDP_FUNCTION_FASTBOOT is not set +CONFIG_SANDBOX_GPIO=y +CONFIG_DM_I2C_COMPAT=y +CONFIG_PCI=y +CONFIG_DM_PCI=y +CONFIG_PCI_SANDBOX=y +CONFIG_DM_RTC=y +CONFIG_SOUND=y +CONFIG_SYSRESET=y +# CONFIG_VIRTIO_MMIO is not set +# CONFIG_VIRTIO_PCI is not set +# CONFIG_VIRTIO_SANDBOX is not set +# CONFIG_EFI_LOADER is not set diff --git a/tools/Makefile b/tools/Makefile index c26b631560..2c4d91f199 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -126,7 +126,7 @@ fit_info-objs := $(dumpimage-mkimage-objs) fit_info.o fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o file2include-objs := file2include.o -ifneq ($(CONFIG_MX23)$(CONFIG_MX28),) +ifneq ($(CONFIG_MX23)$(CONFIG_MX28)$(CONFIG_FIT_SIGNATURE),) # Add CONFIG_MXS into host CFLAGS, so we can check whether or not register # the mxsimage support within tools/mxsimage.c . HOSTCFLAGS_mxsimage.o += -DCONFIG_MXS From 413888a54675a41578ac635a5c24a3bcee95db8b Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Thu, 13 Dec 2018 17:10:43 +0800 Subject: [PATCH 06/10] poplar: add a co-maintainer for poplar board Add myself as co-maintainer for poplar board, as I'm actively working on the board. Signed-off-by: Shawn Guo --- board/hisilicon/poplar/MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/board/hisilicon/poplar/MAINTAINERS b/board/hisilicon/poplar/MAINTAINERS index 0cc01c8321..622e5cb18e 100644 --- a/board/hisilicon/poplar/MAINTAINERS +++ b/board/hisilicon/poplar/MAINTAINERS @@ -1,5 +1,6 @@ Poplar BOARD M: Jorge Ramirez-Ortiz +M: Shawn Guo S: Maintained F: board/hisilicon/poplar F: include/configs/poplar.h From 655c6d997d47838229ed2d31a7338dcdffea886a Mon Sep 17 00:00:00 2001 From: Shawn Guo Date: Wed, 12 Dec 2018 15:24:44 +0800 Subject: [PATCH 07/10] poplar: fix boot failure caused by serial driver change Commit 4687919684e0 ("serial: Remove DM_FLAG_PRE_RELOC flag in various drivers") essentially drops flag DM_FLAG_PRE_RELOC from serial_pl01x driver for Poplar platform, because the platform falls into the following strategy category made by the commit. Surround DM_FLAG_PRE_RELOC flag with OF_CONTROL check, for drivers that support both statically declared devices and configuration from device tree Before the commit lands, Poplar platform works by statically declaring pl011 serial device via U_BOOT_DEVICE() with DM_FLAG_PRE_RELOC flag set in the driver. But since Poplar also supports device configuration from device tree, the commit practically drops the flag for Poplar, and hence breaks the platform from booting. This patch changes platform code and device tree to initiate pl011 serial device from device tree rather than static declaration, so that above strategy about DM_FLAG_PRE_RELOC applies to Poplar, and therefore the reported boot failure gets fixed. Reported-by: Igor Opaniuk Fixes: 4687919684e0 ("serial: Remove DM_FLAG_PRE_RELOC flag in various drivers") Cc: Bin Meng Cc: Simon Glass Signed-off-by: Shawn Guo Reviewed-by: Igor Opaniuk Tested-by: Igor Opaniuk Reviewed-by: Bin Meng --- arch/arm/dts/hi3798cv200-u-boot.dtsi | 10 ++-------- board/hisilicon/poplar/poplar.c | 2 ++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/arch/arm/dts/hi3798cv200-u-boot.dtsi b/arch/arm/dts/hi3798cv200-u-boot.dtsi index 709ae1cbc9..7844c5208c 100644 --- a/arch/arm/dts/hi3798cv200-u-boot.dtsi +++ b/arch/arm/dts/hi3798cv200-u-boot.dtsi @@ -17,12 +17,6 @@ }; &uart0 { - status = "disabled"; + clock = <75000000>; + status = "okay"; }; - -/{ - chosen { - stdout-path = ""; - }; -}; - diff --git a/board/hisilicon/poplar/poplar.c b/board/hisilicon/poplar/poplar.c index 9e8eac7838..8adc750962 100644 --- a/board/hisilicon/poplar/poplar.c +++ b/board/hisilicon/poplar/poplar.c @@ -35,6 +35,7 @@ static struct mm_region poplar_mem_map[] = { struct mm_region *mem_map = poplar_mem_map; +#if !CONFIG_IS_ENABLED(OF_CONTROL) static const struct pl01x_serial_platdata serial_platdata = { .base = REG_BASE_UART0, .type = TYPE_PL010, @@ -45,6 +46,7 @@ U_BOOT_DEVICE(poplar_serial) = { .name = "serial_pl01x", .platdata = &serial_platdata, }; +#endif int checkboard(void) { From f828fa4d822b61de624a6e8db288d3778a69ee7a Mon Sep 17 00:00:00 2001 From: Patrice Chotard Date: Tue, 4 Dec 2018 14:11:36 +0100 Subject: [PATCH 08/10] serial: serial_stm32: Add reset support In some cases, UART is configured by early boot stage. To be sure of the initial state of UART and to avoid spurious chars on console, reset the serial block before configuring it. Signed-off-by: Patrice Chotard Reviewed-by: Simon Glass --- drivers/serial/serial_stm32.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/serial/serial_stm32.c b/drivers/serial/serial_stm32.c index 31b43ee88d..e31c87b9ac 100644 --- a/drivers/serial/serial_stm32.c +++ b/drivers/serial/serial_stm32.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -171,6 +172,7 @@ static int stm32_serial_probe(struct udevice *dev) { struct stm32x7_serial_platdata *plat = dev_get_platdata(dev); struct clk clk; + struct reset_ctl reset; int ret; plat->uart_info = (struct stm32_uart_info *)dev_get_driver_data(dev); @@ -185,6 +187,13 @@ static int stm32_serial_probe(struct udevice *dev) return ret; } + ret = reset_get_by_index(dev, 0, &reset); + if (!ret) { + reset_assert(&reset); + udelay(2); + reset_deassert(&reset); + } + plat->clock_rate = clk_get_rate(&clk); if (plat->clock_rate < 0) { clk_disable(&clk); From 74473ed0cf171acaf370b6ab2123b763107d5121 Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 11 Dec 2018 16:41:43 +0200 Subject: [PATCH 09/10] tools: mtk_image: replace strncpy(d, s, sizeof(d)) with snprintf() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Starting from version 8 the GCC, i.e. C compiler, starts complaining about possible '\0' terminator loss or, as in this case, garbage copy. In function ‘mtk_image_set_gen_header’, inlined from ‘mtk_image_set_header’ at tools/mtk_image.c:733:3: tools/mtk_image.c:659:2: warning: ‘strncpy’ specified bound 12 equals destination size [-Wstringop-truncation] strncpy(hdr->boot.name, bootname, sizeof(hdr->boot.name)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In function ‘mtk_brom_parse_imagename’, inlined from ‘mtk_image_check_params’ at tools/mtk_image.c:388:9: tools/mtk_image.c:325:5: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation] strncpy(lk_name, val, sizeof(lk_name)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Replace it with snprintf() to tell compiler how much room we have in the destination buffer for source string. Fixes: 3b975a147c3c ("tools: MediaTek: add MTK boot header generation to mkimage") Cc: Ryder Lee Cc: Weijie Gao Signed-off-by: Andy Shevchenko Reviewed-by: Weijie Gao --- tools/mtk_image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/mtk_image.c b/tools/mtk_image.c index 2706d2de32..2ca519483d 100644 --- a/tools/mtk_image.c +++ b/tools/mtk_image.c @@ -322,7 +322,7 @@ static int mtk_brom_parse_imagename(const char *imagename) lk = val; if (!strcmp(key, "lkname")) - strncpy(lk_name, val, sizeof(lk_name)); + snprintf(lk_name, sizeof(lk_name), "%s", val); } if (next) @@ -656,7 +656,7 @@ static void mtk_image_set_gen_header(void *ptr, off_t filesize, bootname = SDMMC_BOOT_NAME; /* Generic device header */ - strncpy(hdr->boot.name, bootname, sizeof(hdr->boot.name)); + snprintf(hdr->boot.name, sizeof(hdr->boot.name), "%s", bootname); hdr->boot.version = cpu_to_le32(1); hdr->boot.size = cpu_to_le32(sizeof(hdr->boot)); From de5bab9c59807b109f89a39855c9eacfe4d08822 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Wed, 31 Oct 2018 16:49:03 +0100 Subject: [PATCH 10/10] syscon: update syscon_node_to_regmap to use the DM functions + Update the function syscon_node_to_regmap() to force bound on syscon uclass and directly use the list of device from DM. + Remove the static list syscon_list. This patch avoid issue (crash) when syscon_node_to_regmap() is called before and after reallocation (list content is invalid). Signed-off-by: Patrick Delaunay --- drivers/core/syscon-uclass.c | 55 +++++++++++------------------------- 1 file changed, 17 insertions(+), 38 deletions(-) diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c index 661cf61d62..3cf9dd9dbe 100644 --- a/drivers/core/syscon-uclass.c +++ b/drivers/core/syscon-uclass.c @@ -146,52 +146,31 @@ U_BOOT_DRIVER(generic_syscon) = { * The syscon node can be bound to another driver, but still works * as a syscon provider. */ -static LIST_HEAD(syscon_list); - -struct syscon { - ofnode node; - struct regmap *regmap; - struct list_head list; -}; - -static struct syscon *of_syscon_register(ofnode node) +struct regmap *syscon_node_to_regmap(ofnode node) { - struct syscon *syscon; + struct udevice *dev, *parent; int ret; + if (!uclass_get_device_by_ofnode(UCLASS_SYSCON, node, &dev)) + return syscon_get_regmap(dev); + if (!ofnode_device_is_compatible(node, "syscon")) return ERR_PTR(-EINVAL); - syscon = malloc(sizeof(*syscon)); - if (!syscon) - return ERR_PTR(-ENOMEM); + /* bound to driver with same ofnode or to root if not found */ + if (device_find_global_by_ofnode(node, &parent)) + parent = dm_root(); - ret = regmap_init_mem(node, &syscon->regmap); - if (ret) { - free(syscon); + /* force bound to syscon class */ + ret = device_bind_driver_to_node(parent, "syscon", + ofnode_get_name(node), + node, &dev); + if (ret) return ERR_PTR(ret); - } - list_add_tail(&syscon->list, &syscon_list); + ret = device_probe(dev); + if (ret) + return ERR_PTR(ret); - return syscon; -} - -struct regmap *syscon_node_to_regmap(ofnode node) -{ - struct syscon *entry, *syscon = NULL; - - list_for_each_entry(entry, &syscon_list, list) - if (ofnode_equal(entry->node, node)) { - syscon = entry; - break; - } - - if (!syscon) - syscon = of_syscon_register(node); - - if (IS_ERR(syscon)) - return ERR_CAST(syscon); - - return syscon->regmap; + return syscon_get_regmap(dev); }