| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 2 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 # | 5 # |
| 6 # Usage: dev_debug_vboot [ --cleanup | DIRECTORY ] |
| 7 # |
| 8 # This extracts some useful debugging information about verified boot. A short |
| 9 # summary is printed on stdout, more detailed information and working files are |
| 10 # left in a log directory. |
| 11 # |
| 6 | 12 |
| 13 TMPDIR=/tmp/debug_vboot |
| 7 LOGFILE=noisy.log | 14 LOGFILE=noisy.log |
| 8 | 15 |
| 16 # TODO(wfrichar): Need to support ARM. The hard disk path is likely different. |
| 17 HD=/dev/sda |
| 18 ACPI=/sys/devices/platform/chromeos_acpi |
| 19 |
| 20 cleanup() { |
| 21 if [ -n "${CLEANUP}" ]; then |
| 22 find "${TMPDIR}" -type f -not -name "${LOGFILE}" -exec rm {} ";" |
| 23 fi |
| 24 } |
| 25 |
| 9 die() { | 26 die() { |
| 10 echo "$*" 1>&2 | 27 echo "$*" 1>&2 |
| 11 exit 1 | 28 exit 1 |
| 12 } | 29 } |
| 13 | 30 |
| 14 info() { | 31 info() { |
| 15 echo "$@" | 32 echo "$@" |
| 16 echo "#" "$@" >> "$LOGFILE" | 33 echo "#" "$@" >> "$LOGFILE" |
| 17 } | 34 } |
| 18 | 35 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 33 } | 50 } |
| 34 | 51 |
| 35 result() { | 52 result() { |
| 36 if [ "$?" = "0" ]; then | 53 if [ "$?" = "0" ]; then |
| 37 info "OK" | 54 info "OK" |
| 38 else | 55 else |
| 39 info "FAILED" | 56 info "FAILED" |
| 40 fi | 57 fi |
| 41 } | 58 } |
| 42 | 59 |
| 43 # Optional directory name containing "bios.rom" and "*kern*.blob" files. If not | 60 require_chromeos_bios() { |
| 44 # provided, we'll attempt to extract them ourselves. | 61 log cgpt show "${HD}" |
| 45 if [ -d "$1" ]; then | 62 log rootdev -s |
| 46 TMPDIR="$1" | 63 if [ ! -e "${ACPI}/HWID" ]; then |
| 47 [ -d ${TMPDIR} ] || die "${TMPDIR} doesn't exist" | 64 info "Not running Chrome OS BIOS, no further information available" |
| 48 USE_EXISTING=yes | 65 exit 0 |
| 49 else | 66 fi |
| 50 TMPDIR=/tmp/debug_vboot | 67 # including /dev/null just to get final "\n" |
| 51 [ -d ${TMPDIR} ] || mkdir -p ${TMPDIR} | 68 log head "${ACPI}"/*ID "${ACPI}"/BINF* "${ACPI}"/CHSW /dev/null |
| 69 } |
| 70 |
| 71 # Here we go... |
| 72 trap cleanup EXIT |
| 73 |
| 74 # Parse args |
| 75 if [ -n "$1" ]; then |
| 76 if [ "$1" = "--cleanup" ]; then |
| 77 CLEANUP=1 |
| 78 else |
| 79 TMPDIR="$1" |
| 80 [ -d ${TMPDIR} ] || die "${TMPDIR} doesn't exist" |
| 81 USE_EXISTING=yes |
| 82 fi |
| 52 fi | 83 fi |
| 53 | 84 |
| 85 [ -d ${TMPDIR} ] || mkdir -p ${TMPDIR} || exit 1 |
| 54 cd ${TMPDIR} | 86 cd ${TMPDIR} |
| 55 echo "$0 $*" > "$LOGFILE" | 87 echo "$0 $*" > "$LOGFILE" |
| 56 log date | 88 log date |
| 57 echo "Saving verbose log as $(pwd)/$LOGFILE" | 89 echo "Saving verbose log as $(pwd)/$LOGFILE" |
| 58 | 90 |
| 59 BIOS=bios.rom | 91 BIOS=bios.rom |
| 60 | 92 |
| 61 # Find BIOS and kernel images | 93 # Find BIOS and kernel images |
| 62 if [ -n "$USE_EXISTING" ]; then | 94 if [ -n "$USE_EXISTING" ]; then |
| 63 info "Using images in $(pwd)/" | 95 info "Using images in $(pwd)/" |
| 64 else | 96 else |
| 97 require_chromeos_bios |
| 65 info "Extracting BIOS image from flash..." | 98 info "Extracting BIOS image from flash..." |
| 66 log flashrom -r ${BIOS} | 99 log flashrom -r ${BIOS} |
| 67 | 100 |
| 68 # FIXME: support ARM | 101 HD_KERN_A="${HD}2" |
| 69 HD_KERN_A=/dev/sda2 | 102 HD_KERN_B="${HD}4" |
| 70 HD_KERN_B=/dev/sda4 | |
| 71 tmp=$(rootdev -s -d)2 | 103 tmp=$(rootdev -s -d)2 |
| 72 if [ "$tmp" != "$HD_KERN_A" ]; then | 104 if [ "$tmp" != "$HD_KERN_A" ]; then |
| 73 USB_KERN_A="$tmp" | 105 USB_KERN_A="$tmp" |
| 74 fi | 106 fi |
| 75 | 107 |
| 76 info "Extracting kernel images from drives..." | 108 info "Extracting kernel images from drives..." |
| 77 log dd if=${HD_KERN_A} of=hd_kern_a.blob | 109 log dd if=${HD_KERN_A} of=hd_kern_a.blob |
| 78 log dd if=${HD_KERN_B} of=hd_kern_b.blob | 110 log dd if=${HD_KERN_B} of=hd_kern_b.blob |
| 79 if [ -n "$USB_KERN_A" ]; then | 111 if [ -n "$USB_KERN_A" ]; then |
| 80 log dd if=${USB_KERN_A} of=usb_kern_a.blob | 112 log dd if=${USB_KERN_A} of=usb_kern_a.blob |
| (...skipping 30 matching lines...) Expand all Loading... |
| 111 log vbutil_keyblock --unpack $keyblock ; result | 143 log vbutil_keyblock --unpack $keyblock ; result |
| 112 done | 144 done |
| 113 | 145 |
| 114 # Test each kernel with each key | 146 # Test each kernel with each key |
| 115 for key in kernel_subkey_a.vbpubk kernel_subkey_b.vbpubk recoverykey.vbpubk; do | 147 for key in kernel_subkey_a.vbpubk kernel_subkey_b.vbpubk recoverykey.vbpubk; do |
| 116 for kern in *kern*.blob; do | 148 for kern in *kern*.blob; do |
| 117 infon "Verify $kern with $key... " | 149 infon "Verify $kern with $key... " |
| 118 log vbutil_kernel --verify $kern --signpubkey $key ; result | 150 log vbutil_kernel --verify $kern --signpubkey $key ; result |
| 119 done | 151 done |
| 120 done | 152 done |
| OLD | NEW |