summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Hesling <hesling@chromium.org>2021-06-10 17:31:57 -0700
committerCommit Bot <commit-bot@chromium.org>2021-06-12 02:32:22 +0000
commit9a40c7dbadf8c577660a09807287d9133373803b (patch)
tree595b2acdc9109d2d73cdf8ed29e85c810975aa31
parent26fe6f3c1269da1e66fdf99edaeb09e1758b34b4 (diff)
downloadchrome-ec-9a40c7dbadf8c577660a09807287d9133373803b.tar.gz
flash_fp_mcu: Add debug spi bytes activity
In an effort to understand why we see "Device or resource busy" when binding the raw spidev driver, we add a few byte count prints to indicate if spi activity occurred between certain operations. This should be removed when a fix for the linked bug is determined. BRANCH=none BUG=b:190744837 TEST=# On Hatch and Zork scp util/flash_fp_mcu ${DUT_HOSTNAME}:/usr/local/bin/flash_fp_mcu ssh ${DUT_HOSTNAME} flash_fp_mcu --hello Signed-off-by: Craig Hesling <hesling@chromium.org> Change-Id: I400ca76ee3451f1e155d7912a7c25613d9f68846 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2954304 Reviewed-by: Patryk Duda <patrykd@google.com> Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
-rw-r--r--util/flash_fp_mcu33
1 files changed, 33 insertions, 0 deletions
diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu
index a2f7b118a8..4f788bbcd4 100644
--- a/util/flash_fp_mcu
+++ b/util/flash_fp_mcu
@@ -133,6 +133,24 @@ warn_gpio() {
fi
}
+# TODO(b/190744837): Remove when "Device or resource busy" bug is resolved.
+print_spi_bytes() {
+ local label="$1"
+
+ local timestamp
+ local deviceid
+ local bytes_rx
+ local bytes_tx
+
+ if [[ "${TRANSPORT}" == "SPI" ]]; then
+ timestamp="$(date)"
+ deviceid="$(get_spiid)"
+ bytes_rx="$(cat "/sys/bus/spi/devices/${deviceid}/statistics/bytes_rx")"
+ bytes_tx="$(cat "/sys/bus/spi/devices/${deviceid}/statistics/bytes_tx")"
+ echo "${label}: SPI Bytes (${timestamp}): ${bytes_rx} RX and ${bytes_tx} TX"
+ fi
+}
+
# Taken verbatim from
# https://chromium.googlesource.com/chromiumos/docs/+/master/lsb-release.md#shell
# This should not be used by anything except get_platform_name.
@@ -298,6 +316,9 @@ flash_fp_mcu_stm32() {
gpio 1 "${gpio_pwren}"
fi
+ # TODO(b/190744837): Remove when "Device or resource busy" bug is resolved.
+ print_spi_bytes C
+
# Remove cros_fp if present
if [[ "${transport}" == "UART" ]]; then
echo "${deviceid}" > /sys/bus/serial/drivers/cros-ec-uart/unbind
@@ -314,6 +335,9 @@ flash_fp_mcu_stm32() {
gpio 0 "${gpio_nrst}"
sleep 0.001
+ # TODO(b/190744837): Remove when "Device or resource busy" bug is resolved.
+ print_spi_bytes D
+
if [[ "${transport}" == "UART" ]]; then
# load AMDI0020:01 ttyS1
echo AMDI0020:01 > /sys/bus/platform/drivers/dw-apb-uart/unbind;
@@ -326,6 +350,9 @@ flash_fp_mcu_stm32() {
fi
sleep 0.5
+ # TODO(b/190744837): Remove when "Device or resource busy" bug is resolved.
+ print_spi_bytes E
+
# We do not expect the drivers to change the pin state when binding.
# If you receive this warning, the driver needs to be fixed on this board
# and this flash attempt will probably fail.
@@ -602,12 +629,18 @@ main() {
exit "${EXIT_CONFIG}"
fi
+ # TODO(b/190744837): Remove when "Device or resource busy" bug is resolved.
+ print_spi_bytes A
+
if [[ "${FLAGS_services}" -eq "${FLAGS_TRUE}" ]]; then
echo "# Stopping biod and timberslide"
stop biod
stop timberslide LOG_PATH=/sys/kernel/debug/cros_fp/console_log
fi
+ # TODO(b/190744837): Remove when "Device or resource busy" bug is resolved.
+ print_spi_bytes B
+
# If cros-ec driver isn't bound on startup, this means the final rebinding
# may fail.
if [[ ! -c "/dev/cros_fp" ]]; then