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 <waihong@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/313581
Commit-Ready: Wai-Hong Tam <waihong@chromium.org>
Tested-by: Wai-Hong Tam <waihong@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Tom Wai-Hong Tam
2015-11-21 01:26:53 +08:00
committed by chrome-bot
parent 51afeae605
commit f01d71eb5b

View File

@@ -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
}