From f01d71eb5b0ee8f15e2c85e9302c24bc5fe3ebcd Mon Sep 17 00:00:00 2001 From: Tom Wai-Hong Tam Date: Sat, 21 Nov 2015 01:26:53 +0800 Subject: [PATCH] flash_ec: Don't stop servod or init when claiming EC UART When flashing the STM32 chip, the flash_ec script stops the processes which occupy the EC UART in order to avoid their interference. After flashing, it asks these process to continue. However, when running FAFT in the lab, the EC UART may be occupied by servod for sending some EC commands per test requirements. The flash_ec should not stop the servod; otherwise, all the following dut-control commands will be failed. So this change blacklists the process servod and init. BRANCH=none BUG=chromium:552073 TEST=Manual Ran a FAFT test, e.g. firmware_FAFTSetup, which occupies EC UART. Ran another process, e.g. minicom, which also occupies EC UART. Ran the flash_ec: flash_ec --chip stm32 --image /tmp/ec.bin Its output: INFO: Using ec image : /tmp/ec.bin INFO: ec UART pty : /dev/ttyO1 INFO: Flashing chip stm32. INFO: Using serial flasher : /usr/bin/stm32mon INFO: Sending SIGSTOP to process 2369! INFO: Sending SIGSTOP to process 7949! INFO: Skip stopping servod or init: process 1. INFO: Skip stopping servod or init: process 639. ... INFO: Restoring servo settings... INFO: Sending SIGCONT to process 2369! INFO: Sending SIGCONT to process 7949! Change-Id: I4d72b7e2caf0ca2963bb9dee51764869e829c569 Signed-off-by: Tom Wai-Hong Tam Reviewed-on: https://chromium-review.googlesource.com/313581 Commit-Ready: Wai-Hong Tam Tested-by: Wai-Hong Tam Reviewed-by: Randall Spangler --- util/flash_ec | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/util/flash_ec b/util/flash_ec index 5b05604d76..7635723296 100755 --- a/util/flash_ec +++ b/util/flash_ec @@ -341,13 +341,19 @@ function claim_pty() { "'cros_sdk --no-ns-pid' (see crbug.com/444931 for details)" fi - FROZEN_PIDS=$(lsof -FR 2>/dev/null -- $1 | tr -d 'pR') + pids=$(lsof -FR 2>/dev/null -- $1 | tr -d 'pR') + FROZEN_PIDS="" # reverse order to SIGSTOP parents before children - for pid in $(echo ${FROZEN_PIDS} | tac -s " "); do - info "Sending SIGSTOP to process ${pid}!" - sleep 0.02 - kill -STOP ${pid} + for pid in $(echo ${pids} | tac -s " "); do + if ps -o cmd= "${pid}" | grep -qE "(servod|/sbin/init)"; then + info "Skip stopping servod or init: process ${pid}." + else + info "Sending SIGSTOP to process ${pid}!" + FROZEN_PIDS+=" ${pid}" + sleep 0.02 + kill -STOP ${pid} + fi done }