summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2022-06-30 11:09:50 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-07-07 20:12:38 +0000
commit9a3c514b45976907b9bb566cf8eabf1c53a3f040 (patch)
treec2e47b15cd7f585a4b01764861cda375f1027f36
parenta32330b63cbf94c2314fc7bf62534ba4c7717e0d (diff)
downloadchrome-ec-9a3c514b45976907b9bb566cf8eabf1c53a3f040.tar.gz
test: Add a test to check if the debugger is connected
This is intended to make it easier to debug the behavior of is_debugger_connected(). With JLink we're seeing that C_DEBUGEN is still set even after disconnecting the JLink (see referenced bug). BRANCH=none BUG=b:180945056 TEST=On dragonclaw v0.2 with JLink and servo_micro, flash the "debug" test: Connect the debugger: JLinkExe -device STM32F412CG -if SWD -speed 4000 -autoconnect 1 J-Link>r J-Link>go Run the test on the FPMCU console: > runtest debugger => PASS Disconnect the debugger: J-Link>exit Run the test on the FPMCU console: > runtest no_debugger => PASS TEST=On icetower v0.1 with JLink and servo_micro, flash the "debug" test: Connect the debugger: JLinkExe -device STM32H743ZI -if SWD -speed 4000 -autoconnect 1 J-Link>r J-Link>go Run the test on the FPMCU console: > runtest debugger => PASS Physically disconnect the debugger and servo_micro. Then reconnect servo_micro and start servod. Run the test on the FPMCU console: > runtest no_debugger => PASS Signed-off-by: Tom Hughes <tomhughes@chromium.org> Change-Id: I544cab5814a30310345d4337a818d7b48cc22a8b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3739316 Reviewed-by: Bobby Casey <bobbycasey@google.com>
-rw-r--r--board/hatch_fp/build.mk1
-rw-r--r--board/nocturne_fp/build.mk1
-rw-r--r--board/nucleo-dartmonkey/build.mk1
-rw-r--r--board/nucleo-f412zg/build.mk1
-rw-r--r--board/nucleo-h743zi/build.mk1
-rw-r--r--test/build.mk1
-rw-r--r--test/debug.c48
-rw-r--r--test/debug.tasklist9
8 files changed, 63 insertions, 0 deletions
diff --git a/board/hatch_fp/build.mk b/board/hatch_fp/build.mk
index cdc2a59993..caac6f5822 100644
--- a/board/hatch_fp/build.mk
+++ b/board/hatch_fp/build.mk
@@ -31,6 +31,7 @@ test-list-y=\
compile_time_macros \
cortexm_fpu \
crc \
+ debug \
flash_physical \
flash_write_protect \
fpsensor \
diff --git a/board/nocturne_fp/build.mk b/board/nocturne_fp/build.mk
index 3401c92b8d..c24b9a0d0d 100644
--- a/board/nocturne_fp/build.mk
+++ b/board/nocturne_fp/build.mk
@@ -31,6 +31,7 @@ test-list-y=\
compile_time_macros \
cortexm_fpu \
crc \
+ debug \
flash_physical \
flash_write_protect \
fpsensor \
diff --git a/board/nucleo-dartmonkey/build.mk b/board/nucleo-dartmonkey/build.mk
index 67658498a0..dc3f1139ef 100644
--- a/board/nucleo-dartmonkey/build.mk
+++ b/board/nucleo-dartmonkey/build.mk
@@ -15,6 +15,7 @@ test-list-y=\
cec \
compile_time_macros \
crc \
+ debug \
flash_physical \
flash_write_protect \
fpsensor \
diff --git a/board/nucleo-f412zg/build.mk b/board/nucleo-f412zg/build.mk
index 6fa61ee41f..64a3472e5e 100644
--- a/board/nucleo-f412zg/build.mk
+++ b/board/nucleo-f412zg/build.mk
@@ -14,6 +14,7 @@ test-list-y=\
cec \
compile_time_macros \
crc \
+ debug \
flash_physical \
flash_write_protect \
mpu \
diff --git a/board/nucleo-h743zi/build.mk b/board/nucleo-h743zi/build.mk
index 2934125b32..b961c4841e 100644
--- a/board/nucleo-h743zi/build.mk
+++ b/board/nucleo-h743zi/build.mk
@@ -14,6 +14,7 @@ test-list-y=\
cec \
compile_time_macros \
crc \
+ debug \
flash_physical \
flash_write_protect \
mpu \
diff --git a/test/build.mk b/test/build.mk
index e7cc18d2e8..10e8f720f1 100644
--- a/test/build.mk
+++ b/test/build.mk
@@ -174,6 +174,7 @@ compile_time_macros-y=compile_time_macros.o
console_edit-y=console_edit.o
cortexm_fpu-y=cortexm_fpu.o
crc-y=crc.o
+debug-y=debug.o
entropy-y=entropy.o
extpwr_gpio-y=extpwr_gpio.o
fan-y=fan.o
diff --git a/test/debug.c b/test/debug.c
new file mode 100644
index 0000000000..0e4676b8b1
--- /dev/null
+++ b/test/debug.c
@@ -0,0 +1,48 @@
+/* Copyright 2022 The ChromiumOS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "debug.h"
+#include "string.h"
+#include "test_util.h"
+
+static bool debugger_connected;
+
+static void print_usage(void)
+{
+ ccprintf("usage: runtest [debugger|no_debugger]\n");
+}
+
+test_static int test_debugger_is_connected(void)
+{
+ ccprintf("debugger_is_connected: %d\n", debugger_connected);
+ TEST_EQ(debugger_is_connected(), debugger_connected, "%d");
+ return EC_SUCCESS;
+}
+
+
+void run_test(int argc, char **argv)
+{
+ test_reset();
+
+ if (argc < 2) {
+ print_usage();
+ test_fail();
+ return;
+ }
+
+ if (strncmp(argv[1], "debugger", sizeof("debugger")) == 0)
+ debugger_connected = true;
+ else if (strncmp(argv[1], "no_debugger", sizeof("no_debugger")) == 0) {
+ debugger_connected = false;
+ } else {
+ print_usage();
+ test_fail();
+ return;
+ }
+
+ RUN_TEST(test_debugger_is_connected);
+ test_print_result();
+}
diff --git a/test/debug.tasklist b/test/debug.tasklist
new file mode 100644
index 0000000000..026dc51e90
--- /dev/null
+++ b/test/debug.tasklist
@@ -0,0 +1,9 @@
+/* Copyright 2022 The ChromiumOS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * See CONFIG_TASK_LIST in config.h for details.
+ */
+#define CONFIG_TEST_TASK_LIST