From 9e3eb4a05fa19031781a44b7458bcf690955d358 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Mon, 20 Feb 2023 00:14:58 -0600 Subject: fastboot: Only call the bootm command if it is enabled This fixes an error with trying to link against do_bootm() when CONFIG_CMD_BOOTM is disabled. Signed-off-by: Samuel Holland Reviewed-by: Mattijs Korpershoek Reviewed-by: Patrick Delaunay --- drivers/fastboot/fb_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c index 621146bc6b0..4e9d9b719c6 100644 --- a/drivers/fastboot/fb_common.c +++ b/drivers/fastboot/fb_common.c @@ -135,7 +135,7 @@ void fastboot_boot(void) s = env_get("fastboot_bootcmd"); if (s) { run_command(s, CMD_FLAG_ENV); - } else { + } else if (IS_ENABLED(CONFIG_CMD_BOOTM)) { static char boot_addr_start[20]; static char *const bootm_args[] = { "bootm", boot_addr_start, NULL -- cgit v1.3.1 From 36fc832927eba16b175e07c5a42b9d7ab8f5552b Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 29 Apr 2023 19:21:45 -0600 Subject: Makefile: Fix incorrect FORCE deps on env rules These rules run on every build even if nothing has changed. The FORCE dependency is only needed for if_changed, not for cmd. Drop it. Signed-off-by: Simon Glass --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3f5249ceb52..65098ad32ad 100644 --- a/Makefile +++ b/Makefile @@ -1812,7 +1812,7 @@ quiet_cmd_gen_envp = ENVP $@ rm -f $@; \ touch $@ ; \ fi -include/generated/env.in: include/generated/env.txt FORCE +include/generated/env.in: include/generated/env.txt $(call cmd,gen_envp) # Regenerate the environment if it changes @@ -1830,7 +1830,7 @@ quiet_cmd_envc = ENVC $@ touch $@ ; \ fi -include/generated/env.txt: $(wildcard $(ENV_FILE)) FORCE +include/generated/env.txt: $(wildcard $(ENV_FILE)) $(call cmd,envc) # Write out the resulting environment, converted to a C string -- cgit v1.3.1 From 1e4d965b592fb2f790948eed2db8010bda674fc5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 29 Apr 2023 19:21:46 -0600 Subject: acpi: Put the version numbers in a central place At present two acpi files are built every time since they use a version number from version.h This is not necessary. Make use of the same technique as for the version string, so that they are build only when they change. Signed-off-by: Simon Glass --- cmd/version.c | 2 ++ include/version_string.h | 2 ++ lib/acpi/acpi_table.c | 15 +++++++-------- test/dm/acpi.c | 16 +++++++--------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/cmd/version.c b/cmd/version.c index 190ef6a9061..87e1fa4159c 100644 --- a/cmd/version.c +++ b/cmd/version.c @@ -19,6 +19,8 @@ U_BOOT_TIME " " U_BOOT_TZ ")" CONFIG_IDENT_STRING const char version_string[] = U_BOOT_VERSION_STRING; +const unsigned short version_num = U_BOOT_VERSION_NUM; +const unsigned char version_num_patch = U_BOOT_VERSION_NUM_PATCH; static int do_version(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) diff --git a/include/version_string.h b/include/version_string.h index a89a6e43705..a7d07e4cc7c 100644 --- a/include/version_string.h +++ b/include/version_string.h @@ -4,5 +4,7 @@ #define __VERSION_STRING_H__ extern const char version_string[]; +extern const unsigned short version_num; +extern const unsigned char version_num_patch; #endif /* __VERSION_STRING_H__ */ diff --git a/lib/acpi/acpi_table.c b/lib/acpi/acpi_table.c index 7c4189e2434..a8d4b470001 100644 --- a/lib/acpi/acpi_table.c +++ b/lib/acpi/acpi_table.c @@ -11,8 +11,7 @@ #include #include #include -#include -#include +#include #include #include #include @@ -25,12 +24,12 @@ * to have valid date. So for U-Boot version 2021.04 OEM_REVISION is set to * value 0x20210401. */ -#define OEM_REVISION ((((U_BOOT_VERSION_NUM / 1000) % 10) << 28) | \ - (((U_BOOT_VERSION_NUM / 100) % 10) << 24) | \ - (((U_BOOT_VERSION_NUM / 10) % 10) << 20) | \ - ((U_BOOT_VERSION_NUM % 10) << 16) | \ - (((U_BOOT_VERSION_NUM_PATCH / 10) % 10) << 12) | \ - ((U_BOOT_VERSION_NUM_PATCH % 10) << 8) | \ +#define OEM_REVISION ((((version_num / 1000) % 10) << 28) | \ + (((version_num / 100) % 10) << 24) | \ + (((version_num / 10) % 10) << 20) | \ + ((version_num % 10) << 16) | \ + (((version_num_patch / 10) % 10) << 12) | \ + ((version_num_patch % 10) << 8) | \ 0x01) int acpi_create_dmar(struct acpi_dmar *dmar, enum dmar_flags flags) diff --git a/test/dm/acpi.c b/test/dm/acpi.c index 9634fc2e900..818f71572c7 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -11,10 +11,8 @@ #include #include #include -#include -#include #include -#include +#include #include #include #include @@ -26,12 +24,12 @@ #define BUF_SIZE 4096 -#define OEM_REVISION ((((U_BOOT_VERSION_NUM / 1000) % 10) << 28) | \ - (((U_BOOT_VERSION_NUM / 100) % 10) << 24) | \ - (((U_BOOT_VERSION_NUM / 10) % 10) << 20) | \ - ((U_BOOT_VERSION_NUM % 10) << 16) | \ - (((U_BOOT_VERSION_NUM_PATCH / 10) % 10) << 12) | \ - ((U_BOOT_VERSION_NUM_PATCH % 10) << 8) | \ +#define OEM_REVISION ((((version_num / 1000) % 10) << 28) | \ + (((version_num / 100) % 10) << 24) | \ + (((version_num / 10) % 10) << 20) | \ + ((version_num % 10) << 16) | \ + (((version_num_patch / 10) % 10) << 12) | \ + ((version_num_patch % 10) << 8) | \ 0x01) /** -- cgit v1.3.1 From c52bd0362dc3830013de290d02ea69181a0ab8e6 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 29 Apr 2023 19:21:47 -0600 Subject: efi: Correct .efi rules These files should have both 'always' and 'targets' so that dependencies are detected correctly. When only 'always' is used, the target is built every time, although I am not quite sure why. Make sure each has both 'always' and 'targets' to avoid this problem. Signed-off-by: Simon Glass --- lib/efi_loader/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 13a35eae6c0..1a8c8d7cab5 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -23,6 +23,7 @@ CFLAGS_REMOVE_initrddump.o := $(CFLAGS_NON_EFI) ifdef CONFIG_RISCV always += boothart.efi +targets += boothart.o endif ifneq ($(CONFIG_CMD_BOOTEFI_HELLO_COMPILE),) @@ -32,10 +33,12 @@ endif ifeq ($(CONFIG_GENERATE_ACPI_TABLE),) always += dtbdump.efi +targets += dtbdump.o endif ifdef CONFIG_EFI_LOAD_FILE2_INITRD always += initrddump.efi +targets += initrddump.o endif obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o -- cgit v1.3.1 From 33c63cea5ee13da6cc7c62443b1f953f74828302 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 1 May 2023 11:35:25 +0800 Subject: cmd: fdt: Correct checking of configuration node fit_conf_get_node() returns a negative value on error. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- cmd/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/fdt.c b/cmd/fdt.c index aae3278526c..2401ea8b44c 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -733,7 +733,7 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) gd->fdt_blob = blob; cfg_noffset = fit_conf_get_node(working_fdt, NULL); - if (!cfg_noffset) { + if (cfg_noffset < 0) { printf("Could not find configuration node: %s\n", fdt_strerror(cfg_noffset)); return CMD_RET_FAILURE; -- cgit v1.3.1 From 1310ad3aacf5cae97a2f3457ec9ef56f0d88bc09 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Mon, 1 May 2023 11:35:26 +0800 Subject: spl: Correct checking of configuration node Per the fit_conf_get_node() API doc, it returns configuration node offset when found (>=0). Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- common/spl/spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index 72078a8ebc8..801c4b507ca 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -331,7 +331,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image, conf_noffset = fit_conf_get_node((const void *)header, fit_uname_config); - if (conf_noffset <= 0) + if (conf_noffset < 0) return 0; for (idx = 0; -- cgit v1.3.1 From 7bae13da36477ce451ef5975e0cf79dbe035b52c Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 2 May 2023 04:34:09 +0200 Subject: cli: avoid buffer overrun MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Invoking the sandbox with /u-boot -c ⧵0xef⧵0xbf⧵0xbd results in a segmentation fault. Function b_getch() retrieves a character from the input stream. This character may be > 0x7f. If type char is signed, static_get() will return a negative number and in parse_stream() we will use that negative number as an index for array map[] resulting in a buffer overflow. Reported-by: Harry Lockyer Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- common/cli_hush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/cli_hush.c b/common/cli_hush.c index 171069f5f49..cee87249bc2 100644 --- a/common/cli_hush.c +++ b/common/cli_hush.c @@ -324,7 +324,7 @@ typedef struct { /* I can almost use ordinary FILE *. Is open_memstream() universally * available? Where is it documented? */ struct in_str { - const char *p; + const unsigned char *p; #ifndef __U_BOOT__ char peek_buf[2]; #endif -- cgit v1.3.1 From d20481ee3c8a95ce713f595b5ee84969b1c9fa01 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Sun, 7 May 2023 13:48:06 +0300 Subject: cmd: fs: document where 'size' stores its result Make it a little bit easier for the user to utilize the 'size' command. Signed-off-by: Baruch Siach Reviewed-by: Simon Glass --- cmd/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/fs.c b/cmd/fs.c index 5ad11647c2d..6044f73af5b 100644 --- a/cmd/fs.c +++ b/cmd/fs.c @@ -20,7 +20,7 @@ U_BOOT_CMD( "determine a file's size", " \n" " - Find file 'filename' from 'dev' on 'interface'\n" - " and determine its size." + " determine its size, and store in the 'filesize' variable." ); static int do_load_wrapper(struct cmd_tbl *cmdtp, int flag, int argc, -- cgit v1.3.1 From 719120392f4b2818767c38172f68272b1a50a5cd Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Fri, 12 May 2023 16:31:05 -0600 Subject: arm: set alignment properly for asm funcs ARM requires a 4-byte alignment on all ARM code (though this requirement is relaxed to 2-byte for some THUMB code) and we should be explicit about that here. GAS has its own fix for this[1] that forces proper alignment on any section containing assembled instructions, but this is not universal: Clang's and other gaslike assemblers lack this implicit alignment. Whether or not this is considered a bug in those assemblers, it is better to ask directly for what we want. [1]: https://sourceware.org/bugzilla/show_bug.cgi?id=12931 Signed-off-by: Sam Edwards --- arch/arm/include/asm/linkage.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/linkage.h b/arch/arm/include/asm/linkage.h index dbe4b4e31a5..73bf25ba4e1 100644 --- a/arch/arm/include/asm/linkage.h +++ b/arch/arm/include/asm/linkage.h @@ -1,7 +1,7 @@ #ifndef __ASM_LINKAGE_H #define __ASM_LINKAGE_H -#define __ALIGN .align 0 -#define __ALIGN_STR ".align 0" +#define __ALIGN .p2align 2 +#define __ALIGN_STR ".p2align 2" #endif -- cgit v1.3.1 From 2f9943beb310e42ec806f79eec51a81217687982 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 13 May 2023 00:47:03 +0200 Subject: semihosting: create file in smh_fs_write_at() If a file does not exist, it should be created. Fixes: f676b45151c3 ("fs: Add semihosting filesystem") Signed-off-by: Heinrich Schuchardt --- fs/semihostingfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/semihostingfs.c b/fs/semihostingfs.c index 96eb3349a2f..3592338a686 100644 --- a/fs/semihostingfs.c +++ b/fs/semihostingfs.c @@ -57,7 +57,11 @@ static int smh_fs_write_at(const char *filename, loff_t pos, void *buffer, { long fd, size, ret; + /* Try to open existing file */ fd = smh_open(filename, MODE_READ | MODE_BINARY | MODE_PLUS); + if (fd < 0) + /* Create new file */ + fd = smh_open(filename, MODE_WRITE | MODE_BINARY); if (fd < 0) return fd; ret = smh_seek(fd, pos); -- cgit v1.3.1 From 2f27405902894c3cb1b274536d623c286aa7c425 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Tue, 16 May 2023 11:17:56 +0200 Subject: scripts/Makefile.lib: change spelling of $(srctree)/arch/$(ARCH)/dts in dtc_cpp_flags Currently, all in-tree .dts files (apart from some under test/ and tools/), reside in arch/$ARCH/dts. However, in the linux kernel tree, dts files for arm64 boards, and probably in the not too distant future [1], arm boards as well, live in subdirectories of that. For private forks, using a vendor or project subdirectory is also more convenient to clearly separate private code from upstream - in the same way that code under board/ is also split and easy to maintain. In order to prepare for us to follow suit and do the splitting of the in-tree .dts files, and to make life a little easier for private forks that already place dts files not directly in arch/$ARCH/dts, change the $(srctree)/arch/$(ARCH)/dts path to instead refer to the directory of the .dts file being compiled. This should be a no-op for all existing cases. [1] https://lore.kernel.org/lkml/20220328000915.15041-1-ansuelsmth@gmail.com/ Signed-off-by: Rasmus Villemoes --- scripts/Makefile.lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 7362a392ada..f5ab7af0f45 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -186,7 +186,7 @@ u_boot_dtsi = $(strip $(u_boot_dtsi_options_debug) \ # Modified for U-Boot dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ $(UBOOTINCLUDE) \ - -I$(srctree)/arch/$(ARCH)/dts \ + -I$(dir $<) \ -I$(srctree)/arch/$(ARCH)/dts/include \ -I$(srctree)/include \ -D__ASSEMBLY__ \ -- cgit v1.3.1 From 899fb5aa8becc159b1eb086d8828c4e8eb28f121 Mon Sep 17 00:00:00 2001 From: Ashok Reddy Soma Date: Tue, 16 May 2023 05:52:36 -0600 Subject: cmd: sf/nand: Print and return failure when 0 length is passed For sf commands, when '0' length is passed for erase, update, write or read, there might be undesired results. Ideally '0' length means nothing to do. So print 'ERROR: Invalid size 0' and return cmd failure when length '0' is passed to sf commands. Same thing applies for nand commands also. Example: ZynqMP> sf erase 0 0 ERROR: Invalid size 0 ZynqMP> sf write 10000 0 0 ERROR: Invalid size 0 ZynqMP> sf read 10000 0 0 ERROR: Invalid size 0 ZynqMP> sf update 1000 10000 0 ERROR: Invalid size 0 ZynqMP> Signed-off-by: Ashok Reddy Soma --- cmd/legacy-mtd-utils.c | 5 +++++ cmd/sf.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/cmd/legacy-mtd-utils.c b/cmd/legacy-mtd-utils.c index ac7139f84d6..5903a90fe53 100644 --- a/cmd/legacy-mtd-utils.c +++ b/cmd/legacy-mtd-utils.c @@ -88,6 +88,11 @@ int mtd_arg_off_size(int argc, char *const argv[], int *idx, loff_t *off, return -1; } + if (*size == 0) { + debug("ERROR: Invalid size 0\n"); + return -1; + } + print: printf("device %d ", *idx); if (*size == chipsize) diff --git a/cmd/sf.c b/cmd/sf.c index 11b9c25896a..55bef2f7699 100644 --- a/cmd/sf.c +++ b/cmd/sf.c @@ -353,6 +353,11 @@ static int do_spi_flash_erase(int argc, char *const argv[]) if (ret != 1) return CMD_RET_USAGE; + if (size == 0) { + debug("ERROR: Invalid size 0\n"); + return CMD_RET_FAILURE; + } + /* Consistency checking */ if (offset + size > flash->size) { printf("ERROR: attempting %s past flash size (%#x)\n", -- cgit v1.3.1 From de06083c8808c57d55fffabb727a0d7c8c15612c Mon Sep 17 00:00:00 2001 From: Ravi Gunasekaran Date: Thu, 18 May 2023 12:06:23 +0530 Subject: common: dfu: Remove leading space characters As per [1], dfu_alt_info is mentioned to be as semicolon separated string of information on each alternate and the parsing logic in the dfu.c is based on this. Typically, the dfu_alt_info_* is defined in .h files as preprocessor macros with 'alt' info separated by semicolon. But when dfu_alt_info_* is added in the environment files(.env) the script at "scripts/env2string.awk" converts a newline to space. Thus adding a space character after semicolon. This results in incorrect parsing in dfu.c which is based on the information that 'alt' info are only semicolon separated. One option is to add dfu_alt_info_* variable in .env in single line. But there is possiblity for it to exceed the line length limit. So update the parsing logic to remove leading space characters before adding to the dfu list. [1]: https://u-boot.readthedocs.io/en/latest/usage/dfu.html Signed-off-by: Ravi Gunasekaran --- drivers/dfu/dfu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index 516dda61796..b2ee5f1ede6 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -135,6 +135,7 @@ int dfu_config_interfaces(char *env) a = s; do { part = strsep(&a, ";"); + part = skip_spaces(part); ret = dfu_alt_add(dfu, i, d, part); if (ret) return ret; @@ -629,6 +630,7 @@ int dfu_config_entities(char *env, char *interface, char *devstr) for (i = 0; i < dfu_alt_num; i++) { s = strsep(&env, ";"); + s = skip_spaces(s); ret = dfu_alt_add(dfu, interface, devstr, s); if (ret) { /* We will free "dfu" in dfu_free_entities() */ -- cgit v1.3.1 From 229d689e3c32164875667da282e496b858dbc608 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Thu, 18 May 2023 13:47:07 -0600 Subject: mmc: fix improper use of memset Buffers created through DEFINE_(CACHE_)ALIGN_BUFFER are actually pointers to the real underlying buffer. Using sizeof(...) is not appropriate in this case. Signed-off-by: Sam Edwards Reviewed-by: Peng Fan --- drivers/mmc/mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 1af6af82e6b..72c1076c56d 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -2262,7 +2262,7 @@ static int mmc_startup_v4(struct mmc *mmc) return 0; if (!mmc->ext_csd) - memset(ext_csd_bkup, 0, sizeof(ext_csd_bkup)); + memset(ext_csd_bkup, 0, MMC_MAX_BLOCK_LEN); err = mmc_send_ext_csd(mmc, ext_csd); if (err) -- cgit v1.3.1