summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Baltieri <fabiobaltieri@google.com>2021-02-19 15:24:20 +0000
committerCommit Bot <commit-bot@chromium.org>2021-03-04 12:18:41 +0000
commit723d411da02ce6e0de7f901c1f91a774a1adf19c (patch)
treeee73231ad33dfdec032fe0b3f7d9193637688160
parent894a02b53b56f54094222d3acf701f44ed49ba41 (diff)
downloadchrome-ec-723d411da02ce6e0de7f901c1f91a774a1adf19c.tar.gz
zephyr: Add chargen command support
This adds support for the chargen command. The command is used to test the console output to verify that no data has been lost. To do that, it uses the low level UART APIs, so the normal shell operation is temporarily suspended while the command is running. BRANCH=none BUG=b:177604307 TEST=tested the command in both zerphyr and ECOS builds Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com> Change-Id: I7e41902ab7d841ebb7b9e14c52337ad18e10ad7f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2707104 Reviewed-by: Yuval Peress <peress@chromium.org>
-rw-r--r--common/chargen.c8
-rw-r--r--zephyr/CMakeLists.txt3
-rw-r--r--zephyr/Kconfig10
-rw-r--r--zephyr/projects/volteer/prj.conf3
-rw-r--r--zephyr/shim/include/config_chip.h5
5 files changed, 29 insertions, 0 deletions
diff --git a/common/chargen.c b/common/chargen.c
index 24e30bb878..1a57e7f539 100644
--- a/common/chargen.c
+++ b/common/chargen.c
@@ -68,6 +68,8 @@ static int command_chargen(int argc, char **argv)
}
#endif
+ uart_shell_stop();
+
c = '0';
prev_watchdog_time = get_time();
while (uart_getc() != 'x' && usb_getc() != 'x') {
@@ -90,6 +92,9 @@ static int command_chargen(int argc, char **argv)
prev_watchdog_time.val = current_time.val;
}
+ if (IS_ENABLED(CONFIG_ZEPHYR) && c == '0')
+ watchdog_reload();
+
putc_(c++);
if (seq_number && (++seq_counter == seq_number))
@@ -110,6 +115,9 @@ static int command_chargen(int argc, char **argv)
}
putc_('\n');
+
+ uart_shell_start();
+
return EC_SUCCESS;
}
DECLARE_SAFE_CONSOLE_COMMAND(chargen, command_chargen,
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index d06f56da6a..aba0ff177d 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -280,6 +280,9 @@ zephyr_sources_ifdef(CONFIG_PLATFORM_EC_USB_POWER_DELIVERY
"${PLATFORM_EC}/common/usbc/usb_sm.c"
"${PLATFORM_EC}/common/usbc_intr_task.c")
+zephyr_sources_ifdef(CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGEN
+ "${PLATFORM_EC}/common/chargen.c")
+
zephyr_sources_ifdef(CONFIG_PLATFORM_EC_CONSOLE_CMD_PD
"${PLATFORM_EC}/common/usbc/usb_pd_console.c")
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index 5378ef0ee4..313566625b 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -390,6 +390,16 @@ config PLATFORM_EC_WRITABLE_STORAGE_SIZE
ending position of the RW image being copied into RAM when combined
with PLATFORM_EC_WRITABLE_STORAGE_OFF.
+config PLATFORM_EC_CONSOLE_CMD_CHARGEN
+ bool "Console command: chargen"
+ depends on UART_INTERRUPT_DRIVEN
+ help
+ Enables the "chargen" console command, which sends a continuous
+ stream of characters to the EC console.
+
+ This allows to create tests which validate console output by
+ verifying that no characters in the received sequence were lost.
+
config PLATFORM_EC_CONSOLE_CMD_FLASH
bool "Console commands: flasherase, flashread, flashwp, flashwrite"
default y
diff --git a/zephyr/projects/volteer/prj.conf b/zephyr/projects/volteer/prj.conf
index 49203bfdbe..070a2c3523 100644
--- a/zephyr/projects/volteer/prj.conf
+++ b/zephyr/projects/volteer/prj.conf
@@ -89,6 +89,9 @@ CONFIG_PLATFORM_EC_STEINHART_HART_3V3_30K9_47K_4050B=y
CONFIG_HAS_TASK_KEYPROTO=y
CONFIG_HAS_TASK_POWERBTN=y
+# Miscellaneous configs
+CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGEN=y
+
# MKBP event
CONFIG_PLATFORM_EC_MKBP_EVENT=y
CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 859450571d..c3ea783d8b 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -1153,6 +1153,11 @@ enum battery_type {
#define CONFIG_SPI_FLASH_REGS
#endif
+#undef CONFIG_CMD_CHARGEN
+#ifdef PLATFORM_EC_CONSOLE_CMD_CHARGEN
+#define CONFIG_CMD_CHARGEN
+#endif
+
#undef CONFIG_DEBUG_ASSERT
#ifdef CONFIG_PLATFORM_EC_DEBUG_ASSERT
#define CONFIG_DEBUG_ASSERT