[coreboot-gerrit] New patch to review for coreboot: 548f232 board_status.sh updates
Martin Roth (gaumless@gmail.com)
gerrit at coreboot.org
Mon Jun 23 05:47:30 CEST 2014
Martin Roth (gaumless at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6094
-gerrit
commit 548f2322bc35abbe58691a1d006e8c9264a619e1
Author: Martin Roth <martin.roth at se-eng.com>
Date: Sun Jun 22 21:46:24 2014 -0600
board_status.sh updates
- add a non-fatal option to test_cmd.
- allow for cmd() to be run, but not pipe to a file.
- Read the boot log from a serial device.
- give a template to the temp dir so they're recognizable.
- show the location of the temp files again at the end of the script.
Change-Id: Idc5a89ccf80bfe77b220a85868ff803c12008b54
Signed-off-by: Martin Roth <martin.roth at se-eng.com>
---
util/board_status/board_status.sh | 94 ++++++++++++++++++++++++++++++++++-----
1 file changed, 84 insertions(+), 10 deletions(-)
diff --git a/util/board_status/board_status.sh b/util/board_status/board_status.sh
index 65576f4..f718008 100755
--- a/util/board_status/board_status.sh
+++ b/util/board_status/board_status.sh
@@ -3,6 +3,7 @@
# This file is part of the coreboot project.
#
# Copyright (C) 2013 Google Inc.
+# Copyright (C) 2014 Sage Electronic Engineering, LLC.
#
EXIT_SUCCESS=0
@@ -12,6 +13,7 @@ EXIT_FAILURE=1
REMOTE_HOST=""
CLOBBER_OUTPUT=0
UPLOAD_RESULTS=0
+SERIAL_PORT_SPEED=115200
# Used to specify whether a command should always be run locally or
# if command should be run remoteley when a remote host is specified.
@@ -22,6 +24,7 @@ REMOTE=1
#
# $1: test command on remote host (0=no, 1=yes)
# $2: command to test
+# $3: non-fatal (0 (or blank)=no, 1=yes)
test_cmd()
{
local rc
@@ -31,7 +34,7 @@ test_cmd()
fi
if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then
- ssh root@${REMOTE_HOST} which "$2" >/dev/null
+ ssh root@${REMOTE_HOST} which "$2" > /dev/null
rc=$?
else
which "$2" >/dev/null
@@ -39,7 +42,11 @@ test_cmd()
fi
if [ $rc -eq 0 ]; then
- return
+ return 0
+ fi
+
+ if [ $3 -eq 1 ]; then
+ return 1
fi
echo "$2 not found"
@@ -52,10 +59,16 @@ _cmd()
return $EXIT_FAILURE
fi
+ if [ -n "$3" ]; then
+ pipe_location="${3}"
+ else
+ pipe_location="/dev/null"
+ fi
+
if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then
- ssh root@${REMOTE_HOST} "$2" > "${3}" 2>&1
+ ssh root@${REMOTE_HOST} "$2" > "$pipe_location" 2>&1
else
- $2 > "${3}" 2>&1
+ $2 > "$pipe_location" 2>&1
fi
return $?
@@ -96,6 +109,50 @@ cmd_nonfatal()
rm -f "$3" # don't leave an empty file
}
+# read from a serial port device
+#
+# $1: serial device to read from
+# $2: serial port speed
+# $3: filename to direct output of command into
+get_serial_bootlog () {
+
+ if [ ! -c "$1" ]; then
+ echo "$1 is not a valid serial device"
+ exit $EXIT_FAILURE
+ fi
+
+ #make the text more noticible
+ test_cmd 0 "tput" 1
+ tput_not_available=$?
+ if [ $tput_not_available -eq 0 ]; then
+ tput bold
+ tput setaf 10 #set bright green
+ fi
+
+ echo
+ echo "Waiting to receive boot log from $1"
+ echo "Press [Enter] when the boot is complete and the"
+ echo "system is ready for ssh to get the dmesg log."
+
+ if [ $tput_not_available -eq 0 ]; then
+ tput sgr0
+ fi
+
+ #set up the serial port
+ cmd 0 "stty -F $1 $2 cs8 -cstopb"
+
+ #read from the serial port - user must press enter when complete
+ test_cmd 0 "tee"
+ cat "$SERIAL_DEVICE" | tee "$3" &
+ PID=$!
+
+ read
+ kill "$PID" 2>/dev/null &
+
+ #remove the binary zero value that gets inserted into the file.
+ sed -i 's/\x00//' "$3"
+}
+
show_help() {
echo "Usage:
${0} <option>
@@ -107,12 +164,16 @@ Options
Clobber temporary output when finished. Useful for debugging.
-r <host>
Obtain machine information from remote host (using ssh).
+ -s </dev/xxx>
+ Obtain boot log via serial device.
+ -S <speed>
+ Set the port speed for the serial device (Default is 115200).
-u
Upload results to coreboot.org.
"
}
-while getopts "Chr:u" opt; do
+while getopts "Chr:s:S:u" opt; do
case "$opt" in
h)
show_help
@@ -124,6 +185,12 @@ while getopts "Chr:u" opt; do
r)
REMOTE_HOST="$OPTARG"
;;
+ s)
+ SERIAL_DEVICE="$OPTARG"
+ ;;
+ S)
+ SERIAL_PORT_SPEED="$OPTARG"
+ ;;
u)
UPLOAD_RESULTS=1
;;
@@ -138,7 +205,7 @@ fi
# Results will be placed in a temporary location until we're ready to upload.
# If the user does not wish to upload, results will remain in /tmp.
-tmpdir=$(mktemp -d)
+tmpdir=$(mktemp -d --tmpdir coreboot_board_status.XXXXXXXX)
# Obtain board and revision info to form the directory structure:
# <vendor>/<board>/<revision>/<timestamp>
@@ -170,16 +237,20 @@ printf "Upstream revision: %s\n" $($getrevision -u) >> ${tmpdir}/${results}/revi
printf "Upstream URL: %s\n" $($getrevision -U)>> ${tmpdir}/${results}/revision.txt
printf "Timestamp: %s\n" "$timestamp" >> ${tmpdir}/${results}/revision.txt
-test_cmd $REMOTE "cbmem"
-cmd $REMOTE "cbmem -c" "${tmpdir}/${results}/coreboot_console.txt"
-cmd_nonfatal $REMOTE "cbmem -t" "${tmpdir}/${results}/coreboot_timestamps.txt"
+if [ -z "$SERIAL_DEVICE" ]; then
+ test_cmd $REMOTE "cbmem"
+ cmd $REMOTE "cbmem -c" "${tmpdir}/${results}/coreboot_console.txt"
+ cmd_nonfatal $REMOTE "cbmem -t" "${tmpdir}/${results}/coreboot_timestamps.txt"
+else
+ get_serial_bootlog "$SERIAL_DEVICE" "$SERIAL_PORT_SPEED" "${tmpdir}/${results}/coreboot_console.txt"
+fi
cmd $REMOTE dmesg "${tmpdir}/${results}/kernel_log.txt"
#
# Finish up.
#
-coreboot_dir=`pwd`
+coreboot_dir=$(pwd)
if [ $UPLOAD_RESULTS -eq 1 ]; then
# extract username from ssh://<username>@review.coreboot.org/blah
username=$(git config --get remote.origin.url | sed 's/ssh\:\/\///' | sed 's/@.*//')
@@ -215,6 +286,9 @@ cd "$coreboot_dir"
if [ $CLOBBER_OUTPUT -eq 1 ]; then
rm -rf ${tmpdir}
+else
+ echo
+ echo "output files are in ${tmpdir}/${results}"
fi
exit $EXIT_SUCCESS
More information about the coreboot-gerrit
mailing list