diff options
author | Tom Hughes <tomhughes@chromium.org> | 2019-04-12 16:21:46 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-04-26 04:19:09 -0700 |
commit | 696d45e6306c7cdb40024b94ec7a16327001a038 (patch) | |
tree | 0e2a155e6e8007c6d7e324ceacde7d469fe5060a /util | |
parent | 8c50dc29cb6f7cdb077fe9ba49425404ae98207b (diff) | |
download | chrome-ec-696d45e6306c7cdb40024b94ec7a16327001a038.tar.gz |
flash_fp_mcu: use modalias to detect FP spiid
During bringup there was a point where the spiid for the fingerprint
sensor changed between devices (apparently due to broken TPM firmware
since the TPM is usually the first SPI device)). This resulted in
non-obvious failures when running flash_fp_mcu since many other things
were also not working.
BRANCH=none
BUG=chromium:955117
TEST=emerge-nocturne ec-utils-test && cros deploy nocturne ec-utils-test
flash_fp_mcu /opt/google/biod/fw/nocturne_fp_v2.2.110-b936c0a3c.bin
Change-Id: I9161361e2c66de200f618c00074eeb42a9ecb29b
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1566653
Reviewed-by: Nicolas Norvez <norvez@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/flash_fp_mcu_common.sh | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/util/flash_fp_mcu_common.sh b/util/flash_fp_mcu_common.sh index 38528382eb..5ef9029f92 100644 --- a/util/flash_fp_mcu_common.sh +++ b/util/flash_fp_mcu_common.sh @@ -22,6 +22,8 @@ fi # /usr/bin installs echo "$(readlink -f "$0")" +readonly CROS_EC_SPI_MODALIAS_STR="of:NcrfpTCgoogle,cros-ec-spi" + check_hardware_write_protect_disabled() { if ectool gpioget EC_WP_L | grep -q '= 0'; then echo "Please make sure WP is deasserted." @@ -29,13 +31,26 @@ check_hardware_write_protect_disabled() { fi } +# Get the spiid for the fingerprint sensor based on the modalias +# string: https://crbug.com/955117 +get_spiid() { + for dev in /sys/bus/spi/devices/*; do + if [[ "$(cat "${dev}/modalias")" == "${CROS_EC_SPI_MODALIAS_STR}" ]]; then + echo "$(basename "${dev}")" + exit 0 + fi + done + + exit 1 +} + flash_fp_mcu_stm32() { local spidev="${1}" - local spiid="${2}" - local gpio_nrst="${3}" - local gpio_boot0="${4}" - local gpio_pwren="${5}" - local file="${6}" + local gpio_nrst="${2}" + local gpio_boot0="${3}" + local gpio_pwren="${4}" + local file="${5}" + local spiid local STM32MON_READ_FLAGS=" -U -u -p -s ${spidev} -r" local STM32MON_WRITE_FLAGS="-U -u -p -s ${spidev} -e -w" @@ -57,6 +72,14 @@ flash_fp_mcu_stm32() { check_hardware_write_protect_disabled + spiid="$(get_spiid)" + if [[ $? -ne 0 ]]; then + echo "Unable to find FP sensor SPI device: ${CROS_EC_SPI_MODALIAS_STR}" + exit 1 + fi + + echo "Flashing SPI device ID: ${spiid}" + # Ensure the ACPI is not cutting power when unloading cros-ec-spi if [[ -n "${gpio_pwren}" ]]; then echo "${gpio_pwren}" > /sys/class/gpio/export |