summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarius Schilder <mschilder@google.com>2020-03-19 14:26:51 -0700
committerCommit Bot <commit-bot@chromium.org>2020-03-20 21:55:33 +0000
commit8755dcc9a750d1f6fb7e9bb9c2d900a8dea932ac (patch)
tree85073ce28fbddb04e8192dff1efe60724f1e2f65
parenta0e749b6352127b8eca690eb1928638ca302d00e (diff)
downloadchrome-ec-8755dcc9a750d1f6fb7e9bb9c2d900a8dea932ac.tar.gz
g: add CONFIG_USB_CONSOLE_DEFAULT_DISABLED
To avoid some sort of race in private-cr52 endpoint initialization, which results in a reboot loop. Calling usb_console_enable() in HOOK_LAST instead appears stable, at cost of missing some early console output. While at it, reduce some SRAM usage and improve legibility by moving to bool from int. Strictly opt-in; behavior unchanged for existing code. BUG=chromium:1063240 BRANCH=cr50 TEST=make buildall; cr52 build w/ usb_console now enumerates w/o resets. Signed-off-by: mschilder@google.com Change-Id: I352edb4c045df401cb99573da5765b88deb45d0d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2111450 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-by: Marius Schilder <mschilder@chromium.org> Reviewed-by: Namyoon Woo <namyoon@chromium.org> Commit-Queue: Marius Schilder <mschilder@chromium.org> Tested-by: Marius Schilder <mschilder@chromium.org> Auto-Submit: Marius Schilder <mschilder@chromium.org>
-rw-r--r--chip/g/usb_console.c17
-rw-r--r--include/config.h3
2 files changed, 14 insertions, 6 deletions
diff --git a/chip/g/usb_console.c b/chip/g/usb_console.c
index 68cdea8a6e..65c15e144f 100644
--- a/chip/g/usb_console.c
+++ b/chip/g/usb_console.c
@@ -11,6 +11,7 @@
#include "printf.h"
#include "queue.h"
#include "registers.h"
+#include "stdbool.h"
#include "task.h"
#include "timer.h"
#include "util.h"
@@ -21,21 +22,25 @@
#define CPRINTF(format, args...) cprintf(CC_USB, format, ## args)
#define USB_CONSOLE_TIMEOUT_US (30 * MSEC)
-static int last_tx_ok = 1;
+static bool last_tx_ok = true;
-static int is_reset;
+static bool is_reset;
+#if defined(CONFIG_USB_CONSOLE_DEFAULT_DISABLED)
+static bool is_enabled;
+#else
/*
* Start enabled, so we can queue early debug output before the board gets
* around to calling usb_console_enable().
*/
-static int is_enabled = 1;
+static bool is_enabled = true;
+#endif
/*
* But start read-only, so we don't accept console input until we explicitly
* decide that we're ready for it.
*/
-static int is_readonly = 1;
+static bool is_readonly = true;
/* USB-Serial descriptors */
const struct usb_interface_descriptor USB_IFACE_DESC(USB_IFACE_CONSOLE) =
@@ -387,6 +392,6 @@ int usb_vprintf(const char *format, va_list args)
void usb_console_enable(int enabled, int readonly)
{
- is_enabled = enabled;
- is_readonly = readonly;
+ is_enabled = !!enabled;
+ is_readonly = !!readonly;
}
diff --git a/include/config.h b/include/config.h
index 00ea17e4fd..f810be8e90 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4044,6 +4044,9 @@
/* Enable USB serial console module. */
#undef CONFIG_USB_CONSOLE
+/* Require explicit enable call vs. active at time zero. */
+#undef CONFIG_USB_CONSOLE_DEFAULT_DISABLED
+
/*
* Enable USB serial console module using usb stream config.
* NOTE: CONFIG_USB_CONSOLE and CONFIG_USB_CONSOLE_STREAM should be defined