summaryrefslogtreecommitdiff
path: root/board/sweetberry/board.c
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/board.c
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/board.c')
-rw-r--r--board/sweetberry/board.c23
1 files changed, 23 insertions, 0 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)))