MLK-23124 fastboot: support duplicate uart console output to uuu
authorFrank Li <Frank.Li@nxp.com>
Fri, 13 Dec 2019 20:36:01 +0000 (14:36 -0600)
committerYe Li <ye.li@nxp.com>
Thu, 29 Apr 2021 07:56:36 +0000 (00:56 -0700)
to enable it, in uuu script add below command
fb: ucmd setenv stdout serial,fastboot
uuu add -v opition.
output will show in uuu console

Signed-off-by: Frank Li <Frank.Li@nxp.com>
(cherry picked from commit a5e86802515221cdfa4b6d82e697cf9dc0d29a98)
(cherry picked from commit e4bcf17c0c7eaf8365435927be43577a98deed78)

drivers/fastboot/Kconfig
drivers/fastboot/fb_fsl/fb_fsl_common.c
drivers/usb/gadget/f_fastboot.c

index 05f68ca..588cc2a 100644 (file)
@@ -80,6 +80,8 @@ config FASTBOOT_UUU_SUPPORT
        select CMD_GPT
        select RANDOM_UUID
        select CMD_GPT_RENAME
+       select CONSOLE_MUX
+       select SYS_STDIO_DEREGISTER
        help
          The fastboot protocol includes "UCmd" and "ACmd" command.
          Be aware that you provide full access to any U-Boot command,
index 00e43fd..cfb2031 100644 (file)
@@ -48,6 +48,9 @@ extern void trusty_os_init(void);
 
 #include "fb_fsl_common.h"
 
+#include <serial.h>
+#include <stdio_dev.h>
+
 #if defined(CONFIG_AVB_SUPPORT) && defined(CONFIG_MMC)
 AvbABOps fsl_avb_ab_ops = {
        .read_ab_metadata = fsl_read_ab_metadata,
@@ -376,3 +379,37 @@ void fastboot_setup(void)
 #endif
 #endif
 }
+
+static void fastboot_putc(struct stdio_dev *dev, const char c)
+{
+       char buff[6] = "INFO";
+       buff[4] = c;
+       buff[5] = 0;
+       fastboot_tx_write_more(buff);
+}
+
+#define FASTBOOT_MAX_LEN 64
+
+static void fastboot_puts(struct stdio_dev *dev, const char *s)
+{
+       char buff[FASTBOOT_MAX_LEN + 1] = "INFO";
+       int len = strlen(s);
+       int i, left;
+
+       for (i = 0; i < len; i += FASTBOOT_MAX_LEN - 4) {
+               left = len - i;
+               if (left > FASTBOOT_MAX_LEN - 4)
+                       left = FASTBOOT_MAX_LEN - 4;
+
+               memcpy(buff + 4, s + i, left);
+               buff[left + 4] = 0;
+               fastboot_tx_write_more(buff);
+       }
+}
+
+struct stdio_dev g_fastboot_stdio = {
+       .name = "fastboot",
+       .flags = DEV_FLAGS_OUTPUT,
+       .putc = fastboot_putc,
+       .puts = fastboot_puts,
+};
index e8444cb..cfd1f0b 100644 (file)
@@ -22,6 +22,8 @@
 #include <linux/usb/composite.h>
 #include <linux/compiler.h>
 #include <g_dnl.h>
+#include <serial.h>
+#include <stdio_dev.h>
 
 #define FASTBOOT_INTERFACE_CLASS       0xff
 #define FASTBOOT_INTERFACE_SUB_CLASS   0x42
@@ -200,6 +202,10 @@ static struct usb_gadget_strings *fastboot_strings[] = {
        NULL,
 };
 
+#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
+extern struct stdio_dev g_fastboot_stdio;
+#endif
+
 static void rx_handler_command(struct usb_ep *ep, struct usb_request *req);
 
 static void fastboot_fifo_complete(struct usb_ep *ep, struct usb_request *req)
@@ -290,6 +296,10 @@ static int fastboot_bind(struct usb_configuration *c, struct usb_function *f)
        if (s)
                g_dnl_set_serialnumber((char *)s);
 
+#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
+       stdio_register(&g_fastboot_stdio);
+#endif
+
        return 0;
 }
 
@@ -298,6 +308,14 @@ static void fastboot_unbind(struct usb_configuration *c, struct usb_function *f)
        f->os_desc_table = NULL;
        list_del(&fb_os_desc.ext_prop);
        memset(fastboot_func, 0, sizeof(*fastboot_func));
+
+#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT) && CONFIG_IS_ENABLED(SYS_STDIO_DEREGISTER)
+       struct stdio_dev *dev;
+       dev = stdio_get_by_name("fastboot");
+       if (dev)
+               stdio_deregister_dev(dev, 1);
+#endif
+
 }
 
 static void fastboot_disable(struct usb_function *f)