[PATCH v3 08/16] fastboot: Remove dependencies on CMDLINE
Simon Glass
sjg at chromium.org
Sat Dec 16 14:16:38 CET 2023
It is possible to boot a kernel without CMDLINE being enabled. Update
the implementation to handle this, and drop the condition from the
FASTBOOT config.
Reviewed-by: Mattijs Korpershoek <mkorpershoek at baylibre.com>
Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v3:
- Expand the fastboot help
Changes in v2:
- Avoid changing the logic when a command is not set
drivers/fastboot/Kconfig | 5 ++++-
drivers/fastboot/fb_common.c | 30 ++++++++++++++----------------
2 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index 11fc0fe1c800..449244ab6a8e 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -1,5 +1,4 @@
menu "Fastboot support"
- depends on CMDLINE
config FASTBOOT
bool
@@ -13,6 +12,10 @@ config FASTBOOT
More information about the protocol and usecases:
https://android.googlesource.com/platform/system/core/+/refs/heads/master/fastboot/
+ Note that enabling CMDLINE is recommended since fastboot allows U-Boot
+ commands to be executed on request. The CMDLINE option is required
+ for anything other than simply booting the OS.
+
config USB_FUNCTION_FASTBOOT
bool "Enable USB fastboot gadget"
depends on USB_GADGET
diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
index 07f5946d9ed1..595954542a6e 100644
--- a/drivers/fastboot/fb_common.c
+++ b/drivers/fastboot/fb_common.c
@@ -11,6 +11,7 @@
*/
#include <bcb.h>
+#include <bootm.h>
#include <common.h>
#include <command.h>
#include <env.h>
@@ -142,22 +143,19 @@ void (*fastboot_get_progress_callback(void))(const char *)
*/
void fastboot_boot(void)
{
- char *s;
-
- s = env_get("fastboot_bootcmd");
- if (s) {
- run_command(s, CMD_FLAG_ENV);
- } else if (IS_ENABLED(CONFIG_CMD_BOOTM)) {
- static char boot_addr_start[20];
- static char *const bootm_args[] = {
- "bootm", boot_addr_start, NULL
- };
-
- snprintf(boot_addr_start, sizeof(boot_addr_start) - 1,
- "%lx", fastboot_buf_addr);
- printf("Booting kernel at %s...\n\n\n", boot_addr_start);
-
- do_bootm(NULL, 0, 2, bootm_args);
+ char *s = NULL;
+
+ if (IS_ENABLED(CONFIG_CMDLINE)) {
+ s = env_get("fastboot_bootcmd");
+ if (s)
+ run_command(s, CMD_FLAG_ENV);
+ }
+
+ if (!s && IS_ENABLED(CONFIG_BOOTM)) {
+ int ret;
+
+ printf("Booting kernel at %lx...\n\n\n", fastboot_buf_addr);
+ ret = bootm_boot_start(fastboot_buf_addr, NULL);
/*
* This only happens if image is somehow faulty so we start
--
2.43.0.472.g3155946c3a-goog
More information about the U-Boot
mailing list