summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Short <keithshort@chromium.org>2021-08-13 15:45:33 -0600
committerCommit Bot <commit-bot@chromium.org>2021-08-18 23:45:57 +0000
commit1c616f739262f1271617ff0979b8e7606d45a441 (patch)
treea8a81c658abcd1d9d01600b1063d1f03c02bcec2
parentf78eee4550dc747b558c1dfc333ba9b629216f39 (diff)
downloadchrome-ec-1c616f739262f1271617ff0979b8e7606d45a441.tar.gz
zephyr: Disable console help strings
Add support for disabling the console command help strings. With CONFIG_SHELL_HELP=n, 2000 bytes saved on Volteer BUG=none BRANCH=none TEST=zmake testall TEST=Verify console on Volteer with and without CONFIG_SHELL_HELP enabled. Signed-off-by: Keith Short <keithshort@chromium.org> Change-Id: I2186828f28691182f673851ac27d207b4a4a6f44 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3093492 Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/Kconfig.console5
-rw-r--r--zephyr/shim/include/zephyr_console_shim.h13
-rw-r--r--zephyr/shim/src/console.c9
3 files changed, 24 insertions, 3 deletions
diff --git a/zephyr/Kconfig.console b/zephyr/Kconfig.console
index c1edee71d5..04e1d137bd 100644
--- a/zephyr/Kconfig.console
+++ b/zephyr/Kconfig.console
@@ -26,7 +26,12 @@ config SHELL_PRINTF_BUFF_SIZE
default 130
# Some boards may need to increase the size, depending on the amount of output
+#
+# TODO(b/196627937): zephyr: hang when running help with CONFIG_SHELL_HELP
+# enabled. Increase the TX buffer size to workaround the hang when the help
+# is enabled.
config SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE
+ default 4096 if SHELL_HELP
default 1024
menuconfig PLATFORM_EC_HOSTCMD_CONSOLE
diff --git a/zephyr/shim/include/zephyr_console_shim.h b/zephyr/shim/include/zephyr_console_shim.h
index a45d65659b..b3c1f23922 100644
--- a/zephyr/shim/include/zephyr_console_shim.h
+++ b/zephyr/shim/include/zephyr_console_shim.h
@@ -11,12 +11,22 @@
struct zephyr_console_command {
/* Handler for the command. argv[0] will be the command name. */
int (*handler)(int argc, char **argv);
+#ifdef CONFIG_SHELL_HELP
/* Description of args */
const char *argdesc;
/* Short help for command */
const char *help;
+#endif
};
+#ifdef CONFIG_SHELL_HELP
+#define _HELP_ARGS(A, H) \
+ .argdesc = A, \
+ .help = H,
+#else
+#define _HELP_ARGS(A, H)
+#endif
+
/**
* zshim_run_ec_console_command() - Dispatch a CrOS EC console command
* using Zephyr's shell
@@ -35,8 +45,7 @@ int zshim_run_ec_console_command(const struct zephyr_console_command *command,
WRAPPER_ID, ENTRY_ID) \
static const struct zephyr_console_command ENTRY_ID = { \
.handler = ROUTINE_ID, \
- .argdesc = ARGDESC, \
- .help = HELP, \
+ _HELP_ARGS(ARGDESC, HELP) \
}; \
static int WRAPPER_ID(const struct shell *shell, size_t argc, \
char **argv) \
diff --git a/zephyr/shim/src/console.c b/zephyr/shim/src/console.c
index 929f7a9d1c..23f169f70c 100644
--- a/zephyr/shim/src/console.c
+++ b/zephyr/shim/src/console.c
@@ -164,10 +164,16 @@ void uart_shell_start(void)
int zshim_run_ec_console_command(const struct zephyr_console_command *command,
size_t argc, char **argv)
{
+ /*
+ * The Zephyr shell only displays the help string and not
+ * the argument descriptor when passing "-h" or "--help". Mimic the
+ * cros-ec behavior by displaying both the user types "<command> help",
+ */
+#ifdef CONFIG_SHELL_HELP
for (int i = 1; i < argc; i++) {
if (!command->help && !command->argdesc)
break;
- if (!strcmp(argv[i], "-h")) {
+ if (!strcmp(argv[i], "help")) {
if (command->help)
printk("%s\n", command->help);
if (command->argdesc)
@@ -175,6 +181,7 @@ int zshim_run_ec_console_command(const struct zephyr_console_command *command,
return 0;
}
}
+#endif
return command->handler(argc, argv);
}