aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@google.com>2018-01-09 18:42:26 -0800
committerBill Richardson <wfrichar@google.com>2018-01-10 11:12:42 -0800
commit9a759c4b89ce9d9d1acb1d8d751d47dc5db81e27 (patch)
treeb331d2f16a5c09f417ffdbd6aedac86b003bea93
parent4991a94ee20574cbcb47e611ba157fa8dd404171 (diff)
downloadandroid-9a759c4b89ce9d9d1acb1d8d751d47dc5db81e27.tar.gz
test_citadel: wake Citadel from deep sleep
Citadel is usually in deep sleep, so before we start sending it raw datagrams and other test-related stuff, we need to poke it once to wake it up. Change-Id: I27deae15b4786d5b5ac67398cf76e03d188f2633 Signed-off-by: Bill Richardson <wfrichar@google.com>
-rw-r--r--manual_tests/test_citadel.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/manual_tests/test_citadel.c b/manual_tests/test_citadel.c
index bbfeb96..242893f 100644
--- a/manual_tests/test_citadel.c
+++ b/manual_tests/test_citadel.c
@@ -890,6 +890,29 @@ out:
/****************************************************************************/
+/*
+ * Any SPI bus activity will wake Citadel from deep sleep, so we'll just send
+ * it a single bogus command. If Citadel's already awake, it will ignore it.
+ * We don't bother tracking or reporting errors. The test will report any real
+ * errors.
+ */
+#define IGNORED_COMMAND 0x00ffffff
+static void poke_citadel(void)
+{
+ struct nos_device dev;
+ int rv;
+
+ if (nos_device_open(option.device, &dev) != 0)
+ return;
+
+ rv = dev.ops.write(dev.ctx, IGNORED_COMMAND, 0, 0);
+ dev.ops.close(dev.ctx);
+
+ /* If Citadel was asleep, give it some time to wake up */
+ if (rv == -EAGAIN)
+ usleep(50000);
+}
+
int main(int argc, char *argv[])
{
int i;
@@ -967,14 +990,15 @@ int main(int argc, char *argv[])
if (errorcnt)
return !!errorcnt;
+ /* Wake Citadel from deep sleep */
+ poke_citadel();
+
/*
* We can freely intermingle options and args, so the function should
* be the first non-option. Try to pick it out if it exists.
*/
if (argc > optind) {
- if (!strcmp("help", argv[optind]))
- usage(this_prog);
- else if (!strcmp("tpm", argv[optind]))
+ if (!strcmp("tpm", argv[optind]))
do_tpm(argc - optind, argv + optind);
else if (!strcmp("app", argv[optind]))
do_app(argc - optind, argv + optind);