diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2016-05-04 17:20:37 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-05-11 18:24:29 -0700 |
commit | 3e9490031bbf5cd48c2acc314c38b201d50cb748 (patch) | |
tree | d703197416bfb6d906399ae1911634187bf7df75 | |
parent | 61a0b59cacf20cde0c79acc863811318014fbb95 (diff) | |
download | chrome-ec-3e9490031bbf5cd48c2acc314c38b201d50cb748.tar.gz |
twinkie: disable tracing when injecting packets
The tracing runs a higher priority task (SNIFFER) than the packet
injection (on CONSOLE task) and both RX and TX are using the same buffer,
so when we are sending a packet, we are getting immediately preempted by
the tracer and bad stuffs happen.
Now, we can manually inject packets and get the text trace of the
response.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=none
BUG=none
TEST=with the SOP' experimental patch, plug a full-featured cable into
Samus with Twinkie as an interposer, then do the following sequence:
Pretend there is a device
> tw resistor rd 0
Enable the text tracing
> tw trace on
Send discover identity to the cable (and get the descriptors)
> tw sendprime 1 0x104f ff008001
Sent CC1 104f + 1 = 381
165.939687 SRC/0 [0141]GOODCRC
165.942520 SRC/0 [514f]VDM Vff00:DISCID,ACK:ff008041 1c00050d 00000000 030a0000 11082032
Change-Id: Ie0ad57341c6476e983229b532716986dffefa8a1
Reviewed-on: https://chromium-review.googlesource.com/342512
Commit-Ready: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Benson Leung <bleung@chromium.org>
-rw-r--r-- | board/twinkie/injector.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/board/twinkie/injector.c b/board/twinkie/injector.c index 7dd1571abb..22031b9236 100644 --- a/board/twinkie/injector.c +++ b/board/twinkie/injector.c @@ -88,22 +88,43 @@ DECLARE_HOOK(HOOK_INIT, twinkie_init, HOOK_PRIO_DEFAULT); /* ------ Helper functions ------ */ +static inline int disable_tracing_save(void) +{ + int tr_enabled = STM32_EXTI_IMR & EXTI_COMP_MASK(0); + + if (tr_enabled) + pd_rx_disable_monitoring(0); + return tr_enabled; +} + +static inline void enable_tracing_ifneeded(int flag) +{ + if (flag) + pd_rx_enable_monitoring(0); +} + static int send_message(int polarity, uint16_t header, uint8_t cnt, const uint32_t *data) { int bit_len; + /* Don't get preempted by the tracing */ + int flag = disable_tracing_save(); + bit_len = prepare_message(0, header, cnt, data); /* Transmit the packet */ pd_start_tx(0, polarity, bit_len); pd_tx_done(0, polarity); + enable_tracing_ifneeded(flag); + return bit_len; } static int send_hrst(int polarity) { int off; + int flag = disable_tracing_save(); /* 64-bit preamble */ off = pd_write_preamble(0); /* Hard-Reset: 3x RST-1 + 1x RST-2 */ @@ -116,6 +137,7 @@ static int send_hrst(int polarity) /* Transmit the packet */ pd_start_tx(0, polarity, off); pd_tx_done(0, polarity); + enable_tracing_ifneeded(flag); return off; } @@ -169,11 +191,14 @@ static void fsm_wave(uint32_t w) int off = 0; int nbwords = DIV_ROUND_UP(bit_len, 32); int i; + int flag; /* Buffer overflow */ if (idx + nbwords > INJ_CMD_COUNT) return; + flag = disable_tracing_save(); + for (i = idx; i < idx + nbwords; i++) off = encode_word(0, off, inj_cmds[i]); /* Ensure that we have a final edge */ @@ -181,6 +206,7 @@ static void fsm_wave(uint32_t w) /* Transmit the packet */ pd_start_tx(0, inj_polarity, off); pd_tx_done(0, inj_polarity); + enable_tracing_ifneeded(flag); } static void fsm_wait(uint32_t w) |