diff options
author | Patryk Duda <pdk@semihalf.com> | 2022-12-21 16:09:30 +0100 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-01-11 19:30:53 +0000 |
commit | ff76f1ddb73f3bafc87fc6e81453c9084e735269 (patch) | |
tree | 3dbce5fa2973efa1d9a1d50fbf7d6c30f99ffc6b | |
parent | 23b85496baeaa77ae582ff50659ccfb51469ab99 (diff) | |
download | chrome-ec-ff76f1ddb73f3bafc87fc6e81453c9084e735269.tar.gz |
zephyr/test/drivers: Add flash page layout test variant
Introduce drivers.flash test variant with
CONFIG_PLATFORM_EC_USE_ZEPHYR_FLASH_PAGE_LAYOUT enabled.
If the option is enabled, we use Zephyr's flash page API to get
information about flash sectors, sizes, etc. instead of providing these
information in EC.
Since the API provides flash sector description, we only support flash
info version 2 host command. Also output from "flashinfo" command is
slightly different.
BUG=b:239712345
BRANCH=none
TEST=./twister -v -i -T zephyr/test/drivers/ --test external/platform/\
ec/zephyr/test/drivers/drivers.flash.page_layout
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: I1f459232f6bc1c786e8c16bf2537f68229b90862
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4118762
Reviewed-by: Bobby Casey <bobbycasey@google.com>
Commit-Queue: Patryk Duda <patrykd@google.com>
Reviewed-by: Ting Shen <phoenixshen@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Tested-by: Patryk Duda <patrykd@google.com>
-rw-r--r-- | zephyr/test/drivers/flash/src/flash.c | 59 | ||||
-rw-r--r-- | zephyr/test/drivers/testcase.yaml | 5 |
2 files changed, 44 insertions, 20 deletions
diff --git a/zephyr/test/drivers/flash/src/flash.c b/zephyr/test/drivers/flash/src/flash.c index 2bfb30c8ee..998cbdaae8 100644 --- a/zephyr/test/drivers/flash/src/flash.c +++ b/zephyr/test/drivers/flash/src/flash.c @@ -269,26 +269,40 @@ ZTEST_USER(flash, test_hostcmd_flash_info_1) struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(EC_CMD_FLASH_INFO, 1, response); - /* Get the flash info. */ - zassert_ok(host_command_process(&args), NULL); - zassert_equal(response.flash_size, - CONFIG_FLASH_SIZE_BYTES - EC_FLASH_REGION_START, - "response.flash_size = %d", response.flash_size); - zassert_equal(response.flags, 0, "response.flags = %d", response.flags); - zassert_equal(response.write_block_size, CONFIG_FLASH_WRITE_SIZE, - "response.write_block_size = %d", - response.write_block_size); - zassert_equal(response.erase_block_size, CONFIG_FLASH_ERASE_SIZE, - "response.erase_block_size = %d", - response.erase_block_size); - zassert_equal(response.protect_block_size, CONFIG_FLASH_BANK_SIZE, - "response.protect_block_size = %d", - response.protect_block_size); - zassert_equal( - response.write_ideal_size, - (args.response_max - sizeof(struct ec_params_flash_write)) & - ~(CONFIG_FLASH_WRITE_SIZE - 1), - "response.write_ideal_size = %d", response.write_ideal_size); + if (!IS_ENABLED(CONFIG_PLATFORM_EC_USE_ZEPHYR_FLASH_PAGE_LAYOUT)) { + /* Get the flash info. */ + zassert_ok(host_command_process(&args), NULL); + zassert_equal(response.flash_size, + CONFIG_FLASH_SIZE_BYTES - EC_FLASH_REGION_START, + "response.flash_size = %d", response.flash_size); + zassert_equal(response.flags, 0, "response.flags = %d", + response.flags); + zassert_equal(response.write_block_size, + CONFIG_FLASH_WRITE_SIZE, + "response.write_block_size = %d", + response.write_block_size); + zassert_equal(response.erase_block_size, + CONFIG_FLASH_ERASE_SIZE, + "response.erase_block_size = %d", + response.erase_block_size); + zassert_equal(response.protect_block_size, + CONFIG_FLASH_BANK_SIZE, + "response.protect_block_size = %d", + response.protect_block_size); + zassert_equal(response.write_ideal_size, + (args.response_max - + sizeof(struct ec_params_flash_write)) & + ~(CONFIG_FLASH_WRITE_SIZE - 1), + "response.write_ideal_size = %d", + response.write_ideal_size); + } else { + /* + * Flash sector description not supported in FLASH_INFO + * version 1 command + */ + zassert_equal(host_command_process(&args), + EC_RES_INVALID_VERSION, NULL); + } } ZTEST_USER(flash, test_hostcmd_flash_info_2) @@ -358,6 +372,11 @@ ZTEST_USER(flash, test_console_cmd_flash_info) CONFIG_FLASH_WRITE_SIZE, CONFIG_FLASH_WRITE_IDEAL_SIZE); zassert_not_null(strstr(outbuffer, format_buffer)); + if (IS_ENABLED(CONFIG_PLATFORM_EC_USE_ZEPHYR_FLASH_PAGE_LAYOUT)) { + sprintf(format_buffer, "%d regions", crec_flash_total_banks()); + zassert_not_null(strstr(outbuffer, format_buffer)); + } + sprintf(format_buffer, "Erase: %4d B", CONFIG_FLASH_ERASE_SIZE); zassert_not_null(strstr(outbuffer, format_buffer)); diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml index e6e5458d00..aa56d41966 100644 --- a/zephyr/test/drivers/testcase.yaml +++ b/zephyr/test/drivers/testcase.yaml @@ -92,6 +92,11 @@ tests: drivers.flash: extra_configs: - CONFIG_LINK_TEST_SUITE_FLASH=y + drivers.flash.page_layout: + extra_configs: + - CONFIG_LINK_TEST_SUITE_FLASH=y + - CONFIG_SHELL_BACKEND_DUMMY_BUF_SIZE=500 + - CONFIG_PLATFORM_EC_USE_ZEPHYR_FLASH_PAGE_LAYOUT=y drivers.host_cmd: extra_configs: - CONFIG_LINK_TEST_SUITE_HOST_COMMANDS=y |