[v5 01/30] sandbox: eliminate unused functions from binaries

From: Heinrich Schuchardt heinrich.schuchardt@canonical.com
The sandbox should closely mimic other architectures.
Place each function or data in a separate section and let the linker eliminate unused ones. This will reduce the binary size.
In the linker script mark that u_boot_sandbox_getopt are to be kept.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com Reviewed-by: Tom Rini trini@konsulko.com --- Changes in v5: - This is Heinrich's v3 just brought to this series to enable the overall series goal to work --- arch/sandbox/config.mk | 4 ++-- arch/sandbox/cpu/u-boot.lds | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 2d184c5f652a..1d50991f8d24 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -2,7 +2,7 @@ # Copyright (c) 2011 The Chromium OS Authors.
PLATFORM_CPPFLAGS += -D__SANDBOX__ -U_FORTIFY_SOURCE -PLATFORM_CPPFLAGS += -fPIC +PLATFORM_CPPFLAGS += -fPIC -ffunction-sections -fdata-sections PLATFORM_LIBS += -lrt SDL_CONFIG ?= sdl2-config
@@ -30,7 +30,7 @@ cmd_u-boot__ = $(CC) -o $@ -Wl,-T u-boot.lds $(u-boot-init) \ $(u-boot-main) \ $(u-boot-keep-syms-lto) \ -Wl,--no-whole-archive \ - $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map + $(PLATFORM_LIBS) -Wl,-Map -Wl,u-boot.map -Wl,--gc-sections
cmd_u-boot-spl = (cd $(obj) && $(CC) -o $(SPL_BIN) -Wl,-T u-boot-spl.lds \ $(KBUILD_LDFLAGS:%=-Wl,%) \ diff --git a/arch/sandbox/cpu/u-boot.lds b/arch/sandbox/cpu/u-boot.lds index ba8dee50c7bd..52f13af3742f 100644 --- a/arch/sandbox/cpu/u-boot.lds +++ b/arch/sandbox/cpu/u-boot.lds @@ -15,7 +15,7 @@ SECTIONS
_u_boot_sandbox_getopt : { *(_u_boot_sandbox_getopt_start) - *(_u_boot_sandbox_getopt) + KEEP(*(_u_boot_sandbox_getopt)) *(_u_boot_sandbox_getopt_end) }

From: Simon Glass sjg@chromium.org
We cannot be sure that the new config is consistent, particularly when changing a major item like CONFIG_CMDLINE. Use 'make oldconfig' to check that and avoid any such problems.
Signed-off-by: Simon Glass sjg@chromium.org --- tools/buildman/builder.py | 2 +- tools/buildman/builderthread.py | 6 ++++++ tools/buildman/func_test.py | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/buildman/builder.py b/tools/buildman/builder.py index 5305477c5be6..782e59dd5cca 100644 --- a/tools/buildman/builder.py +++ b/tools/buildman/builder.py @@ -476,7 +476,7 @@ class Builder: Args: commit: Commit object that is being built brd: Board object that is being built - stage: Stage that we are at (mrproper, config, build) + stage: Stage that we are at (mrproper, config, oldconfig, build) cwd: Directory where make should be run args: Arguments to pass to make kwargs: Arguments to pass to command.run_pipe() diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index 6a61f64da1d4..a8599c0bb2a8 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -426,6 +426,12 @@ class BuilderThread(threading.Thread):
# Now do the build, if everything looks OK if result.return_code == 0: + if adjust_cfg: + oldc_args = list(args) + ['oldconfig'] + oldc_result = self.make(commit, brd, 'oldconfig', cwd, + *oldc_args, env=env) + if oldc_result.return_code: + return oldc_result result = self._build(commit, brd, cwd, args, env, cmd_list, config_only) if adjust_cfg: diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py index 55dd494fe8ee..6b88ed815d65 100644 --- a/tools/buildman/func_test.py +++ b/tools/buildman/func_test.py @@ -439,6 +439,8 @@ class TestFunctional(unittest.TestCase): tools.write_file(fname, b'CONFIG_SOMETHING=1') return command.CommandResult(return_code=0, combined='Test configuration complete') + elif stage == 'oldconfig': + return command.CommandResult(return_code=0) elif stage == 'build': stderr = '' fname = os.path.join(cwd or '', out_dir, 'u-boot') @@ -461,7 +463,7 @@ Some images are invalid''' return command.CommandResult(return_code=0)
# Not handled, so abort - print('make', stage) + print('_HandleMake failure: make', stage) sys.exit(1)
# Example function to print output lines

On Thu, Oct 26, 2023 at 02:31:10PM -0400, Tom Rini wrote:
From: Simon Glass sjg@chromium.org
We cannot be sure that the new config is consistent, particularly when changing a major item like CONFIG_CMDLINE. Use 'make oldconfig' to check that and avoid any such problems.
Signed-off-by: Simon Glass sjg@chromium.org
For this and the rest of this series (patch 1 is already applied), applied to u-boot/next, thanks!

As VIRTIO_NET is the symbol for enabling network devices, make this depend on NETDEVICES
Signed-off-by: Tom Rini trini@konsulko.com --- Cc: Bin Meng bmeng.cn@gmail.com --- drivers/virtio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/virtio/Kconfig b/drivers/virtio/Kconfig index 852f6735b602..1de68867d52e 100644 --- a/drivers/virtio/Kconfig +++ b/drivers/virtio/Kconfig @@ -56,7 +56,7 @@ config VIRTIO_SANDBOX
config VIRTIO_NET bool "virtio net driver" - depends on VIRTIO + depends on VIRTIO && NETDEVICES help This is the virtual net driver for virtio. It can be used with QEMU based targets.

In order to do a DFU update over TFTP we need to have some network device available, so make this depend on NETDEVICES
Signed-off-by: Tom Rini trini@konsulko.com --- drivers/dfu/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig index 4e80e85d10d7..8771678ca5a0 100644 --- a/drivers/dfu/Kconfig +++ b/drivers/dfu/Kconfig @@ -19,6 +19,7 @@ config DFU_WRITE_ALT
config DFU_TFTP bool "DFU via TFTP" + depends on NETDEVICES select UPDATE_COMMON select DFU_OVER_TFTP help

In order to be able to disable all commands we need to construct our version string in a common file, and have the version command reference that string, like the other users of it do. Create common/version.c with just the strings.
Signed-off-by: Tom Rini trini@konsulko.com --- cmd/version.c | 9 --------- common/Makefile | 1 + common/version.c | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 common/version.c
diff --git a/cmd/version.c b/cmd/version.c index 87e1fa4159c1..d99a44f19fb3 100644 --- a/cmd/version.c +++ b/cmd/version.c @@ -7,21 +7,12 @@ #include <common.h> #include <command.h> #include <display_options.h> -#include <timestamp.h> -#include <version.h> #include <version_string.h> #include <linux/compiler.h> #ifdef CONFIG_SYS_COREBOOT #include <asm/cb_sysinfo.h> #endif
-#define U_BOOT_VERSION_STRING U_BOOT_VERSION " (" U_BOOT_DATE " - " \ - 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/common/Makefile b/common/Makefile index cdeadf72026c..b711dc29b65e 100644 --- a/common/Makefile +++ b/common/Makefile @@ -10,6 +10,7 @@ obj-y += main.o obj-y += exports.o obj-$(CONFIG_HUSH_PARSER) += cli_hush.o obj-$(CONFIG_AUTOBOOT) += autoboot.o +obj-y += version.o
# # boards obj-y += board_f.o diff --git a/common/version.c b/common/version.c new file mode 100644 index 000000000000..6e27bb80e398 --- /dev/null +++ b/common/version.c @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2000-2009 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#include <timestamp.h> +#include <version.h> +#include <version_string.h> + +#define U_BOOT_VERSION_STRING U_BOOT_VERSION " (" U_BOOT_DATE " - " \ + 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;

Rather than selecting CMD_QFW, we should make the option itself by enabled by default on these platforms. Then in the board-specific Kconfig we should select the appropriate back-end as needed if the command is enabled.
Signed-off-by: Tom Rini trini@konsulko.com --- Cc: Tuomas Tynkkynen tuomas.tynkkynen@iki.fi Cc: Bin Meng bmeng.cn@gmail.com --- board/emulation/qemu-arm/Kconfig | 3 +-- board/emulation/qemu-x86/Kconfig | 2 +- cmd/Kconfig | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/board/emulation/qemu-arm/Kconfig b/board/emulation/qemu-arm/Kconfig index 09c95413a541..ac2d078f42a1 100644 --- a/board/emulation/qemu-arm/Kconfig +++ b/board/emulation/qemu-arm/Kconfig @@ -5,8 +5,7 @@ config TEXT_BASE
config BOARD_SPECIFIC_OPTIONS # dummy def_bool y - select CMD_QFW - select QFW_MMIO + select QFW_MMIO if CMD_QFW imply VIRTIO_MMIO imply VIRTIO_PCI imply VIRTIO_NET diff --git a/board/emulation/qemu-x86/Kconfig b/board/emulation/qemu-x86/Kconfig index 787751abba4f..01dc1d497aec 100644 --- a/board/emulation/qemu-x86/Kconfig +++ b/board/emulation/qemu-x86/Kconfig @@ -20,7 +20,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy def_bool y select X86_RESET_VECTOR select QEMU - select QFW_PIO + select QFW_PIO if CMD_QFW select BOARD_ROMSIZE_KB_1024 imply VIRTIO_PCI imply VIRTIO_NET diff --git a/cmd/Kconfig b/cmd/Kconfig index 205df2f1fb65..cd2793b6876b 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2247,6 +2247,8 @@ config CMD_SYSBOOT config CMD_QFW bool "qfw" select QFW + default y if TARGET_QEMU_ARM_32BIT || TARGET_QEMU_ARM_64BIT || \ + TARGET_QEMU_X86 || TARGET_QEMU_X86_64 help This provides access to the QEMU firmware interface. The main feature is to allow easy loading of files passed to qemu-system

Move CONFIG_SYS_CBSIZE (console buffer size) and CONFIG_SYS_PBSIZE (console print buffer size) out of cmd/Kconfig and in to common/Kconfig. Create help entries for both which explain their usage and why they are both not entirely command centric.
Signed-off-by: Tom Rini trini@konsulko.com --- cmd/Kconfig | 14 -------------- common/Kconfig | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/cmd/Kconfig b/cmd/Kconfig index cd2793b6876b..cbba39099659 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -75,20 +75,6 @@ config SYS_MAXARGS int "Maximum number arguments accepted by commands" default 16
-config SYS_CBSIZE - int "Console input buffer size" - default 2048 if ARCH_TEGRA || ARCH_VERSAL || ARCH_ZYNQ || ARCH_ZYNQMP || \ - RCAR_GEN3 || TARGET_SOCFPGA_SOC64 - default 512 if ARCH_MX5 || ARCH_MX6 || ARCH_MX7 || FSL_LSCH2 || \ - FSL_LSCH3 || X86 - default 256 if M68K || PPC - default 1024 - -config SYS_PBSIZE - int "Buffer size for console output" - default 1024 if ARCH_SUNXI - default 1044 - config SYS_XTRACE bool "Command execution tracer" depends on CMDLINE diff --git a/common/Kconfig b/common/Kconfig index 43701fe9e897..4f7292f155db 100644 --- a/common/Kconfig +++ b/common/Kconfig @@ -52,6 +52,29 @@ config CONSOLE_RECORD_IN_SIZE The buffer is allocated immediately after the malloc() region is ready.
+config SYS_CBSIZE + int "Console input buffer size" + default 2048 if ARCH_TEGRA || ARCH_VERSAL || ARCH_ZYNQ || ARCH_ZYNQMP || \ + RCAR_GEN3 || TARGET_SOCFPGA_SOC64 + default 512 if ARCH_MX5 || ARCH_MX6 || ARCH_MX7 || FSL_LSCH2 || \ + FSL_LSCH3 || X86 + default 256 if M68K || PPC + default 1024 + help + Set the size of the console input buffer. This is used both in the + case of reading input literally from the user in some manner as well + as when we need to construct or modify that type of input, for + example when constructing "bootargs" for the OS. + +config SYS_PBSIZE + int "Console output buffer size" + default 1024 if ARCH_SUNXI + default 1044 + help + Set the size of the console output buffer. This is used when we need + to work with some form of a buffer while providing output in some + form to the user. + config DISABLE_CONSOLE bool "Add functionality to disable console completely" help

Inside of env/common.c we already have our helper env_set_xxx functions, and even have a comment that explains why env_set() itself wasn't moved. We now handle that move. This requires that we rename the previous _do_env_set() to env_do_env_set() and note it as an internal env function. Add comments about this function to explain why we do this when we add the prototype. Add a new function, env_inc_id() to allow for the counter to be updated by both commands and callers, and document this as well by the prototype.
Signed-off-by: Tom Rini trini@konsulko.com --- cmd/Makefile | 4 +- cmd/nvedit.c | 122 ++--------------------------------------- env/common.c | 113 ++++++++++++++++++++++++++++++++++++-- include/env.h | 8 +++ include/env_internal.h | 12 ++++ 5 files changed, 135 insertions(+), 124 deletions(-)
diff --git a/cmd/Makefile b/cmd/Makefile index 9a6790cc1708..dbeeebe2c4b1 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -128,6 +128,7 @@ endif obj-$(CONFIG_CMD_MUX) += mux.o obj-$(CONFIG_CMD_NAND) += nand.o obj-$(CONFIG_CMD_NET) += net.o +obj-$(CONFIG_ENV_SUPPORT) += nvedit.o obj-$(CONFIG_CMD_NVEDIT_EFI) += nvedit_efi.o obj-$(CONFIG_CMD_ONENAND) += onenand.o obj-$(CONFIG_CMD_OSD) += osd.o @@ -245,9 +246,6 @@ endif # !CONFIG_SPL_BUILD
obj-$(CONFIG_$(SPL_)CMD_TLV_EEPROM) += tlv_eeprom.o
-# core command -obj-y += nvedit.o - obj-$(CONFIG_CMD_BCM_EXT_UTILS) += broadcom/
filechk_data_gz = (echo "static const char data_gz[] ="; cat $< | scripts/bin2c; echo ";") diff --git a/cmd/nvedit.c b/cmd/nvedit.c index daf1ad37f9be..e77338f81394 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -49,20 +49,6 @@ DECLARE_GLOBAL_DATA_PTR; */ #define MAX_ENV_SIZE (1 << 20) /* 1 MiB */
-/* - * This variable is incremented on each do_env_set(), so it can - * be used via env_get_id() as an indication, if the environment - * has changed or not. So it is possible to reread an environment - * variable only if the environment was changed ... done so for - * example in NetInitLoop() - */ -static int env_id = 1; - -int env_get_id(void) -{ - return env_id; -} - #ifndef CONFIG_SPL_BUILD /* * Command interface: print one or all environment variables @@ -198,104 +184,6 @@ DONE: #endif #endif /* CONFIG_SPL_BUILD */
-/* - * Set a new environment variable, - * or replace or delete an existing one. - */ -static int _do_env_set(int flag, int argc, char *const argv[], int env_flag) -{ - int i, len; - char *name, *value, *s; - struct env_entry e, *ep; - - debug("Initial value for argc=%d\n", argc); - -#if !IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_CMD_NVEDIT_EFI) - if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'e') - return do_env_set_efi(NULL, flag, --argc, ++argv); -#endif - - while (argc > 1 && **(argv + 1) == '-') { - char *arg = *++argv; - - --argc; - while (*++arg) { - switch (*arg) { - case 'f': /* force */ - env_flag |= H_FORCE; - break; - default: - return CMD_RET_USAGE; - } - } - } - debug("Final value for argc=%d\n", argc); - name = argv[1]; - - if (strchr(name, '=')) { - printf("## Error: illegal character '='" - "in variable name "%s"\n", name); - return 1; - } - - env_id++; - - /* Delete only ? */ - if (argc < 3 || argv[2] == NULL) { - int rc = hdelete_r(name, &env_htab, env_flag); - - /* If the variable didn't exist, don't report an error */ - return rc && rc != -ENOENT ? 1 : 0; - } - - /* - * Insert / replace new value - */ - for (i = 2, len = 0; i < argc; ++i) - len += strlen(argv[i]) + 1; - - value = malloc(len); - if (value == NULL) { - printf("## Can't malloc %d bytes\n", len); - return 1; - } - for (i = 2, s = value; i < argc; ++i) { - char *v = argv[i]; - - while ((*s++ = *v++) != '\0') - ; - *(s - 1) = ' '; - } - if (s != value) - *--s = '\0'; - - e.key = name; - e.data = value; - hsearch_r(e, ENV_ENTER, &ep, &env_htab, env_flag); - free(value); - if (!ep) { - printf("## Error inserting "%s" variable, errno=%d\n", - name, errno); - return 1; - } - - return 0; -} - -int env_set(const char *varname, const char *varvalue) -{ - const char * const argv[4] = { "setenv", varname, varvalue, NULL }; - - /* before import into hashtable */ - if (!(gd->flags & GD_FLG_ENV_READY)) - return 1; - - if (varvalue == NULL || varvalue[0] == '\0') - return _do_env_set(0, 2, (char * const *)argv, H_PROGRAMMATIC); - else - return _do_env_set(0, 3, (char * const *)argv, H_PROGRAMMATIC); -} - #ifndef CONFIG_SPL_BUILD static int do_env_set(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) @@ -303,7 +191,7 @@ static int do_env_set(struct cmd_tbl *cmdtp, int flag, int argc, if (argc < 2) return CMD_RET_USAGE;
- return _do_env_set(flag, argc, argv, H_INTERACTIVE); + return env_do_env_set(flag, argc, argv, H_INTERACTIVE); }
/* @@ -381,7 +269,7 @@ int do_env_ask(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) }
/* Continue calling setenv code */ - return _do_env_set(flag, len, local_args, H_INTERACTIVE); + return env_do_env_set(flag, len, local_args, H_INTERACTIVE); } #endif
@@ -561,12 +449,12 @@ static int do_env_edit(struct cmd_tbl *cmdtp, int flag, int argc, if (buffer[0] == '\0') { const char * const _argv[3] = { "setenv", argv[1], NULL };
- return _do_env_set(0, 2, (char * const *)_argv, H_INTERACTIVE); + return env_do_env_set(0, 2, (char * const *)_argv, H_INTERACTIVE); } else { const char * const _argv[4] = { "setenv", argv[1], buffer, NULL };
- return _do_env_set(0, 3, (char * const *)_argv, H_INTERACTIVE); + return env_do_env_set(0, 3, (char * const *)_argv, H_INTERACTIVE); } } #endif /* CONFIG_CMD_EDITENV */ @@ -679,7 +567,7 @@ static int do_env_delete(struct cmd_tbl *cmdtp, int flag, } debug("Final value for argc=%d\n", argc);
- env_id++; + env_inc_id();
while (--argc > 0) { char *name = *++argv; diff --git a/env/common.c b/env/common.c index eb1a91379539..656748c1f5b7 100644 --- a/env/common.c +++ b/env/common.c @@ -37,11 +37,116 @@ struct hsearch_data env_htab = { };
/* - * This env_set() function is defined in cmd/nvedit.c, since it calls - * _do_env_set(), whis is a static function in that file. - * - * int env_set(const char *varname, const char *varvalue); + * This variable is incremented each time we set an environment variable so we + * can be check via env_get_id() to see if the environment has changed or not. + * This makes it possible to reread an environment variable only if the + * environment was changed, typically used by networking code. */ +static int env_id = 1; + +int env_get_id(void) +{ + return env_id; +} + +void env_inc_id(void) +{ + env_id++; +} + +int env_do_env_set(int flag, int argc, char *const argv[], int env_flag) +{ + int i, len; + char *name, *value, *s; + struct env_entry e, *ep; + + debug("Initial value for argc=%d\n", argc); + +#if !IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_CMD_NVEDIT_EFI) + if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'e') + return do_env_set_efi(NULL, flag, --argc, ++argv); +#endif + + while (argc > 1 && **(argv + 1) == '-') { + char *arg = *++argv; + + --argc; + while (*++arg) { + switch (*arg) { + case 'f': /* force */ + env_flag |= H_FORCE; + break; + default: + return CMD_RET_USAGE; + } + } + } + debug("Final value for argc=%d\n", argc); + name = argv[1]; + + if (strchr(name, '=')) { + printf("## Error: illegal character '='" + "in variable name "%s"\n", name); + return 1; + } + + env_inc_id(); + + /* Delete only ? */ + if (argc < 3 || argv[2] == NULL) { + int rc = hdelete_r(name, &env_htab, env_flag); + + /* If the variable didn't exist, don't report an error */ + return rc && rc != -ENOENT ? 1 : 0; + } + + /* + * Insert / replace new value + */ + for (i = 2, len = 0; i < argc; ++i) + len += strlen(argv[i]) + 1; + + value = malloc(len); + if (value == NULL) { + printf("## Can't malloc %d bytes\n", len); + return 1; + } + for (i = 2, s = value; i < argc; ++i) { + char *v = argv[i]; + + while ((*s++ = *v++) != '\0') + ; + *(s - 1) = ' '; + } + if (s != value) + *--s = '\0'; + + e.key = name; + e.data = value; + hsearch_r(e, ENV_ENTER, &ep, &env_htab, env_flag); + free(value); + if (!ep) { + printf("## Error inserting "%s" variable, errno=%d\n", + name, errno); + return 1; + } + + return 0; +} + +int env_set(const char *varname, const char *varvalue) +{ + const char * const argv[4] = { "setenv", varname, varvalue, NULL }; + + /* before import into hashtable */ + if (!(gd->flags & GD_FLG_ENV_READY)) + return 1; + + if (varvalue == NULL || varvalue[0] == '\0') + return env_do_env_set(0, 2, (char * const *)argv, H_PROGRAMMATIC); + else + return env_do_env_set(0, 3, (char * const *)argv, H_PROGRAMMATIC); +}
/** * Set an environment variable to an integer value diff --git a/include/env.h b/include/env.h index 430c4fa94a42..9778e3e4f2ce 100644 --- a/include/env.h +++ b/include/env.h @@ -72,6 +72,14 @@ enum env_redund_flags { */ int env_get_id(void);
+/** + * env_inc_id() - Increase the sequence number for the environment + * + * Increment the value that is used by env_get_id() to inform callers + * if the environment has changed since they last checked. + */ +void env_inc_id(void); + /** * env_init() - Set up the pre-relocation environment * diff --git a/include/env_internal.h b/include/env_internal.h index 6a6949464689..ae7816d38e58 100644 --- a/include/env_internal.h +++ b/include/env_internal.h @@ -193,6 +193,18 @@ struct env_driver {
extern struct hsearch_data env_htab;
+/** + * env_do_env_set() - Perform the actual setting of an environment variable + * + * Due to the number of places we may need to set an environmental variable + * from we have an exposed internal function that performs the real work and + * then call this from both the command line function as well as other + * locations. + * + * Return: 0 on success or 1 on failure + */ +int env_do_env_set(int flag, int argc, char *const argv[], int env_flag); + /** * env_ext4_get_intf() - Provide the interface for env in EXT4 *

From: Simon Glass sjg@chromium.org
Many tests make some use of the command line, so require it for all test code.
This could be teased apart, perhaps with a test flag indicating that it uses the command line. Leave that for later.
Signed-off-by: Simon Glass sjg@chromium.org Reviewed-by: Tom Rini trini@konsulko.com --- test/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/test/Kconfig b/test/Kconfig index ca648d23376f..c3db727c58e3 100644 --- a/test/Kconfig +++ b/test/Kconfig @@ -2,6 +2,7 @@ menu "Testing"
config UNIT_TEST bool "Unit tests" + depends on CMDLINE help Select this to compile in unit tests for various parts of U-Boot. Test suites will be subcommands of the "ut" command.

From: Simon Glass sjg@chromium.org
While it is nice to have the font command, using 'select' makes it impossible to build the console code without it. Stop using 'select' and make it default if CONSOLE_TRUETYPE is enabled when asking the command.
Signed-off-by: Simon Glass sjg@chromium.org Signed-off-by: Tom Rini trini@konsulko.com --- Changes in v4: - Rework to have the command itself be default y if CONSOLE_TRUETYPE instead of selecting it. (Tom) --- cmd/Kconfig | 2 +- drivers/video/Kconfig | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/cmd/Kconfig b/cmd/Kconfig index cbba39099659..f8b34ca504b2 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -2348,7 +2348,7 @@ config CMD_VIDCONSOLE config CMD_SELECT_FONT bool "select font size" depends on VIDEO - default n + default y if CONSOLE_TRUETYPE help Enabling this will provide 'font' command. Allows font selection at runtime. diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index ab927641bb7a..6f319ba0d544 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -180,7 +180,6 @@ config CONSOLE_ROTATION
config CONSOLE_TRUETYPE bool "Support a console that uses TrueType fonts" - select CMD_SELECT_FONT help TrueTrype fonts can provide outline-drawing capability rather than needing to provide a bitmap for each font and size that is needed.

The interactive portion of our non-HUSH 'simple' parser is guarded by CONFIG_CMDLINE already. Much of the code behind this simple parser is also used as "input" parser, such as from menu interfaces and so forth and not strictly command line input. To support this, always build the assorted cli object files, but guard the interactive portions of cli_simple.c with a CMDLINE check.
Signed-off-by: Tom Rini trini@konsulko.com --- common/Makefile | 2 +- common/cli_simple.c | 77 +++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 39 deletions(-)
diff --git a/common/Makefile b/common/Makefile index b711dc29b65e..1495436d5d45 100644 --- a/common/Makefile +++ b/common/Makefile @@ -8,6 +8,7 @@ ifndef CONFIG_SPL_BUILD obj-y += init/ obj-y += main.o obj-y += exports.o +obj-y += cli_getch.o cli_simple.o cli_readline.o obj-$(CONFIG_HUSH_PARSER) += cli_hush.o obj-$(CONFIG_AUTOBOOT) += autoboot.o obj-y += version.o @@ -38,7 +39,6 @@ obj-$(CONFIG_SPLASH_SOURCE) += splash_source.o obj-$(CONFIG_MENU) += menu.o obj-$(CONFIG_UPDATE_COMMON) += update.o obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o -obj-$(CONFIG_CMDLINE) += cli_getch.o cli_readline.o cli_simple.o
endif # !CONFIG_SPL_BUILD
diff --git a/common/cli_simple.c b/common/cli_simple.c index e80ba488a5eb..f89ba92d1b05 100644 --- a/common/cli_simple.c +++ b/common/cli_simple.c @@ -22,44 +22,6 @@ #define debug_parser(fmt, args...) \ debug_cond(DEBUG_PARSER, fmt, ##args)
- -int cli_simple_parse_line(char *line, char *argv[]) -{ - int nargs = 0; - - debug_parser("%s: "%s"\n", __func__, line); - while (nargs < CONFIG_SYS_MAXARGS) { - /* skip any white space */ - while (isblank(*line)) - ++line; - - if (*line == '\0') { /* end of line, no more args */ - argv[nargs] = NULL; - debug_parser("%s: nargs=%d\n", __func__, nargs); - return nargs; - } - - argv[nargs++] = line; /* begin of argument string */ - - /* find end of string */ - while (*line && !isblank(*line)) - ++line; - - if (*line == '\0') { /* end of line, no more args */ - argv[nargs] = NULL; - debug_parser("parse_line: nargs=%d\n", nargs); - return nargs; - } - - *line++ = '\0'; /* terminate current arg */ - } - - printf("** Too many args (max. %d) **\n", CONFIG_SYS_MAXARGS); - - debug_parser("%s: nargs=%d\n", __func__, nargs); - return nargs; -} - int cli_simple_process_macros(const char *input, char *output, int max_size) { char c, prev; @@ -172,6 +134,44 @@ int cli_simple_process_macros(const char *input, char *output, int max_size) return ret; }
+#ifdef CONFIG_CMDLINE +int cli_simple_parse_line(char *line, char *argv[]) +{ + int nargs = 0; + + debug_parser("%s: "%s"\n", __func__, line); + while (nargs < CONFIG_SYS_MAXARGS) { + /* skip any white space */ + while (isblank(*line)) + ++line; + + if (*line == '\0') { /* end of line, no more args */ + argv[nargs] = NULL; + debug_parser("%s: nargs=%d\n", __func__, nargs); + return nargs; + } + + argv[nargs++] = line; /* begin of argument string */ + + /* find end of string */ + while (*line && !isblank(*line)) + ++line; + + if (*line == '\0') { /* end of line, no more args */ + argv[nargs] = NULL; + debug_parser("parse_line: nargs=%d\n", nargs); + return nargs; + } + + *line++ = '\0'; /* terminate current arg */ + } + + printf("** Too many args (max. %d) **\n", CONFIG_SYS_MAXARGS); + + debug_parser("%s: nargs=%d\n", __func__, nargs); + return nargs; +} + /* * WARNING: * @@ -346,3 +346,4 @@ int cli_simple_run_command_list(char *cmd, int flag)
return rcode; } +#endif

From: Simon Glass sjg@chromium.org
The command should not be used to enable library functionality. Add a new BOOTEFI_BOOTMGR Kconfig for that. Adjust the conditions so that the same code is built.
Signed-off-by: Simon Glass sjg@chromium.org Suggested-by: AKASHI Takahiro takahiro.akashi@linaro.org --- Cc: Heinrich Schuchardt heinrich.schuchardt@canonical.com Cc: Ilias Apalodimas ilias.apalodimas@linaro.org Cc: AKASHI Takahiro takahiro.akashi@linaro.org
Changes in v5: None, because AKASHI Takahiro has taken up the work of a further refactor. In response to v4 Heinrich wanted to just use BOOTEFI_BOOTMGR and drop the CMD portion entirely. While I understand conceptually the request, it would then make this code very different from all other subcommands, even when they depend on CONFIG symbols for additional functionality. If there's a strong objection to taking this patch, and then further reworking things with AKASHI Takahiro's series being on top of this series, an alternative would be moving the final portion where CMDLINE=n is allowed and tested out of this series and in to a further series that depends on both. They would all be applied in short order.
Changes in v4: - Integrate AKASHI Takahiro's feedback from v3 - Reword the help text on CMD_BOOTEFI_BOOTMGR slightly --- cmd/Kconfig | 11 ++++++++++- lib/efi_loader/Kconfig | 6 +++--- lib/efi_loader/Makefile | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/cmd/Kconfig b/cmd/Kconfig index f8b34ca504b2..bfe363710c79 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -379,6 +379,15 @@ config CMD_BOOTEFI help Boot an EFI image from memory.
+config CMD_BOOTEFI_BOOTMGR + bool "UEFI Boot Manager command" + depends on BOOTEFI_BOOTMGR && CMD_BOOTEFI + default y + help + Select this option to enable the 'bootmgr' subcommand of 'bootefi'. + This subcommand will allow you to select the UEFI binary to be booted + via UEFI variables Boot####, BootOrder, and BootNext. + config CMD_BOOTEFI_HELLO_COMPILE bool "Compile a standard EFI hello world binary for testing" depends on CMD_BOOTEFI && !CPU_V7M @@ -2118,7 +2127,7 @@ config CMD_EFIDEBUG config CMD_EFICONFIG bool "eficonfig - provide menu-driven uefi variables maintenance interface" default y if !HAS_BOARD_SIZE_LIMIT - depends on CMD_BOOTEFI_BOOTMGR + depends on BOOTEFI_BOOTMGR select MENU help Enable the 'eficonfig' command which provides the menu-driven UEFI diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index d20aaab6dba4..13cad6342c36 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -32,14 +32,14 @@ config EFI_LOADER
if EFI_LOADER
-config CMD_BOOTEFI_BOOTMGR +config BOOTEFI_BOOTMGR bool "UEFI Boot Manager" default y select BOOTMETH_GLOBAL if BOOTSTD help Select this option if you want to select the UEFI binary to be booted - via UEFI variables Boot####, BootOrder, and BootNext. This enables the - 'bootefi bootmgr' command. + via UEFI variables Boot####, BootOrder, and BootNext. You should also + normally enable CMD_BOOTEFI_BOOTMGR so that the command is available.
choice prompt "Store for non-volatile UEFI variables" diff --git a/lib/efi_loader/Makefile b/lib/efi_loader/Makefile index 8d31fc61c601..0a2cb6e3c476 100644 --- a/lib/efi_loader/Makefile +++ b/lib/efi_loader/Makefile @@ -42,7 +42,7 @@ targets += initrddump.o endif
obj-$(CONFIG_CMD_BOOTEFI_HELLO) += helloworld_efi.o -obj-$(CONFIG_CMD_BOOTEFI_BOOTMGR) += efi_bootmgr.o +obj-$(CONFIG_BOOTEFI_BOOTMGR) += efi_bootmgr.o obj-y += efi_boottime.o obj-y += efi_helper.o obj-$(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) += efi_capsule.o

Today, the bootmeth for using the EFI loader via bootefi depends on calling the bootefi command directly, so make this in turn depend on CMD_BOOTEFI.
Signed-off-by: Tom Rini trini@konsulko.com --- boot/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/boot/Kconfig b/boot/Kconfig index a01e6cb8aafe..e0ded3249343 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -504,7 +504,7 @@ config BOOTMETH_EXTLINUX_PXE
config BOOTMETH_EFILOADER bool "Bootdev support for EFI boot" - depends on EFI_LOADER + depends on CMD_BOOTEFI default y help Enables support for EFI boot using bootdevs. This makes the @@ -539,7 +539,7 @@ config BOOTMETH_DISTRO select BOOTMETH_SCRIPT # E.g. Armbian uses scripts select BOOTMETH_EXTLINUX # E.g. Debian uses these select BOOTMETH_EXTLINUX_PXE if CMD_PXE && CMD_NET && DM_ETH - select BOOTMETH_EFILOADER if EFI_LOADER # E.g. Ubuntu uses this + select BOOTMETH_EFILOADER if CMD_BOOTEFI # E.g. Ubuntu uses this
config SPL_BOOTMETH_VBE bool "Bootdev support for Verified Boot for Embedded (SPL)"

From: Simon Glass sjg@chromium.org
Make AUTOBOOT depend on CMDLINE since it is mostly meaningless without it.
Signed-off-by: Simon Glass sjg@chromium.org Reviewed-by: Tom Rini trini@konsulko.com --- boot/Kconfig | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/boot/Kconfig b/boot/Kconfig index e0ded3249343..0dbd10a93469 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -1162,14 +1162,16 @@ menu "Autoboot options"
config AUTOBOOT bool "Autoboot" + depends on CMDLINE default y help This enables the autoboot. See doc/README.autoboot for detail.
+if AUTOBOOT + config BOOTDELAY int "delay in seconds before automatically booting" default 2 - depends on AUTOBOOT help Delay before automatically running bootcmd; set to 0 to autoboot with no delay, but you can stop it by key input. @@ -1191,9 +1193,11 @@ config AUTOBOOT_KEYED U-Boot automatic booting process and bring the device to the U-Boot prompt for user input.
+if AUTOBOOT_KEYED + config AUTOBOOT_FLUSH_STDIN bool "Enable flushing stdin before starting to read the password" - depends on AUTOBOOT_KEYED && !SANDBOX + depends on !SANDBOX help When this option is enabled stdin buffer will be flushed before starting to read the password. @@ -1202,7 +1206,6 @@ config AUTOBOOT_FLUSH_STDIN
config AUTOBOOT_PROMPT string "Autoboot stop prompt" - depends on AUTOBOOT_KEYED default "Autoboot in %d seconds\n" help This string is displayed before the boot delay selected by @@ -1218,7 +1221,6 @@ config AUTOBOOT_PROMPT
config AUTOBOOT_ENCRYPTION bool "Enable encryption in autoboot stopping" - depends on AUTOBOOT_KEYED help This option allows a string to be entered into U-Boot to stop the autoboot. @@ -1245,7 +1247,7 @@ config AUTOBOOT_SHA256_FALLBACK
config AUTOBOOT_DELAY_STR string "Delay autobooting via specific input key / string" - depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION + depends on !AUTOBOOT_ENCRYPTION help This option delays the automatic boot feature by issuing a specific input key or string. If CONFIG_AUTOBOOT_DELAY_STR @@ -1257,7 +1259,7 @@ config AUTOBOOT_DELAY_STR
config AUTOBOOT_STOP_STR string "Stop autobooting via specific input key / string" - depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION + depends on !AUTOBOOT_ENCRYPTION help This option enables stopping (aborting) of the automatic boot feature only by issuing a specific input key or @@ -1269,7 +1271,7 @@ config AUTOBOOT_STOP_STR
config AUTOBOOT_KEYED_CTRLC bool "Enable Ctrl-C autoboot interruption" - depends on AUTOBOOT_KEYED && !AUTOBOOT_ENCRYPTION + depends on !AUTOBOOT_ENCRYPTION help This option allows for the boot sequence to be interrupted by ctrl-c, in addition to the "bootdelaykey" and "bootstopkey". @@ -1278,7 +1280,7 @@ config AUTOBOOT_KEYED_CTRLC
config AUTOBOOT_NEVER_TIMEOUT bool "Make the password entry never time-out" - depends on AUTOBOOT_KEYED && AUTOBOOT_ENCRYPTION && CRYPT_PW + depends on AUTOBOOT_ENCRYPTION && CRYPT_PW help This option removes the timeout from the password entry when the user first presses the <Enter> key before entering @@ -1286,7 +1288,7 @@ config AUTOBOOT_NEVER_TIMEOUT
config AUTOBOOT_STOP_STR_ENABLE bool "Enable fixed string to stop autobooting" - depends on AUTOBOOT_KEYED && AUTOBOOT_ENCRYPTION + depends on AUTOBOOT_ENCRYPTION help This option enables the feature to add a fixed stop string that is defined at compile time. @@ -1317,9 +1319,12 @@ config AUTOBOOT_STOP_STR_SHA256 includes a ":", the portion prior to the ":" will be treated as a salt value.
+endif # AUTOBOOT_KEYED + +if !AUTOBOOT_KEYED + config AUTOBOOT_USE_MENUKEY bool "Allow a specify key to run a menu from the environment" - depends on !AUTOBOOT_KEYED help If a specific key is pressed to stop autoboot, then the commands in the environment variable 'menucmd' are executed before boot starts. @@ -1334,6 +1339,10 @@ config AUTOBOOT_MENUKEY For example, 33 means "!" in ASCII, so pressing ! at boot would take this action.
+endif + +endif # AUTOBOOT + config AUTOBOOT_MENU_SHOW bool "Show a menu on boot" depends on CMD_BOOTMENU

The implementation of DISTRO_DEFAULTS is done in environment scripts and requires the command line in order to work. Because of this, select CMDLINE here.
Signed-off-by: Tom Rini trini@konsulko.com --- boot/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/boot/Kconfig b/boot/Kconfig index 0dbd10a93469..2075ecd34b1f 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -777,6 +777,7 @@ endmenu # Boot images
config DISTRO_DEFAULTS bool "(deprecated) Script-based booting of Linux distributions" + select CMDLINE select BOOT_DEFAULTS select AUTO_COMPLETE select CMDLINE_EDITING

We split BOOT_DEFAULTS to have BOOT_DEFAULTS_FEATURES and BOOT_DEFAULTS_CMDS that in turn list general features or commands that we want enabled when BOOT_DEFAULTS is selected. We only select BOOT_DEFAULTS_CMDS if CMDLINE is set.
Signed-off-by: Tom Rini trini@konsulko.com --- boot/Kconfig | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/boot/Kconfig b/boot/Kconfig index 2075ecd34b1f..88b9296ee1bf 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -346,8 +346,16 @@ config PXE_UTILS help Utilities for parsing PXE file formats.
-config BOOT_DEFAULTS - bool # Common defaults for standard boot and distroboot +config BOOT_DEFAULTS_FEATURES + bool + select SUPPORT_RAW_INITRD + select ENV_VARS_UBOOT_CONFIG + imply USB_STORAGE + imply EFI_PARTITION + imply ISO_PARTITION + +config BOOT_DEFAULTS_CMDS + bool imply USE_BOOTCOMMAND select CMD_ENV_EXISTS select CMD_EXT2 @@ -358,14 +366,14 @@ config BOOT_DEFAULTS select CMD_DHCP if CMD_NET select CMD_PING if CMD_NET select CMD_PXE if CMD_NET - select SUPPORT_RAW_INITRD - select ENV_VARS_UBOOT_CONFIG select CMD_BOOTI if ARM64 select CMD_BOOTZ if ARM && !ARM64 imply CMD_MII if NET - imply USB_STORAGE - imply EFI_PARTITION - imply ISO_PARTITION + +config BOOT_DEFAULTS + bool # Common defaults for standard boot and distroboot + select BOOT_DEFAULTS_FEATURES + select BOOT_DEFAULTS_CMDS if CMDLINE help These are not required but are commonly needed to support a good selection of booting methods. Enable this to improve the capability @@ -431,7 +439,6 @@ config BOOTSTD_FULL config BOOTSTD_DEFAULTS bool "Select some common defaults for standard boot" depends on BOOTSTD - imply USE_BOOTCOMMAND select BOOT_DEFAULTS select BOOTMETH_DISTRO help

This particular option is required for booting all image types, regardless of if we are starting an OS via command line or something else. Move the question for SYS_BOOTM_LEN to be by the question for LEGACY_IMAGE_FORMAT, as that's where our generic OS questions start.
Signed-off-by: Tom Rini trini@konsulko.com --- boot/Kconfig | 11 +++++++++++ cmd/Kconfig | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/boot/Kconfig b/boot/Kconfig index 88b9296ee1bf..7c92e0974c5f 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -692,6 +692,17 @@ config LEGACY_IMAGE_FORMAT loaded. If a board needs the legacy image format support in this case, enable it here.
+config SYS_BOOTM_LEN + hex "Maximum size of a decompresed OS image" + depends on CMD_BOOTM || CMD_BOOTI || CMD_BOOTZ || \ + LEGACY_IMAGE_FORMAT || SPL_LEGACY_IMAGE_FORMAT + default 0x4000000 if PPC || ARM64 + default 0x1000000 if X86 || ARCH_MX6 || ARCH_MX7 + default 0x800000 + help + This is the maximum size of the buffer that is used to decompress the OS + image in to if attempting to boot a compressed image. + config SUPPORT_RAW_INITRD bool "Enable raw initrd images" help diff --git a/cmd/Kconfig b/cmd/Kconfig index bfe363710c79..febfa2cdaa5f 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -361,17 +361,6 @@ config BOOTM_VXWORKS help Support booting VxWorks images via the bootm command.
-config SYS_BOOTM_LEN - hex "Maximum size of a decompresed OS image" - depends on CMD_BOOTM || CMD_BOOTI || CMD_BOOTZ || \ - LEGACY_IMAGE_FORMAT || SPL_LEGACY_IMAGE_FORMAT - default 0x4000000 if PPC || ARM64 - default 0x1000000 if X86 || ARCH_MX6 || ARCH_MX7 - default 0x800000 - help - This is the maximum size of the buffer that is used to decompress the OS - image in to, if passing a compressed image to bootm/booti/bootz. - config CMD_BOOTEFI bool "bootefi" depends on EFI_LOADER

In order to use bootmeth_cros, at least on non-X86, we need to be able to start any type of kernel that the "bootm" code paths can handle. Add these objects to the required list for this option.
Signed-off-by: Tom Rini trini@konsulko.com --- Cc: Simon Glass sjg@chromium.org --- boot/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/boot/Makefile b/boot/Makefile index ad608598d298..3fd048bb41ab 100644 --- a/boot/Makefile +++ b/boot/Makefile @@ -28,7 +28,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX) += bootmeth_extlinux.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EXTLINUX_PXE) += bootmeth_pxe.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o -obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_CROS) += bootmeth_cros.o +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_CROS) += bootm.o bootm_os.o bootmeth_cros.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL

As this particular bootmeth requires the command line and assorted commands to function, make sure we have CMDLINE enabled.
Signed-off-by: Tom Rini trini@konsulko.com --- boot/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/boot/Kconfig b/boot/Kconfig index 7c92e0974c5f..40a04f43ee3d 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -543,7 +543,7 @@ config BOOTMETH_VBE
config BOOTMETH_DISTRO bool # Options needed to boot any distro - select BOOTMETH_SCRIPT # E.g. Armbian uses scripts + select BOOTMETH_SCRIPT if CMDLINE # E.g. Armbian uses scripts select BOOTMETH_EXTLINUX # E.g. Debian uses these select BOOTMETH_EXTLINUX_PXE if CMD_PXE && CMD_NET && DM_ETH select BOOTMETH_EFILOADER if CMD_BOOTEFI # E.g. Ubuntu uses this @@ -671,6 +671,7 @@ config BOOTMETH_SANDBOX config BOOTMETH_SCRIPT bool "Bootdev support for U-Boot scripts" default y if BOOTSTD_FULL + depends on CMDLINE select HUSH_PARSER help Enables support for booting a distro via a U-Boot script. This makes

In order for a predefined "preboot" or "bootcmd" to be executed by the running system we must have a command line. Add CMDLINE as a dependency.
Signed-off-by: Tom Rini trini@konsulko.com --- boot/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/boot/Kconfig b/boot/Kconfig index 40a04f43ee3d..fabf6fec2195 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -1558,6 +1558,7 @@ config BOOTARGS_SUBST
config USE_BOOTCOMMAND bool "Enable a default value for bootcmd" + depends on CMDLINE help Provide a default value for the bootcmd entry in the environment. If autoboot is enabled this is what will be run automatically. Enable @@ -1577,6 +1578,7 @@ config BOOTCOMMAND
config USE_PREBOOT bool "Enable preboot" + depends on CMDLINE help When this option is enabled, the existence of the environment variable "preboot" will be checked immediately before starting the

From: Simon Glass sjg@chromium.org
If we disable CMDLINE then we should not ask about enabling the hush parser nor any of the commands that would be run on the command line as it is no longer available. Convert the CMDLINE option into a menuconfig and make every command referenced under cmd/Kconfig depend on it.
This leaves as future work moving the commands that are not under the cmd/ hierarchy as future work.
Signed-off-by: Simon Glass sjg@chromium.org Signed-off-by: Tom Rini trini@konsulko.com --- Changes in v4: - Reword the commit message slightly. - Make this not depend on other patches --- Makefile | 2 +- cmd/Kconfig | 20 ++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/Makefile b/Makefile index 8a04dfcf3638..737dcde0b50b 100644 --- a/Makefile +++ b/Makefile @@ -851,7 +851,7 @@ HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makef libs-$(CONFIG_API) += api/ libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ libs-y += boot/ -libs-y += cmd/ +libs-$(CONFIG_CMDLINE) += cmd/ libs-y += common/ libs-$(CONFIG_OF_EMBED) += dts/ libs-y += env/ diff --git a/cmd/Kconfig b/cmd/Kconfig index febfa2cdaa5f..0eb739203ade 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1,7 +1,5 @@ -menu "Command line interface" - -config CMDLINE - bool "Support U-Boot commands" +menuconfig CMDLINE + bool "Command line interface" default y help Enable U-Boot's command-line functions. This provides a means @@ -11,9 +9,10 @@ config CMDLINE Depending on the number of commands enabled, this can add substantially to the size of U-Boot.
+if CMDLINE + config HUSH_PARSER bool "Use hush shell" - depends on CMDLINE help This option enables the "hush" shell (from Busybox) as command line interpreter, thus enabling powerful command line syntax like @@ -25,7 +24,6 @@ config HUSH_PARSER
config CMDLINE_EDITING bool "Enable command line editing" - depends on CMDLINE default y help Enable editing and History functions for interactive command line @@ -40,15 +38,13 @@ config CMDLINE_PS_SUPPORT
config AUTO_COMPLETE bool "Enable auto complete using TAB" - depends on CMDLINE default y help Enable auto completion of commands using TAB.
config SYS_LONGHELP bool "Enable long help messages" - depends on CMDLINE - default y if CMDLINE + default y help Defined when you want long help messages included Do not set this option when short of memory. @@ -77,8 +73,7 @@ config SYS_MAXARGS
config SYS_XTRACE bool "Command execution tracer" - depends on CMDLINE - default y if CMDLINE + default y help This option enables the possiblity to print all commands before executing them and after all variables are evaluated (similar @@ -2880,4 +2875,5 @@ config CMD_MESON default y help Enable useful commands for the Meson Soc family developed by Amlogic Inc. -endmenu + +endif

Much of the functionality of fastboot relies on being able to run commands as defined in the environment. This means it does depend on CMDLINE being enabled.
Signed-off-by: Tom Rini trini@konsulko.com --- Changes in v5: - New patch --- drivers/fastboot/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig index 837c6f1180da..11fc0fe1c800 100644 --- a/drivers/fastboot/Kconfig +++ b/drivers/fastboot/Kconfig @@ -1,4 +1,5 @@ menu "Fastboot support" + depends on CMDLINE
config FASTBOOT bool

From: AKASHI Takahiro takahiro.akashi@linaro.org
This option is independent from any commands and should be managed under lib. For instance, drivers/block/rkmtd.c is a user.
It would be better to remove this configuration.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org Reviewed-by: Tom Rini trini@konsulko.com --- Changes in v5: - Take AKASHI Takahiro's RFC and add my RB tag --- cmd/Kconfig | 7 ------- lib/Kconfig | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/cmd/Kconfig b/cmd/Kconfig index 0eb739203ade..dcf1e54c5ddc 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -1132,13 +1132,6 @@ config CMD_GPT Enable the 'gpt' command to ready and write GPT style partition tables.
-config RANDOM_UUID - bool "GPT Random UUID generation" - select LIB_UUID - help - Enable the generation of partitions with random UUIDs if none - are provided. - config CMD_GPT_RENAME bool "GPT partition renaming commands" depends on CMD_GPT diff --git a/lib/Kconfig b/lib/Kconfig index f6ca559897e7..b6d580c30615 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -74,6 +74,13 @@ config HAVE_PRIVATE_LIBGCC config LIB_UUID bool
+config RANDOM_UUID + bool "GPT Random UUID generation" + select LIB_UUID + help + Enable the generation of partitions with random UUIDs if none + are provided. + config SPL_LIB_UUID depends on SPL bool

From: AKASHI Takahiro takahiro.akashi@linaro.org
This option is necessary to compile any way.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org --- Changes in v5: - Take AKASHI Takahiro's RFC and switch to select per my feedback on the ML --- drivers/block/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 048a6caef00f..b897cf1a3d1b 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -265,6 +265,7 @@ config SYS_64BIT_LBA
config RKMTD bool "Rockchip rkmtd virtual block device" + select RANDOM_UUID help Enable "rkmtd" class and driver to create a virtual block device to transfer Rockchip boot block data to and from NAND with block

From: Simon Glass sjg@chromium.org
This is not used for sandbox, so drop it. Enable the things that it controls to avoid dstrastic changes in the config settings for sandbox builds.
The end result is that these are enabled:
BOOTMETH_DISTRO BOOTSTD_DEFAULTS
and these are disabled:
USE_BOOTCOMMAND BOOTCOMMAND (was "run distro_bootcmd") DISTRO_DEFAULTS
Note that the tools-only build has already disabled DISTRO_DEFAULTS and BOOTSTD_FULL
Signed-off-by: Simon Glass sjg@chromium.org Signed-off-by: Tom Rini trini@konsulko.com --- Changes in v4: - Only modify sandbox and restrict the changes to only DISTRO_DEFAULTS --- arch/Kconfig | 3 +++ configs/sandbox64_defconfig | 1 - configs/sandbox_defconfig | 1 - configs/sandbox_flattree_defconfig | 1 - configs/sandbox_noinst_defconfig | 1 - configs/sandbox_spl_defconfig | 1 - configs/sandbox_vpl_defconfig | 1 - 7 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig index 4f5b75129f34..6fa17b21b8fa 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -210,6 +210,9 @@ config SANDBOX imply BINMAN imply CMD_MBR imply CMD_MMC + imply BOOTSTD_DEFAULTS if BOOTSTD_FULL && CMDLINE + imply BOOTMETH_DISTRO if BOOTSTD_FULL && CMDLINE + imply CMD_SYSBOOT if BOOTSTD_FULL
config SH bool "SuperH architecture" diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig index 1a01f51a0b75..301758a2891b 100644 --- a/configs/sandbox64_defconfig +++ b/configs/sandbox64_defconfig @@ -14,7 +14,6 @@ CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_FIT_VERBOSE=y CONFIG_LEGACY_IMAGE_FORMAT=y -CONFIG_DISTRO_DEFAULTS=y CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index e3a2f9eb1708..ff3f63b5b3dc 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -14,7 +14,6 @@ CONFIG_FIT_RSASSA_PSS=y CONFIG_FIT_CIPHER=y CONFIG_FIT_VERBOSE=y CONFIG_LEGACY_IMAGE_FORMAT=y -CONFIG_DISTRO_DEFAULTS=y CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig index 44ab80725fc7..282b8ff31a4a 100644 --- a/configs/sandbox_flattree_defconfig +++ b/configs/sandbox_flattree_defconfig @@ -12,7 +12,6 @@ CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_FIT_VERBOSE=y CONFIG_LEGACY_IMAGE_FORMAT=y -CONFIG_DISTRO_DEFAULTS=y CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y diff --git a/configs/sandbox_noinst_defconfig b/configs/sandbox_noinst_defconfig index db05e6308329..44e55f4452f3 100644 --- a/configs/sandbox_noinst_defconfig +++ b/configs/sandbox_noinst_defconfig @@ -25,7 +25,6 @@ CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_LOAD_FIT=y -CONFIG_DISTRO_DEFAULTS=y CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig index 56072b15ad2d..015e0a59d085 100644 --- a/configs/sandbox_spl_defconfig +++ b/configs/sandbox_spl_defconfig @@ -20,7 +20,6 @@ CONFIG_FIT=y CONFIG_FIT_SIGNATURE=y CONFIG_FIT_VERBOSE=y CONFIG_SPL_LOAD_FIT=y -CONFIG_DISTRO_DEFAULTS=y CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y diff --git a/configs/sandbox_vpl_defconfig b/configs/sandbox_vpl_defconfig index 5bd0281796d4..9935575352b2 100644 --- a/configs/sandbox_vpl_defconfig +++ b/configs/sandbox_vpl_defconfig @@ -27,7 +27,6 @@ CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_FIT_BEST_MATCH=y CONFIG_SPL_LOAD_FIT=y -CONFIG_DISTRO_DEFAULTS=y CONFIG_BOOTSTAGE=y CONFIG_BOOTSTAGE_REPORT=y CONFIG_BOOTSTAGE_FDT=y

From: Simon Glass sjg@chromium.org
Add some dependencies on features that we had been selecting so that we can still disable CMDLINE.
Signed-off-by: Simon Glass sjg@chromium.org Signed-off-by: Tom Rini trini@konsulko.com --- Changes in v4: - Reword the commit slightly (Tom) - Rework overall to select if CMDLINE
Changes in v3: - Reorder the Kconfig options a little --- arch/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig index 6fa17b21b8fa..1cdcd1fdb8b0 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -134,7 +134,7 @@ config SANDBOX select ARCH_SUPPORTS_LTO select BOARD_LATE_INIT select BZIP2 - select CMD_POWEROFF + select CMD_POWEROFF if CMDLINE select DM select DM_EVENT select DM_FUZZING_ENGINE @@ -152,10 +152,10 @@ config SANDBOX select PCI_ENDPOINT select SPI select SUPPORT_OF_CONTROL - select SYSRESET_CMD_POWEROFF + select SYSRESET_CMD_POWEROFF if CMD_POWEROFF select SYS_CACHE_SHIFT_4 select IRQ - select SUPPORT_EXTENSION_SCAN + select SUPPORT_EXTENSION_SCAN if CMDLINE select SUPPORT_ACPI imply BITREVERSE select BLOBLIST

Add a mostly empty asm/barrier.h file for sandbox where we define nop() to be an empty function.
Signed-off-by: Tom Rini trini@konsulko.com Reviewed-by: Sean Anderson seanga2@gmail.com --- arch/sandbox/include/asm/barrier.h | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 arch/sandbox/include/asm/barrier.h
diff --git a/arch/sandbox/include/asm/barrier.h b/arch/sandbox/include/asm/barrier.h new file mode 100644 index 000000000000..0928a78cbf8b --- /dev/null +++ b/arch/sandbox/include/asm/barrier.h @@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#define nop()

Now that sandbox has <asm/barrier.h> and defines nop() there we should include that in our driver for clarity and then remove our local nop() from <k210/pll.h>.
Signed-off-by: Tom Rini trini@konsulko.com Reviewed-by: Sean Anderson seanga2@gmail.com --- Changes in v5: - Add Sean's RB, drop explanation portion --- drivers/clk/clk_k210.c | 1 + include/k210/pll.h | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/clk/clk_k210.c b/drivers/clk/clk_k210.c index c534cc07e092..b9469b93853b 100644 --- a/drivers/clk/clk_k210.c +++ b/drivers/clk/clk_k210.c @@ -16,6 +16,7 @@ #include <dt-bindings/mfd/k210-sysctl.h> #include <k210/pll.h> #include <linux/bitfield.h> +#include <asm/barrier.h>
DECLARE_GLOBAL_DATA_PTR;
diff --git a/include/k210/pll.h b/include/k210/pll.h index fd16a89cb203..175c47f6f233 100644 --- a/include/k210/pll.h +++ b/include/k210/pll.h @@ -16,9 +16,6 @@ struct k210_pll_config { #ifdef CONFIG_UNIT_TEST TEST_STATIC int k210_pll_calc_config(u32 rate, u32 rate_in, struct k210_pll_config *best); -#ifndef nop -#define nop() -#endif
#endif #endif /* K210_PLL_H */

From: Simon Glass sjg@chromium.org
Now that everything is working, add a test to make sure that this builds correctly.
Signed-off-by: Simon Glass sjg@chromium.org Reviewed-by: Tom Rini trini@konsulko.com --- test/py/tests/test_sandbox_opts.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/py/tests/test_sandbox_opts.py
diff --git a/test/py/tests/test_sandbox_opts.py b/test/py/tests/test_sandbox_opts.py new file mode 100644 index 000000000000..91790b3374b4 --- /dev/null +++ b/test/py/tests/test_sandbox_opts.py @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright 2022 Google LLC +# Written by Simon Glass sjg@chromium.org + +import pytest + +import u_boot_utils as util + +# This is needed for Azure, since the default '..' directory is not writeable +TMPDIR = '/tmp/test_cmdline' + +@pytest.mark.slow +@pytest.mark.boardspec('sandbox') +def test_sandbox_cmdline(u_boot_console): + """Test building sandbox without CONFIG_CMDLINE""" + cons = u_boot_console + + out = util.run_and_log( + cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', + '-a', '~CMDLINE', '-o', TMPDIR])

The primary motivation for having a sandbox without LTO build in CI is to ensure that we don't have that option break. We now have the ability to run tests of specific options being enabled/disabled, so drop the parts of CI that build and test that configuration specifically and add a build test instead. We still test that "NO_LTO=1" rather than editing the config file works via the ftrace tests.
Signed-off-by: Tom Rini trini@konsulko.com Reviewed-by: Simon Glass sjg@chromium.org --- Changes in v5: - Drop now incorrect worry about bisectability --- .azure-pipelines.yml | 3 --- .gitlab-ci.yml | 12 ------------ test/py/tests/test_sandbox_opts.py | 10 ++++++++++ 3 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index eb9353fc3dcf..ec498a832d73 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -287,9 +287,6 @@ stages: sandbox64_clang: TEST_PY_BD: "sandbox64" OVERRIDE: "-O clang-16" - sandbox_nolto: - TEST_PY_BD: "sandbox" - BUILD_ENV: "NO_LTO=1" sandbox_spl: TEST_PY_BD: "sandbox_spl" TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl" diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1e11b5a6fea8..f328f3331f6d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -258,12 +258,6 @@ sandbox with clang test.py: OVERRIDE: "-O clang-16" <<: *buildman_and_testpy_dfn
-sandbox without LTO test.py: - variables: - TEST_PY_BD: "sandbox" - BUILD_ENV: "NO_LTO=1" - <<: *buildman_and_testpy_dfn - sandbox64 test.py: variables: TEST_PY_BD: "sandbox64" @@ -275,12 +269,6 @@ sandbox64 with clang test.py: OVERRIDE: "-O clang-16" <<: *buildman_and_testpy_dfn
-sandbox64 without LTO test.py: - variables: - TEST_PY_BD: "sandbox64" - BUILD_ENV: "NO_LTO=1" - <<: *buildman_and_testpy_dfn - sandbox_spl test.py: variables: TEST_PY_BD: "sandbox_spl" diff --git a/test/py/tests/test_sandbox_opts.py b/test/py/tests/test_sandbox_opts.py index 91790b3374b4..422b43cb3bc1 100644 --- a/test/py/tests/test_sandbox_opts.py +++ b/test/py/tests/test_sandbox_opts.py @@ -18,3 +18,13 @@ def test_sandbox_cmdline(u_boot_console): out = util.run_and_log( cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', '-a', '~CMDLINE', '-o', TMPDIR]) + +@pytest.mark.slow +@pytest.mark.boardspec('sandbox') +def test_sandbox_lto(u_boot_console): + """Test building sandbox without CONFIG_LTO""" + cons = u_boot_console + + out = util.run_and_log( + cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', + '-a', '~LTO', '-o', TMPDIR])
participants (1)
-
Tom Rini