]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fastboot: Add support for 'reboot fastboot' command
authorRoman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Tue, 28 Jul 2020 20:35:33 +0000 (23:35 +0300)
committerMarek Vasut <marex@denx.de>
Tue, 1 Sep 2020 12:47:43 +0000 (14:47 +0200)
Android 10 adds support for dynamic partitions and in order to support
this userspace fastboot must be used[1]. New tool fastbootd is
included into recovery.

Userspace fastboot works from recovery and is launched if:
1) - Dynamic partitioning is enabled
2) - Boot control block has 'boot-fastboot' value into command field
The bootloader is expected to load and boot into the recovery image
upon seeing boot-fastboot in the BCB command. Recovery then parses the
BCB message and switches to fastbootd mode[2].

Please note that boot script is expected to handle 'boot-fastboot'
command in BCB and load into recovery mode.

Bootloader must support 'reboot fastboot' command which should reboot
device into userspace fastboot to accomodate those changes[3].

Another command that bootloader must support[3] is 'reboot recovery'. This
command should simply reboot device into recovery mode.

[1] - https://source.android.com/devices/bootloader/fastbootd
[2] - https://source.android.com/devices/bootloader/fastbootd#unified_fastboot_and_recovery
[3] - https://source.android.com/devices/bootloader/fastbootd#modifications_to_the_bootloader

Signed-off-by: Roman Kovalivskyi <roman.kovalivskyi@globallogic.com>
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
Change-Id: I9d2bdc9a6f6f31ea98572fe155e1cc8341e9af76

drivers/fastboot/fb_command.c
drivers/usb/gadget/f_fastboot.c
include/fastboot.h
net/fastboot.c

index 8ce5d32fb2ba4e733a5e9cb8e0231dc23ac223ce..d3c578672dc6f60226255c7c040c1b9096637995 100644 (file)
@@ -37,6 +37,8 @@ static void flash(char *, char *);
 static void erase(char *, char *);
 #endif
 static void reboot_bootloader(char *, char *);
+static void reboot_fastbootd(char *, char *);
+static void reboot_recovery(char *, char *);
 #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
 static void oem_format(char *, char *);
 #endif
@@ -79,6 +81,14 @@ static const struct {
                .command = "reboot-bootloader",
                .dispatch = reboot_bootloader
        },
+       [FASTBOOT_COMMAND_REBOOT_FASTBOOTD] =  {
+               .command = "reboot-fastboot",
+               .dispatch = reboot_fastbootd
+       },
+       [FASTBOOT_COMMAND_REBOOT_RECOVERY] =  {
+               .command = "reboot-recovery",
+               .dispatch = reboot_recovery
+       },
        [FASTBOOT_COMMAND_SET_ACTIVE] =  {
                .command = "set_active",
                .dispatch = okay
@@ -313,6 +323,34 @@ static void reboot_bootloader(char *cmd_parameter, char *response)
                fastboot_okay(NULL, response);
 }
 
+/**
+ * reboot_fastbootd() - Sets reboot fastboot flag.
+ *
+ * @cmd_parameter: Pointer to command parameter
+ * @response: Pointer to fastboot response buffer
+ */
+static void reboot_fastbootd(char *cmd_parameter, char *response)
+{
+       if (fastboot_set_reboot_flag(FASTBOOT_REBOOT_REASON_FASTBOOTD))
+               fastboot_fail("Cannot set fastboot flag", response);
+       else
+               fastboot_okay(NULL, response);
+}
+
+/**
+ * reboot_recovery() - Sets reboot recovery flag.
+ *
+ * @cmd_parameter: Pointer to command parameter
+ * @response: Pointer to fastboot response buffer
+ */
+static void reboot_recovery(char *cmd_parameter, char *response)
+{
+       if (fastboot_set_reboot_flag(FASTBOOT_REBOOT_REASON_RECOVERY))
+               fastboot_fail("Cannot set recovery flag", response);
+       else
+               fastboot_okay(NULL, response);
+}
+
 #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
 /**
  * oem_format() - Execute the OEM format command
index 384c0f6f6e272870bb5923450983f7efc7ce9a16..30f7a52087fcaaead7b0932ffdf853834502a6ef 100644 (file)
@@ -455,6 +455,8 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
 
                case FASTBOOT_COMMAND_REBOOT:
                case FASTBOOT_COMMAND_REBOOT_BOOTLOADER:
+               case FASTBOOT_COMMAND_REBOOT_FASTBOOTD:
+               case FASTBOOT_COMMAND_REBOOT_RECOVERY:
                        fastboot_func->in_req->complete = compl_do_reset;
                        break;
                }
index 14f4c68868d8b03631248a5117b12f3b7de5afca..b86b508e69fd95288067936642dd28e7b3a5449c 100644 (file)
@@ -32,6 +32,8 @@ enum {
        FASTBOOT_COMMAND_CONTINUE,
        FASTBOOT_COMMAND_REBOOT,
        FASTBOOT_COMMAND_REBOOT_BOOTLOADER,
+       FASTBOOT_COMMAND_REBOOT_FASTBOOTD,
+       FASTBOOT_COMMAND_REBOOT_RECOVERY,
        FASTBOOT_COMMAND_SET_ACTIVE,
 #if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
        FASTBOOT_COMMAND_OEM_FORMAT,
@@ -45,6 +47,8 @@ enum {
  */
 enum fastboot_reboot_reason {
        FASTBOOT_REBOOT_REASON_BOOTLOADER,
+       FASTBOOT_REBOOT_REASON_FASTBOOTD,
+       FASTBOOT_REBOOT_REASON_RECOVERY,
        FASTBOOT_REBOOT_REASONS_COUNT
 };
 
index 0c57fb9947df3a3e4c7a2a5ab4f12dc2f750ca32..7e7a601b9fe618272378b57b158022fd926a8982 100644 (file)
@@ -227,6 +227,8 @@ static void fastboot_send(struct fastboot_header header, char *fastboot_data,
 
                case FASTBOOT_COMMAND_REBOOT:
                case FASTBOOT_COMMAND_REBOOT_BOOTLOADER:
+               case FASTBOOT_COMMAND_REBOOT_FASTBOOTD:
+               case FASTBOOT_COMMAND_REBOOT_RECOVERY:
                        do_reset(NULL, 0, 0, NULL);
                        break;
                }