8 # Stuff from command-line switches
9 COREBOOT_IMAGE
="build/coreboot.rom"
14 SERIAL_PORT_SPEED
=115200
16 # Used to specify whether a command should always be run locally or
17 # if command should be run remoteley when a remote host is specified.
23 # Used if cbmem is not in default $PATH, e.g. not installed or when using `sudo`
26 # Used if nvramtool is not in default $PATH, e.g. not installed or when using `sudo`
31 # $1: 0 ($LOCAL) to run command locally,
32 # 1 ($REMOTE) to run remotely if remote host defined
34 # $3: 0 ($FATAL) Exit with an error if the command fails
35 # 1 ($NONFATAL) Don't exit on command test failure
44 if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then
45 ssh $REMOTE_PORT_OPTION root@
${REMOTE_HOST} command -v "$2" > /dev
/null
48 command -v "$2" >/dev
/null
52 if [ $rc -eq 0 ]; then
56 if [ "$3" = "1" ]; then
73 pipe_location
="/dev/null"
76 if [ "$1" -eq "$REMOTE" ] && [ -n "$REMOTE_HOST" ]; then
77 ssh $REMOTE_PORT_OPTION "root@${REMOTE_HOST}" "$2" > "$pipe_location" 2>&1
79 $2 > "$pipe_location" 2>&1
87 # $1: 0 ($LOCAL) to run command locally,
88 # 1 ($REMOTE) to run remotely if remote host defined
90 # $3: filename to direct output of command into
99 echo "Failed to run \"$2\", aborting"
100 rm -f "$3" # don't leave an empty file
104 # run a command where failure is considered to be non-fatal
106 # $1: 0 ($LOCAL) to run command locally,
107 # 1 ($REMOTE) to run remotely if remote host defined
109 # $3: filename to direct output of command into
114 if [ $?
-eq 0 ]; then
118 echo "Failed to run \"$2\", ignoring"
119 rm -f "$3" # don't leave an empty file
122 # read from a serial port device
124 # $1: serial device to read from
125 # $2: serial port speed
126 # $3: filename to direct output of command into
127 get_serial_bootlog
() {
133 if [ ! -c "$TTY" ]; then
134 echo "$TTY is not a valid serial device"
138 # make the text more noticible
139 test_cmd
$LOCAL "tput" $NONFATAL
140 tput_not_available
=$?
141 if [ $tput_not_available -eq 0 ]; then
143 tput setaf
10 # set bright green
147 echo "Waiting to receive boot log from $TTY"
148 echo "Press [Enter] when the boot is complete."
151 if [ $tput_not_available -eq 0 ]; then
155 # set up the serial port
156 stty
-F $TTY $SPEED cs8
-cstopb -parenb clocal
158 # read from the serial port - user must press enter when complete
159 test_cmd
$LOCAL "tee"
161 echo "$LINE" |
tee -a "$FILENAME"
162 done < "$SERIAL_DEVICE" &
166 kill "$PID" 2>/dev
/null
168 echo "Finished reading boot log."
177 Path to cbmem on device under test (DUT).
179 Path to nvramtool on device under test (DUT).
181 Clobber temporary output when finished. Useful for debugging.
185 Path to coreboot image (Default is $COREBOOT_IMAGE).
186 -r, --remote-host <host>
187 Obtain machine information from remote host (using ssh).
188 -s, --serial-device </dev/xxx>
189 Obtain boot log via serial device.
190 -S, --serial-speed <speed>
191 Set the port speed for the serial device (Default is $SERIAL_PORT_SPEED).
193 Upload results to coreboot.org.
197 Use a specific SSH port.
202 if [ $?
-ne 4 ]; then
203 echo "GNU-compatible getopt(1) required."
207 LONGOPTS
="cbmem:,clobber,help,image:,remote-host:,upload-results"
208 LONGOPTS
="${LONGOPTS},serial-device:,serial-speed:"
209 LONGOPTS
="${LONGOPTS},ssh-port:"
211 ARGS
=$
(getopt
-o c
:n
:Chi
:r
:s
:S
:u
-l "$LONGOPTS" -n "$0" -- "$@");
212 if [ $?
!= 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
244 # serial port options
251 SERIAL_PORT_SPEED
="$1"
257 REMOTE_PORT_OPTION
="-p $1"
264 echo "Non-option parameters detected: '$*'"
270 echo "error processing options at '$1'"
276 grep -rH 'coreboot.org' .git
/config
>/dev
/null
2>&1
277 if [ $?
-ne 0 ]; then
278 echo "Script must be run from root of coreboot directory"
282 if [ ! -e "$COREBOOT_IMAGE" ]; then
283 echo "board_status needs $COREBOOT_IMAGE, but it does not exist."
284 echo "Use \"-i IMAGE_FILE\" to select a different image, or \"--help\" for more options."
288 # Results will be placed in a temporary location until we're ready to upload.
289 # If the user does not wish to upload, results will remain in /tmp.
290 tmpdir
=$
(mktemp
-d --tmpdir coreboot_board_status.XXXXXXXX
)
292 # Obtain coreboot config by running cbfstool on the ROM image. cbfstool may
293 # already exist in build/ or util/cbfstool/, but if not then we'll build it
294 # now and clean it when we're done.
295 cbfstool_cmd
="build/cbfstool"
297 if [ ! -x $cbfstool_cmd ]; then
298 cbfstool_cmd
="util/cbfstool/cbfstool"
299 if [ -e $cbfstool_cmd ]; then
300 if test ! -x $cbfstool_cmd; then
301 echo "Cannot execute $cbfstool_cmd."
305 make -C util
/cbfstool
/
309 test_cmd
$LOCAL "$cbfstool_cmd"
311 tmpcfg
=$
(mktemp coreboot_config.XXXXXX
)
312 echo "Extracting config.txt from $COREBOOT_IMAGE"
313 $cbfstool_cmd "$COREBOOT_IMAGE" extract
-n config
-f "${tmpdir}/config.txt" >/dev
/null
2>&1
314 mv "${tmpdir}/config.txt" "${tmpdir}/config.short.txt"
315 cp "${tmpdir}/config.short.txt" "${tmpcfg}"
316 yes "" |
make "DOTCONFIG=${tmpcfg}" oldconfig
2>/dev
/null
>/dev
/null
317 mv "${tmpcfg}" "${tmpdir}/config.txt"
318 rm -f "${tmpcfg}.old"
319 $cbfstool_cmd "$COREBOOT_IMAGE" print
> "${tmpdir}/cbfs.txt"
320 rom_contents
=$
($cbfstool_cmd "$COREBOOT_IMAGE" print
2>&1)
321 if [ -n "$(echo $rom_contents | grep payload_config)" ]; then
322 echo "Extracting payload_config from $COREBOOT_IMAGE"
323 $cbfstool_cmd "$COREBOOT_IMAGE" extract
-n payload_config
-f "${tmpdir}/payload_config.txt" >/dev
/null
2>&1
325 if [ -n "$(echo $rom_contents | grep payload_version)" ]; then
326 echo "Extracting payload_version from $COREBOOT_IMAGE"
327 $cbfstool_cmd "$COREBOOT_IMAGE" extract
-n payload_version
-f "${tmpdir}/payload_version.txt" >/dev
/null
2>&1
329 md5sum -b "$COREBOOT_IMAGE" > "${tmpdir}/rom_checksum.txt"
331 if test $do_clean_cbfstool -eq 1; then
332 make -C util
/cbfstool clean
335 # Obtain board and revision info to form the directory structure:
336 # <vendor>/<board>/<revision>/<timestamp>
337 mainboard_dir
="$(grep CONFIG_MAINBOARD_DIR "${tmpdir}/config.txt
" | awk -F '"' '{ print
$2 }')"
338 vendor=$(echo "$mainboard_dir" | awk -F '/' '{ print
$1 }')
339 mainboard=$(echo "$mainboard_dir" | awk -F '/' '{ print
$2 }')
341 getrevision="util/board_status/getrevision.sh"
342 test_cmd $LOCAL $getrevision
343 tagged_version=$($getrevision -T)
344 timestamp=$($getrevision -t)
346 results="${vendor}/${mainboard}/${tagged_version}/${timestamp}"
348 if [ -n "$(echo $tagged_version | grep dirty)" ]; then
349 echo "The repository is in a dirty state. Please see the output of"
350 echo "'git status
' below."
355 echo "Temporarily placing output in ${tmpdir}/${results}"
356 mkdir -p "${tmpdir}/${results}"
358 mv "${tmpdir}/config.txt" "${tmpdir}/${results}"
359 test -f "${tmpdir}/payload_config.txt" && mv "${tmpdir}/payload_config.txt" "${tmpdir}/${results}"
360 test -f "${tmpdir}/payload_version.txt" && mv "${tmpdir}/payload_version.txt" "${tmpdir}/${results}"
361 mv "${tmpdir}/config.short.txt" "${tmpdir}/${results}"
362 mv "${tmpdir}/cbfs.txt" "${tmpdir}/${results}"
363 mv "${tmpdir}/rom_checksum.txt" "${tmpdir}/${results}"
365 touch "${tmpdir}/${results}/revision.txt"
366 printf "Local revision: %s\n" "$($getrevision -l)" >> "${tmpdir}/${results}/revision.txt"
367 printf "Tagged revision: %s\n" "${tagged_version}" >> "${tmpdir}/${results}/revision.txt"
368 printf "Upstream revision: %s\n" "$($getrevision -u)" >> "${tmpdir}/${results}/revision.txt"
369 printf "Upstream URL: %s\n" "$($getrevision -U)" >> "${tmpdir}/${results}/revision.txt"
370 printf "Timestamp: %s\n" "$timestamp" >> "${tmpdir}/${results}/revision.txt"
372 if [ -n "$CBMEM_PATH" ]; then
373 cbmem_cmd="$CBMEM_PATH"
379 if grep -q "CONFIG_USE_OPTION_TABLE=y" "${tmpdir}/${results}/config.short.txt" > /dev/null; then
383 if [ -n "$NVRAMTOOL_PATH" ]; then
384 nvramtool_cmd="$NVRAMTOOL_PATH"
386 nvramtool_cmd="nvramtool"
389 if [ -n "$SERIAL_DEVICE" ]; then
390 get_serial_bootlog "$SERIAL_DEVICE" "$SERIAL_PORT_SPEED" "${tmpdir}/${results}/coreboot_console.txt"
391 elif [ -n "$REMOTE_HOST" ]; then
392 echo "Verifying that CBMEM is available on remote device"
393 test_cmd $REMOTE "$cbmem_cmd"
394 echo "Getting coreboot boot log"
395 cmd $REMOTE "$cbmem_cmd -1" "${tmpdir}/${results}/coreboot_console.txt"
396 echo "Getting timestamp data"
397 cmd_nonfatal $REMOTE "$cbmem_cmd -t" "${tmpdir}/${results}/coreboot_timestamps.txt"
399 if [ "$cmos_enabled" -eq 1 ]; then
400 echo "Verifying that nvramtool is available on remote device"
401 test_cmd $REMOTE "$nvramtool_cmd"
402 echo "Getting all CMOS values"
403 cmd $REMOTE "$nvramtool_cmd -a" "${tmpdir}/${results}/cmos_values.txt"
406 echo "Getting remote dmesg"
407 cmd $REMOTE dmesg "${tmpdir}/${results}/kernel_log.txt"
409 echo "Verifying that CBMEM is available"
410 if [ $(id -u) -ne 0 ]; then
411 command -v "$cbmem_cmd" >/dev/null
412 if [ $? -ne 0 ]; then
413 echo "Failed to run $cbmem_cmd. Check \$PATH or" \
414 "use -c to specify path to cbmem binary."
417 cbmem_cmd="sudo $cbmem_cmd"
420 test_cmd $LOCAL "$cbmem_cmd"
423 echo "Getting coreboot boot log"
424 cmd $LOCAL "$cbmem_cmd -1" "${tmpdir}/${results}/coreboot_console.txt"
426 echo "Getting timestamp data"
427 cmd_nonfatal $LOCAL "$cbmem_cmd -t" "${tmpdir}/${results}/coreboot_timestamps.txt"
429 if [ "$cmos_enabled" -eq 1 ]; then
430 echo "Verifying that nvramtool is available"
431 if [ $(id -u) -ne 0 ]; then
432 command -v "$nvramtool_cmd" >/dev/null
433 if [ $? -ne 0 ]; then
434 echo "Failed to run $nvramtool_cmd. Check \$PATH or" \
435 "use -n to specify path to nvramtool binary."
438 nvramtool_cmd="sudo $nvramtool_cmd"
441 test_cmd $LOCAL "$nvramtool_cmd"
444 echo "Getting all CMOS values"
445 cmd $LOCAL "$nvramtool_cmd -a" "${tmpdir}/${results}/cmos_values.txt"
448 echo "Getting local dmesg"
449 cmd $LOCAL "sudo dmesg" "${tmpdir}/${results}/kernel_log.txt"
455 if [ $(grep -- -dirty "${tmpdir}/${results}/coreboot_console.txt") ]; then
456 echo "coreboot or the payload are built from a source tree in a" \
457 "dirty state, making it hard to reproduce the result. Please" \
458 "check in your source tree with 'git status
'."
462 if [ $(grep -- unknown "${tmpdir}/${results}/coreboot_timestamps.txt") ]; then
463 echo "Unknown timestamps found in 'coreboot_timestamps.txt
'." \
464 "Please rebuild the 'cbmem
' utility and try again."
472 if [ $UPLOAD_RESULTS -eq 1 ]; then
473 # extract username from ssh://<username>@review.coreboot.org/blah
474 bsrepo=$(git config --get remote.origin.url | sed "s,\(.*\)/coreboot,\1/board-status,")
476 cd "util/board_status/"
477 if [ ! -e "board-status" ]; then
478 # FIXME: the board-status directory might get big over time.
479 # Is there a way we can push the results without fetching the
482 if [ $? -ne 0 ]; then
483 echo "Error cloning board-status repo, aborting."
490 echo "Checking for duplicate results"
491 # get any updates to board-status
494 echo "${tagged_version}" | grep dirty >/dev/null 2>&1
496 existing_results=$(git ls-files "${mainboard_dir}/${tagged_version}")
498 # reject duplicate results of non-dirty versions
499 if [ "${clean_version}" -eq 1 ] && [ -n "${existing_results}" ] ; then
500 echo "Result is a duplicate, aborting"
504 echo "Copying results to $(pwd)/${results}"
506 # Note: Result directory should be unique due to the timestamp.
507 cp -R "${tmpdir}/${vendor}" .
509 echo "Uploading results"
511 git commit -a -m "${mainboard_dir}/${tagged_version}/${timestamp}"
513 until git push origin master || test $count -eq 3; do
518 # Results have been uploaded so it's pointless to keep the
519 # temporary files around.
521 if test $count -eq 3; then
522 echo "Error uploading to board-status repo, aborting."
528 if [ $CLOBBER_OUTPUT -eq 1 ]; then
531 if [ $UPLOAD_RESULTS -eq 1 ]; then
533 echo "output files are in $(dirname $0)/board-status/${mainboard_dir}/${tagged_version}/${timestamp}"
536 echo "output files are in ${tmpdir}/${results}"