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>
This commit is contained in:
Tom Hughes 2020-05-28 15:46:21 -07:00 committed by Commit Bot
parent 99434726be
commit 55231c0c77
7 changed files with 58 additions and 0 deletions

View File

@ -15,6 +15,7 @@ test-list-y=\
aes \
compile_time_macros \
crc32 \
flash_physical \
mpu \
mutex \
pingpong \

View File

@ -16,6 +16,7 @@ test-list-y=\
aes \
compile_time_macros \
crc32 \
flash_physical \
mpu \
mutex \
pingpong \

View File

@ -13,6 +13,7 @@ test-list-y=\
aes \
compile_time_macros \
crc32 \
flash_physical \
mpu \
mutex \
pingpong \

View File

@ -13,6 +13,7 @@ test-list-y=\
aes \
compile_time_macros \
crc32 \
flash_physical \
mpu \
mutex \
pingpong \

View File

@ -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

44
test/flash_physical.c Normal file
View File

@ -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();
}

View File

@ -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 */