From 4976c1a60ca660d530e6dcaeb6dbd6fe4403fed7 Mon Sep 17 00:00:00 2001 From: Nikolai Artemiev Date: Tue, 21 Feb 2023 13:52:32 +1100 Subject: futility: Add `flash` subcommand Add a new subcommand for getting/setting flash properties such as the flash size and writeprotect configuration. The operations provided by `futility flash` require less information from the user and are less error prone than the equivalents provided by `flashrom`. For example, --wp-enable automatically choses the protection range based on the firmware image and --wp-status gives a warning if the protection range does not match the RO firmware region. BUG=b:268574030 BRANCH=none TEST=`futility flash --{flash-size,wp-enable,wp-disable,wp-status}` Co-authored-by: Edward O'Callaghan Signed-off-by: Edward O'Callaghan Signed-off-by: Nikolai Artemiev Change-Id: I36d7468616a5bcdf3c4542d48652bd24c3377a61 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4279661 Reviewed-by: Edward O'Callaghan Commit-Queue: Edward O'Callaghan --- tests/futility/run_test_scripts.sh | 1 + tests/futility/test_flash_util.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100755 tests/futility/test_flash_util.sh (limited to 'tests') diff --git a/tests/futility/run_test_scripts.sh b/tests/futility/run_test_scripts.sh index 662304da..2f9fbfce 100755 --- a/tests/futility/run_test_scripts.sh +++ b/tests/futility/run_test_scripts.sh @@ -20,6 +20,7 @@ export OUTDIR TESTS=" ${SCRIPT_DIR}/futility/test_create.sh ${SCRIPT_DIR}/futility/test_dump_fmap.sh +${SCRIPT_DIR}/futility/test_flash_util.sh ${SCRIPT_DIR}/futility/test_gbb_utility.sh ${SCRIPT_DIR}/futility/test_load_fmap.sh ${SCRIPT_DIR}/futility/test_main.sh diff --git a/tests/futility/test_flash_util.sh b/tests/futility/test_flash_util.sh new file mode 100755 index 00000000..e18a35cb --- /dev/null +++ b/tests/futility/test_flash_util.sh @@ -0,0 +1,26 @@ +#!/bin/bash -eux +# Copyright 2023 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +me=${0##*/} +TMP="${me}.tmp" + +# Work in scratch directory +cd "${OUTDIR}" + +# 8MB test image +TEST_BIOS="${SCRIPT_DIR}/futility/data/bios_link_mp.bin" +TEST_PROG="dummy:image=${TEST_BIOS},emulate=VARIABLE_SIZE,size=8388608" + +# Test flash size +flash_size=$("${FUTILITY}" flash --flash-size -p "${TEST_PROG}") +[ "${flash_size}" = "Flash size: 0x00800000" ] + +# Test WP status (VARIABLE_SIZE always has WP disabled) +wp_status=$("${FUTILITY}" flash --wp-status -p "${TEST_PROG}") +[ "${wp_status}" = "WP status: disabled" ] + +# Cleanup +rm -f "${TMP}"* +exit 0 -- cgit v1.2.1