summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatryk Duda <pdk@semihalf.com>2022-07-27 16:20:16 +0200
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-08-17 09:26:29 +0000
commita2e7061347b91f4dbb06beb4ba882f331dbbcc00 (patch)
treed1bdc38048d8b9d48af99b7cc38800feca1e2a20
parent42b05e8e248bb283e0f8e8e672fd2a159df0041d (diff)
downloadchrome-ec-a2e7061347b91f4dbb06beb4ba882f331dbbcc00.tar.gz
flash_fp_mcu: Wait for FPMCU to disable sector write protect
To disable ro_now protection FPMCU must be booted with HW write protect disabled. Actually running 'flash_fp_mcu --read' doesn't cause 'stm32mon' to disable sector write protect and as a result first FPMCU boot with HW WP disabled takes place after power cycling FPMCU. Disabling sector write protection takes some time due to flash internal structures update. During that time we can't reset or power cycle FPMCU otherwise we will corrupt internal flash state which will brick FPMCU. This situation can occur if DUT is rebooted immediately after flash_fp_mcu finishes, so give some time to remove sector write protection. The issue can be reproduced with the following script: do_ssh() { sshpass -ptest0000 ssh root@<IP> "$*" } do_ssh ectool --name=cros_fp version dut-control fw_wp_state:force_on do_ssh ectool --name=cros_fp flashprotect enable sleep 2 do_ssh ectool --name=cros_fp reboot_ec sleep 2 do_ssh ectool --name=cros_fp flashprotect dut-control fw_wp_state:force_off do_ssh 'flash_fp_mcu --noservices \ --noremove_flash_read_protect --read; reboot' sleep 2 do_ssh ectool --name=cros_fp version BUG=b:233276135 BRANCH=none TEST=Run 'tast run <IP> firmware.FpRDP1' on zork, hatch, nami, nocturne, strongbad Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I86a4d1ce7833bc4aeefd9f963febf1a2d3a7c809 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3785338 Reviewed-by: Josie Nordrum <josienordrum@google.com> Reviewed-by: Bobby Casey <bobbycasey@google.com> Tested-by: Patryk Duda <patrykd@google.com> Commit-Queue: Patryk Duda <patrykd@google.com>
-rw-r--r--util/flash_fp_mcu12
1 files changed, 12 insertions, 0 deletions
diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu
index aff479dba9..bfaa391fc0 100644
--- a/util/flash_fp_mcu
+++ b/util/flash_fp_mcu
@@ -472,6 +472,18 @@ flash_fp_mcu_stm32() {
klog "Binding cros-ec driver"
echo "" > "/sys/bus/spi/devices/${deviceid}/driver_override"
echo "${deviceid}" > /sys/bus/spi/drivers/cros-ec-spi/bind
+ else
+ # FPMCU can still have ro_now protection (sector write protection) enabled
+ # e.g. when flash_fp_mcu was run with --read option. It is disabled when
+ # FPMCU boots with HW write protect disabled.
+ # Disabling sector write protection takes some time due to flash internal
+ # structures update. During that time we can't reset or power cycle FPMCU
+ # otherwise we will corrupt internal flash state which will brick FPMCU.
+ # This situation can occur if DUT is rebooted immediately after flash_fp_mcu
+ # finishes, so give some time to remove sector write protection. No need to
+ # wait if transport is SPI because later we query for version and reset
+ # flags.
+ sleep 3
fi
if [[ "${cmd_exit_status}" -ne 0 ]]; then