summaryrefslogtreecommitdiff
path: root/board/sweetberry
diff options
context:
space:
mode:
authorNick Sanders <nsanders@chromium.org>2016-08-29 14:37:34 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-02 21:17:22 -0700
commitf4dba3b7d35c4db495f9a8eed442d005a2bc8ae7 (patch)
tree8d0c9448ccccf86e9a482ab6c81e664a8546ae9a /board/sweetberry
parent1e23739997bdf85d3767d072377d6e607e3c96d5 (diff)
downloadchrome-ec-f4dba3b7d35c4db495f9a8eed442d005a2bc8ae7.tar.gz
sweetberry: add usb fw update
Port USB firmware update to stm32f4 dwc usb from st usb. This includes usb dwc usb stream inplementation, generic endpoint interfaces, and the sweetberry test case. BUG=chromium:608039 TEST=usb update works BRANCH=None Change-Id: Ia26e4f7e990ee64991468799c99b036f5f32190f Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/377520 Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'board/sweetberry')
-rw-r--r--board/sweetberry/board.c23
-rw-r--r--board/sweetberry/board.h15
2 files changed, 33 insertions, 5 deletions
diff --git a/board/sweetberry/board.c b/board/sweetberry/board.c
index 5c29b553ee..7f1018d315 100644
--- a/board/sweetberry/board.c
+++ b/board/sweetberry/board.c
@@ -14,10 +14,12 @@
#include "registers.h"
#include "stm32-dma.h"
#include "task.h"
+#include "update_fw.h"
#include "usb_descriptor.h"
#include "util.h"
#include "usb_dwc_hw.h"
#include "usb_dwc_console.h"
+#include "usb_dwc_update.h"
/******************************************************************************
* Define the strings used in our USB descriptors.
@@ -29,6 +31,7 @@ const void *const usb_strings[] = {
[USB_STR_SERIALNO] = USB_STRING_DESC("1234-a"),
[USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32),
[USB_STR_CONSOLE_NAME] = USB_STRING_DESC("Sweetberry EC Shell"),
+ [USB_STR_UPDATE_NAME] = USB_STRING_DESC("Firmware update"),
};
BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT);
@@ -37,6 +40,7 @@ struct dwc_usb usb_ctl = {
.ep = {
&ep0_ctl,
&ep_console_ctl,
+ &usb_update_ep_ctl,
},
.speed = USB_SPEED_FS,
.phy_type = USB_PHY_ULPI,
@@ -57,6 +61,25 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+/******************************************************************************
+ * Support firmware upgrade over USB. We can update whichever section is not
+ * the current section.
+ */
+
+/*
+ * This array defines possible sections available for the firmware update.
+ * The section which does not map the current executing code is picked as the
+ * valid update area. The values are offsets into the flash space.
+ */
+const struct section_descriptor board_rw_sections[] = {
+ {CONFIG_RO_MEM_OFF,
+ CONFIG_RO_MEM_OFF + CONFIG_RO_SIZE},
+ {CONFIG_RW_MEM_OFF,
+ CONFIG_RW_MEM_OFF + CONFIG_RW_SIZE},
+};
+const struct section_descriptor * const rw_sections = board_rw_sections;
+const int num_rw_sections = ARRAY_SIZE(board_rw_sections);
+
#define GPIO_SET_HS(bank, number) \
(STM32_GPIO_OSPEEDR(GPIO_##bank) |= (0x3 << ((number) * 2)))
diff --git a/board/sweetberry/board.h b/board/sweetberry/board.h
index 4bb8a13535..b73d5ad188 100644
--- a/board/sweetberry/board.h
+++ b/board/sweetberry/board.h
@@ -40,6 +40,8 @@
#define CONFIG_USB
#define CONFIG_USB_PID 0x5020
#define CONFIG_USB_CONSOLE
+#define CONFIG_STREAM_USB
+#define CONFIG_USB_UPDATE
#undef CONFIG_USB_MAXPOWER_MA
#define CONFIG_USB_MAXPOWER_MA 100
@@ -48,13 +50,15 @@
#define DEFAULT_SERIALNO "Uninitialized"
/* USB interface indexes (use define rather than enum to expand them) */
-#define USB_IFACE_CONSOLE 0
-#define USB_IFACE_COUNT 1
+#define USB_IFACE_CONSOLE 0
+#define USB_IFACE_UPDATE 1
+#define USB_IFACE_COUNT 2
/* USB endpoint indexes (use define rather than enum to expand them) */
-#define USB_EP_CONTROL 0
-#define USB_EP_CONSOLE 1
-#define USB_EP_COUNT 2
+#define USB_EP_CONTROL 0
+#define USB_EP_CONSOLE 1
+#define USB_EP_UPDATE 2
+#define USB_EP_COUNT 3
/* This is not actually a Chromium EC so disable some features. */
#undef CONFIG_WATCHDOG_HELP
@@ -85,6 +89,7 @@ enum usb_strings {
USB_STR_SERIALNO,
USB_STR_VERSION,
USB_STR_CONSOLE_NAME,
+ USB_STR_UPDATE_NAME,
USB_STR_COUNT
};