[PATCH v2] fastboot: Add OEM run command
Sean Anderson
sean.anderson at seco.com
Fri Dec 2 22:03:23 CET 2022
This adds the UUU UCmd functionality as an OEM command. While the
fastboot tool allows sending arbitrary commands as long as they are
prefixed with "oem". This allows running generic U-Boot commands over
fastboot without UUU, which is especially useful when not using USB.
This is really the route we should have gone in the first place when
adding these commands.
While we're here, clean up the Kconfig a bit.
Signed-off-by: Sean Anderson <sean.anderson at seco.com>
---
Changes in v2:
- Document usage
- Keep enum in order
doc/android/fastboot.rst | 15 +++++++++++++++
drivers/fastboot/Kconfig | 10 +++++-----
drivers/fastboot/fb_command.c | 4 ++++
include/fastboot.h | 1 +
4 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/doc/android/fastboot.rst b/doc/android/fastboot.rst
index 7611f07038..7f343d5dfc 100644
--- a/doc/android/fastboot.rst
+++ b/doc/android/fastboot.rst
@@ -28,6 +28,7 @@ The following OEM commands are supported (if enabled):
- ``oem partconf`` - this executes ``mmc partconf %x <arg> 0`` to configure eMMC
with <arg> = boot_ack boot_partition
- ``oem bootbus`` - this executes ``mmc bootbus %x %s`` to configure eMMC
+- ``oem run`` - this executes an arbitrary U-Boot command
Support for both eMMC and NAND devices is included.
@@ -127,6 +128,19 @@ Boot command
When executing the fastboot ``boot`` command, if ``fastboot_bootcmd`` is set
then that will be executed in place of ``bootm <CONFIG_FASTBOOT_BUF_ADDR>``.
+Running Shell Commands
+----------------------
+
+Normally, arbitrary U-Boot command execution is not enabled. This is so
+fastboot can be used to update systems using verified boot. However, such
+functionality can be useful for production or when verified boot is not in use.
+Enable ``CONFIG_FASTBOOT_UUU_SUPPORT`` to use this functionality. This will
+enable the ``UCmd`` and ``ACmd`` commands for use with UUU [3]_. It also
+enables the ``oem run`` command, which can be used with the fastboot client.
+For example, to print "Hello world", run::
+
+ $ fastboot oem run:echo Hello world
+
Partition Names
---------------
@@ -232,3 +246,4 @@ References
.. [1] :doc:`fastboot-protocol`
.. [2] https://developer.android.com/studio/releases/platform-tools
+.. [3] https://github.com/NXPmicro/mfgtools
diff --git a/drivers/fastboot/Kconfig b/drivers/fastboot/Kconfig
index b97c67bf60..8f2d52cb8a 100644
--- a/drivers/fastboot/Kconfig
+++ b/drivers/fastboot/Kconfig
@@ -80,12 +80,12 @@ config FASTBOOT_FLASH
this to enable the "fastboot flash" command.
config FASTBOOT_UUU_SUPPORT
- bool "Enable FASTBOOT i.MX UUU special command"
+ bool "Enable running arbitrary commands from FASTBOOT"
help
- The fastboot protocol includes "UCmd" and "ACmd" command.
- Be aware that you provide full access to any U-Boot command,
- including working with memory and may open a huge backdoor,
- when enabling this option.
+ This extends the fastboot protocol with the "UCmd" and "ACmd"
+ commands, as well as the "oem run" command. These commands provide
+ full access to any U-Boot command, including working with memory.
+ This may open a huge backdoor if you are using verified boot.
choice
prompt "Flash provider for FASTBOOT"
diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index 98eccc3455..1732406c18 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
@@ -123,6 +123,10 @@ static const struct {
},
#endif
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
+ [FASTBOOT_COMMAND_OEM_RUN] = {
+ .command = "oem run",
+ .dispatch = run_ucmd,
+ },
[FASTBOOT_COMMAND_UCMD] = {
.command = "UCmd",
.dispatch = run_ucmd,
diff --git a/include/fastboot.h b/include/fastboot.h
index 57daaf1298..8b6b4b934a 100644
--- a/include/fastboot.h
+++ b/include/fastboot.h
@@ -45,6 +45,7 @@ enum {
FASTBOOT_COMMAND_OEM_BOOTBUS,
#endif
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
+ FASTBOOT_COMMAND_OEM_RUN,
FASTBOOT_COMMAND_ACMD,
FASTBOOT_COMMAND_UCMD,
#endif
--
2.35.1.1320.gc452695387.dirty
More information about the U-Boot
mailing list