3 # SPDX-License-Identifier: GPL-2.0-only
6 echo "Error: You must provide a valid filename"
12 if [[ "$2" = "" ]]; then
13 # create new dir '$IMAGE-blobs' (less file extension)
14 DIR
=$
(basename $IMAGE)
21 if [ -f .
/cbfstool
]; then
24 CBFSTOOL
=$
(command -v cbfstool
)
26 if [[ "$CBFSTOOL" = "" ]]; then
27 echo "Error: cbfstool must be in your path or exist locally"
31 if [ -f .
/ifdtool
]; then
34 IFDTOOL
=$
(which ifdtool
)
36 if [[ "$IFDTOOL" = "" ]]; then
37 echo "Error: ifdtool must be in your path or exist locally"
41 # ensure valid coreboot image / get list of CBFS contents
42 # try using RW_MAIN_A region first as it may contain newer
43 # files / files not present in the COREBOOT region
44 if $CBFSTOOL $IMAGE print
-r FW_MAIN_A
>$DIR/cbfs.txt
2>/dev
/null
; then
46 elif $CBFSTOOL $IMAGE print
-r COREBOOT
>$DIR/cbfs.txt
; then
49 elif $CBFSTOOL $IMAGE print
-r BOOT_STUB
>$DIR/cbfs.txt
; then
50 # use BOOT_STUB region
53 echo "Error reading CBFS: $IMAGE is not a valid coreboot image"
58 echo "Extracting blobs from region $REGION..."
61 # extract flash regions
62 if ! $IFDTOOL -x $IMAGE >/dev
/null
; then
63 echo "Error reading flash descriptor/extracting flash regions"
66 # rename to normal convention; drop unused regions
67 mv flashregion_0_flashdescriptor.bin
$DIR/flashdescriptor.bin
68 [ -f flashregion_2_intel_me.bin
] && mv flashregion_2_intel_me.bin
$DIR/me.bin
72 $CBFSTOOL $IMAGE extract
-r $REGION -n cpu_microcode_blob.bin
-f $DIR/cpu_microcode_blob.bin
75 VGA
=$
(grep pci
$DIR/cbfs.txt | cut
-f1 -d\
)
76 if [ "$VGA" != "" ]; then
77 $CBFSTOOL $IMAGE extract
-r $REGION -n $VGA -f $DIR/vgabios.bin
81 MRC
=$
(grep mrc.bin
$DIR/cbfs.txt | cut
-f1 -d\
)
82 if [ "$MRC" != "" ]; then
83 $CBFSTOOL $IMAGE extract
-r $REGION -n "$MRC" -f "$DIR/$MRC"
87 REF
=$
(grep refcode
$DIR/cbfs.txt | cut
-f1 -d\
)
88 if [ "$REF" != "" ]; then
89 $CBFSTOOL $IMAGE extract
-r $REGION -n fallback
/refcode
-f "$DIR/refcode.elf" -m x86
93 for FSP
in $
(grep fsp
$DIR/cbfs.txt | cut
-f1 -d\
); do
94 $CBFSTOOL $IMAGE extract
-r $REGION -n $FSP -f $DIR/$FSP
98 for AUD
in $
(grep -e "-2ch-" -e "-4ch-" $DIR/cbfs.txt | cut
-f1 -d\
); do
99 $CBFSTOOL $IMAGE extract
-r $REGION -n $AUD -f $DIR/$AUD
103 for VBT
in $
(grep vbt
$DIR/cbfs.txt | cut
-f1 -d\
); do
104 $CBFSTOOL $IMAGE extract
-r $REGION -n $VBT -f $DIR/$VBT
108 IFWI
=$
(cbfstool
$IMAGE layout
-w |
grep IFWI
)
109 if [ "$IFWI" != "" ]; then
110 $CBFSTOOL $IMAGE read -r IFWI
-f $DIR/ifwi.bin
117 for FILE
in $
(ls *.
{bin
,elf
} 2>/dev
/null
); do
118 sha256sum
$FILE >>hashes.txt
122 # a little housekeeping