Joe Pillow | 9a4881a | 2016-02-19 15:18:14 -0800 | [diff] [blame] | 1 | #!/bin/bash -x |
| 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 | |
| 17 | IMAGE=$1 |
| 18 | |
| 19 | if [ ! -r "$IMAGE" ]; then |
| 20 | echo "Can't find image $IMAGE." |
| 21 | exit 1 |
| 22 | fi |
| 23 | |
| 24 | CBFSTOOL=$(which cbfstool) |
| 25 | if [ $? != 0 ]; then |
| 26 | echo "Can't find cbfstool." |
| 27 | exit 1 |
| 28 | fi |
| 29 | |
| 30 | IFDTOOL=$(which ifdtool) |
| 31 | if [ $? != 0 ]; then |
| 32 | echo "Can't find ifdtool." |
| 33 | exit 1 |
| 34 | fi |
| 35 | |
| 36 | $CBFSTOOL $IMAGE print |
| 37 | |
| 38 | if [ $? -ne 0 ]; then |
| 39 | echo "Not a coreboot image: $IMAGE" |
| 40 | exit 1 |
| 41 | fi |
| 42 | |
| 43 | PCI=$($CBFSTOOL $IMAGE print|grep pci|cut -f1 -d\ ) |
| 44 | MRC=$($CBFSTOOL $IMAGE print|grep mrc.bin|cut -f1 -d\ ) |
| 45 | |
| 46 | $CBFSTOOL $IMAGE extract -n $PCI -f $PCI |
| 47 | $CBFSTOOL $IMAGE extract -n $MRC -f $MRC |
| 48 | $IFDTOOL -x $IMAGE |
| 49 | mv flashregion_0_flashdescriptor.bin flashdescriptor.bin |
| 50 | mv flashregion_2_intel_me.bin me.bin |
| 51 | rm flashregion_*.bin |