From 840ba2b6e48f6378e4d70ad29dfa26190019536d Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Wed, 19 Oct 2016 12:24:41 +0800 Subject: hammer: Initial checkout BRANCH=none BUG=chrome-os-partner:59083 TEST=make BOARD=hammer -j && bash flash_hammer Change-Id: I8cc11408d28677a800af58e738f47d5dcadea3e6 Reviewed-on: https://chromium-review.googlesource.com/407739 Commit-Ready: Nicolas Boichat Tested-by: Nicolas Boichat Reviewed-by: Vincent Palatin --- board/hammer/board.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++ board/hammer/board.h | 91 ++++++++++++++++++++++++++++++++++++++++++++++++ board/hammer/build.mk | 13 +++++++ board/hammer/dev_key.pem | 28 +++++++++++++++ board/hammer/ec.tasklist | 21 +++++++++++ board/hammer/gpio.inc | 19 ++++++++++ util/flash_ec | 1 + 7 files changed, 262 insertions(+) create mode 100644 board/hammer/board.c create mode 100644 board/hammer/board.h create mode 100644 board/hammer/build.mk create mode 100644 board/hammer/dev_key.pem create mode 100644 board/hammer/ec.tasklist create mode 100644 board/hammer/gpio.inc diff --git a/board/hammer/board.c b/board/hammer/board.c new file mode 100644 index 0000000000..3aef27269c --- /dev/null +++ b/board/hammer/board.c @@ -0,0 +1,89 @@ +/* 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. + */ +/* Hammer board configuration */ + +#include "common.h" +#include "ec_version.h" +#include "gpio.h" +#include "hooks.h" +#include "i2c.h" +#include "registers.h" +#include "task.h" +#include "update_fw.h" +#include "usart-stm32f0.h" +#include "usart_tx_dma.h" +#include "usart_rx_dma.h" +#include "usb_descriptor.h" +#include "util.h" + +#include "gpio_list.h" + +/****************************************************************************** + * Define the strings used in our USB descriptors. + */ +const void *const usb_strings[] = { + [USB_STR_DESC] = usb_string_desc, + [USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."), + [USB_STR_PRODUCT] = USB_STRING_DESC("Hammer"), + [USB_STR_SERIALNO] = 0, + [USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32), + [USB_STR_UPDATE_NAME] = USB_STRING_DESC("Firmware update"), +}; + +BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT); + +/****************************************************************************** + * Support I2C master port for trackpad. + */ + +/* I2C ports */ +const struct i2c_port_t i2c_ports[] = { + {"master", I2C_PORT_MASTER, 100, + GPIO_MASTER_I2C_SCL, GPIO_MASTER_I2C_SDA}, +}; +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); + + +/****************************************************************************** + * Initialize board. + */ +static void board_init(void) +{ + +} +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); + +void board_config_pre_init(void) +{ + /* enable SYSCFG clock */ + STM32_RCC_APB2ENR |= 1 << 0; + + /* Remap USART DMA to match the USART driver */ + /* + * the DMA mapping is : + * Chan 4 : USART1_TX + * Chan 5 : USART1_RX + */ + STM32_SYSCFG_CFGR1 |= (1 << 9) | (1 << 10); /* Remap USART1 RX/TX DMA */ +} diff --git a/board/hammer/board.h b/board/hammer/board.h new file mode 100644 index 0000000000..37c014ec0b --- /dev/null +++ b/board/hammer/board.h @@ -0,0 +1,91 @@ +/* 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. + */ + +/* Hammer configuration */ + +#ifndef __CROS_EC_BOARD_H +#define __CROS_EC_BOARD_H + +/* TODO: Remove CONFIG_SYSTEM_UNLOCKED prior to building MP FW. */ +#define CONFIG_SYSTEM_UNLOCKED + +/* 48 MHz SYSCLK clock frequency */ +#define CPU_CLOCK 48000000 + +/* The UART console is on USART1 (PA9/PA10) */ +#undef CONFIG_UART_CONSOLE +#define CONFIG_UART_CONSOLE 1 + +/* Optional features */ +#define CONFIG_STM_HWTIMER32 +#define CONFIG_HW_CRC + +/* USB Configuration */ +#define CONFIG_USB +#define CONFIG_USB_PID 0x5022 +#define CONFIG_STREAM_USB +#define CONFIG_USB_UPDATE +#define CONFIG_USB_HID + +#undef CONFIG_USB_MAXPOWER_MA +#define CONFIG_USB_MAXPOWER_MA 100 + +#define CONFIG_USB_SERIALNO +/* TODO(drinkcat): Replace this by proper serial number. Note that according to + * USB standard, we must either unset this (iSerialNumber = 0), or have a unique + * serial number per device. + */ +#define DEFAULT_SERIALNO "Uninitialized" + +/* USB interface indexes (use define rather than enum to expand them) */ +#define USB_IFACE_UPDATE 0 +#define USB_IFACE_HID 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_UPDATE 1 +#define USB_EP_HID 2 +#define USB_EP_COUNT 3 + +/* Optional features */ +#define CONFIG_BOARD_PRE_INIT +#define CONFIG_WATCHDOG_HELP + +/* No lid switch */ +#undef CONFIG_LID_SWITCH + +/* Enable I2C */ +#define CONFIG_I2C +#define CONFIG_I2C_MASTER +#define I2C_PORT_MASTER 0 + +/* Sign and switch to RW partition on boot. */ +#define CONFIG_RWSIG +#define CONFIG_RSA +#define CONFIG_SHA256 +#define CONFIG_RSA_KEY_SIZE 2048 + +#ifndef __ASSEMBLER__ + +/* Timer selection */ +#define TIM_CLOCK32 2 +#define TIM_WATCHDOG 17 + +#include "gpio_signal.h" + +/* USB string indexes */ +enum usb_strings { + USB_STR_DESC = 0, + USB_STR_VENDOR, + USB_STR_PRODUCT, + USB_STR_SERIALNO, + USB_STR_VERSION, + USB_STR_UPDATE_NAME, + USB_STR_COUNT +}; + +#endif /* !__ASSEMBLER__ */ +#endif /* __CROS_EC_BOARD_H */ diff --git a/board/hammer/build.mk b/board/hammer/build.mk new file mode 100644 index 0000000000..0e069a31ad --- /dev/null +++ b/board/hammer/build.mk @@ -0,0 +1,13 @@ +# -*- makefile -*- +# 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. +# +# Board specific files build + +# the IC is STmicro STM32F072RBT6 +CHIP:=stm32 +CHIP_FAMILY:=stm32f0 +CHIP_VARIANT:=stm32f07x + +board-y=board.o diff --git a/board/hammer/dev_key.pem b/board/hammer/dev_key.pem new file mode 100644 index 0000000000..b3400e90e5 --- /dev/null +++ b/board/hammer/dev_key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDjFBICIxHFIYC/ +yaXKrOAJoR58nbVGJzrcYokkCkIa00juLlSg0shxIZxNincMf8yYkzFSiMfrY6B+ +nim+tiWYMpPKE34ncup5i/4/qiRfVpcfmjDIOZ/GBHik3YtZHz5wIVzd26GdpKb4 +P5EIp8h6ivSNDHEAci5ld6bjRlWqX75dEoj/of251/tLQq6YKsa0Xp+X7sWQdotv +ojbbN/BAF6gyg+pFcPcz08UvgSkRcxnv8Et/+SZ6nBW6sC2YWAmkug0+opeHqi2N +qbv7Fw6s5i3Ii0sdIFevr1nJB3yF4wM2Vvm1y3X8p7oavVSQpG//AT2oIo0f7M0+ +zvPVvElfAgMBAAECggEAQ5C5OwGMTAeH84jgV8nQb40NMS8LvO/3R5PaEmsq+Chd +zuDiNWgCVAcYJspIWeO80LkbN9+S/KsMGiCdcy1nSj3iU4IxSzOaKMhKwk6xu9xb +4v9R/IGI1LaH3yY8TCxLu7lxlGHBWNKhC8R+NwEVWcD2uvE0vlk7DN3pPj6zRpne +1LEBj5Y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ff --git a/board/hammer/ec.tasklist b/board/hammer/ec.tasklist new file mode 100644 index 0000000000..73f46d37d4 --- /dev/null +++ b/board/hammer/ec.tasklist @@ -0,0 +1,21 @@ +/* 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. + */ + +/** + * List of enabled tasks in the priority order + * + * The first one has the lowest priority. + * + * For each task, use the macro TASK_ALWAYS(n, r, d, s) for base tasks and + * TASK_NOTEST(n, r, d, s) for tasks that can be excluded in test binaries, + * where : + * 'n' in the name of the task + * 'r' in the main routine of the task + * 'd' in an opaque parameter passed to the routine at startup + * '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(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/board/hammer/gpio.inc b/board/hammer/gpio.inc new file mode 100644 index 0000000000..5825d08310 --- /dev/null +++ b/board/hammer/gpio.inc @@ -0,0 +1,19 @@ +/* -*- mode:c -*- + * + * 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. + */ + +/* I2C pins should be configured as inputs until I2C module is */ +/* initialized. This will avoid driving the lines unintentionally.*/ +GPIO(MASTER_I2C_SCL, PIN(B, 8), GPIO_INPUT) +GPIO(MASTER_I2C_SDA, PIN(B, 9), GPIO_INPUT) + +/* Unimplemented signals since we are not an EC */ +UNIMPLEMENTED(ENTERING_RW) +UNIMPLEMENTED(WP_L) + +ALTERNATE(PIN_MASK(A, 0x0600), 1, MODULE_UART, 0) /* USART1: PA09/PA10 - Servo stm32 console UART */ + +ALTERNATE(PIN_MASK(B, 0x0300), 1, MODULE_I2C, 0) /* I2C MASTER:PB8/9 GPIO_ODR_HIGH */ diff --git a/util/flash_ec b/util/flash_ec index 9dcc8e0b79..1d25112abc 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -61,6 +61,7 @@ BOARDS_STM32=( chell_pd elm glados_pd + hammer honeybuns jerry kitty -- cgit v1.2.1