summaryrefslogtreecommitdiff
path: root/test/flash_physical.c
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2020-05-28 15:46:21 -0700
committerCommit Bot <commit-bot@chromium.org>2020-05-30 05:16:32 +0000
commit55231c0c776ad42b195318ebddf974ca48294f9f (patch)
tree7ba4f459fc0a73f8821c6bde00703eb4e9551b2f /test/flash_physical.c
parent99434726be49517332272752af6dffefdea7bb8a (diff)
downloadchrome-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>
Diffstat (limited to 'test/flash_physical.c')
-rw-r--r--test/flash_physical.c44
1 files changed, 44 insertions, 0 deletions
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();
+}