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 | # |
| 3 | # This file is part of the coreboot project. |
| 4 | # |
| 5 | # Copyright (C) 2016 Joe Pillow |
| 6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; version 2 of the License. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | # |
| 16 | |
Yegor Timoshenko | c2e4941 | 2018-10-07 01:58:27 +0000 | [diff] [blame] | 17 | set -x |
| 18 | |
Joe Pillow | 9a4881a | 2016-02-19 15:18:14 -0800 | [diff] [blame] | 19 | IMAGE=$1 |
| 20 | |
| 21 | if [ ! -r "$IMAGE" ]; then |
| 22 | echo "Can't find image $IMAGE." |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
| 26 | CBFSTOOL=$(which cbfstool) |
| 27 | if [ $? != 0 ]; then |
| 28 | echo "Can't find cbfstool." |
| 29 | exit 1 |
| 30 | fi |
| 31 | |
| 32 | IFDTOOL=$(which ifdtool) |
| 33 | if [ $? != 0 ]; then |
| 34 | echo "Can't find ifdtool." |
| 35 | exit 1 |
| 36 | fi |
| 37 | |
| 38 | $CBFSTOOL $IMAGE print |
| 39 | |
| 40 | if [ $? -ne 0 ]; then |
| 41 | echo "Not a coreboot image: $IMAGE" |
| 42 | exit 1 |
| 43 | fi |
| 44 | |
| 45 | PCI=$($CBFSTOOL $IMAGE print|grep pci|cut -f1 -d\ ) |
| 46 | MRC=$($CBFSTOOL $IMAGE print|grep mrc.bin|cut -f1 -d\ ) |
| 47 | |
| 48 | $CBFSTOOL $IMAGE extract -n $PCI -f $PCI |
| 49 | $CBFSTOOL $IMAGE extract -n $MRC -f $MRC |
| 50 | $IFDTOOL -x $IMAGE |
| 51 | mv flashregion_0_flashdescriptor.bin flashdescriptor.bin |
| 52 | mv flashregion_2_intel_me.bin me.bin |
| 53 | rm flashregion_*.bin |