summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@google.com>2017-02-28 11:05:49 -0800
committerYoucheng Syu <youcheng@google.com>2017-03-07 06:01:50 +0000
commit816ebb63793ffc95d098bd799d618ece275b6d90 (patch)
tree135e5b06db42fc189ade6530c3018123256b5923
parente4d56f5870f8171a03d9c70365503e9719e15b19 (diff)
downloadchrome-ec-816ebb63793ffc95d098bd799d618ece275b6d90.tar.gz
usb_updater: change command line option from --spi to --systemdev
The command line option to trigger communicating with the cr50 over /dev/tpm0 has been set to 'spi' originally, as SPI was the interface to communicate with the TPM on first devices using cr50. This is not technically correct, as many devices use i2c for this purpose. Let's rename the command line option from 'spi' to 'dev' and correct names and comments to reflect this too. BRANCH=none BUG=none TEST=ran on a reef device: localhost tmp # ./usb_updater -f --systemdev Could not open TPM: Device or resource busy localhost tmp # initctl stop trunksd trunksd stop/waiting localhost tmp # ./usb_updater -f --systemdev start target running protocol version 6 offsets: backup RO at 0x40000, backup RW at 0x4000 keyids: RO 0xaa66150f, RW 0xb93d6539 Current versions: RO 0.0.10 RW 0.0.16 localhost tmp # ./usb_updater -f -s start target running protocol version 6 offsets: backup RO at 0x40000, backup RW at 0x4000 keyids: RO 0xaa66150f, RW 0xb93d6539 Current versions: RO 0.0.10 RW 0.0.16 Change-Id: Ifbdd3618209ad9930e0678cf50e82a789ae5e2cd Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/447781 Reviewed-by: Aaron Durbin <adurbin@chromium.org> (cherry picked from commit 6ceabb07e3ee571437cba34360701b73e83f5516) Reviewed-on: https://chromium-review.googlesource.com/451041 Reviewed-by: Youcheng Syu <youcheng@google.com> Commit-Queue: Youcheng Syu <youcheng@google.com> Tested-by: Youcheng Syu <youcheng@google.com>
-rw-r--r--extra/usb_updater/usb_updater.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/extra/usb_updater/usb_updater.c b/extra/usb_updater/usb_updater.c
index 4b33a219c1..123bb31c0e 100644
--- a/extra/usb_updater/usb_updater.c
+++ b/extra/usb_updater/usb_updater.c
@@ -53,8 +53,8 @@
* is restarted, the new RO and RW are used if they pass verification and are
* logically newer than the existing sections.
*
- * There are two ways to communicate with the CR50 device: USB and SPI (when
- * this app is running on a chromebook with the CR50 device). Originally
+ * There are two ways to communicate with the CR50 device: USB and /dev/tpm0
+ * (when this app is running on a chromebook with the CR50 device). Originally
* different protocols were used to communicate over different channels,
* starting with version 3 the same protocol is used.
*
@@ -66,7 +66,7 @@
* update protocol, it sends data to the cr50 device, which proceeses it and
* responds.
*
- * The encapsultation format is different between the SPI and USB cases:
+ * The encapsultation format is different between the /dev/tpm0 and USB cases:
*
* 4 bytes 4 bytes 4 bytes variable size
* +-----------+--------------+---------------+----------~~--------------+
@@ -74,17 +74,18 @@
* +-----------+--------------+---------------+----------~~--------------+
* \ \ /
* \ \ /
- * \ +-------- FW update PDU sent over SPI --------------+
+ * \ +----- FW update PDU sent over /dev/tpm0 -----------+
* \ /
* +--------- USB frame, requires total size field ------------+
*
- * The update protocol data unints (PDUs) are passed over SPI, the
+ * The update protocol data unints (PDUs) are passed over /dev/tpm0, the
* encapsulation includes integritiy verification and destination address of
- * the data (more of this later). SPI transactions pretty much do not have
- * size limits, whereas the USB data is sent in chunks of the size determined
- * when the USB connestion is set up. This is why USB requires an additional
- * encapsulation int frames to communicate the PDU size to the client side so
- * that the PDU can be reassembled before passing to the programming function.
+ * the data (more of this later). /dev/tpm0 transactions pretty much do not
+ * have size limits, whereas the USB data is sent in chunks of the size
+ * determined when the USB connestion is set up. This is why USB requires an
+ * additional encapsulation into frames to communicate the PDU size to the
+ * client side so that the PDU can be reassembled before passing to the
+ * programming function.
*
* In general, the protocol consists of two phases: connection establishment
* and actual image transfer.
@@ -96,9 +97,9 @@
*
* The response to the first PDU varies depending on the protocol version.
*
- * Version 1 is used over SPI. The response is either 4 or 1 bytes in size.
- * The 4 byte response is the *base address* of the backup RW section, no
- * support for RO updates. The one byte response is an error indication,
+ * Version 1 is used over /dev/tpm0. The response is either 4 or 1 bytes in
+ * size. The 4 byte response is the *base address* of the backup RW section,
+ * no support for RO updates. The one byte response is an error indication,
* possibly reporting flash erase failure, command format error, etc.
*
* Version 2 is used over USB. The response is 8 bytes in size. The first four
@@ -106,7 +107,7 @@
* updates), or an error code, the same as in Version 1. The second 4 bytes
* are the protocol version number (set to 2).
*
- * All versions above 2 behave the same over SPI and USB.
+ * All versions above 2 behave the same over /dev/tpm0 and USB.
*
* Version 3 response is 16 bytes in size. The first 4 bytes are the error code
* the second 4 bytes are the protocol version (set to 3) and then 4 byte
@@ -207,7 +208,7 @@ struct transfer_descriptor {
uint32_t post_reset;
enum transfer_type {
usb_xfer = 0,
- spi_xfer = 1
+ dev_xfer = 1
} ep_type;
union {
struct usb_endpoint uep;
@@ -226,7 +227,7 @@ static const struct option long_opts[] = {
{"fwver", 0, NULL, 'f'},
{"help", 0, NULL, 'h'},
{"post_reset", 0, NULL, 'p'},
- {"spi", 0, NULL, 's'},
+ {"systemdev", 0, NULL, 's'},
{"upstart", 0, NULL, 'u'},
{},
};
@@ -332,7 +333,7 @@ static void usage(int errs)
" -d,--device VID:PID USB device (default %04x:%04x)\n"
" -f,--fwver Report running firmware versions.\n"
" -h,--help Show this message\n"
- " -s,--spi Use /dev/tmp0 (-d is ignored)\n"
+ " -s,--systemdev Use /dev/tmp0 (-d is ignored)\n"
" -u,--upstart "
"Upstart mode (strict header checks)\n"
"\n", progname, VID, PID);
@@ -904,7 +905,7 @@ static void setup_connection(struct transfer_descriptor *td)
/* We got something. Check for errors in response */
if (rxed_size <= 4) {
- if (td->ep_type != spi_xfer) {
+ if (td->ep_type != dev_xfer) {
size_t i;
fprintf(stderr, "Unexpected response size %zd: ",
@@ -1236,7 +1237,7 @@ int main(int argc, char *argv[])
usage(errorcnt);
break;
case 's':
- td.ep_type = spi_xfer;
+ td.ep_type = dev_xfer;
break;
case 'p':
td.post_reset = 1;