Yegor Timoshenko | c2e4941 | 2018-10-07 01:58:27 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Joe Pillow | 9a4881a | 2016-02-19 15:18:14 -0800 | [diff] [blame] | 2 | # |
Patrick Georgi | 7333a11 | 2020-05-08 20:48:04 +0200 | [diff] [blame] | 3 | # SPDX-License-Identifier: GPL-2.0-only |
Joe Pillow | 9a4881a | 2016-02-19 15:18:14 -0800 | [diff] [blame] | 4 | |
Yegor Timoshenko | c2e4941 | 2018-10-07 01:58:27 +0000 | [diff] [blame] | 5 | set -x |
| 6 | |
Joe Pillow | 9a4881a | 2016-02-19 15:18:14 -0800 | [diff] [blame] | 7 | IMAGE=$1 |
| 8 | |
| 9 | if [ ! -r "$IMAGE" ]; then |
| 10 | echo "Can't find image $IMAGE." |
| 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | CBFSTOOL=$(which cbfstool) |
| 15 | if [ $? != 0 ]; then |
| 16 | echo "Can't find cbfstool." |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | IFDTOOL=$(which ifdtool) |
| 21 | if [ $? != 0 ]; then |
| 22 | echo "Can't find ifdtool." |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
| 26 | $CBFSTOOL $IMAGE print |
| 27 | |
| 28 | if [ $? -ne 0 ]; then |
| 29 | echo "Not a coreboot image: $IMAGE" |
| 30 | exit 1 |
| 31 | fi |
| 32 | |
| 33 | PCI=$($CBFSTOOL $IMAGE print|grep pci|cut -f1 -d\ ) |
| 34 | MRC=$($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 |
| 39 | mv flashregion_0_flashdescriptor.bin flashdescriptor.bin |
| 40 | mv flashregion_2_intel_me.bin me.bin |
| 41 | rm flashregion_*.bin |