From 62cd2cb56cee0655ce7ef18661058db7738d096e Mon Sep 17 00:00:00 2001 From: Marius Schilder Date: Mon, 26 Mar 2018 22:15:14 -0700 Subject: [PATCH] g: add stream sniffing for DUT spiflash content. Use the stream signing mechanism to hook outgoing spiflash content. This is (only?) used by Mn50 during chip production flows. BUG=None BRANCH=none TEST=make buildall -j8 Signed-off-by: mschilder@google.com Change-Id: Iccfee173865f587f088a31fcbc7b939823884c31 Reviewed-on: https://chromium-review.googlesource.com/981892 Commit-Ready: Marius Schilder Tested-by: Marius Schilder Reviewed-by: Marius Schilder Reviewed-by: Vadim Bendebury --- chip/g/spi_master.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/chip/g/spi_master.c b/chip/g/spi_master.c index e3547d0d97..96acfa4315 100644 --- a/chip/g/spi_master.c +++ b/chip/g/spi_master.c @@ -12,6 +12,10 @@ #include "timer.h" #include "util.h" +#ifdef CONFIG_STREAM_SIGNATURE +#include "signing.h" +#endif + /* Not defined in the hardware register spec, the RX and TX buffers are 128B. */ #define SPI_BUF_SIZE 0x80 @@ -69,6 +73,13 @@ int spi_transaction(const struct spi_device_t *spi_device, /* Grab the port's mutex. */ mutex_lock(&spi_mutex[port]); +#ifdef CONFIG_STREAM_SIGNATURE + /* + * This hook allows mn50 to sniff data written to target + * manufactured H1 devices. + */ + sig_append(stream_spiflash, txdata, txlen); +#endif /* Copy the txdata into the 128B Transmit Buffer. */ memmove((uint8_t *)GREG32_ADDR_I(SPI, port, TX_DATA), txdata, txlen);