blob: 39f2a3b4e998c8f342daf193f52a73940ad72551 [file] [log] [blame]
Yegor Timoshenkoc2e49412018-10-07 01:58:27 +00001#!/usr/bin/env bash
Joe Pillow9a4881a2016-02-19 15:18:14 -08002#
Patrick Georgi7333a112020-05-08 20:48:04 +02003# SPDX-License-Identifier: GPL-2.0-only
Joe Pillow9a4881a2016-02-19 15:18:14 -08004
Yegor Timoshenkoc2e49412018-10-07 01:58:27 +00005set -x
6
Joe Pillow9a4881a2016-02-19 15:18:14 -08007IMAGE=$1
8
9if [ ! -r "$IMAGE" ]; then
10 echo "Can't find image $IMAGE."
11 exit 1
12fi
13
14CBFSTOOL=$(which cbfstool)
15if [ $? != 0 ]; then
16 echo "Can't find cbfstool."
17 exit 1
18fi
19
20IFDTOOL=$(which ifdtool)
21if [ $? != 0 ]; then
22 echo "Can't find ifdtool."
23 exit 1
24fi
25
26$CBFSTOOL $IMAGE print
27
28if [ $? -ne 0 ]; then
29 echo "Not a coreboot image: $IMAGE"
30 exit 1
31fi
32
33PCI=$($CBFSTOOL $IMAGE print|grep pci|cut -f1 -d\ )
34MRC=$($CBFSTOOL $IMAGE print|grep mrc.bin|cut -f1 -d\ )
35
36$CBFSTOOL $IMAGE extract -n $PCI -f $PCI
37$CBFSTOOL $IMAGE extract -n $MRC -f $MRC
38$IFDTOOL -x $IMAGE
39mv flashregion_0_flashdescriptor.bin flashdescriptor.bin
40mv flashregion_2_intel_me.bin me.bin
41rm flashregion_*.bin