board_status.sh: Update to fix serial port reads

The old serial port read method lost characters from the boot log. This
method works better for me.

- Put get_serial_bootlog arguments into variable names for clarity.
- Fully configure the serial port with stty: disable parity and flow control.
- Change serial port read from reading with 'cat' to reading with 'read'.
- Update help to show current default speed from the variable.

tested under dash, bash, and zsh on several platfoms.

Change-Id: I91ae63a3c226e61019dbdf69c405c3f20ba7db54
Signed-off-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://review.coreboot.org/12757
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Martin Roth 2015-12-17 12:02:45 -07:00
parent 1eaaa0e446
commit d0128df777
1 changed files with 16 additions and 10 deletions

View File

@ -122,8 +122,12 @@ cmd_nonfatal()
# $3: filename to direct output of command into # $3: filename to direct output of command into
get_serial_bootlog () { get_serial_bootlog () {
if [ ! -c "$1" ]; then local TTY=$1
echo "$1 is not a valid serial device" local SPEED=$2
local FILENAME=$3
if [ ! -c "$TTY" ]; then
echo "$TTY is not a valid serial device"
exit $EXIT_FAILURE exit $EXIT_FAILURE
fi fi
@ -136,27 +140,29 @@ get_serial_bootlog () {
fi fi
echo echo
echo "Waiting to receive boot log from $1" echo "Waiting to receive boot log from $TTY"
echo "Press [Enter] when the boot is complete and the" echo "Press [Enter] when the boot is complete and the"
echo "system is ready for ssh to get the dmesg log." echo "system is ready for ssh to get the dmesg log."
echo
if [ $tput_not_available -eq 0 ]; then if [ $tput_not_available -eq 0 ]; then
tput sgr0 tput sgr0
fi fi
# set up the serial port # set up the serial port
cmd $LOCAL "stty -F $1 $2 cs8 -cstopb" stty -F $TTY $SPEED cs8 -cstopb -parenb clocal
# read from the serial port - user must press enter when complete # read from the serial port - user must press enter when complete
test_cmd $LOCAL "tee" test_cmd $LOCAL "tee"
cat "$SERIAL_DEVICE" | tee "$3" & while read LINE; do
echo "$LINE" | tee -a "$FILENAME"
done < "$SERIAL_DEVICE" &
PID=$! PID=$!
read read foo
kill "$PID" 2>/dev/null & kill "$PID" 2>/dev/null
# remove the binary zero value that gets inserted into the file. echo "Finished reading boot log."
sed -i 's/\x00//' "$3"
} }
show_help() { show_help() {
@ -173,7 +179,7 @@ Options
-s </dev/xxx> -s </dev/xxx>
Obtain boot log via serial device. Obtain boot log via serial device.
-S <speed> -S <speed>
Set the port speed for the serial device (Default is 115200). Set the port speed for the serial device (Default is $SERIAL_PORT_SPEED).
-u -u
Upload results to coreboot.org. Upload results to coreboot.org.
" "