Skip to content

Commit

Permalink
Add script which extracts blobs from romdump.
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed May 30, 2020
1 parent 04b6557 commit 6e19100
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions blobs/t430s/extract.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

function printusage {
echo "Usage: $0 -f <romdump> -m <me_cleaner> -i <ifdtool>"
exit 0
}

BLOBDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MECLEAN="$BLOBDIR/me_cleaner/me_cleaner.py"
IFDTOOL="$BLOBDIR/ifdtool/ifdtool"

if [ "$#" -eq 0 ] || [ "$1" == "-h" ] || [ "$1" == "--help" ];
then printusage; fi

while getopts ":f:m:i:" opt; do
case $opt in
f)
FILE="$OPTARG"
;;
m)
if [ -x "$OPTARG" ]; then
MECLEAN="$OPTARG"
fi
;;
i)
if [ -x "$OPTARG" ]; then
IFDTOOL="$OPTARG"
fi
;;
esac
done

if [ ! -f "$FILE" ]; then
echo "romdump required but not found. Aborting."
exit 1;
fi

if [ ! -f "$MECLEAN" ]; then
echo "me_cleaner.py required but not found. Aborting."
exit 1;
fi
MECLEAN=$(realpath $MECLEAN)

if [ ! -f "$IFDTOOL" ]; then
echo "ifdtool required but not found. Aborting."
exit 1;
fi
IFDTOOL=$(realpath $IFDTOOL)

echo "FILE: $FILE"
echo "ME: $MECLEAN"
echo "IFD: $IFDTOOL"

bioscopy=$(mktemp)
extractdir=$(mktemp -d)

cp "$FILE" $bioscopy

cd "$extractdir"
$IFDTOOL -x $bioscopy
cp "$extractdir/flashregion_3_gbe.bin" "$BLOBDIR/gbe.bin"
$MECLEAN -O "$BLOBDIR/me.bin" -r -t "$extractdir/flashregion_2_intel_me.bin"
$IFDTOOL -n "$BLOBDIR/layout.txt" $bioscopy
$IFDTOOL -x $bioscopy.new
cp "$extractdir/flashregion_0_flashdescriptor.bin" "$BLOBDIR/ifd.bin"

rm "$bioscopy"
rm "$bioscopy.new"
rm -r "$extractdir"

0 comments on commit 6e19100

Please sign in to comment.