diff options
Diffstat (limited to 'board/nucleo-f412zg')
-rw-r--r-- | board/nucleo-f412zg/README.md | 85 | ||||
-rw-r--r-- | board/nucleo-f412zg/board.c | 64 | ||||
-rw-r--r-- | board/nucleo-f412zg/board.h | 25 | ||||
-rw-r--r-- | board/nucleo-f412zg/build.mk | 12 | ||||
-rw-r--r-- | board/nucleo-f412zg/dev_key.pem | 39 | ||||
-rw-r--r-- | board/nucleo-f412zg/ec.tasklist | 13 | ||||
-rw-r--r-- | board/nucleo-f412zg/gpio.inc | 11 | ||||
l--------- | board/nucleo-f412zg/openocd-flash.cfg | 1 | ||||
l--------- | board/nucleo-f412zg/openocd.cfg | 1 |
9 files changed, 251 insertions, 0 deletions
diff --git a/board/nucleo-f412zg/README.md b/board/nucleo-f412zg/README.md new file mode 100644 index 0000000000..fcdd5e40df --- /dev/null +++ b/board/nucleo-f412zg/README.md @@ -0,0 +1,85 @@ +# Nucleo F412ZG + +This is a simpler EC example for the ST Nucleo F412ZG +development board. + +# Quick Start + +The Nucleo dev boards have lots of developer friendly features, +like an in-circuit debugger/programmer/UART-bridge, programmable +LEDs, and a button, to name a few. + +The built-in debugger can be connected to using a Micro USB cable. +It provides three great interfaces to the host. +1. Mass storage interface for drag-drop programming +2. Full ST-Link in-circuit debugger +3. UART bridge for logs/consoles + +We will use a few of these interfaces below to program and interact +with out Nucleo dev board. + +## Build + +```bash +make BOARD=nucleo-f412zg -j +``` + +## Program + +The easiest way to flash the Nucleo board is to Copy-Paste/Drag-Drop +the firmware image onto the exposed mass storage drive. + +Open a file browser and `Copy` the file in `build/nucleo-f412zg/ec.bin`. +Now, find the removable storage that the Nucleo device has presented, +and `Paste` the file into the directory. + +## Interact + +After the Nucelo finishes programming, you can open the EC console. +On GNU/Linux, this is mapped to `/dev/ttyACM0`. + +Install `minicom` and issue the following command: + +```bash +minicom -D/dev/ttyACM0 +``` + +# Unit Testing + +A fun EC feature is that unit tests can be run on-device. + +This is made possible by an alternative build rule that generates a +test image per unit test. These test images use a unit test specific taskset +and console command to trigger them. + +## Create + +To enable an existing unit test, add it to the [build.mk](build.mk)'s +`test-list-y` variable. + +See the main [README.md](/README.md) on how to write a new unit test. + +## Build + +To build all unit test images for this board, run the following command: + +```bash +make BOARD=nucleo-f412zg tests +``` + +You can build a specific unit test image by changing `tests` to `test-aes`, +for the `aes` unit test. + +## Flash + +Copy/paste the `build/nucleo-f412zg/${TEST}/${TEST}.bin` file to the +Nucleo's mass storage drive, where `${TEST}` is the name of the unit test, +like `aes`. + +## Run + +1. Connect to UART console + ```bash + minicom -D/dev/ttyACM0 + ``` +2. Run the `runtest` command
\ No newline at end of file diff --git a/board/nucleo-f412zg/board.c b/board/nucleo-f412zg/board.c new file mode 100644 index 0000000000..e06408c404 --- /dev/null +++ b/board/nucleo-f412zg/board.c @@ -0,0 +1,64 @@ +/* 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. + */ + +#include "common.h" +#include "console.h" +#include "gpio.h" +#include "hooks.h" +#include "registers.h" +#include "spi.h" +#include "system.h" +#include "task.h" +#include "util.h" + +/** + * Disable restricted commands when the system is locked. + * + * @see console.h system.c + */ +int console_is_restricted(void) +{ + return system_is_locked(); +} + +static void ap_deferred(void) +{ + /* + * in S3: SLP_S3_L is 0 and SLP_S0_L is X. + * in S0ix: SLP_S3_L is X and SLP_S0_L is 0. + * in S0: SLP_S3_L is 1 and SLP_S0_L is 1. + * in S5/G3, the FP MCU should not be running. + */ + int running = gpio_get_level(GPIO_PCH_SLP_S3_L) + && gpio_get_level(GPIO_PCH_SLP_S0_L); + + if (running) { /* S0 */ + disable_sleep(SLEEP_MASK_AP_RUN); + hook_notify(HOOK_CHIPSET_RESUME); + } else { /* S0ix/S3 */ + hook_notify(HOOK_CHIPSET_SUSPEND); + enable_sleep(SLEEP_MASK_AP_RUN); + } +} +DECLARE_DEFERRED(ap_deferred); + +/* PCH power state changes */ +static void slp_event(enum gpio_signal signal) +{ + hook_call_deferred(&ap_deferred_data, 0); +} + +#include "gpio_list.h" + +/* Initialize board. */ +static void board_init(void) +{ + /* Enable interrupt on PCH power signals */ + gpio_enable_interrupt(GPIO_PCH_SLP_S3_L); + gpio_enable_interrupt(GPIO_PCH_SLP_S0_L); + /* enable the SPI slave interface if the PCH is up */ + hook_call_deferred(&ap_deferred_data, 0); +} +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); diff --git a/board/nucleo-f412zg/board.h b/board/nucleo-f412zg/board.h new file mode 100644 index 0000000000..331fa29578 --- /dev/null +++ b/board/nucleo-f412zg/board.h @@ -0,0 +1,25 @@ +/* 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. + */ + +/* STM32F412 */ + +#ifndef __BOARD_H +#define __BOARD_H + +/* Baseboard features */ +#include "base-board.h" + +#undef CONFIG_SYSTEM_UNLOCKED + +/* + * These allow console commands to be flagged as restricted. + * Restricted commands will only be permitted to run when + * console_is_restricted() returns false. + * See console_is_restricted's definition in board.c. + */ +#define CONFIG_CONSOLE_COMMAND_FLAGS +#define CONFIG_RESTRICTED_CONSOLE_COMMANDS + +#endif /* __BOARD_H */ diff --git a/board/nucleo-f412zg/build.mk b/board/nucleo-f412zg/build.mk new file mode 100644 index 0000000000..8e58009d96 --- /dev/null +++ b/board/nucleo-f412zg/build.mk @@ -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. +# +# Board specific files build + +BASEBOARD:=nucleo-f412zg + +board-y=board.o + +# Enable on device tests +test-list-y=aes sha256 sha256_unrolled diff --git a/board/nucleo-f412zg/dev_key.pem b/board/nucleo-f412zg/dev_key.pem new file mode 100644 index 0000000000..1eb0d88b78 --- /dev/null +++ b/board/nucleo-f412zg/dev_key.pem @@ -0,0 +1,39 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIG4wIBAAKCAYEAwLY2WYJas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hNO/7TfHTrSuGpIj9DWXbPj8X8UZZkZH +O8w5NIrQB6fo5OmS1NnZCWDYEd7yGO/8vARvDLriVZ1lykIrP3ZkCEuRo+mVMtcP +9J3otNKcnnyAlTqZnHgqlW0upMQXiHCWKHHqXUTG0KsGFu6qHPQBqwQ/k5qD+Osv +tJS8v/ziA33WUHm2OyFgsLNW1tBjkLCDiYJD24/B+3Rc5/fic31r +-----END RSA PRIVATE KEY----- diff --git a/board/nucleo-f412zg/ec.tasklist b/board/nucleo-f412zg/ec.tasklist new file mode 100644 index 0000000000..896eb2fdb3 --- /dev/null +++ b/board/nucleo-f412zg/ec.tasklist @@ -0,0 +1,13 @@ +/* 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_RO(RWSIG, rwsig_task, NULL, 1280) \ + TASK_ALWAYS(HOOKS, hook_task, NULL, 1024) \ + TASK_ALWAYS(HOSTCMD, host_command_task, NULL, 4096) \ + TASK_ALWAYS(CONSOLE, console_task, NULL, CONSOLE_TASK_STACK_SIZE) diff --git a/board/nucleo-f412zg/gpio.inc b/board/nucleo-f412zg/gpio.inc new file mode 100644 index 0000000000..57f78203ba --- /dev/null +++ b/board/nucleo-f412zg/gpio.inc @@ -0,0 +1,11 @@ +/* + * 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. + */ + +#include "base-gpio.inc" + +/* Interrupts */ +GPIO_INT(PCH_SLP_S0_L, PIN(A, 8), GPIO_INT_BOTH, slp_event) +GPIO_INT(PCH_SLP_S3_L, PIN(B, 6), GPIO_INT_BOTH, slp_event) diff --git a/board/nucleo-f412zg/openocd-flash.cfg b/board/nucleo-f412zg/openocd-flash.cfg new file mode 120000 index 0000000000..bafbe75704 --- /dev/null +++ b/board/nucleo-f412zg/openocd-flash.cfg @@ -0,0 +1 @@ +../../baseboard/nucleo-f412zg/openocd-flash.cfg
\ No newline at end of file diff --git a/board/nucleo-f412zg/openocd.cfg b/board/nucleo-f412zg/openocd.cfg new file mode 120000 index 0000000000..29e0be4ba2 --- /dev/null +++ b/board/nucleo-f412zg/openocd.cfg @@ -0,0 +1 @@ +../../baseboard/nucleo-f412zg/openocd.cfg
\ No newline at end of file |