diff options
author | Patryk Duda <pdk@semihalf.com> | 2022-10-14 17:42:35 +0200 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-17 10:43:02 +0000 |
commit | c606b02622d6aea49b2081864121ccc9173b6da9 (patch) | |
tree | 25255d08f5e3c963dab77c0d85f48187634f374d | |
parent | aabf5bf9a3a943a2c69355ddab98fe8263293781 (diff) | |
download | chrome-ec-c606b02622d6aea49b2081864121ccc9173b6da9.tar.gz |
flash_fp_mcu: Do not exit if FPMCU UART device id is missing
On boards with UART transport (e.g. zork, guybrush) cros-ec-uart is not
bound at the end of flash_fp_mcu script, because rebinding AMDI0020:01
destroys the serial bus used by cros-ec-uart. As a result, running
flash_fp_mcu twice causes the latter run to fail, because the script
can't get cros-ec-uart device id. See b:189992450 for more details.
Actually, missing cros-ec-uart device id is not critical when UART
transport is used. That's because underlying dw-apb-uart device is still
present.
BUG=b:253033860
BRANCH=none
TEST=Run 'flash_fp_mcu --hello' twice on Zork. Make sure that the script
finishes successfully.
TEST=Run 'flash_fp_mcu --hello' twice on Hatch. Make sure that the
script finishes successfully.
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: I1ef931f0c12d1dfc1970558840b556062e63cb65
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3955897
Reviewed-by: Josie Nordrum <josienordrum@google.com>
Tested-by: Patryk Duda <patrykd@google.com>
Commit-Queue: Patryk Duda <patrykd@google.com>
-rw-r--r-- | util/flash_fp_mcu | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu index ed30fdeb08..578382c213 100644 --- a/util/flash_fp_mcu +++ b/util/flash_fp_mcu @@ -334,25 +334,35 @@ flash_fp_mcu_stm32() { if [[ "${transport}" == "UART" ]]; then if ! deviceid="$(get_uartid)"; then + # Failure to get Device ID when transport is UART is not critical. + # Cros-ec-uart driver was built on top of serial bus. Serial bus is + # created on top of UART driver (in our case it's dw-apb-uart). + # To get /dev/ttyS1 device, we need to unbind cros-ec-uart and rebind + # dw-apb-uart driver which creates ttyS1, but destroyes the serial bus. + # If we can't get the Device ID, it means that dw-apb-uart was rebound + # previously. echo "Unable to find FP sensor UART device: ${CROS_EC_UART_MODALIAS_STR}" - return "${EXIT_PRECONDITION}" fi else - if ! deviceid="$(get_spiid)"; then + # Failure to get Device ID when transport is SPI is critical. + # It means that the FPMCU is missing on the device or it's not defined + # in ACPI properly. echo "Unable to find FP sensor SPI device: ${CROS_EC_SPI_MODALIAS_STR}" return "${EXIT_PRECONDITION}" fi fi - echo "Flashing ${transport} device ID: ${deviceid}" + # Unbind cros-ec driver + if [[ ! -z "${deviceid}" ]]; then + klog "Unbinding cros-ec driver" + if [[ "${transport}" == "UART" ]]; then + echo "${deviceid}" > /sys/bus/serial/drivers/cros-ec-uart/unbind + else + echo "${deviceid}" > /sys/bus/spi/drivers/cros-ec-spi/unbind + fi - # Remove cros_fp if present - klog "Unbinding cros-ec driver" - if [[ "${transport}" == "UART" ]]; then - echo "${deviceid}" > /sys/bus/serial/drivers/cros-ec-uart/unbind - else - echo "${deviceid}" > /sys/bus/spi/drivers/cros-ec-spi/unbind + echo "Flashing ${transport} device ID: ${deviceid}" fi # Configure the MCU Boot0 and NRST GPIOs |