From: Mehmet Fide <[email protected]>
do_bootd() runs the "bootcmd" environment variable through run_command()
and does nothing else. It uses no bootm functionality, and neither does
the "bootd" recursion guard in cmd_process(). doc/usage/cmd/bootd.rst
documents it that way, with an example that sets bootcmd to
"echo Hello World".
Commit 1fd04cf46baf ("cmd: Correct dependencies for CMD_BOOTD") made
CMD_BOOTD depend on CMD_BOOTM because the build fails otherwise:
common/command.c is compiled unconditionally and references do_bootd(),
whose definition sits in cmd/bootm.c, which is only compiled when
CMD_BOOTM=y. The dependency therefore describes where the code lives
rather than what it needs, and the boards that disable CMD_BOOTM
(colibri_vf, iot_devkit, mx6memcal and r8a78000_ironhide_cm33) cannot
offer "boot" or "bootd" at all, although the implementation would work
there.
Move do_bootd() and its two command registrations into cmd/bootd.c,
compiled from CMD_BOOTD, and drop the artificial dependency. To leave
every board in tree unchanged, CMD_BOOTD now defaults to y only when
CMD_BOOTM is enabled, which is precisely the set of boards that have it
today. Boards without bootm can enable it deliberately.
Tested on sandbox: bootd, the "boot" alias, the return value taken from
a failing bootcmd and the recursion guard all behave as before. Also
tested on a Colibri VF50 (vf610) board built with CMD_BOOTM=n and
CMD_BOOTD=y, a combination that could not be selected before: "boot" and
"bootd" run bootcmd and bring up the OS, and a bootcmd of "false"
returns 1. A colibri_vf_defconfig build with CMD_BOOTD left off is byte
identical to the previous one apart from the version string; enabling
CMD_BOOTD costs 272 bytes.
Signed-off-by: Mehmet Fide <[email protected]>
Reviewed-by: Tom Rini <[email protected]>
---
cmd/Kconfig | 3 +--
cmd/Makefile | 1 +
cmd/bootd.c | 30 ++++++++++++++++++++++++++++++
cmd/bootm.c | 24 ------------------------
4 files changed, 32 insertions(+), 26 deletions(-)
create mode 100644 cmd/bootd.c
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 35ce42f8397..f8eed5a5bdf 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -300,8 +300,7 @@ menu "Boot commands"
config CMD_BOOTD
bool "bootd"
- depends on CMD_BOOTM
- default y
+ default y if CMD_BOOTM
help
Run the command stored in the environment "bootcmd", i.e.
"bootd" does the same thing as "run bootcmd".
diff --git a/cmd/Makefile b/cmd/Makefile
index ce772e5555b..7c3db81e524 100644
--- a/cmd/Makefile
+++ b/cmd/Makefile
@@ -6,6 +6,7 @@
ifndef CONFIG_XPL_BUILD
# core command
obj-y += boot.o
+obj-$(CONFIG_CMD_BOOTD) += bootd.o
obj-$(CONFIG_CMD_BOOTM) += bootm.o
obj-$(CONFIG_CMD_HELP) += help.o
obj-y += panic.o
diff --git a/cmd/bootd.c b/cmd/bootd.c
new file mode 100644
index 00000000000..d39b1bfe888
--- /dev/null
+++ b/cmd/bootd.c
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2000-2009
+ * Wolfgang Denk, DENX Software Engineering, [email protected].
+ */
+
+/*
+ * bootd - boot default, i.e. run the command in the "bootcmd" environment
+ * variable
+ */
+#include <command.h>
+#include <env.h>
+
+int do_bootd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
+{
+ return run_command(env_get("bootcmd"), flag);
+}
+
+U_BOOT_CMD(
+ boot, 1, 1, do_bootd,
+ "boot default, i.e., run 'bootcmd'",
+ ""
+);
+
+/* keep old command name "bootd" for backward compatibility */
+U_BOOT_CMD(
+ bootd, 1, 1, do_bootd,
+ "boot default, i.e., run 'bootcmd'",
+ ""
+);
diff --git a/cmd/bootm.c b/cmd/bootm.c
index ca7cec91fad..07fd995ebed 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -229,30 +229,6 @@ U_BOOT_CMD(
"boot application image from memory", bootm_help_text
);
-/*******************************************************************/
-/* bootd - boot default image */
-/*******************************************************************/
-#if defined(CONFIG_CMD_BOOTD)
-int do_bootd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
-{
- return run_command(env_get("bootcmd"), flag);
-}
-
-U_BOOT_CMD(
- boot, 1, 1, do_bootd,
- "boot default, i.e., run 'bootcmd'",
- ""
-);
-
-/* keep old command name "bootd" for backward compatibility */
-U_BOOT_CMD(
- bootd, 1, 1, do_bootd,
- "boot default, i.e., run 'bootcmd'",
- ""
-);
-
-#endif
-
/*******************************************************************/
/* iminfo - print header info for a requested image */
/*******************************************************************/
--
2.54.0