mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-03 10:17:21 +00:00
fastboot: add UUU command UCmd and ACmd support
add support for the UUU commands ACmd and UCmd. Enable them through the Kconfig option CONFIG_FASTBOOT_UUU_SUPPORT base was commit in NXP kernel 9b149c2a2882: ("MLK-18591-3 android: Add FSL android fastboot support") and ported it to current mainline. Tested this patch on imx6ul based board. Signed-off-by: Heiko Schocher <hs@denx.de> Acked-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
This commit is contained in:
parent
403c2e46b4
commit
bc820d5bcc
6 changed files with 108 additions and 0 deletions
|
@ -144,6 +144,11 @@ Command Reference
|
||||||
|
|
||||||
"powerdown" Power off the device.
|
"powerdown" Power off the device.
|
||||||
|
|
||||||
|
"ucmd" execute any bootloader command and wait until it
|
||||||
|
finishs.
|
||||||
|
|
||||||
|
"acmd" execute any bootloader command, do not wait.
|
||||||
|
|
||||||
Client Variables
|
Client Variables
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ The current implementation supports the following standard commands:
|
||||||
- ``reboot``
|
- ``reboot``
|
||||||
- ``reboot-bootloader``
|
- ``reboot-bootloader``
|
||||||
- ``set_active`` (only a stub implementation which always succeeds)
|
- ``set_active`` (only a stub implementation which always succeeds)
|
||||||
|
- ``ucmd`` (if enabled)
|
||||||
|
- ``acmd`` (if enabled)
|
||||||
|
|
||||||
The following OEM commands are supported (if enabled):
|
The following OEM commands are supported (if enabled):
|
||||||
|
|
||||||
|
|
|
@ -72,6 +72,15 @@ config FASTBOOT_FLASH
|
||||||
the downloaded image to a non-volatile storage device. Define
|
the downloaded image to a non-volatile storage device. Define
|
||||||
this to enable the "fastboot flash" command.
|
this to enable the "fastboot flash" command.
|
||||||
|
|
||||||
|
config FASTBOOT_UUU_SUPPORT
|
||||||
|
bool "Enable FASTBOOT i.MX UUU special command"
|
||||||
|
default n
|
||||||
|
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.
|
||||||
|
|
||||||
choice
|
choice
|
||||||
prompt "Flash provider for FASTBOOT"
|
prompt "Flash provider for FASTBOOT"
|
||||||
depends on FASTBOOT_FLASH
|
depends on FASTBOOT_FLASH
|
||||||
|
|
|
@ -49,6 +49,11 @@ static void oem_partconf(char *, char *);
|
||||||
static void oem_bootbus(char *, char *);
|
static void oem_bootbus(char *, char *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
|
||||||
|
static void run_ucmd(char *, char *);
|
||||||
|
static void run_acmd(char *, char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
const char *command;
|
const char *command;
|
||||||
void (*dispatch)(char *cmd_parameter, char *response);
|
void (*dispatch)(char *cmd_parameter, char *response);
|
||||||
|
@ -117,6 +122,16 @@ static const struct {
|
||||||
.dispatch = oem_bootbus,
|
.dispatch = oem_bootbus,
|
||||||
},
|
},
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
|
||||||
|
[FASTBOOT_COMMAND_UCMD] = {
|
||||||
|
.command = "UCmd",
|
||||||
|
.dispatch = run_ucmd,
|
||||||
|
},
|
||||||
|
[FASTBOOT_COMMAND_ACMD] = {
|
||||||
|
.command = "ACmd",
|
||||||
|
.dispatch = run_acmd,
|
||||||
|
},
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -327,6 +342,59 @@ static void erase(char *cmd_parameter, char *response)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
|
||||||
|
/**
|
||||||
|
* run_ucmd() - Execute the UCmd command
|
||||||
|
*
|
||||||
|
* @cmd_parameter: Pointer to command parameter
|
||||||
|
* @response: Pointer to fastboot response buffer
|
||||||
|
*/
|
||||||
|
static void run_ucmd(char *cmd_parameter, char *response)
|
||||||
|
{
|
||||||
|
if (!cmd_parameter) {
|
||||||
|
pr_err("missing slot suffix\n");
|
||||||
|
fastboot_fail("missing command", response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (run_command(cmd_parameter, 0))
|
||||||
|
fastboot_fail("", response);
|
||||||
|
else
|
||||||
|
fastboot_okay(NULL, response);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char g_a_cmd_buff[64];
|
||||||
|
|
||||||
|
void fastboot_acmd_complete(void)
|
||||||
|
{
|
||||||
|
run_command(g_a_cmd_buff, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* run_acmd() - Execute the ACmd command
|
||||||
|
*
|
||||||
|
* @cmd_parameter: Pointer to command parameter
|
||||||
|
* @response: Pointer to fastboot response buffer
|
||||||
|
*/
|
||||||
|
static void run_acmd(char *cmd_parameter, char *response)
|
||||||
|
{
|
||||||
|
if (!cmd_parameter) {
|
||||||
|
pr_err("missing slot suffix\n");
|
||||||
|
fastboot_fail("missing command", response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(cmd_parameter) > sizeof(g_a_cmd_buff)) {
|
||||||
|
pr_err("too long command\n");
|
||||||
|
fastboot_fail("too long command", response);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(g_a_cmd_buff, cmd_parameter);
|
||||||
|
fastboot_okay(NULL, response);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reboot_bootloader() - Sets reboot bootloader flag.
|
* reboot_bootloader() - Sets reboot bootloader flag.
|
||||||
*
|
*
|
||||||
|
|
|
@ -494,6 +494,18 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *req)
|
||||||
do_exit_on_complete(ep, req);
|
do_exit_on_complete(ep, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
|
||||||
|
static void do_acmd_complete(struct usb_ep *ep, struct usb_request *req)
|
||||||
|
{
|
||||||
|
/* When usb dequeue complete will be called
|
||||||
|
* Need status value before call run_command.
|
||||||
|
* otherwise, host can't get last message.
|
||||||
|
*/
|
||||||
|
if (req->status == 0)
|
||||||
|
fastboot_acmd_complete();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
|
static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
|
||||||
{
|
{
|
||||||
char *cmdbuf = req->buf;
|
char *cmdbuf = req->buf;
|
||||||
|
@ -532,6 +544,11 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)
|
||||||
case FASTBOOT_COMMAND_REBOOT_RECOVERY:
|
case FASTBOOT_COMMAND_REBOOT_RECOVERY:
|
||||||
fastboot_func->in_req->complete = compl_do_reset;
|
fastboot_func->in_req->complete = compl_do_reset;
|
||||||
break;
|
break;
|
||||||
|
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
|
||||||
|
case FASTBOOT_COMMAND_ACMD:
|
||||||
|
fastboot_func->in_req->complete = do_acmd_complete;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,10 @@ enum {
|
||||||
#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
|
#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
|
||||||
FASTBOOT_COMMAND_OEM_BOOTBUS,
|
FASTBOOT_COMMAND_OEM_BOOTBUS,
|
||||||
#endif
|
#endif
|
||||||
|
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
|
||||||
|
FASTBOOT_COMMAND_ACMD,
|
||||||
|
FASTBOOT_COMMAND_UCMD,
|
||||||
|
#endif
|
||||||
|
|
||||||
FASTBOOT_COMMAND_COUNT
|
FASTBOOT_COMMAND_COUNT
|
||||||
};
|
};
|
||||||
|
@ -169,4 +173,7 @@ void fastboot_data_download(const void *fastboot_data,
|
||||||
*/
|
*/
|
||||||
void fastboot_data_complete(char *response);
|
void fastboot_data_complete(char *response);
|
||||||
|
|
||||||
|
#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
|
||||||
|
void fastboot_acmd_complete(void);
|
||||||
|
#endif
|
||||||
#endif /* _FASTBOOT_H_ */
|
#endif /* _FASTBOOT_H_ */
|
||||||
|
|
Loading…
Add table
Reference in a new issue