mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-25 01:07:22 +00:00
* Display only the synopsis on stdout * Keep a verbose log of all activity in the scratch directory. * Add more checks * Providing a directory argument will use the images found there instead of trying to extract them from the system (for use on host machines). Change-Id: I065a18c9467c625cc33484ee5556d955dc79b01d BUG=none TEST=manual Get a root shell and run "dev_debug_vboot". You should see nicer output. Review URL: http://codereview.chromium.org/4106001
121 lines
2.9 KiB
Bash
Executable File
121 lines
2.9 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
#
|
|
|
|
LOGFILE=noisy.log
|
|
|
|
die() {
|
|
echo "$*" 1>&2
|
|
exit 1
|
|
}
|
|
|
|
info() {
|
|
echo "$@"
|
|
echo "#" "$@" >> "$LOGFILE"
|
|
}
|
|
|
|
infon() {
|
|
echo -n "$@"
|
|
echo "#" "$@" >> "$LOGFILE"
|
|
}
|
|
|
|
log() {
|
|
echo "+" "$@" >> "$LOGFILE"
|
|
"$@" >> "$LOGFILE" 2>&1
|
|
}
|
|
|
|
logdie() {
|
|
echo "+" "$@" >> "$LOGFILE"
|
|
"$@" >> "$LOGFILE" 2>&1
|
|
die "$@"
|
|
}
|
|
|
|
result() {
|
|
if [ "$?" = "0" ]; then
|
|
info "OK"
|
|
else
|
|
info "FAILED"
|
|
fi
|
|
}
|
|
|
|
# Optional directory name containing "bios.rom" and "*kern*.blob" files. If not
|
|
# provided, we'll attempt to extract them ourselves.
|
|
if [ -d "$1" ]; then
|
|
TMPDIR="$1"
|
|
[ -d ${TMPDIR} ] || die "${TMPDIR} doesn't exist"
|
|
USE_EXISTING=yes
|
|
else
|
|
TMPDIR=/tmp/debug_vboot
|
|
[ -d ${TMPDIR} ] || mkdir -p ${TMPDIR}
|
|
fi
|
|
|
|
cd ${TMPDIR}
|
|
echo "$0 $*" > "$LOGFILE"
|
|
log date
|
|
echo "Saving verbose log as $(pwd)/$LOGFILE"
|
|
|
|
BIOS=bios.rom
|
|
|
|
# Find BIOS and kernel images
|
|
if [ -n "$USE_EXISTING" ]; then
|
|
info "Using images in $(pwd)/"
|
|
else
|
|
info "Extracting BIOS image from flash..."
|
|
log flashrom -r ${BIOS}
|
|
|
|
# FIXME: support ARM
|
|
HD_KERN_A=/dev/sda2
|
|
HD_KERN_B=/dev/sda4
|
|
tmp=$(rootdev -s -d)2
|
|
if [ "$tmp" != "$HD_KERN_A" ]; then
|
|
USB_KERN_A="$tmp"
|
|
fi
|
|
|
|
info "Extracting kernel images from drives..."
|
|
log dd if=${HD_KERN_A} of=hd_kern_a.blob
|
|
log dd if=${HD_KERN_B} of=hd_kern_b.blob
|
|
if [ -n "$USB_KERN_A" ]; then
|
|
log dd if=${USB_KERN_A} of=usb_kern_a.blob
|
|
fi
|
|
fi
|
|
|
|
# Make sure we have something to work on
|
|
[ -f "$BIOS" ] || logdie "no BIOS image found"
|
|
ls *kern*.blob >/dev/null 2>&1 || logdie "no kernel images found"
|
|
|
|
info "Extracting BIOS components..."
|
|
log dump_fmap -x ${BIOS} || logdie "Unable to extract BIOS components"
|
|
|
|
info "Pulling root and recovery keys from GBB..."
|
|
log gbb_utility -g --rootkey rootkey.vbpubk --recoverykey recoverykey.vbpubk \
|
|
GBB_Area || logdie "Unable to extract keys from GBB"
|
|
log vbutil_key --unpack rootkey.vbpubk
|
|
log vbutil_key --unpack recoverykey.vbpubk
|
|
|
|
infon "Verify firmware A with root key... "
|
|
log vbutil_firmware --verify Firmware_A_Key --signpubkey rootkey.vbpubk \
|
|
--fv Firmware_A_Data --kernelkey kernel_subkey_a.vbpubk ; result
|
|
infon "Verify firmware B with root key... "
|
|
log vbutil_firmware --verify Firmware_B_Key --signpubkey rootkey.vbpubk \
|
|
--fv Firmware_B_Data --kernelkey kernel_subkey_b.vbpubk ; result
|
|
|
|
for key in kernel_subkey_a.vbpubk kernel_subkey_b.vbpubk; do
|
|
infon "Test $key... "
|
|
log vbutil_key --unpack $key ; result
|
|
done
|
|
|
|
for keyblock in *kern*.blob; do
|
|
infon "Test $keyblock... "
|
|
log vbutil_keyblock --unpack $keyblock ; result
|
|
done
|
|
|
|
# Test each kernel with each key
|
|
for key in kernel_subkey_a.vbpubk kernel_subkey_b.vbpubk recoverykey.vbpubk; do
|
|
for kern in *kern*.blob; do
|
|
infon "Verify $kern with $key... "
|
|
log vbutil_kernel --verify $kern --signpubkey $key ; result
|
|
done
|
|
done
|