Hi Heiko,
On 2/8/21 12:38 PM, Heiko Schocher wrote:
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 <h...@denx.de>
---

azure build was fine:
https://dev.azure.com/hs0298/hs/_build/results?buildId=59&view=results

Changes in v4:
- fixed missing parts from Sean Anderson patches
   lost while rebased to tree from lukasz

Changes in v3:
- rebased to https://github.com/lmajewski/u-boot-dfu/commits/testing
   as Lukasz mentioned.

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(+)

(...)
diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
index 41fc8d7904d..960e73089e0 100644
--- a/drivers/fastboot/fb_command.c
+++ b/drivers/fastboot/fb_command.c
(...)
+
+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);

to avoid overflow:


+ strncpy (g_a_cmd_buff, cmd_parameter, sizeof(g_a_cmd_buff));


or check strlen(cmd_parameter) ?


+ if (check strlen(cmd_parameter) > sizeof(g_a_cmd_buff)) {

+               pr_err("too long command\n");

+               fastboot_fail("too long command", response);
+               return;
+       }


+       fastboot_okay(NULL, response);
+}
+#endif
+
  /**
   * reboot_bootloader() - Sets reboot bootloader flag.
   *
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index 950cc119495..8ba55aab9f8 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -494,6 +494,18 @@ static void do_bootm_on_complete(struct usb_ep *ep, struct 
usb_request *req)
        do_exit_on_complete(ep, req);
  }
(...)

Anyway, except this remark.

Acked-by: Patrick Delaunay <patrick.delau...@foss.st.com>

Regards

Patrick

Reply via email to