diff options
author | Tom Hughes <tomhughes@chromium.org> | 2020-05-28 15:46:21 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-05-30 05:16:32 +0000 |
commit | 55231c0c776ad42b195318ebddf974ca48294f9f (patch) | |
tree | 7ba4f459fc0a73f8821c6bde00703eb4e9551b2f | |
parent | 99434726be49517332272752af6dffefdea7bb8a (diff) | |
download | chrome-ec-55231c0c776ad42b195318ebddf974ca48294f9f.tar.gz |
test: Add flash_physical test
This test is intended to be used for testing the physical layer flash
APIs.
BRANCH=none
BUG=b:155897971
TEST=On dragonclaw v0.2 with Segger J-Trace and servo micro connected:
./test/run_device_tests.py -t flash_physical
=> PASS
TEST=On dragontalon with servo micro connected:
> runtest
=> PASS
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Ifd3c30da5f42ff84e77a7292cd2a7c88e8c594dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2220734
Commit-Queue: Yicheng Li <yichengli@chromium.org>
Tested-by: Yicheng Li <yichengli@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
-rw-r--r-- | board/hatch_fp/build.mk | 1 | ||||
-rw-r--r-- | board/nocturne_fp/build.mk | 1 | ||||
-rw-r--r-- | board/nucleo-f412zg/build.mk | 1 | ||||
-rw-r--r-- | board/nucleo-h743zi/build.mk | 1 | ||||
-rw-r--r-- | test/build.mk | 1 | ||||
-rw-r--r-- | test/flash_physical.c | 44 | ||||
-rw-r--r-- | test/flash_physical.tasklist | 9 |
7 files changed, 58 insertions, 0 deletions
diff --git a/board/hatch_fp/build.mk b/board/hatch_fp/build.mk index 48ed6d2aae..eb5b8906c1 100644 --- a/board/hatch_fp/build.mk +++ b/board/hatch_fp/build.mk @@ -15,6 +15,7 @@ test-list-y=\ aes \ compile_time_macros \ crc32 \ + flash_physical \ mpu \ mutex \ pingpong \ diff --git a/board/nocturne_fp/build.mk b/board/nocturne_fp/build.mk index d11c25c805..b1ea0d27a2 100644 --- a/board/nocturne_fp/build.mk +++ b/board/nocturne_fp/build.mk @@ -16,6 +16,7 @@ test-list-y=\ aes \ compile_time_macros \ crc32 \ + flash_physical \ mpu \ mutex \ pingpong \ diff --git a/board/nucleo-f412zg/build.mk b/board/nucleo-f412zg/build.mk index 17be2a15bf..ed320938b0 100644 --- a/board/nucleo-f412zg/build.mk +++ b/board/nucleo-f412zg/build.mk @@ -13,6 +13,7 @@ test-list-y=\ aes \ compile_time_macros \ crc32 \ + flash_physical \ mpu \ mutex \ pingpong \ diff --git a/board/nucleo-h743zi/build.mk b/board/nucleo-h743zi/build.mk index 25d76458d2..dae28a73a4 100644 --- a/board/nucleo-h743zi/build.mk +++ b/board/nucleo-h743zi/build.mk @@ -13,6 +13,7 @@ test-list-y=\ aes \ compile_time_macros \ crc32 \ + flash_physical \ mpu \ mutex \ pingpong \ diff --git a/test/build.mk b/test/build.mk index 8f82f917f4..af5ed3355e 100644 --- a/test/build.mk +++ b/test/build.mk @@ -128,6 +128,7 @@ entropy-y=entropy.o extpwr_gpio-y=extpwr_gpio.o fan-y=fan.o flash-y=flash.o +flash_physical-y=flash_physical.o fpsensor-y=fpsensor.o fpsensor_crypto-y=fpsensor_crypto.o fpsensor_state-y=fpsensor_state.o diff --git a/test/flash_physical.c b/test/flash_physical.c new file mode 100644 index 0000000000..9b01445582 --- /dev/null +++ b/test/flash_physical.c @@ -0,0 +1,44 @@ +/* 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 "flash.h" +#include "test_util.h" + +struct flash_info { + int num_flash_banks; + int write_protect_bank_offset; + int write_protect_bank_count; +}; + +#if defined(CHIP_VARIANT_STM32F412) +struct flash_info flash_info = { + .num_flash_banks = 12, + .write_protect_bank_offset = 0, + .write_protect_bank_count = 5, +}; +#elif defined(CHIP_VARIANT_STM32H7X3) +struct flash_info flash_info = { + .num_flash_banks = 16, + .write_protect_bank_offset = 0, + .write_protect_bank_count = 6, +}; +#else +#error "Flash info not defined for this chip. Please add it." +#endif + +test_static int test_flash_config(void) +{ + TEST_EQ(PHYSICAL_BANKS, flash_info.num_flash_banks, "%d"); + TEST_EQ(WP_BANK_OFFSET, flash_info.write_protect_bank_offset, "%d"); + TEST_EQ(WP_BANK_COUNT, flash_info.write_protect_bank_count, "%d"); + return EC_SUCCESS; +} + +void run_test(int argc, char **argv) +{ + ccprintf("Running flash physical test\n"); + RUN_TEST(test_flash_config); + test_print_result(); +} diff --git a/test/flash_physical.tasklist b/test/flash_physical.tasklist new file mode 100644 index 0000000000..51734f058d --- /dev/null +++ b/test/flash_physical.tasklist @@ -0,0 +1,9 @@ +/* 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_TEST_TASK_LIST /* no tasks */ |