diff options
-rw-r--r-- | board/hatch_fp/flash_fp_mcu | 3 | ||||
-rwxr-xr-x | board/nami_fp/flash_fp_mcu | 3 | ||||
-rwxr-xr-x | board/nocturne_fp/flash_fp_mcu | 3 | ||||
-rw-r--r-- | util/flash_fp_mcu_common.sh | 33 |
4 files changed, 28 insertions, 14 deletions
diff --git a/board/hatch_fp/flash_fp_mcu b/board/hatch_fp/flash_fp_mcu index 7b014961bf..2a3c11564f 100644 --- a/board/hatch_fp/flash_fp_mcu +++ b/board/hatch_fp/flash_fp_mcu @@ -12,8 +12,6 @@ if [[ -e "/sys/class/gpio/${KBL_GPIOCHIP}" ]]; then # Hatch configuration echo "NOTE: For use with updating FP MCU on HATCH boards only" readonly SPIDEV="/dev/spidev1.1" - # GSPI1 ACPI device for FP MCU - readonly SPIID="spi-PRP0001:01" # FPMCU RST_ODL is on GPP_A12 = 200 + 12 = 212 readonly GPIO_NRST=212 # FPMCU BOOT0 is on GPP_A22 = 200 + 22 = 222 @@ -27,7 +25,6 @@ fi flash_fp_mcu_stm32 \ "${SPIDEV}" \ - "${SPIID}" \ "${GPIO_NRST}" \ "${GPIO_BOOT0}" \ "${GPIO_PWREN}" \ diff --git a/board/nami_fp/flash_fp_mcu b/board/nami_fp/flash_fp_mcu index eeb65764d9..70e9824597 100755 --- a/board/nami_fp/flash_fp_mcu +++ b/board/nami_fp/flash_fp_mcu @@ -12,8 +12,6 @@ if [[ -e "/sys/class/gpio/${KBL_GPIOCHIP}" ]]; then # Ekko configuration echo "NOTE: For use with updating FP MCU on NAMI boards only" readonly SPIDEV="/dev/spidev32765.0" - # GSPI1 ACPI device for FP MCU - readonly SPIID="spi-PRP0001:02" # FPMCU RST_ODL is on GPP_C9 = 360 + 57 = 417 readonly GPIO_NRST=417 # FPMCU BOOT0 is on GPP_D5 = 360 + 77 = 437 @@ -27,7 +25,6 @@ fi flash_fp_mcu_stm32 \ "${SPIDEV}" \ - "${SPIID}" \ "${GPIO_NRST}" \ "${GPIO_BOOT0}" \ "${GPIO_PWREN}" \ diff --git a/board/nocturne_fp/flash_fp_mcu b/board/nocturne_fp/flash_fp_mcu index 42cba3defd..b82083b518 100755 --- a/board/nocturne_fp/flash_fp_mcu +++ b/board/nocturne_fp/flash_fp_mcu @@ -12,8 +12,6 @@ if [[ -e "/sys/class/gpio/${KBL_GPIOCHIP}" ]]; then # Nocturne configuration readonly SPIDEV="/dev/spidev32765.0" - # GSPI1 ACPI device for FP MCU - readonly SPIID="spi-PRP0001:02" # FPMCU RST_ODL is on GPP_C10 = 360 + 58 = 418 readonly GPIO_NRST=418 # FPMCU BOOT0 is on GPP_C8 = 360 + 56 = 416 @@ -27,7 +25,6 @@ fi flash_fp_mcu_stm32 \ "${SPIDEV}" \ - "${SPIID}" \ "${GPIO_NRST}" \ "${GPIO_BOOT0}" \ "${GPIO_PWREN}" \ 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 |