summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2016-04-13 17:26:36 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-04-15 15:09:08 -0700
commitb28ed970c4fab168dcc9fe2fb00d5c76de4de3fe (patch)
treed740d063fcfa39835ef603bdacebcd4da31401fd
parentde45353bbdf0c6c4afb88420d3cb2e182eae7450 (diff)
downloadchrome-ec-b28ed970c4fab168dcc9fe2fb00d5c76de4de3fe.tar.gz
Cr50: Update the USB VID:PID:subclass constants
The device-specific subclass used for Non-HC firmware updates is in the spreadsheet now, so we can rename the macros to be "official". BUG=chrome-os-partner:49962 BRANCH=none TEST=make buildall; test on cr50 make BOARD=cr50 (plus whatever signing magic works for you) make -C extra/usb_updater ./extra/usb_updater/usb_updater build/cr50/ec.bin (sudo if needed) Note that you may need to rebuild ec.bin in order to see any difference after the update. If the A & B images are identical, the RO bootloader always picks A. Change-Id: I385ce89a9abe2059d52da2d82a0b92b9b3e3c93f Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/339220 Reviewed-by: Vadim Bendebury <vbendeb@chromium.org>
-rw-r--r--chip/g/upgrade_fw.h3
-rw-r--r--chip/g/usb_upgrade.c5
-rw-r--r--chip/g/usb_upgrade.h14
-rw-r--r--extra/usb_updater/Makefile4
-rw-r--r--extra/usb_updater/usb_updater.c25
-rw-r--r--include/usb_descriptor.h4
6 files changed, 28 insertions, 27 deletions
diff --git a/chip/g/upgrade_fw.h b/chip/g/upgrade_fw.h
index 1e6c595fb7..ce9debd5fb 100644
--- a/chip/g/upgrade_fw.h
+++ b/chip/g/upgrade_fw.h
@@ -8,6 +8,9 @@
#include <stddef.h>
+/* TODO: Handle this in upgrade_fw.c, not usb_upgrade.c */
+#define UPGRADE_DONE 0xB007AB1E
+
void fw_upgrade_command_handler(void *body,
size_t cmd_size,
size_t *response_size);
diff --git a/chip/g/usb_upgrade.c b/chip/g/usb_upgrade.c
index 54e4fb6d1c..7e86a0c035 100644
--- a/chip/g/usb_upgrade.c
+++ b/chip/g/usb_upgrade.c
@@ -12,7 +12,6 @@
#include "system.h"
#include "upgrade_fw.h"
#include "usb-stream.h"
-#include "usb_upgrade.h"
#define CPRINTS(format, args...) cprints(CC_USB, format, ## args)
@@ -49,8 +48,8 @@ static struct queue const usb_to_upgrade = QUEUE_DIRECT(64, uint8_t,
USB_STREAM_CONFIG_FULL(usb_upgrade,
USB_IFACE_UPGRADE,
USB_CLASS_VENDOR_SPEC,
- UNOFFICIAL_USB_SUBCLASS_GOOGLE_CR50,
- 0xff, /* vendor-specific protocol */
+ USB_SUBCLASS_GOOGLE_CR50,
+ USB_PROTOCOL_GOOGLE_CR50_NON_HC_FW_UPDATE,
USB_STR_UPGRADE_NAME,
USB_EP_UPGRADE,
USB_MAX_PACKET_SIZE,
diff --git a/chip/g/usb_upgrade.h b/chip/g/usb_upgrade.h
deleted file mode 100644
index 7fe25b5895..0000000000
--- a/chip/g/usb_upgrade.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Copyright 2016 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_USB_UPGRADE_H
-#define __CROS_EC_USB_UPGRADE_H
-
-#define UNOFFICIAL_USB_SUBCLASS_GOOGLE_CR50 0x53
-
-/* Commands from host */
-#define UPGRADE_DONE 0xB007AB1E
-
-#endif /* __CROS_EC_USB_UPGRADE_H */
diff --git a/extra/usb_updater/Makefile b/extra/usb_updater/Makefile
index 8a55f750f6..b4c208f4af 100644
--- a/extra/usb_updater/Makefile
+++ b/extra/usb_updater/Makefile
@@ -25,7 +25,9 @@ CFLAGS := -std=gnu99 \
LIBS += $(shell pkg-config --libs libusb-1.0) -lcrypto
CFLAGS += $(shell pkg-config --cflags libusb-1.0)
-CFLAGS += -I../../board/cr50 -I ../../chip/g -I../../util
+# NOTE: This may be board-specific
+BOARD ?= cr50
+CFLAGS += -I../../include -I../../board/$(BOARD) -I ../../chip/g -I../../util
$(PROGRAM): $(SOURCE) Makefile
gcc $(CFLAGS) $(SOURCE) $(LFLAGS) $(LIBS) -o $@
diff --git a/extra/usb_updater/usb_updater.c b/extra/usb_updater/usb_updater.c
index f1183de852..2b528779d2 100644
--- a/extra/usb_updater/usb_updater.c
+++ b/extra/usb_updater/usb_updater.c
@@ -15,15 +15,22 @@
#include <sys/types.h>
#include <unistd.h>
+
+#ifndef __packed
+#define __packed __attribute__((packed))
+#endif
+
#include "misc_util.h"
-#include "usb_upgrade.h"
+#include "usb_descriptor.h"
+#include "upgrade_fw.h"
#include "config_chip.h"
+#include "board.h"
-/* Google Cr50 */
-#define VID 0x18d1
-#define PID 0x5014
-#define SUBCLASS UNOFFICIAL_USB_SUBCLASS_GOOGLE_CR50
-#define PROTOCOL 0xff
+/* Look for Cr50 FW update interface */
+#define VID USB_VID_GOOGLE
+#define PID CONFIG_USB_PID
+#define SUBCLASS USB_SUBCLASS_GOOGLE_CR50
+#define PROTOCOL USB_PROTOCOL_GOOGLE_CR50_NON_HC_FW_UPDATE
/* Globals */
static char *progname;
@@ -211,8 +218,8 @@ static int parse_vidpid(const char *input, uint16_t *vid_ptr, uint16_t *pid_ptr)
}
-static struct libusb_device_handle *usb_connect(uint16_t vid, uint16_t pid,
- uint8_t *ep_num, int *chunk_len)
+static struct libusb_device_handle *usb_findit(uint16_t vid, uint16_t pid,
+ uint8_t *ep_num, int *chunk_len)
{
struct libusb_device_handle *devh;
int iface_num, r;
@@ -442,7 +449,7 @@ int main(int argc, char *argv[])
exit(1);
}
- devh = usb_connect(vid, pid, &ep_num, &chunk_len);
+ devh = usb_findit(vid, pid, &ep_num, &chunk_len);
transfer_and_reboot(devh, data, data_len, ep_num, chunk_len);
diff --git a/include/usb_descriptor.h b/include/usb_descriptor.h
index 8fdb7ef774..baa6e6421b 100644
--- a/include/usb_descriptor.h
+++ b/include/usb_descriptor.h
@@ -167,6 +167,10 @@ struct usb_endpoint_descriptor {
#define USB_SUBCLASS_GOOGLE_I2C 0x52
#define USB_PROTOCOL_GOOGLE_I2C 0x01
+#define USB_SUBCLASS_GOOGLE_CR50 0x53
+/* We can use any protocol we want */
+#define USB_PROTOCOL_GOOGLE_CR50_NON_HC_FW_UPDATE 0xff
+
/* Control requests */