Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(804)

Unified Diff: scripts/image_signing/unpack_firmwarefd.sh

Issue 3026018: Add script for re-signing final firmware images with the correct keys. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: . Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « scripts/image_signing/resign_firmwarefd.sh ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/image_signing/unpack_firmwarefd.sh
diff --git a/scripts/image_signing/unpack_firmwarefd.sh b/scripts/image_signing/unpack_firmwarefd.sh
new file mode 100755
index 0000000000000000000000000000000000000000..a9a0f9fbad5a25acd771b571efc594af572dd1fd
--- /dev/null
+++ b/scripts/image_signing/unpack_firmwarefd.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+
+# 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.
+
+# Script that unpacks a firmware image (in .fd format) into its component
+# pieces. Only outputs firmware A and B data, vblocks and the GBB.
+
+# The fmap_decode tool must be in the system path.
+
+# Abort on error
+set -e
+
+# Check arguments
+if [ $# -ne 1 ] ; then
+ echo "Usage: $0 src_fd"
+ echo "Outputs firmware.gbb, firmware[A|B].[data|vblock]"
+ exit 1
+fi
+
+# Make sure the tools we need are available.
+type -P fmap_decode &>/dev/null || \
+ { echo "fmap_decode tool not found."; exit 1; }
+
+src_fd=$1
+
+# Parse offsets and size of firmware data and vblocks
+let gbb_offset="$(fmap_decode $1 | grep GBB | cut -b 14-23)"
+let gbb_size="$(fmap_decode $1 | grep GBB | cut -b 37-46)"
+set -x
+for i in "A" "B"
+do
+ match_str="$i Key"
+ eval let \
+ fw${i}_vblock_offset="$(fmap_decode $1 | grep "$match_str" | cut -b 14-23)"
+ eval let \
+ fw${i}_vblock_size="$(fmap_decode $1 | grep "$match_str" | cut -b 37-46)"
+
+ match_str="$i Data"
+ eval let fw${i}_offset="$(fmap_decode $1 | grep "$match_str" | cut -b 14-23)"
+ eval let fw${i}_size="$(fmap_decode $1 | grep "$match_str" | cut -b 37-46)"
+done
+
+echo "Extracting GBB"
+dd if="${src_fd}" of="firmware.gbb" skip="${gbb_offset}" bs=1 \
+ count="${gbb_size}"
+echo "Extracting Firmware data and vblock(s)"
+dd if="${src_fd}" of="firmwareA.data" skip="${fwA_offset}" bs=1 \
+ count="${fwA_size}"
+dd if="${src_fd}" of="firmwareA.vblock" skip="${fwA_vblock_offset}" bs=1 \
+ count="${fwA_vblock_size}"
+dd if="${src_fd}" of="firmwareB.data" skip="${fwB_offset}" bs=1 \
+ count="${fwB_size}"
+dd if="${src_fd}" of="firmwareB.vblock" skip="${fwB_vblock_offset}" bs=1 \
+ count="${fwB_vblock_size}"
« no previous file with comments | « scripts/image_signing/resign_firmwarefd.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698