Skip to contentSkip to conversation

sandbox: eliminate unused functions from binaries

PATCH In review Tom Rini 1 participant 31 messages Oct 26, 2023 – Nov 7, 2023

Subsystems (6)
lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH v5 1/30 sandbox: eliminate unused functions from binaries

From: Heinrich Schuchardt <[email protected]>

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.

---
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(-)
arch/sandbox/config.mk +2 -2
index 2d184c5f652a..1d50991f8d24 100644
@@ -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,%) \
arch/sandbox/cpu/u-boot.lds +1 -1
index ba8dee50c7bd..52f13af3742f 100644
@@ -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)
 	}
 
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v5 2/30 buildman: Use oldconfig when adjusting the config

From: Simon Glass <[email protected]>

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.

---
 tools/buildman/builder.py       | 2 +-
 tools/buildman/builderthread.py | 6 ++++++
 tools/buildman/func_test.py     | 4 +++-
 3 files changed, 10 insertions(+), 2 deletions(-)
tools/buildman/builder.py +1 -1
index 5305477c5be6..782e59dd5cca 100644
@@ -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()
tools/buildman/builderthread.py +6 -0
index 6a61f64da1d4..a8599c0bb2a8 100644
@@ -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:
tools/buildman/func_test.py +3 -1
index 55dd494fe8ee..6b88ed815d65 100644
@@ -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
Signature · 1 line
2.34.1
author
#2 lore raw

Re: [v5 02/30] buildman: Use oldconfig when adjusting the config

Quoted 7 lines · Tom Rini

From: Simon Glass <[email protected]>

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.

For this and the rest of this series (patch 1 is already applied), applied to u-boot/next, thanks!

Signature · 1 line
Tom
author
#3 lore raw

PATCH v5 3/30 virtio: Make VIRTIO_NET depend on NETDEVICES

In reply to Tom Rini

As VIRTIO_NET is the symbol for enabling network devices, make this depend on NETDEVICES

---
Cc: Bin Meng <[email protected]>

---
 drivers/virtio/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/virtio/Kconfig +1 -1
index 852f6735b602..1de68867d52e 100644
@@ -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.
Signature · 1 line
2.34.1
author
#4 lore raw

PATCH v5 4/30 dfu: Make DFU_TFTP depend on NETDEVICES

In reply to Tom Rini

In order to do a DFU update over TFTP we need to have some network device available, so make this depend on NETDEVICES

---
 drivers/dfu/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/dfu/Kconfig +1 -0
index 4e80e85d10d7..8771678ca5a0 100644
@@ -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
Signature · 1 line
2.34.1
author
#5 lore raw

PATCH v5 5/30 version: Separate our version string from the version command

In reply to Tom Rini

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.

---
 cmd/version.c    |  9 ---------
 common/Makefile  |  1 +
 common/version.c | 16 ++++++++++++++++
 3 files changed, 17 insertions(+), 9 deletions(-)
 create mode 100644 common/version.c
cmd/version.c +0 -9
index 87e1fa4159c1..d99a44f19fb3 100644
@@ -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[])
 {
common/Makefile +1 -0
index cdeadf72026c..b711dc29b65e 100644
@@ -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
common/version.c new file +16 -0
new file mode 100644
index 000000000000..6e27bb80e398
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, [email protected].
+ */
+
+#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;
Signature · 1 line
2.34.1
author
#6 lore raw

PATCH v5 6/30 qemu: Correct CMD_QFW dependencies in Kconfig

In reply to Tom Rini

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.

---
Cc: Tuomas Tynkkynen <[email protected]>
Cc: Bin Meng <[email protected]>

---
 board/emulation/qemu-arm/Kconfig | 3 +--
 board/emulation/qemu-x86/Kconfig | 2 +-
 cmd/Kconfig                      | 2 ++
 3 files changed, 4 insertions(+), 3 deletions(-)
board/emulation/qemu-arm/Kconfig +1 -2
index 09c95413a541..ac2d078f42a1 100644
@@ -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
board/emulation/qemu-x86/Kconfig +1 -1
index 787751abba4f..01dc1d497aec 100644
@@ -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
cmd/Kconfig +2 -0
index 205df2f1fb65..cd2793b6876b 100644
@@ -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
Signature · 1 line
2.34.1
author
#7 lore raw

PATCH v5 7/30 Kconfig: Move CONFIG_SYS_[CP]BSIZE to common/Kconfig

In reply to Tom Rini

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.

---
 cmd/Kconfig    | 14 --------------
 common/Kconfig | 23 +++++++++++++++++++++++
 2 files changed, 23 insertions(+), 14 deletions(-)
cmd/Kconfig +0 -14
index cd2793b6876b..cbba39099659 100644
@@ -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
common/Kconfig +23 -0
index 43701fe9e897..4f7292f155db 100644
@@ -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
Signature · 1 line
2.34.1
author
#8 lore raw

PATCH v5 8/30 env: Move env_set() out of cmd/nvedit.c and in to env/common.c

In reply to Tom Rini

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.

---
 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(-)
cmd/Makefile +1 -3
index 9a6790cc1708..dbeeebe2c4b1 100644
@@ -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 ";")
cmd/nvedit.c +5 -117

162 lines not on this page · raw message

env/common.c +109 -4

120 lines not on this page · raw message

include/env.h +8 -0
index 430c4fa94a42..9778e3e4f2ce 100644
@@ -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
  *
include/env_internal.h +12 -0
index 6a6949464689..ae7816d38e58 100644
@@ -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
  *
Signature · 1 line
2.34.1
author
#9 lore raw

PATCH v5 9/30 test: Make UNIT_TEST depend on CMDLINE

In reply to Tom Rini

From: Simon Glass <[email protected]>

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.

---
 test/Kconfig | 1 +
 1 file changed, 1 insertion(+)
test/Kconfig +1 -0
index ca648d23376f..c3db727c58e3 100644
@@ -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.
Signature · 1 line
2.34.1
author
#10 lore raw

PATCH v5 10/30 video: Don't require the font command

In reply to Tom Rini

From: Simon Glass <[email protected]>

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.

---
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(-)
cmd/Kconfig +1 -1
index cbba39099659..f8b34ca504b2 100644
@@ -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.
drivers/video/Kconfig +0 -1
index ab927641bb7a..6f319ba0d544 100644
@@ -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.
Signature · 1 line
2.34.1
author
#11 lore raw

PATCH v5 11/30 cli_simple: Rework this support slightly

In reply to Tom Rini

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.

---
 common/Makefile     |  2 +-
 common/cli_simple.c | 77 +++++++++++++++++++++++----------------------
 2 files changed, 40 insertions(+), 39 deletions(-)
common/Makefile +1 -1
index b711dc29b65e..1495436d5d45 100644
@@ -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
 
common/cli_simple.c +39 -38

92 lines not on this page · raw message

Signature · 1 line
2.34.1
author
#12 lore raw

PATCH v5 12/30 efi: Rearrange the Kconfig for CMD_BOOTEFI_BOOTMGR

In reply to Tom Rini

From: Simon Glass <[email protected]>

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.

---
Cc: Heinrich Schuchardt <[email protected]>
Cc: Ilias Apalodimas <[email protected]>
Cc: AKASHI Takahiro <[email protected]>

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(-)
cmd/Kconfig +10 -1
index f8b34ca504b2..bfe363710c79 100644
@@ -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
lib/efi_loader/Kconfig +3 -3
index d20aaab6dba4..13cad6342c36 100644
@@ -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"
lib/efi_loader/Makefile +1 -1
index 8d31fc61c601..0a2cb6e3c476 100644
@@ -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
Signature · 1 line
2.34.1
author
#13 lore raw

PATCH v5 13/30 bootmeth: Make BOOTMETH_EFILOADER depend on CMD_BOOTEFI

In reply to Tom Rini

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.

---
 boot/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
boot/Kconfig +2 -2
index a01e6cb8aafe..e0ded3249343 100644
@@ -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)"
Signature · 1 line
2.34.1
author
#14 lore raw

PATCH v5 14/30 autoboot: Correct dependencies on CMDLINE

In reply to Tom Rini

From: Simon Glass <[email protected]>

Make AUTOBOOT depend on CMDLINE since it is mostly meaningless without it.

---
 boot/Kconfig | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)
boot/Kconfig +19 -10
index e0ded3249343..0dbd10a93469 100644
@@ -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
Signature · 1 line
2.34.1
author
#15 lore raw

PATCH v5 15/30 boot: Make DISTRO_DEFAULTS select CMDLINE

In reply to Tom Rini

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.

---
 boot/Kconfig | 1 +
 1 file changed, 1 insertion(+)
boot/Kconfig +1 -0
index 0dbd10a93469..2075ecd34b1f 100644
@@ -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
Signature · 1 line
2.34.1
author
#16 lore raw

PATCH v5 16/30 boot: Rework BOOT_DEFAULTS to allow for CMDLINE to be disabled

In reply to Tom Rini

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.

---
 boot/Kconfig | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
boot/Kconfig +15 -8
index 2075ecd34b1f..88b9296ee1bf 100644
@@ -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
Signature · 1 line
2.34.1
author
#17 lore raw

PATCH v5 17/30 boot: Move SYS_BOOTM_LEN to be by LEGACY_IMAGE_FORMAT

In reply to Tom Rini

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.

---
 boot/Kconfig | 11 +++++++++++
 cmd/Kconfig  | 11 -----------
 2 files changed, 11 insertions(+), 11 deletions(-)
boot/Kconfig +11 -0
index 88b9296ee1bf..7c92e0974c5f 100644
@@ -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
cmd/Kconfig +0 -11
index bfe363710c79..febfa2cdaa5f 100644
@@ -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
Signature · 1 line
2.34.1
author
#18 lore raw

PATCH v5 18/30 bootmeth_cros: Require bootm.o and bootm_os.o

In reply to Tom Rini

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.

---
Cc: Simon Glass <[email protected]>

---
 boot/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
boot/Makefile +1 -1
index ad608598d298..3fd048bb41ab 100644
@@ -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
Signature · 1 line
2.34.1
author
#19 lore raw

PATCH v5 19/30 bootmeth_script: Depend on CMDLINE

In reply to Tom Rini

As this particular bootmeth requires the command line and assorted commands to function, make sure we have CMDLINE enabled.

---
 boot/Kconfig | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
boot/Kconfig +2 -1
index 7c92e0974c5f..40a04f43ee3d 100644
@@ -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
Signature · 1 line
2.34.1
author
#20 lore raw

PATCH v5 20/30 boot: Make preboot and bootcmd require CMDLINE

In reply to Tom Rini

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.

---
 boot/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
boot/Kconfig +2 -0
index 40a04f43ee3d..fabf6fec2195 100644
@@ -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
Signature · 1 line
2.34.1
author
#21 lore raw

PATCH v5 21/30 cmd: Make most commands depend on CMDLINE

In reply to Tom Rini

From: Simon Glass <[email protected]>

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.

---
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(-)
Makefile +1 -1
index 8a04dfcf3638..737dcde0b50b 100644
@@ -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/
cmd/Kconfig +8 -12
index febfa2cdaa5f..0eb739203ade 100644
@@ -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
Signature · 1 line
2.34.1
author
#22 lore raw

PATCH v5 22/30 fastboot: Depend on CMDLINE

In reply to Tom Rini

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.

---
Changes in v5:
- New patch

---
 drivers/fastboot/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/fastboot/Kconfig +1 -0
index 837c6f1180da..11fc0fe1c800 100644
@@ -1,4 +1,5 @@
 menu "Fastboot support"
+	depends on CMDLINE
 
 config FASTBOOT
 	bool
Signature · 1 line
2.34.1
author
#23 lore raw

PATCH v5 23/30 lib: uuid: move CONFIG_RANDOM_UUID

In reply to Tom Rini

From: AKASHI Takahiro <[email protected]>

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.

---
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(-)
cmd/Kconfig +0 -7
index 0eb739203ade..dcf1e54c5ddc 100644
@@ -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
lib/Kconfig +7 -0
index f6ca559897e7..b6d580c30615 100644
@@ -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
Signature · 1 line
2.34.1
author
#24 lore raw

PATCH v5 24/30 block: rkmtd: select CONFIG_RANDOM_UUID explicitly

In reply to Tom Rini

From: AKASHI Takahiro <[email protected]>

This option is necessary to compile any way.

---
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(+)
drivers/block/Kconfig +1 -0
index 048a6caef00f..b897cf1a3d1b 100644
@@ -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
Signature · 1 line
2.34.1
author
#25 lore raw

PATCH v5 25/30 sandbox: Disable CONFIG_DISTRO_DEFAULTS

In reply to Tom Rini

From: Simon Glass <[email protected]>

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

---
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(-)
arch/Kconfig +3 -0
index 4f5b75129f34..6fa17b21b8fa 100644
@@ -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"
configs/sandbox64_defconfig +0 -1
index 1a01f51a0b75..301758a2891b 100644
@@ -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
configs/sandbox_defconfig +0 -1
index e3a2f9eb1708..ff3f63b5b3dc 100644
@@ -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
configs/sandbox_flattree_defconfig +0 -1
index 44ab80725fc7..282b8ff31a4a 100644
@@ -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
configs/sandbox_noinst_defconfig +0 -1
index db05e6308329..44e55f4452f3 100644
@@ -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
configs/sandbox_spl_defconfig +0 -1
index 56072b15ad2d..015e0a59d085 100644
@@ -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
configs/sandbox_vpl_defconfig +0 -1
index 5bd0281796d4..9935575352b2 100644
@@ -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
Signature · 1 line
2.34.1
author
#26 lore raw

PATCH v5 26/30 sandbox: Avoid requiring CMDLINE

In reply to Tom Rini

From: Simon Glass <[email protected]>

Add some dependencies on features that we had been selecting so that we can still disable CMDLINE.

---
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(-)
arch/Kconfig +3 -3
index 6fa17b21b8fa..1cdcd1fdb8b0 100644
@@ -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
Signature · 1 line
2.34.1
author
#27 lore raw

PATCH v5 27/30 sandbox: Add <asm/barrier.h>

In reply to Tom Rini

Add a mostly empty asm/barrier.h file for sandbox where we define nop() to be an empty function.

---
 arch/sandbox/include/asm/barrier.h | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 arch/sandbox/include/asm/barrier.h
arch/sandbox/include/asm/barrier.h new file +3 -0
new file mode 100644
index 000000000000..0928a78cbf8b
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#define nop()
Signature · 1 line
2.34.1
author
#28 lore raw

PATCH v5 28/30 clk_k210.c: Clean up how we handle nop

In reply to Tom Rini

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>.

---
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(-)
drivers/clk/clk_k210.c +1 -0
index c534cc07e092..b9469b93853b 100644
@@ -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;
 
include/k210/pll.h +0 -3
index fd16a89cb203..175c47f6f233 100644
@@ -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 */
Signature · 1 line
2.34.1
author
#29 lore raw

PATCH v5 29/30 sandbox: Add a test for disabling CONFIG_CMDLINE

In reply to Tom Rini

From: Simon Glass <[email protected]>

Now that everything is working, add a test to make sure that this builds correctly.

---
 test/py/tests/test_sandbox_opts.py | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 test/py/tests/test_sandbox_opts.py
test/py/tests/test_sandbox_opts.py new file +20 -0
new file mode 100644
index 000000000000..91790b3374b4
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright 2022 Google LLC
+# Written by Simon Glass <[email protected]>
+
+import pytest
+
+import u_boot_utils as util
+
+# This is needed for Azure, since the default '..' directory is not writeable
+TMPDIR = '/tmp/test_cmdline'
+
[email protected]
[email protected]('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])
Signature · 1 line
2.34.1
author
#30 lore raw

PATCH v5 30/30 CI, pytest: Add a test for sandbox without LTO

In reply to Tom Rini

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.

---
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(-)
.azure-pipelines.yml +0 -3
index eb9353fc3dcf..ec498a832d73 100644
@@ -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"
.gitlab-ci.yml +0 -12
index 1e11b5a6fea8..f328f3331f6d 100644
@@ -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"
test/py/tests/test_sandbox_opts.py +10 -0
index 91790b3374b4..422b43cb3bc1 100644
@@ -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])
+
[email protected]
[email protected]('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])
Signature · 1 line
2.34.1