3 # SPDX-License-Identifier: GPL-2.0-only
6 echo "Error: You must provide a valid filename"
11 # create new dir '$IMAGE-blobs' (less file extension)
12 DIR
=$
(basename $IMAGE)
16 if [ -f .
/cbfstool
]; then
19 CBFSTOOL
=$
(command -v cbfstool
)
21 if [[ "$CBFSTOOL" = "" ]]; then
22 echo "Error: cbfstool must be in your path or exist locally"
26 if [ -f .
/ifdtool
]; then
29 IFDTOOL
=$
(which ifdtool
)
31 if [[ "$IFDTOOL" = "" ]]; then
32 echo "Error: ifdtool must be in your path or exist locally"
36 # ensure valid coreboot image / get list of main COREBOOT CBFS contents
38 if ! $CBFSTOOL $IMAGE print
>$DIR/cbfs.txt
2>/dev
/null
; then
39 # try using BOOT_STUB region
40 if ! $CBFSTOOL $IMAGE print
-r BOOT_STUB
>$DIR/cbfs.txt
; then
41 echo "Error reading CBFS: $IMAGE is not a valid coreboot image"
49 echo "Extracting blobs..."
52 # extract flash regions
53 if ! $IFDTOOL -x $IMAGE >/dev
/null
; then
54 echo "Error reading flash descriptor/extracting flash regions"
57 # rename to normal convention; drop unused regions
58 mv flashregion_0_flashdescriptor.bin
$DIR/flashdescriptor.bin
59 [ -f flashregion_2_intel_me.bin
] && mv flashregion_2_intel_me.bin
$DIR/me.bin
63 $CBFSTOOL $IMAGE extract
$REGION -n cpu_microcode_blob.bin
-f $DIR/cpu_microcode_blob.bin
66 VGA
=$
(grep pci
$DIR/cbfs.txt | cut
-f1 -d\
)
67 if [ "$VGA" != "" ]; then
68 $CBFSTOOL $IMAGE extract
$REGION -n $VGA -f $DIR/vgabios.bin
72 MRC
=$
(grep mrc.bin
$DIR/cbfs.txt | cut
-f1 -d\
)
73 if [ "$MRC" != "" ]; then
74 $CBFSTOOL $IMAGE extract
$REGION -n "$MRC" -f "$DIR/$MRC"
78 REF
=$
(grep refcode
$DIR/cbfs.txt | cut
-f1 -d\
)
79 if [ "$REF" != "" ]; then
80 $CBFSTOOL $IMAGE extract
$REGION -n fallback
/refcode
-f "$DIR/refcode.elf" -m x86
84 for FSP
in $
(grep fsp
$DIR/cbfs.txt | cut
-f1 -d\
); do
85 $CBFSTOOL $IMAGE extract
$REGION -n $FSP -f $DIR/$FSP
89 for AUD
in $
(grep -e "-2ch-" -e "-4ch-" $DIR/cbfs.txt | cut
-f1 -d\
); do
90 $CBFSTOOL $IMAGE extract
$REGION -n $AUD -f $DIR/$AUD
94 for VBT
in $
(grep vbt
$DIR/cbfs.txt | cut
-f1 -d\
); do
95 $CBFSTOOL $IMAGE extract
$REGION -n $VBT -f $DIR/$VBT
99 IFWI
=$
(cbfstool
$IMAGE layout
-w |
grep IFWI
)
100 if [ "$IFWI" != "" ]; then
101 $CBFSTOOL $IMAGE read -r IFWI
-f $DIR/ifwi.bin
108 for FILE
in $
(ls *.
{bin
,elf
} 2>/dev
/null
); do
109 sha256sum
$FILE >>hashes.txt
113 # a little housekeeping