summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorNick Sanders <nsanders@chromium.org>2017-12-04 16:49:39 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-12-06 20:24:14 -0800
commitdc85ecf029fd73e7ee5febd0ab625c3442f83a43 (patch)
tree535d3a03d333cca2549096e6282465b6f099d747 /util
parent9b922a6317c8814bfd07ca360d2abe3ce74437d5 (diff)
downloadchrome-ec-dc85ecf029fd73e7ee5febd0ab625c3442f83a43.tar.gz
flash_ec: add --verbose arg
Add the option to dump all dut-control and flashrom commands and their arguments. BUG=b:37513705 BRANCH=None TEST=./util/flash_ec --board fizz --verbose Change-Id: Ie57c270a925a00f76d25e52831aa11e23ab9a524 Signed-off-by: Nick Sanders <nsanders@google.com> Reviewed-on: https://chromium-review.googlesource.com/807485 Commit-Ready: Nick Sanders <nsanders@chromium.org> Tested-by: Nick Sanders <nsanders@chromium.org> Reviewed-by: Wai-Hong Tam <waihong@google.com>
Diffstat (limited to 'util')
-rwxr-xr-xutil/flash_ec30
1 files changed, 25 insertions, 5 deletions
diff --git a/util/flash_ec b/util/flash_ec
index 395e492e1f..2ac1d9e93e 100755
--- a/util/flash_ec
+++ b/util/flash_ec
@@ -178,6 +178,8 @@ DEFINE_boolean raiden "${FLAGS_FALSE}" \
"Use raiden_debug_spi programmer"
DEFINE_boolean ro "${FLAGS_FALSE}" \
"Write only the read-only partition"
+DEFINE_boolean verbose "${FLAGS_FALSE}" \
+ "Verbose hw control logging"
# Parse command line
FLAGS_HELP="usage: $0 [flags]"
@@ -196,6 +198,10 @@ fi
DUT_CONTROL_CMD="dut-control --port=${FLAGS_port}"
function dut_control() {
+ if [ "${FLAGS_verbose}" = ${FLAGS_TRUE} ]; then
+ echo "$DUT_CONTROL_CMD $@" 1>&2
+ fi
+
$DUT_CONTROL_CMD "$@" >/dev/null
}
@@ -627,7 +633,12 @@ function flash_flashrom() {
# flashrom should report the image size at the end of the output.
- SPI_SIZE=$(sudo ${FLASHROM} ${FLASHROM_PARAM} --get-size 2>/dev/null |\
+ FLASHROM_CMDLINE="sudo ${FLASHROM} ${FLASHROM_PARAM} --get-size"
+ if [ "${FLAGS_verbose}" = ${FLAGS_TRUE} ]; then
+ echo "Running flashrom:" 1>&2
+ echo " ${FLASHROM_CMDLINE}" 1>&2
+ fi
+ SPI_SIZE=$(sudo ${FLASHROM_CMDLINE} 2>/dev/null |\
grep -oe '[0-9]\+$') || \
die "Failed to determine chip size!"
@@ -637,7 +648,7 @@ function flash_flashrom() {
# Temp image
T=/tmp/flash_spi_$$
-if [ "${CHIP}" = "npcx_spi" ] ; then
+ if [ "${CHIP}" = "npcx_spi" ] ; then
{ # Patch temp image up to SPI_SIZE
cat $IMG
if [[ ${IMG_SIZE} -lt ${SPI_SIZE} ]] ; then
@@ -645,7 +656,7 @@ if [ "${CHIP}" = "npcx_spi" ] ; then
tr '\0' '\377'
fi
} > $T
-else
+ else
{ # Patch temp image up to SPI_SIZE
if [[ ${IMG_SIZE} -lt ${SPI_SIZE} ]] ; then
dd if=/dev/zero bs=${PATCH_SIZE} count=1 | \
@@ -653,9 +664,18 @@ else
fi
cat $IMG
} > $T
-fi
+ fi
+
+ # Generate the correct flashrom command to write the ec.
+ FLASHROM_CMDLINE="${FLASHROM} ${FLASHROM_PARAM}"
+ FLASHROM_CMDLINE+="${FLASHROM_OPTIONS} -w ${T}"
+
+ if [ "${FLAGS_verbose}" = ${FLAGS_TRUE} ]; then
+ echo "Running flashrom:" 1>&2
+ echo " ${FLASHROM_CMDLINE}" 1>&2
+ fi
sudo timeout -k 10 -s 9 "${FLAGS_timeout}" \
- ${FLASHROM} ${FLASHROM_PARAM} ${FLASHROM_OPTIONS} -w "${T}"
+ ${FLASHROM_CMDLINE}
rm $T