From 211d5c19b9ce28dabb7465c53a76f5855d04728b Mon Sep 17 00:00:00 2001 From: Craig Hesling Date: Sun, 18 Jul 2021 16:56:01 -0400 Subject: flash_fp_mcu: Fix nocturne/nami kernelnext Nocturne and Nami are legacy kernel v4.4 devices. The spidev char device naming changed between their v4.4 and newer v5.4. Since these devices have a kernelnext build+tests, we need an alternative configuration that uses the new spidev name. This is achieved by allowing for specific alt configs that match the full platform name, like "nami-kernelnext". If a config is not provided for the full platform name, it will fallback to using the normal base config name, like "nami". BRANCH=none BUG=b:194004525 TEST=# Run the following commands on a nocturne, nocturne-kernelnext, # nami, nami-kernelnext, and hatch setups. # # Note, you get a kernelnext setup by flashing the base platform # device with an xbuddy line similar to # xbuddy://remote/nami-kernelnext/latest-dev/test scp util/flash_fp_mcu ${DUT_HOSTNAME}:/usr/local/bin/flash_fp_mcu ssh ${DUT_HOSTNAME} flash_fp_mcu --hello # Check that full platform name and base name was identified # correctly. # Check that it succeeded. Signed-off-by: Craig Hesling Change-Id: Ib2ad991291639ef33799abb4bc3379c1659f754d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3035686 Reviewed-by: Jora Jacobi --- util/flash_fp_mcu | 80 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 11 deletions(-) diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu index 85ab64dfc5..2b2e31918f 100644 --- a/util/flash_fp_mcu +++ b/util/flash_fp_mcu @@ -163,6 +163,8 @@ lsbval() { # Get the underlying board (reference design) that we're running on (not the # FPMCU or sensor). +# This may be an extended platform name, like nami-kernelnext, hatch-arc-r, +# or hatch-borealis. get_platform_name() { local platform_name @@ -186,15 +188,33 @@ get_platform_name() { return 1 fi - # Tests are also run on modified images, like hatch-arc-r or hatch-borealis. - # These devices still have fingerprint and are expected to pass tests. - # See b/186697064. - # We remove any suffix starting at the first '-'. - platform_name="${platform_name%%-*}" - echo "${platform_name}" } +# Given a full platform name, extract the base platform. +# +# Tests are also run on modified images, like hatch-arc-r, hatch-borealis, or +# hatch-kernelnext. These devices still have fingerprint and are expected to +# pass tests. The full platform name reflects these modifications and might +# be needed to apply an alternative configuration (kernelnext). Other modified +# tests (arc-r) just need to default to the base platform config, which is +# identified by this function. +# See b/186697064. +# +# Examples: +# * platform_base_name "hatch-kernelnext" --> "hatch" +# * platform_base_name "hatch-arc-r" --> "hatch" +# * platform_base_name "hatch-borealis" --> "hatch" +# * platform_base_name "hatch" --> "hatch" +# +# Usage: platform_base_name +platform_base_name() { + local platform_name="$1" + + # We remove any suffix starting at the first '-'. + echo "${platform_name%%-*}" +} + get_default_fw() { local board board="$(cros_config /fingerprint board)" @@ -450,6 +470,19 @@ config_nami() { readonly GPIO_PWREN=395 } +config_nami-kernelnext() { + readonly TRANSPORT="SPI" + readonly DEVICE="/dev/spidev1.0" + + readonly GPIO_CHIP="gpiochip360" + # FPMCU RST_ODL is on GPP_C9 = 360 + 57 = 417 + readonly GPIO_NRST=417 + # FPMCU BOOT0 is on GPP_D5 = 360 + 77 = 437 + readonly GPIO_BOOT0=437 + # FP_PWR_EN is on GPP_B11 = 360 + 35 = 395 + readonly GPIO_PWREN=395 +} + config_nocturne() { readonly TRANSPORT="SPI" readonly DEVICE="/dev/spidev32765.0" @@ -463,6 +496,19 @@ config_nocturne() { readonly GPIO_PWREN=371 } +config_nocturne-kernelnext() { + readonly TRANSPORT="SPI" + readonly DEVICE="/dev/spidev1.0" + + readonly GPIO_CHIP="gpiochip360" + # FPMCU RST_ODL is on GPP_C10 = 360 + 58 = 418 + readonly GPIO_NRST=418 + # FPMCU BOOT0 is on GPP_C8 = 360 + 56 = 416 + readonly GPIO_BOOT0=416 + # FP_PWR_EN is on GPP_A11 = 360 + 11 = 371 + readonly GPIO_PWREN=371 +} + config_strongbad() { readonly TRANSPORT="SPI" readonly DEVICE="/dev/spidev10.0" @@ -570,16 +616,28 @@ main() { fi readonly PLATFORM_NAME - echo "Using config for ${PLATFORM_NAME}" + if ! PLATFORM_BASE_NAME="$(platform_base_name "${PLATFORM_NAME}")"; then + echo "Failed to get platform base name" + exit "${EXIT_CONFIG}" + fi + readonly PLATFORM_BASE_NAME + + echo "Platform name is ${PLATFORM_NAME} (${PLATFORM_BASE_NAME})." # Check that the config function exists - if [[ "$(type -t "config_${PLATFORM_NAME}")" != "function" ]]; then - echo "No config for platform ${PLATFORM_NAME}" + if [[ "$(type -t "config_${PLATFORM_NAME}")" == "function" ]]; then + readonly PLATFORM_CONFIG="${PLATFORM_NAME}" + elif [[ "$(type -t "config_${PLATFORM_BASE_NAME}")" == "function" ]]; then + readonly PLATFORM_CONFIG="${PLATFORM_BASE_NAME}" + else + echo "No config for platform ${PLATFORM_NAME}." >&2 exit "${EXIT_CONFIG}" fi - if ! "config_${PLATFORM_NAME}"; then - echo "Configuration failed for platform ${PLATFORM_NAME}" + echo "Using config for ${PLATFORM_CONFIG}." + + if ! "config_${PLATFORM_CONFIG}"; then + echo "Configuration failed for platform ${PLATFORM_CONFIG}." >&2 exit "${EXIT_CONFIG}" fi -- cgit v1.2.1