fastboot: add UUU command UCmd and ACmd support
PATCH v2 1/1 fastboot: add UUU command UCmd and ACmd support
add support for the UUU commands ACmd and UCmd.
Enable them through the Kconfig optionCONFIG_FASTBOOT_UUU_SUPPORT
base was commit in NXP kernel9b149c2a2882: ("MLK-18591-3 android: Add FSL android fastboot support")
and ported it to current mainline. Tested this patch on imx6ul based board.
---
Changes in v2:
- remove unused FSL_FASTBOOT option
- add comment from Roman:
do not enable this option per default
add Kconfig comment that enabling this option may introduce a security issue.
doc/android/fastboot-protocol.rst | 5 +++ doc/android/fastboot.rst | 2 + drivers/fastboot/Kconfig | 9 +++++ drivers/fastboot/fb_command.c | 62 +++++++++++++++++++++++++++++++ drivers/usb/gadget/f_fastboot.c | 17 +++++++++ include/fastboot.h | 7 ++++ 6 files changed, 102 insertions(+)
doc/android/fastboot-protocol.rst +5 -0
@@ -144,6 +144,11 @@ Command Reference "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 ----------------
doc/android/fastboot.rst +2 -0
@@ -19,6 +19,8 @@ The current implementation supports the following standard commands: - ``reboot`` - ``reboot-bootloader`` - ``set_active`` (only a stub implementation which always succeeds) +- ``ucmd`` (if enabled) +- ``acmd`` (if enabled) The following OEM commands are supported (if enabled):
drivers/fastboot/Kconfig +9 -0
@@ -72,6 +72,15 @@ config FASTBOOT_FLASH the downloaded image to a non-volatile storage device. Define 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 prompt "Flash provider for FASTBOOT" depends on FASTBOOT_FLASH
drivers/fastboot/fb_command.c +62 -0
80 lines not on this page · raw message
drivers/usb/gadget/f_fastboot.c +17 -0
@@ -419,6 +419,18 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *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) {char *cmdbuf = req->buf;
@@ -457,6 +469,11 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req)case FASTBOOT_COMMAND_REBOOT_RECOVERY : fastboot_func->in_req->complete = compl_do_reset;break ; +#if CONFIG_IS_ENABLED (FASTBOOT_UUU_SUPPORT ) +case FASTBOOT_COMMAND_ACMD : + fastboot_func->in_req->complete = do_acmd_complete; +break ; +#endif } }
include/fastboot.h +7 -0
@@ -38,6 +38,10 @@ enum {#if CONFIG_IS_ENABLED (FASTBOOT_CMD_OEM_FORMAT ) FASTBOOT_COMMAND_OEM_FORMAT,#endif +#if CONFIG_IS_ENABLED (FASTBOOT_UUU_SUPPORT ) +FASTBOOT_COMMAND_ACMD , +FASTBOOT_COMMAND_UCMD , +#endifFASTBOOT_COMMAND_COUNT };
@@ -172,4 +176,7 @@ void fastboot_data_download(const void *fastboot_data,*/ void fastboot_data_complete (char *response); +#if CONFIG_IS_ENABLED (FASTBOOT_UUU_SUPPORT ) +void fastboot_acmd_complete (void ); +#endif #endif /* _FASTBOOT_H_ */
Signature · 1 line
2.29.2
PATCH v2 1/1 fastboot: add UUU command UCmd and ACmd support
Hi Heiko,
Quoted 13 lines
add support for the UUU commands ACmd and UCmd.
Enable them through the
KconfigoptionCONFIG_FASTBOOT_UUU_SUPPORTbase 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 <[email protected]>
Quoted 8 lines
---
Changes in v2:
- remove unusedFSL_FASTBOOToption
- add comment from Roman:
do not enable this option per default
addKconfigcomment that enabling this option may introduce a security issue.
Could you fix this patch to be applicable on top of:
https://github.com/lmajewski/u-boot-dfu/commits/testing
Thanks in advance,
Best regards,
Lukasz
Quoted 200 lines
doc/android/fastboot-protocol.rst | 5 +++ doc/android/fastboot.rst | 2 + drivers/fastboot/Kconfig | 9 +++++ drivers/fastboot/fb_command.c | 62 +++++++++++++++++++++++++++++++ drivers/usb/gadget/f_fastboot.c | 17 +++++++++ include/fastboot.h | 7 ++++ 6 files changed, 102 insertions(+)(quoted diff) +0
-0
b/doc/android/fastboot-protocol.rstindexe723659e49c..e8cbd7f24ea100644 ---a/doc/android/fastboot-protocol.rst
+++b/doc/android/fastboot-protocol.rstdoc/android/fastboot-protocol.rst +1
-0@@ -144,6 +144,11 @@ Command Reference "powerdown" Power off the device. + "ucmd" execute any bootloader command and wait untilit
doc/android/fastboot-protocol.rst +4
-0+ finishs. + + "acmd" execute any bootloader command, do not wait. + Client Variables ----------------doc/android/fastboot.rst +0
-0@@ -19,6 +19,8 @@ The current implementation supports the followingstandard commands:
- ``reboot``
- ``reboot-bootloader``
- ``set_active`` (only a stub implementation which always succeeds)+- ``ucmd`` (if enabled) +- ``acmd`` (if enabled)The following OEM commands are supported (if enabled):
drivers/fastboot/Kconfig +0
-0@@ -72,6 +72,15 @@ config FASTBOOT_FLASH the downloaded image to a non-volatile storage device.Define this to enable the "fastboot flash" command.
drivers/fastboot/Kconfig +6
-0+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-Bootcommand,
drivers/fastboot/Kconfig +3
-0+ including working with memory and may open a huge backdoor, + when enabling this option. + choice prompt "Flash provider for FASTBOOT" depends on FASTBOOT_FLASH(quoted diff) +0
-0
b/drivers/fastboot/fb_command.cindexd3c578672dc..31a47e46386100644drivers/fastboot/fb_command.c +62
-0@@ -43,6 +43,11 @@ static void reboot_recovery(char *, char *);static void oem_format (char *,char *);#endif +#if CONFIG_IS_ENABLED (FASTBOOT_UUU_SUPPORT ) +static void run_ucmd (char *,char *); +static void run_acmd (char *,char *); +#endif + static const struct { const char *command; void (*dispatch)(char *cmd_parameter, char *response);@@ -99,6 +104,16 @@ static const struct { .dispatch = oem_format, },#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 };/** @@ -309,6 +324,53 @@ static void erase(char *cmd_parameter, char *response) }#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 ; + } + +strcpy (g_a_cmd_buff, cmd_parameter); +fastboot_okay (NULL , response); +} +#endif +/** * reboot_bootloader() - Sets reboot bootloader flag. * (quoted diff) +0
-0
b/drivers/usb/gadget/f_fastboot.cindexd1d087e12b2..bf52d2505f4100644 ---a/drivers/usb/gadget/f_fastboot.c
+++b/drivers/usb/gadget/f_fastboot.cdrivers/usb/gadget/f_fastboot.c +16
-0@@ -419,6 +419,18 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct usb_request *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) {char *cmdbuf = req->buf;@@ -457,6 +469,11 @@ static void rx_handler_command(struct usb_ep *ep, struct usb_request *req) case FASTBOOT_COMMAND_REBOOT_RECOVERY: fastboot_func->in_req->complete = compl_do_reset;break ; +#if CONFIG_IS_ENABLED (FASTBOOT_UUU_SUPPORT ) +case FASTBOOT_COMMAND_ACMD : + fastboot_func->in_req->complete = do_acmd_complete; +break ; +#endif } }include/fastboot.h +4
-0@@ -38,6 +38,10 @@ enum {#if CONFIG_IS_ENABLED (FASTBOOT_CMD_OEM_FORMAT ) FASTBOOT_COMMAND_OEM_FORMAT,#endif +#if CONFIG_IS_ENABLED (FASTBOOT_UUU_SUPPORT ) +FASTBOOT_COMMAND_ACMD , +FASTBOOT_COMMAND_UCMD , +#endifFASTBOOT_COMMAND_COUNT };
include/fastboot.h void fastboot_data_download(const void · line 182
Quoted 7 lines
include/fastboot.h +3
-0@@ -172,4 +176,7 @@ void fastboot_data_download(const void*fastboot_data, */ void fastboot_data_complete (char *response); +#if CONFIG_IS_ENABLED (FASTBOOT_UUU_SUPPORT ) +void fastboot_acmd_complete (void ); +#endif #endif /* _FASTBOOT_H_ */
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210205/da4e1ada/attachment.sig>
PATCH v2 1/1 fastboot: add UUU command UCmd and ACmd support
Hi Lukasz,
Am 05.02.21 um 00:17 schrieb Lukasz Majewski:
Quoted 24 lines
Hi Heiko,
Quoted 13 lines
add support for the UUU commands ACmd and UCmd.
Enable them through the
KconfigoptionCONFIG_FASTBOOT_UUU_SUPPORTbase 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 <[email protected]>Quoted 8 lines
---
Changes in v2:
- remove unusedFSL_FASTBOOToption
- add comment from Roman:
do not enable this option per default
addKconfigcomment that enabling this option may introduce a security issue.
Quoted 3 lines
Could you fix this patch to be applicable on top of:
sent v3, which is based on above branch
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de