summaryrefslogtreecommitdiff
path: root/utility/dev_debug_vboot
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2011-06-01 19:20:35 -0700
committerVadim Bendebury <vbendeb@chromium.org>2011-06-02 11:28:57 -0700
commitad3e3ac8a3e80c33d3db542f71bde11880b426d6 (patch)
treea14f612734dc26b67b23ec3ede9a785e2ef6df36 /utility/dev_debug_vboot
parent6bd03d4a88fa049bd72cf18fec701cec1dfc042b (diff)
downloadvboot-ad3e3ac8a3e80c33d3db542f71bde11880b426d6.tar.gz
Expand dev_debug_vboot to cover both x86 and arm platforms.
The script needs to use proper device names when looking for 'hard drive' and USB storage. This change makes these names platforms specific. Another change is to look for the USB device when running off SSD and include it in report if found. BUG=chromium-os:15896 TEST=manual Ran dev_debug_vboot in the four permutations (on Alex or Kaen, off USB or SSD), observed expected results reported, for instance when running off USB stick on Kaen with a valid system installed on the SSD partitions 2/4: localhost chronos # dev_debug_vboot Saving verbose log as /tmp/debug_vboot_IhtMvRsGt/noisy.log Extracting BIOS image from flash... Extracting kernel images from drives... Extracting BIOS components... Pulling root and recovery keys from GBB... Verify firmware A with root key... OK Verify firmware B with root key... OK Test kernel_subkey_a.vbpubk... OK Test kernel_subkey_b.vbpubk... OK Test hd_kern_a.blob... OK Test hd_kern_b.blob... OK Test usb_kern_a.blob... OK Verify hd_kern_a.blob with kernel_subkey_a.vbpubk... OK Verify hd_kern_b.blob with kernel_subkey_a.vbpubk... FAILED Verify usb_kern_a.blob with kernel_subkey_a.vbpubk... FAILED Verify hd_kern_a.blob with kernel_subkey_b.vbpubk... OK Verify hd_kern_b.blob with kernel_subkey_b.vbpubk... FAILED Verify usb_kern_a.blob with kernel_subkey_b.vbpubk... FAILED Verify hd_kern_a.blob with recoverykey.vbpubk... FAILED Verify hd_kern_b.blob with recoverykey.vbpubk... FAILED Verify usb_kern_a.blob with recoverykey.vbpubk... OK exporting log file as /var/log/debug_vboot_noisy.log On the same system after corrupting the SSD kernel: localhost tmp # dev_debug_vboot Saving verbose log as /tmp/debug_vboot_uLSfFS2g9/noisy.log Extracting BIOS image from flash... Extracting kernel images from drives... Extracting BIOS components... Pulling root and recovery keys from GBB... Verify firmware A with root key... OK Verify firmware B with root key... OK Test kernel_subkey_a.vbpubk... OK Test kernel_subkey_b.vbpubk... OK Test hd_kern_a.blob... FAILED Test hd_kern_b.blob... OK Test usb_kern_a.blob... OK Verify hd_kern_a.blob with kernel_subkey_a.vbpubk... FAILED Verify hd_kern_b.blob with kernel_subkey_a.vbpubk... FAILED Verify usb_kern_a.blob with kernel_subkey_a.vbpubk... FAILED Verify hd_kern_a.blob with kernel_subkey_b.vbpubk... FAILED Verify hd_kern_b.blob with kernel_subkey_b.vbpubk... FAILED Verify usb_kern_a.blob with kernel_subkey_b.vbpubk... FAILED Verify hd_kern_a.blob with recoverykey.vbpubk... FAILED Verify hd_kern_b.blob with recoverykey.vbpubk... FAILED Verify usb_kern_a.blob with recoverykey.vbpubk... OK exporting log file as /var/log/debug_vboot_noisy.log Change-Id: I4f4cd2377c6acf3db433d629ed0a5c43a5d1a76c Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: http://gerrit.chromium.org/gerrit/1938 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'utility/dev_debug_vboot')
-rwxr-xr-xutility/dev_debug_vboot52
1 files changed, 43 insertions, 9 deletions
diff --git a/utility/dev_debug_vboot b/utility/dev_debug_vboot
index ceb86588..2f0b643b 100755
--- a/utility/dev_debug_vboot
+++ b/utility/dev_debug_vboot
@@ -16,9 +16,16 @@ TMPDIR=$(mktemp -d /tmp/debug_vboot_XXXXXXXXX)
LOGFILE="${TMPDIR}/noisy.log"
PUBLOGFILE="/var/log/debug_vboot_noisy.log"
-# TODO(wfrichar): Need to support ARM. The hard disk path is likely different.
-# We can use 'crossystem arch' to distinguish between x86 and ARM.
-HD=/dev/sda
+ARCH="$(crossystem arch)"
+ROOT_BASE=$(rootdev -s -d)
+
+if [ "${ARCH}" = "arm" ]; then
+ HD='/dev/mmcblk0'
+ PARTITION_PREFIX='p'
+else
+ HD='/dev/sda'
+ PARTITION_PREFIX=''
+fi
cleanup() {
if [ -z "${USE_EXISTING:-}" ]; then
@@ -90,6 +97,28 @@ find_name() {
exit 1
}
+# Iterate through block devices, as soon as the first removable USB device
+# which is not mounted as root file system is found - consider it the USB
+# flash stick and return its device name.
+find_usb_device() {
+ dm_dev=$(rootdev | cut -f3 -d/)
+ real_dev=$(echo ${ROOT_BASE} | cut -f3 -d/)
+ block_dir='/sys/block'
+ for d in $(ls ${block_dir}); do
+ if [ "$d" = "${dm_dev}" -o "$d" = "${real_dev}" ]; then
+ continue # Skip root file system.
+ fi
+ if [ "$(readlink -f ${block_dir}/$d | grep usb)" = "" ]; then
+ continue # Not a usb device.
+ fi
+ r=${block_dir}/$d/removable
+ if [ -f $r -a "$(cat $r)" = "1" ]; then
+ echo /dev/$d
+ return
+ fi
+ done
+}
+
# Here we go...
umask 022
trap cleanup EXIT
@@ -122,13 +151,18 @@ else
log flashrom -p internal:bus=spi --wp-status
log flashrom -p internal:bus=spi -r ${BIOS}
- HD_KERN_A="${HD}2"
- HD_KERN_B="${HD}4"
- tmp=$(rootdev -s -d)2
- if [ "$tmp" != "$HD_KERN_A" ]; then
- USB_KERN_A="$tmp"
- fi
+ HD_KERN_A="${HD}${PARTITION_PREFIX}2"
+ HD_KERN_B="${HD}${PARTITION_PREFIX}4"
+ if [ "${ROOT_BASE}" != "${HD}" ]; then
+ # Not running off HD, must be ruining off USB.
+ USB_KERN_A="${ROOT_BASE}2"
+ else
+ USB_DEV="$(find_usb_device)"
+ if [ -n "${USB_DEV}" ]; then
+ USB_KERN_A="${USB_DEV}2"
+ fi
+ 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