diff options
author | Martin Roth <martinroth@google.com> | 2015-12-17 12:02:45 -0700 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2015-12-20 01:14:41 +0100 |
commit | d0128df777b761bbf72233d3e3f248cea2f3c484 (patch) | |
tree | ebdf28d2d0734df0e2e9585d70ba14c3c87ac144 /util | |
parent | 1eaaa0e446b88e0ad60c4b6f68a022a9184f1df8 (diff) |
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>
Diffstat (limited to 'util')
-rwxr-xr-x | util/board_status/board_status.sh | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/util/board_status/board_status.sh b/util/board_status/board_status.sh index ee27bc06fa..d8bd3a83c2 100755 --- a/util/board_status/board_status.sh +++ b/util/board_status/board_status.sh @@ -122,8 +122,12 @@ cmd_nonfatal() # $3: filename to direct output of command into get_serial_bootlog () { - if [ ! -c "$1" ]; then - echo "$1 is not a valid serial device" + local TTY=$1 + local SPEED=$2 + local FILENAME=$3 + + if [ ! -c "$TTY" ]; then + echo "$TTY is not a valid serial device" exit $EXIT_FAILURE fi @@ -136,27 +140,29 @@ get_serial_bootlog () { fi 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 "system is ready for ssh to get the dmesg log." + echo if [ $tput_not_available -eq 0 ]; then tput sgr0 fi # 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 test_cmd $LOCAL "tee" - cat "$SERIAL_DEVICE" | tee "$3" & + while read LINE; do + echo "$LINE" | tee -a "$FILENAME" + done < "$SERIAL_DEVICE" & PID=$! - read - kill "$PID" 2>/dev/null & + read foo + kill "$PID" 2>/dev/null - # remove the binary zero value that gets inserted into the file. - sed -i 's/\x00//' "$3" + echo "Finished reading boot log." } show_help() { @@ -173,7 +179,7 @@ Options -s </dev/xxx> Obtain boot log via serial device. -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 Upload results to coreboot.org. " |