summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Sanders <nsanders@chromium.org>2016-07-19 15:33:47 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-21 17:33:04 -0700
commit08aebf624ca1b8bed94cb5b4378ed058e9d9c007 (patch)
treeec83a814b5545e863b99c364dc9c735145a88e20
parentf623eaf077a4050cd7ae6dd3c96525325060d647 (diff)
downloadchrome-ec-08aebf624ca1b8bed94cb5b4378ed058e9d9c007.tar.gz
servo_micro: add USB updater
This adds a Google FW update endpoint to servo micro in place of a GPIO enpoint. BUG=chromium:571477 TEST=successfully update servo micro via usb BRANCH=None Signed-off-by: Nick Sanders <nsanders@chromium.org> Change-Id: I3d6c501d515b3f1db6e8259fbb829abe18f72e00 Reviewed-on: https://chromium-review.googlesource.com/361834 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--board/servo_micro/board.c24
-rw-r--r--board/servo_micro/board.h40
-rw-r--r--board/servo_micro/ec.tasklist2
3 files changed, 45 insertions, 21 deletions
diff --git a/board/servo_micro/board.c b/board/servo_micro/board.c
index bf25f86630..305c1ce320 100644
--- a/board/servo_micro/board.c
+++ b/board/servo_micro/board.c
@@ -13,6 +13,7 @@
#include "registers.h"
#include "spi.h"
#include "task.h"
+#include "update_fw.h"
#include "usart-stm32f0.h"
#include "usart_tx_dma.h"
#include "usart_rx_dma.h"
@@ -23,7 +24,6 @@
#include "gpio_list.h"
-
/******************************************************************************
* Forward UARTs as a USB serial interface.
*/
@@ -134,6 +134,7 @@ const void *const usb_strings[] = {
[USB_STR_CONSOLE_NAME] = USB_STRING_DESC("Servo EC Shell"),
[USB_STR_USART3_STREAM_NAME] = USB_STRING_DESC("Servo UART2"),
[USB_STR_USART2_STREAM_NAME] = USB_STRING_DESC("Servo UART1"),
+ [USB_STR_UPDATE_NAME] = USB_STRING_DESC("Firmware update"),
};
BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT);
@@ -186,7 +187,6 @@ void usb_spi_board_disable(struct usb_spi_config const *config)
USB_SPI_CONFIG(usb_spi, USB_IFACE_SPI, USB_EP_SPI);
-
/******************************************************************************
* Support I2C bridging over USB, this requires usb_i2c_board_enable and
* usb_i2c_board_disable to be defined to enable and disable the SPI bridge.
@@ -203,6 +203,26 @@ USB_I2C_CONFIG(usb_i2c, USB_IFACE_I2C, USB_EP_I2C);
/******************************************************************************
+ * 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);
+
+
+/******************************************************************************
* Initialize board.
*/
static void board_init(void)
diff --git a/board/servo_micro/board.h b/board/servo_micro/board.h
index ddb4316415..03e583afeb 100644
--- a/board/servo_micro/board.h
+++ b/board/servo_micro/board.h
@@ -33,25 +33,31 @@
#define CONFIG_USB
#define CONFIG_USB_PID 0x501a
#define CONFIG_USB_CONSOLE
+#define CONFIG_USB_UPDATE
+
+#define CONFIG_USB_SERIALNO
+#define DEFAULT_SERIALNO "Uninitialized"
/* USB interface indexes (use define rather than enum to expand them) */
-#define USB_IFACE_USART4_STREAM 0
-#define USB_IFACE_SPI 2
-#define USB_IFACE_CONSOLE 3
-#define USB_IFACE_I2C 4
-#define USB_IFACE_USART3_STREAM 5
-#define USB_IFACE_USART2_STREAM 6
-#define USB_IFACE_COUNT 7
+#define USB_IFACE_USART4_STREAM 0
+#define USB_IFACE_UPDATE 1
+#define USB_IFACE_SPI 2
+#define USB_IFACE_CONSOLE 3
+#define USB_IFACE_I2C 4
+#define USB_IFACE_USART3_STREAM 5
+#define USB_IFACE_USART2_STREAM 6
+#define USB_IFACE_COUNT 7
/* USB endpoint indexes (use define rather than enum to expand them) */
-#define USB_EP_CONTROL 0
-#define USB_EP_USART4_STREAM 1
-#define USB_EP_SPI 3
-#define USB_EP_CONSOLE 4
-#define USB_EP_I2C 5
-#define USB_EP_USART3_STREAM 6
-#define USB_EP_USART2_STREAM 7
-#define USB_EP_COUNT 8
+#define USB_EP_CONTROL 0
+#define USB_EP_USART4_STREAM 1
+#define USB_EP_UPDATE 2
+#define USB_EP_SPI 3
+#define USB_EP_CONSOLE 4
+#define USB_EP_I2C 5
+#define USB_EP_USART3_STREAM 6
+#define USB_EP_USART2_STREAM 7
+#define USB_EP_COUNT 8
/* Enable console recasting of GPIO type. */
#define CONFIG_CMD_GPIO_EXTENDED
@@ -84,9 +90,6 @@
#include "gpio_signal.h"
-#define CONFIG_USB_SERIALNO
-#define DEFAULT_SERIALNO "Uninitialized"
-
/* USB string indexes */
enum usb_strings {
USB_STR_DESC = 0,
@@ -98,6 +101,7 @@ enum usb_strings {
USB_STR_CONSOLE_NAME,
USB_STR_USART3_STREAM_NAME,
USB_STR_USART2_STREAM_NAME,
+ USB_STR_UPDATE_NAME,
USB_STR_COUNT
};
diff --git a/board/servo_micro/ec.tasklist b/board/servo_micro/ec.tasklist
index 1944ef3874..cd197cfd36 100644
--- a/board/servo_micro/ec.tasklist
+++ b/board/servo_micro/ec.tasklist
@@ -17,5 +17,5 @@
* 's' is the stack size in bytes; must be a multiple of 8
*/
#define CONFIG_TASK_LIST \
- TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOOKS, hook_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE)