summaryrefslogtreecommitdiff
path: root/board/nucleo-g431rb
diff options
context:
space:
mode:
authorScott Collyer <scollyer@google.com>2020-04-01 11:02:38 -0700
committerCommit Bot <commit-bot@chromium.org>2020-09-24 20:41:25 +0000
commitc91a3801ed810bb13f964a70c323906b187f3cba (patch)
tree4d35fdc195f55f554e732655790fa4d23775f373 /board/nucleo-g431rb
parent71b27a53005725f1ec868ea871ad7f46f180ce51 (diff)
downloadchrome-ec-c91a3801ed810bb13f964a70c323906b187f3cba.tar.gz
nucleo-g431rb: Adding support for nucleo-g431rb dev board
This CL renames what was /board/honeybuns to /board/nuclero-g431rb and adds code to blink the user LED (once per second) and enables MCO alt function so that system clocks can be measured. BUG=None BRANCH=None TEST=flashed image to nucleo board using the STM32CubeIDE debugger and verified sysclock frequency, LED, and EC console is accessed via STLINK /dev/ttyACM0 Signed-off-by: Scott Collyer <scollyer@google.com> Change-Id: I2b614a0e71f3f15638667f80e80a998ba731d929 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2168433 Reviewed-by: Diana Z <dzigterman@chromium.org> Commit-Queue: Scott Collyer <scollyer@chromium.org> Tested-by: Scott Collyer <scollyer@chromium.org>
Diffstat (limited to 'board/nucleo-g431rb')
-rw-r--r--board/nucleo-g431rb/board.c34
-rw-r--r--board/nucleo-g431rb/board.h72
-rw-r--r--board/nucleo-g431rb/build.mk13
-rw-r--r--board/nucleo-g431rb/ec.tasklist12
-rw-r--r--board/nucleo-g431rb/gpio.inc21
5 files changed, 152 insertions, 0 deletions
diff --git a/board/nucleo-g431rb/board.c b/board/nucleo-g431rb/board.c
new file mode 100644
index 0000000000..01f8a55629
--- /dev/null
+++ b/board/nucleo-g431rb/board.c
@@ -0,0 +1,34 @@
+/* Copyright 2020 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.
+ */
+
+/* STM32G431 Nucleo-64 board-specific configuration */
+
+#include "common.h"
+#include "gpio.h"
+#include "hooks.h"
+
+#include "gpio_list.h" /* Must come after other header files. */
+
+
+static void board_init(void)
+{
+ /*
+ * Using alt-function to send system clock to MCO pin (PA8). The alt
+ * function for module clock will not get configured unless the module
+ * is configured here.
+ */
+ gpio_config_module(MODULE_CLOCK, 1);
+}
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+
+static void led_second(void)
+{
+ static int count;
+
+ /* Blink user LED on nucleo board */
+ gpio_set_level(GPIO_LED1, count++ & 0x1);
+}
+DECLARE_HOOK(HOOK_SECOND, led_second, HOOK_PRIO_DEFAULT);
+
diff --git a/board/nucleo-g431rb/board.h b/board/nucleo-g431rb/board.h
new file mode 100644
index 0000000000..a65daa4364
--- /dev/null
+++ b/board/nucleo-g431rb/board.h
@@ -0,0 +1,72 @@
+/* Copyright 2020 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.
+ */
+
+/* STM32G431 Nucleo-64 board configuration */
+
+#ifndef __CROS_EC_BOARD_H
+#define __CROS_EC_BOARD_H
+
+/* Optional features */
+#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands while in dev. */
+
+#define CPU_CLOCK 48000000
+#define CONFIG_STM_HWTIMER32
+#define TIM_CLOCK32 2
+#define TIM_CLOCK_MSB 3
+#define TIM_CLOCK_LSB 15
+#define TIM_WATCHDOG 7
+
+/* Nucelo platform does not have a lid switch */
+#undef CONFIG_LID_SWITCH
+
+
+/* Setup UART console */
+/*
+ * The STM32G431 Nucleo-64 has two UARTs which can be connected to the virtual
+ * com port(VCP) of the STLINK chip. The VCP to STM32G4 connection depends on
+ * solder bridge configuration. The default configuration is VCP to LUPAURT
+ * (PA2/PA3). In order to reuse existing stm32 uart drivers, UART9 is used to
+ * indicate that lpuart is being used.
+ *
+ * The STM32G4 has a DMAMUX and so both the DMA channel and DMAMUX request
+ * numbers need to be specified here.
+ */
+#define STM32G431_EVAL_USE_LPUART_CONSOLE
+#undef CONFIG_UART_CONSOLE
+#define CONFIG_UART_TX_DMA
+#undef CONFIG_UART_TX_BUF_SIZE
+#define CONFIG_UART_TX_BUF_SIZE 2048
+
+#ifdef STM32G431_EVAL_USE_LPUART_CONSOLE
+#define CONFIG_UART_CONSOLE 9
+#define CONFIG_UART_TX_DMA_CH STM32_DMAC_LPUART_TX
+#define CONFIG_UART_TX_DMA_PH DMAMUX_REQ_UART9_TX
+#else
+#define CONFIG_UART_CONSOLE 1
+#define CONFIG_UART_TX_DMA_CH STM32_DMAC_USART1_TX
+#define CONFIG_UART_TX_DMA_PH DMAMUX_REQ_USART1_TX
+#endif
+
+
+/*
+ * Macros for GPIO signals used in common code that don't match the
+ * schematic names. Signal names in gpio.inc match the schematic and are
+ * then redefined here to so it's more clear which signal is being used for
+ * which purpose.
+ */
+#define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW
+#define GPIO_WP_L GPIO_EC_WP_L
+
+
+
+#ifndef __ASSEMBLER__
+
+#include "gpio_signal.h"
+#include "registers.h"
+
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __CROS_EC_BOARD_H */
diff --git a/board/nucleo-g431rb/build.mk b/board/nucleo-g431rb/build.mk
new file mode 100644
index 0000000000..8140048cdd
--- /dev/null
+++ b/board/nucleo-g431rb/build.mk
@@ -0,0 +1,13 @@
+# -*- makefile -*-
+# Copyright 2020 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
+#
+
+CHIP:=stm32
+CHIP_FAMILY:=stm32g4
+CHIP_VARIANT:=stm32g431xb
+
+board-y=board.o
diff --git a/board/nucleo-g431rb/ec.tasklist b/board/nucleo-g431rb/ec.tasklist
new file mode 100644
index 0000000000..c272906fc7
--- /dev/null
+++ b/board/nucleo-g431rb/ec.tasklist
@@ -0,0 +1,12 @@
+/* Copyright 2020 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.
+ */
+
+/*
+ * See CONFIG_TASK_LIST in config.h for details.
+ */
+
+#define CONFIG_TASK_LIST \
+ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE)
diff --git a/board/nucleo-g431rb/gpio.inc b/board/nucleo-g431rb/gpio.inc
new file mode 100644
index 0000000000..4dd4a6d966
--- /dev/null
+++ b/board/nucleo-g431rb/gpio.inc
@@ -0,0 +1,21 @@
+/* -*- mode:c -*-
+ *
+ * Copyright 2020 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.
+ */
+
+/* Declare symbolic names for all the GPIOs that we care about.
+ * Note: Those with interrupt handlers must be declared first. */
+
+/* Outputs */
+GPIO(LED1, PIN(A, 5), GPIO_OUT_LOW) /* Green */
+
+/* Misc Signals */
+UNIMPLEMENTED(ENTERING_RW)
+UNIMPLEMENTED(EC_WP_L)
+
+/* LPUART1: A2/A3 */
+ALTERNATE(PIN_MASK(A, 0x000C), GPIO_ALT_LPUART, MODULE_UART, GPIO_PULL_UP)
+/* MCO A8 */
+ALTERNATE(PIN_MASK(A, 0x0100), 0, MODULE_CLOCK, 0)