general code cleanup on lbmk shell scripts

in update/blobs/download, i saw instances where
appdir was being deleted with rm -r, but the more
appropriate command would rm -Rf. this is now fixed.

other than that, i've mostly just simplified a bunch
of if statements and consolidated some duplicated
logic (e.g. if/else block for dependencies in
build_dependencies() of update/blobs/download

one or two functions and/or variables have been
renamed, for greater clarity in the code, also
removed a few messages that were redundant

used printf instead of echo, in a few places, also
fixed up the indentation in a few places

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2023-08-21 19:41:49 +01:00
parent 7be4706552
commit 62f23123cb
17 changed files with 307 additions and 581 deletions
+13 -34
View File
@@ -36,20 +36,11 @@ firstoption=""
main() main()
{ {
if [ $# -lt 1 ]; then [ $# -lt 1 ] && usage && exit 1
usage
exit 1
fi
firstoption="${1}"
if [ "${firstoption}" = "help" ]; then firstoption="${1}"
usage [ "${firstoption}" = "help" ] && usage && exit 0
exit 0 [ "${firstoption}" = "list" ] && listboards && exit 0
fi
if [ "${firstoption}" = "list" ]; then
listboards
exit 0
fi
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case ${1} in case ${1} in
@@ -68,21 +59,16 @@ main()
shift shift
done done
if [ -z ${opts+x} ]; then [ -z ${opts+x} ] && opts=""
opts=""
fi
printf "Building %s ROM images\n" "${projectname}" printf "Building %s ROM images\n" "${projectname}"
if [ "${firstoption}" = "all" ]; then if [ "${firstoption}" = "all" ]; then
for boardname in $(listboards); do for boardname in $(listboards); do
buildrom "${boardname}" \ buildrom "${boardname}" || err "build/roms: error"
|| die "build/roms: error"
done done
else else
for board in ${boards}; do for board in ${boards}; do
buildrom "${board}" \ buildrom "${board}" || err "build/roms: error"
|| die "build/roms: error"
done done
fi fi
@@ -116,9 +102,7 @@ usage()
listboards() listboards()
{ {
for boarddir in resources/coreboot/*; do for boarddir in resources/coreboot/*; do
if [ ! -d "${boarddir}" ]; then [ ! -d "${boarddir}" ] && continue
continue
fi
board="${boarddir##resources/coreboot/}" board="${boarddir##resources/coreboot/}"
board="${board%/}" board="${board%/}"
printf '%s\n' "${board##*/}" printf '%s\n' "${board##*/}"
@@ -127,18 +111,13 @@ listboards()
# Build ROM images for supported boards # Build ROM images for supported boards
buildrom() { buildrom() {
board="$1" [ -d "resources/coreboot/${1}/" ] || \
err "build/roms: target not defined: ${1}"
if [ -d "resources/coreboot/${board}/" ]; then ./build boot roms_helper ${1}${opts}
./build boot roms_helper ${board}${opts}
else
printf "\nbuild/roms: target not defined: %s\n" ${board}
die "Run: ./build boot roms list"
fi
} }
die() { err() {
printf 'Error: %s\n' "${@}" 1>&2 printf '%s\n' "${1}" 1>&2
exit 1 exit 1
} }
+54 -70
View File
@@ -115,8 +115,8 @@ fi
# NOTE: reverse logic must NOT be applied. If SeaBIOS-with-GRUB works, that # NOTE: reverse logic must NOT be applied. If SeaBIOS-with-GRUB works, that
# doesn't necessarily mean GRUb-with-SeaBIOS will. For example, the board # doesn't necessarily mean GRUb-with-SeaBIOS will. For example, the board
# might have an external GPU, where it's recommended to boot SeaBIOS first # might have an external GPU, where it's recommended to boot SeaBIOS first
if [ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ] \ if [ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ] && \
&& [ "${payload_uboot}" != "y" ]; then [ "${payload_uboot}" != "y" ]; then
for configfile in "resources/coreboot/${board}/config/"*; do for configfile in "resources/coreboot/${board}/config/"*; do
[ ! -e "${configfile}" ] && continue [ ! -e "${configfile}" ] && continue
printf "ERROR build/roms: Target '%s' defines no payload. " \ printf "ERROR build/roms: Target '%s' defines no payload. " \
@@ -153,7 +153,7 @@ fi
romdir="bin/${board}" romdir="bin/${board}"
cbdir="coreboot/${board}" cbdir="coreboot/${board}"
[ "${board}" != "${tree}" ] && \ [ "${board}" = "${tree}" ] || \
cbdir="coreboot/${tree}" cbdir="coreboot/${tree}"
cbfstool="cbutils/${tree}/cbfstool" cbfstool="cbutils/${tree}/cbfstool"
corebootrom="${cbdir}/build/coreboot.rom" corebootrom="${cbdir}/build/coreboot.rom"
@@ -191,10 +191,7 @@ if [ "${payload_grub}" = "y" ] \
printf "Required GRUB payloads not yet built. Building now:\n" printf "Required GRUB payloads not yet built. Building now:\n"
fi fi
for keymapfile in ${kmapdir}/*; do for keymapfile in ${kmapdir}/*; do
[ -f "${keymapfile}" ] || continue
if [ ! -f "${keymapfile}" ]; then
continue
fi
keymap="${keymapfile##*/}" keymap="${keymapfile##*/}"
keymap="${keymap%.gkb}" keymap="${keymap%.gkb}"
@@ -216,7 +213,7 @@ if [ "${payload_uboot}" = "y" ]; then
ubootelf="${ubdir}/u-boot.elf" ubootelf="${ubdir}/u-boot.elf"
[ ! -f "${ubootelf}" ] && [ -f "${ubdir}/u-boot.bin" ] && \ [ ! -f "${ubootelf}" ] && [ -f "${ubdir}/u-boot.bin" ] && \
ubootelf="${ubdir}/u-boot.bin" ubootelf="${ubdir}/u-boot.bin"
[ ! -f "${ubootelf}" ] && \ [ -f "${ubootelf}" ] || \
err "Could not find u-boot build for board, ${board}" err "Could not find u-boot build for board, ${board}"
fi fi
@@ -234,8 +231,7 @@ moverom() {
if [ "${cuttype}" = "4MiB IFD BIOS region" ]; then if [ "${cuttype}" = "4MiB IFD BIOS region" ]; then
dd if=${rompath} of=${newrompath} bs=1 \ dd if=${rompath} of=${newrompath} bs=1 \
skip=$(($(stat -c %s ${rompath}) - 0x400000)) \ skip=$(($(stat -c %s ${rompath}) - 0x400000)) count=4194304
count=4194304
else else
cp ${rompath} ${newrompath} cp ${rompath} ${newrompath}
fi fi
@@ -248,7 +244,7 @@ moverom() {
touch "${emptyrom}" touch "${emptyrom}"
for deviceID in "0072" "3050"; do for deviceID in "0072" "3050"; do
"${cbfstool}" "${newrompath}" add -f "${emptyrom}" \ "${cbfstool}" "${newrompath}" add -f "${emptyrom}" \
-n pci1000,${deviceID}.rom -t raw -n pci1000,${deviceID}.rom -t raw
done done
rm -f "${emptyrom}" rm -f "${emptyrom}"
fi fi
@@ -256,30 +252,27 @@ moverom() {
for romsize in 4 8 16; do for romsize in 4 8 16; do
ifdgbe="descriptors/ich9m/ich9fdgbe_${romsize}m.bin" ifdgbe="descriptors/ich9m/ich9fdgbe_${romsize}m.bin"
if [ "${cuttype}" = "${romsize}MiB ICH9 IFD NOR flash" ]; then if [ "${cuttype}" = "${romsize}MiB ICH9 IFD NOR flash" ]; then
if [ ! -f "${ifdgbe}" ]; then [ -f "${ifdgbe}" ] || \
./build descriptors ich9m ./build descriptors ich9m
fi
dd if=${ifdgbe} of=${newrompath} bs=1 count=12k \ dd if=${ifdgbe} of=${newrompath} bs=1 count=12k \
conv=notrunc conv=notrunc
fi fi
cmpstr="${romsize}MiB ICH9 IFD NOGBE NOR flash" cmpstr="${romsize}MiB ICH9 IFD NOGBE NOR flash"
ifdgbe="descriptors/ich9m/ich9fdnogbe_${romsize}m.bin" ifdgbe="descriptors/ich9m/ich9fdnogbe_${romsize}m.bin"
if [ "${cuttype}" = "${cmpstr}" ]; then if [ "${cuttype}" = "${cmpstr}" ]; then
if [ ! -f "${ifdgbe}" ]; then [ -f "${ifdgbe}" ] || \
./build descriptors ich9m ./build descriptors ich9m
fi
dd if=${ifdgbe} of=${newrompath} bs=1 count=4k \ dd if=${ifdgbe} of=${newrompath} bs=1 count=4k \
conv=notrunc conv=notrunc
fi fi
done done
if [ "${cuttype}" = "i945 laptop" ]; then if [ "${cuttype}" = "i945 laptop" ]; then
dd if=${newrompath} of=top64k.bin bs=1 \ dd if=${newrompath} of=top64k.bin bs=1 \
skip=$(($(stat -c %s ${newrompath}) - 0x10000)) \ skip=$(($(stat -c %s ${newrompath}) - 0x10000)) count=64k
count=64k
dd if=top64k.bin of=${newrompath} bs=1 \ dd if=top64k.bin of=${newrompath} bs=1 \
seek=$(($(stat -c %s ${newrompath}) - 0x20000)) \ seek=$(($(stat -c %s ${newrompath}) - 0x20000)) count=64k \
count=64k conv=notrunc conv=notrunc
rm -f top64k.bin rm -f top64k.bin
fi fi
@@ -288,11 +281,11 @@ moverom() {
cp "${newrompath}" "${_newrom_b}" || exit 1 cp "${newrompath}" "${_newrom_b}" || exit 1
microcode_present="y" microcode_present="y"
"${cbfstool}" "${_newrom_b}" remove -n \ "${cbfstool}" "${_newrom_b}" remove -n \
cpu_microcode_blob.bin || microcode_present="n" cpu_microcode_blob.bin || microcode_present="n"
if [ "${microcode_present}" = "n" ]; then if [ "${microcode_present}" = "n" ]; then
rm -f "${_newrom_b}" || exit 1 rm -f "${_newrom_b}" || exit 1
printf "REMARK: '%s' already lacks microcode\n" \ printf "REMARK: '%s' already lacks microcode\n" \
${newrompath} ${newrompath}
printf "Renaming default ROM file instead.\n" printf "Renaming default ROM file instead.\n"
mv "${newrompath}" "${_newrom_b}" || exit 1 mv "${newrompath}" "${_newrom_b}" || exit 1
fi fi
@@ -313,27 +306,26 @@ mkSeabiosRom() {
cp "${target_cbrom}" "${tmprom}" cp "${target_cbrom}" "${tmprom}"
"${cbfstool}" "${tmprom}" add-payload -f "${target_seabioself}" \ "${cbfstool}" "${tmprom}" add-payload -f "${target_seabioself}" \
-n ${target_seabios_cbfs_path} -c lzma || exit 1 -n ${target_seabios_cbfs_path} -c lzma || exit 1
"${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup \ "${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup \
|| exit 1 || exit 1
if [ "${target_initmode}" = "normal" ] \ if [ "${target_initmode}" = "normal" ] || \
|| [ "${target_initmode}" = "libgfxinit" ]; then [ "${target_initmode}" = "libgfxinit" ]; then
"${cbfstool}" "${tmprom}" add-int -i 2 \ "${cbfstool}" "${tmprom}" add-int -i 2 \
-n etc/pci-optionrom-exec || exit 1 -n etc/pci-optionrom-exec || exit 1
elif [ "${target_initmode}" = "vgarom" ]; then # coreboot executes it elif [ "${target_initmode}" = "vgarom" ]; then # coreboot executes it
"${cbfstool}" "${tmprom}" add-int -i 0 \ "${cbfstool}" "${tmprom}" add-int -i 0 \
-n etc/pci-optionrom-exec || exit 1 -n etc/pci-optionrom-exec || exit 1
fi # for undefined modes, don't add this integer. use SeaBIOS defaults fi # for undefined modes, don't add this integer. use SeaBIOS defaults
"${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum \ "${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum || \
|| exit 1 exit 1
if [ "${target_initmode}" = "libgfxinit" ]; then [ "${target_initmode}" != "libgfxinit" ] || \
"${cbfstool}" "${tmprom}" add -f "${seavgabiosrom}" \ "${cbfstool}" "${tmprom}" add -f "${seavgabiosrom}" \
-n vgaroms/seavgabios.bin -t raw || exit 1 -n vgaroms/seavgabios.bin -t raw || exit 1
fi
printf "%s\n" "${tmprom}" printf "%s\n" "${tmprom}"
} }
@@ -348,16 +340,16 @@ mkUbootRom() {
target_ubdir="elf/u-boot/${board}/${target_uboot_config}" target_ubdir="elf/u-boot/${board}/${target_uboot_config}"
target_ubootelf="${target_ubdir}/u-boot.elf" target_ubootelf="${target_ubdir}/u-boot.elf"
[ ! -f "${target_ubootelf}" ] && \ [ -f "${target_ubootelf}" ] || \
target_ubootelf="${target_ubdir}/u-boot.bin" target_ubootelf="${target_ubdir}/u-boot.bin"
[ ! -f "${target_ubootelf}" ] && \ [ -f "${target_ubootelf}" ] || \
err "Could not find u-boot build for board, ${board}" err "Could not find u-boot build for board, ${board}"
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
cp "${target_cbrom}" "${tmprom}" cp "${target_cbrom}" "${tmprom}"
"${cbfstool}" "${tmprom}" add-payload -f "${target_ubootelf}" \ "${cbfstool}" "${tmprom}" add-payload -f "${target_ubootelf}" \
-n ${target_uboot_cbfs_path} -c lzma || exit 1 -n ${target_uboot_cbfs_path} -c lzma || exit 1
printf "%s\n" "${tmprom}" printf "%s\n" "${tmprom}"
} }
@@ -376,34 +368,34 @@ mkGrubRom() {
cp "${target_cbrom}" "${tmprom}" || exit 1 cp "${target_cbrom}" "${tmprom}" || exit 1
"${cbfstool}" "${tmprom}" add-payload -f "${grubelf}" \ "${cbfstool}" "${tmprom}" add-payload -f "${grubelf}" \
-n ${target_grubelf_cbfs_path} -c lzma || exit 1 -n ${target_grubelf_cbfs_path} -c lzma || exit 1
tmpgrubcfg=$(mktemp -t grub.cfg.XXXXXXXXXX) tmpgrubcfg=$(mktemp -t grub.cfg.XXXXXXXXXX)
tmpgrubtestcfg=$(mktemp -t grubtest.cfg.XXXXXXXXXX) tmpgrubtestcfg=$(mktemp -t grubtest.cfg.XXXXXXXXXX)
if [ "${grub_scan_disk}" = "ahci" ]; then if [ "${grub_scan_disk}" = "ahci" ]; then
sed \ sed \
's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ahci\"/' \ 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ahci\"/' \
"${grubcfg}" > "${tmpgrubcfg}" "${grubcfg}" > "${tmpgrubcfg}"
sed \ sed \
's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ahci\"/' \ 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ahci\"/' \
"${grubtestcfg}" > "${tmpgrubtestcfg}" "${grubtestcfg}" > "${tmpgrubtestcfg}"
elif [ "${grub_scan_disk}" = "ata" ]; then elif [ "${grub_scan_disk}" = "ata" ]; then
sed \ sed \
's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ata\"/' \ 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ata\"/' \
"${grubcfg}" > "${tmpgrubcfg}" "${grubcfg}" > "${tmpgrubcfg}"
sed \ sed \
's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ata\"/' \ 's/set\ grub_scan_disk=\"both\"/set\ grub_scan_disk=\"ata\"/' \
"${grubtestcfg}" > "${tmpgrubtestcfg}" "${grubtestcfg}" > "${tmpgrubtestcfg}"
else else
cp "${grubcfg}" "${tmpgrubcfg}" cp "${grubcfg}" "${tmpgrubcfg}"
cp "${grubtestcfg}" "${tmpgrubtestcfg}" cp "${grubtestcfg}" "${tmpgrubtestcfg}"
fi fi
"${cbfstool}" "${tmprom}" add -f "${tmpgrubcfg}" -n grub.cfg -t raw \ "${cbfstool}" "${tmprom}" add -f "${tmpgrubcfg}" -n grub.cfg -t raw || \
|| exit 1 exit 1
"${cbfstool}" "${tmprom}" add -f "${tmpgrubtestcfg}" -n grubtest.cfg \ "${cbfstool}" "${tmprom}" add -f "${tmpgrubtestcfg}" -n grubtest.cfg \
-t raw || exit 1 -t raw || exit 1
rm -f "${tmpgrubcfg}" "${tmpgrubtestcfg}" rm -f "${tmpgrubcfg}" "${tmpgrubtestcfg}"
backgroundfile="background1280x800.png" backgroundfile="background1280x800.png"
@@ -413,7 +405,7 @@ mkGrubRom() {
fi fi
backgroundfile="resources/grub/background/${backgroundfile}" backgroundfile="resources/grub/background/${backgroundfile}"
"${cbfstool}" "${tmprom}" add -f ${backgroundfile} -n background.png \ "${cbfstool}" "${tmprom}" add -f ${backgroundfile} -n background.png \
-t raw || exit 1 -t raw || exit 1
printf "%s\n" "${tmprom}" printf "%s\n" "${tmprom}"
} }
@@ -427,20 +419,18 @@ mkRomsWithGrub() {
x=${tmprompath} x=${tmprompath}
y=${initmode} y=${initmode}
if [ "${payload_grub_withseabios}" = "y" ] \ if [ "${payload_grub_withseabios}" = "y" ] && \
&& [ "${firstpayloadname}" = "grub" ]; then [ "${firstpayloadname}" = "grub" ]; then
mv "$(mkSeabiosRom "${x}" "seabios.elf" "${y}")" \ mv "$(mkSeabiosRom "${x}" "seabios.elf" "${y}")" "${tmprompath}"
"${tmprompath}" elif [ "${payload_seabios_withgrub}" ] && \
elif [ "${payload_seabios_withgrub}" ] \ [ "${firstpayloadname}" != "grub" ]; then
&& [ "${firstpayloadname}" != "grub" ]; then
mv "$(mkSeabiosRom "${x}" "fallback/payload" "$y")" \ mv "$(mkSeabiosRom "${x}" "fallback/payload" "$y")" \
"${tmprompath}" "${tmprompath}"
fi fi
keymaps="" keymaps=""
if [ -z ${keyboard_layouts} ]; then if [ -z ${keyboard_layouts} ]; then
for kmapfile in "${kmapdir}"/* for kmapfile in "${kmapdir}"/*; do
do
keymaps="${keymaps} ${kmapfile}" keymaps="${keymaps} ${kmapfile}"
done done
else else
@@ -451,17 +441,14 @@ mkRomsWithGrub() {
for keymapfile in ${keymaps}; do for keymapfile in ${keymaps}; do
echo "keymaps is $keymaps, keymapfile is $keymapfile" echo "keymaps is $keymaps, keymapfile is $keymapfile"
if [ ! -f "${keymapfile}" ]; then [ -f "${keymapfile}" ] || continue
continue
fi
keymap="${keymapfile##*/}" keymap="${keymapfile##*/}"
keymap="${keymap%.gkb}" keymap="${keymap%.gkb}"
grub_path_in_cbfs="fallback/payload" grub_path_in_cbfs="fallback/payload"
if [ "${firstpayloadname}" != "grub" ]; then [ "${firstpayloadname}" = "grub" ] || \
grub_path_in_cbfs="img/grub2" grub_path_in_cbfs="img/grub2"
fi
# evil bofh rfc 2646 compliance hack # evil bofh rfc 2646 compliance hack
x=${keymap} x=${keymap}
@@ -492,8 +479,7 @@ mkRoms()
if [ ! -f "${cbcfgpath}" ]; then if [ ! -f "${cbcfgpath}" ]; then
printf "'%s' does not exist. Skipping build for %s %s %s\n" \ printf "'%s' does not exist. Skipping build for %s %s %s\n" \
${cbcfgpath} ${board} \ ${cbcfgpath} ${board} ${displaymode} ${initmode}
${displaymode} ${initmode}
return 0 return 0
fi fi
@@ -506,11 +492,10 @@ mkRoms()
corebootrom="$(mktemp -t coreboot_rom.XXXXXXXXXX)" corebootrom="$(mktemp -t coreboot_rom.XXXXXXXXXX)"
cp "${_corebootrom}" "${corebootrom}" cp "${_corebootrom}" "${corebootrom}"
if [ "${displaymode}" = "txtmode" ] \ if [ "${displaymode}" = "txtmode" ] && \
&& [ "${payload_memtest}" = "y" ]; then [ "${payload_memtest}" = "y" ]; then
"${cbfstool}" "${corebootrom}" add-payload \ "${cbfstool}" "${corebootrom}" add-payload \
-f memtest86plus/memtest -n img/memtest \ -f memtest86plus/memtest -n img/memtest -c lzma || exit 1
-c lzma || exit 1
fi fi
if [ "${payload_seabios}" = "y" ]; then if [ "${payload_seabios}" = "y" ]; then
@@ -533,15 +518,14 @@ mkRoms()
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
cp "${corebootrom}" "${tmprom}" cp "${corebootrom}" "${tmprom}"
mkRomsWithGrub "${tmprom}" "${initmode}" \ mkRomsWithGrub "${tmprom}" "${initmode}" \
"${displaymode}" "seabios_withgrub" "${displaymode}" "seabios_withgrub"
rm -f "${tmprom}" rm -f "${tmprom}"
fi fi
fi fi
if [ "${payload_grub}" = "y" ]; then [ "${payload_grub}" = "y" ] && \
mkRomsWithGrub "${corebootrom}" "${initmode}" \ mkRomsWithGrub "${corebootrom}" "${initmode}" \
"${displaymode}" "grub" "${displaymode}" "grub"
fi
if [ "${payload_uboot}" = "y" ]; then if [ "${payload_uboot}" = "y" ]; then
x=${corebootrom} x=${corebootrom}
+3 -6
View File
@@ -33,12 +33,9 @@ rm -Rf cbutils
[ ! -d "coreboot/" ] && exit 0 [ ! -d "coreboot/" ] && exit 0
for tree in coreboot/*; do for tree in coreboot/*; do
if [ "${tree##*/}" = "coreboot" ]; then [ "${tree##*/}" = "coreboot" ] && continue
continue [ -d "${tree}" ] || continue
fi
if [ ! -d "${tree}" ]; then
continue
fi
# Clean coreboot, of course # Clean coreboot, of course
make -C "${tree}/" distclean make -C "${tree}/" distclean
+2 -5
View File
@@ -25,14 +25,11 @@ set -u -e
main() main()
{ {
printf "Cleaning crossgcc builds in all coreboot archives\n" printf "Cleaning crossgcc builds in all coreboot archives\n"
[ ! -d "coreboot/" ] && exit 0 [ ! -d "coreboot/" ] && exit 0
for board in coreboot/*; do for board in coreboot/*; do
[ "${board##*/}" = "coreboot" ] && \ [ "${board##*/}" = "coreboot" ] && continue
continue [ ! -d "${board}" ] && continue
[ ! -d "${board}" ] && \
continue
make -C "${board}/" crossgcc-clean || err "make-clean" make -C "${board}/" crossgcc-clean || err "make-clean"
done done
} }
+5 -10
View File
@@ -39,10 +39,8 @@ main()
build_for_mainboard() { build_for_mainboard() {
board="${1}" board="${1}"
[ ! -d "resources/coreboot/${board}" ] && \ [ -d "resources/coreboot/${board}" ] || continue
continue [ -f "resources/coreboot/${board}/target.cfg" ] || continue
[ ! -f "resources/coreboot/${board}/target.cfg" ] && \
continue
tree="undefined" tree="undefined"
. "resources/coreboot/${board}/target.cfg" # source . "resources/coreboot/${board}/target.cfg" # source
if [ "${tree}" = "undefined" ]; then if [ "${tree}" = "undefined" ]; then
@@ -55,15 +53,12 @@ build_for_mainboard() {
buildutils() { buildutils() {
tree="${1}" tree="${1}"
if [ ! -d "coreboot/${tree}/" ]; then [ -d "coreboot/${tree}/" ] || \
./fetch_trees coreboot $tree || return 1 ./fetch_trees coreboot $tree || return 1
fi
for util in cbfstool ifdtool; do for util in cbfstool ifdtool; do
[ -f "cbutils/${tree}/${util}" ] \ [ -f "cbutils/${tree}/${util}" ] && continue
&& continue [ -d "cbutils/${tree}" ] || \
if [ ! -d "cbutils/${tree}" ]; then
mkdir -p "cbutils/${tree}" || return 1 mkdir -p "cbutils/${tree}" || return 1
fi
utildir="coreboot/${tree}/util/${util}" utildir="coreboot/${tree}/util/${util}"
make distclean -C "${utildir}" || return 1 make distclean -C "${utildir}" || return 1
+3 -3
View File
@@ -23,9 +23,9 @@ ich9gen="util/ich9utils/ich9gen"
main() main()
{ {
[ -f "${ich9gen}" ] || ./build src for -b ich9utils || err "ich9utils make" [ -f "${ich9gen}" ] || ./build src for -b ich9utils || \
[ ! -f "${ich9gen}" ] && \ err "ich9utils make"
err "ich9gen doesn't exist" [ ! -f "${ich9gen}" ] && err "ich9gen doesn't exist"
[ -d "descriptors/ich9m/" ] || mkdir -p "descriptors/ich9m/" [ -d "descriptors/ich9m/" ] || mkdir -p "descriptors/ich9m/"
rm -f descriptors/ich9m/* || err "rm-rf" rm -f descriptors/ich9m/* || err "rm-rf"
+14 -19
View File
@@ -53,18 +53,15 @@ main()
build_grub_payloads() build_grub_payloads()
{ {
keylayoutfile=${1} keylayoutfile=${1}
[ -f "${keylayoutfile}" ] || continue
if [ ! -f "${keylayoutfile}" ]; then
continue
fi
keymap="${keylayoutfile##${grubcfgsdir}/keymap/}" keymap="${keylayoutfile##${grubcfgsdir}/keymap/}"
keymap="${keymap%.gkb}" keymap="${keymap%.gkb}"
build_grub_elf "${keylayoutfile}" build_grub_elf "${keylayoutfile}"
create_grub_config create_grub_config
printf "Created 'elf/grub/grub_%s.elf' and configs.'\n" \ printf "Created 'elf/grub/grub_%s.elf' and configs.'\n" "${keymap}"
"${keymap}"
} }
build_grub_elf() build_grub_elf()
@@ -75,24 +72,22 @@ build_grub_elf()
gcfg="${gcfg}/config/grub_memdisk.cfg" gcfg="${gcfg}/config/grub_memdisk.cfg"
grubk="/boot/grub/layouts/${keymap}.gkb=${keylayoutfile}" grubk="/boot/grub/layouts/${keymap}.gkb=${keylayoutfile}"
grub/grub-mkstandalone \ grub/grub-mkstandalone \
--grub-mkimage="grub/grub-mkimage" \ --grub-mkimage="grub/grub-mkimage" \
-O i386-coreboot \ -O i386-coreboot \
-o elf/grub/grub_${keymap}.elf \ -o elf/grub/grub_${keymap}.elf \
-d grub/grub-core/ \ -d grub/grub-core/ \
--fonts= --themes= --locales= \ --fonts= --themes= --locales= \
--modules="${grub_modules}" \ --modules="${grub_modules}" \
--install-modules="${grub_install_modules}" \ --install-modules="${grub_install_modules}" \
${gcfg} ${grubk} ${gcfg} ${grubk}
} }
create_grub_config() create_grub_config()
{ {
sed "s/usqwerty/${keymap}/" \ sed "s/usqwerty/${keymap}/" < ${grubcfgsdir}/config/grub.cfg \
< ${grubcfgsdir}/config/grub.cfg \ > elf/grub/grub_${keymap}.cfg
> elf/grub/grub_${keymap}.cfg sed "s/grubtest.cfg/grub.cfg/" < elf/grub/grub_${keymap}.cfg \
sed "s/grubtest.cfg/grub.cfg/" \ > elf/grub/grub_${keymap}_test.cfg
< elf/grub/grub_${keymap}.cfg \
> elf/grub/grub_${keymap}_test.cfg
} }
main $@ main $@
+2 -13
View File
@@ -25,11 +25,7 @@ set -u -e
main() main()
{ {
printf "Building GRUB\n" printf "Building GRUB\n"
[ -d "grub/" ] || ./fetch grub || exit 1
if [ ! -d "grub/" ]; then
./fetch grub || exit 1
fi
build_grub build_grub
} }
@@ -37,15 +33,8 @@ build_grub()
{ {
( (
cd grub/ || err "cd" cd grub/ || err "cd"
[ ! -d Makefile ] || make distclean || err "make-distclean"
# clean up first
if [ -d Makefile ]; then
make distclean || err "make-distclean"
fi
./bootstrap --gnulib-srcdir=gnulib/ --no-git || err "bootstrap" ./bootstrap --gnulib-srcdir=gnulib/ --no-git || err "bootstrap"
# build
./autogen.sh || err "autogen" ./autogen.sh || err "autogen"
./configure --with-platform=coreboot || err "configure" ./configure --with-platform=coreboot || err "configure"
make -j$(nproc) || err "make" make -j$(nproc) || err "make"
+19 -34
View File
@@ -70,26 +70,22 @@ make_archive()
target="${romdir##*/}" target="${romdir##*/}"
echo ${target} echo ${target}
if [ ! -d "${romdir}/" ]; then [ -d "${romdir}/" ] || continue
continue
fi
CONFIG_HAVE_MRC="y" CONFIG_HAVE_MRC="y"
CONFIG_HAVE_ME_BIN="y" CONFIG_HAVE_ME_BIN="y"
CONFIG_KBC1126_FIRMWARE="y" CONFIG_KBC1126_FIRMWARE="y"
CONFIG_INCLUDE_SMSC_SCH5545_EC_FW="y" CONFIG_INCLUDE_SMSC_SCH5545_EC_FW="y"
grep "CONFIG_HAVE_ME_BIN=y" \ grep "CONFIG_HAVE_ME_BIN=y" "resources/coreboot/${target}/config/"* || \
"resources/coreboot/${target}/config/"* \ CONFIG_HAVE_ME_BIN="n"
|| CONFIG_HAVE_ME_BIN="n" grep "CONFIG_HAVE_MRC=y" "resources/coreboot/${target}/config/"* || \
grep "CONFIG_HAVE_MRC=y" \ CONFIG_HAVE_MRC="n"
"resources/coreboot/${target}/config/"* \
|| CONFIG_HAVE_MRC="n"
grep "CONFIG_KBC1126_FIRMWARE=y" \ grep "CONFIG_KBC1126_FIRMWARE=y" \
"resources/coreboot/${target}/config"/* \ "resources/coreboot/${target}/config"/* || \
|| CONFIG_KBC1126_FIRMWARE="n" CONFIG_KBC1126_FIRMWARE="n"
grep "CONFIG_INCLUDE_SMSC_SCH5545_EC_FW=y" \ grep "CONFIG_INCLUDE_SMSC_SCH5545_EC_FW=y" \
"resources/coreboot/${target}/config"/* \ "resources/coreboot/${target}/config"/* || \
|| CONFIG_INCLUDE_SMSC_SCH5545_EC_FW="n" CONFIG_INCLUDE_SMSC_SCH5545_EC_FW="n"
# remove ME/MRC/EC firmware from ROM images # remove ME/MRC/EC firmware from ROM images
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ] \ if [ "${CONFIG_HAVE_ME_BIN}" = "y" ] \
@@ -107,8 +103,7 @@ make_archive()
f="release/${version}/roms/${projectname}-${version}_${target##*/}" f="release/${version}/roms/${projectname}-${version}_${target##*/}"
tar -c "${romdir}/" | xz -9e > "${f}.tar.xz" tar -c "${romdir}/" | xz -9e > "${f}.tar.xz"
if [ -d "${romdir}_tmp" ] if [ -d "${romdir}_tmp" ]; then
then
rm -Rf "${romdir}" rm -Rf "${romdir}"
mv "${romdir}_tmp" "${romdir}" mv "${romdir}_tmp" "${romdir}"
fi fi
@@ -118,9 +113,8 @@ strip_archive()
{ {
romdir=${1} romdir=${1}
if [ ! -d coreboot/${tree} ]; then [ -d coreboot/${tree} ] || \
./fetch_trees coreboot ${tree} || exit 1 ./fetch_trees coreboot ${tree} || exit 1
fi
./build coreboot utils ${tree} || exit 1 ./build coreboot utils ${tree} || exit 1
rm -Rf "${romdir}_tmp" # dirty hack, to reduce disk io later rm -Rf "${romdir}_tmp" # dirty hack, to reduce disk io later
@@ -128,17 +122,15 @@ strip_archive()
mkdir "${romdir}_tmp" mkdir "${romdir}_tmp"
# Hash the rom before removing blobs # Hash the rom before removing blobs
if [ ! -f "${romdir}/blobhashes" ]; then [ -f "${romdir}/blobhashes" ] || \
printf "ROMs must match these hashes after blob insertion:" \ printf "ROMs must match these hashes after blob insertion:" \
> "${romdir}/blobhashes" > "${romdir}/blobhashes"
fi
( (
cd ${romdir} || err "subshell: cd" cd ${romdir} || err "subshell: cd"
sha1sum *.rom >> blobhashes || err "subshell: sha1sum" sha1sum *.rom >> blobhashes || err "subshell: sha1sum"
) )
for romfile in "${romdir}"/*.rom for romfile in "${romdir}"/*.rom; do
do
strip_rom_image "${romfile}" strip_rom_image "${romfile}"
done done
} }
@@ -147,9 +139,7 @@ strip_rom_image()
{ {
romfile=${1} romfile=${1}
if [ ! -f "${romfile}" ]; then [ -f "${romfile}" ] || continue
continue
fi
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
${ifdtool} --nuke me "${romfile}" || exit 1 ${ifdtool} --nuke me "${romfile}" || exit 1
@@ -157,8 +147,7 @@ strip_rom_image()
mv "${romfile}.new" "${romfile}" mv "${romfile}.new" "${romfile}"
fi fi
if [ "${CONFIG_HAVE_MRC}" = "y" ] if [ "${CONFIG_HAVE_MRC}" = "y" ]; then
then
${cbfstool} "${romfile}" remove -n mrc.bin || exit 1 ${cbfstool} "${romfile}" remove -n mrc.bin || exit 1
${cbfstool} "${romfile}" print ${cbfstool} "${romfile}" print
fi fi
@@ -168,16 +157,12 @@ strip_rom_image()
${cbfstool} "${romfile}" remove -n ecfw2.bin || exit 1 ${cbfstool} "${romfile}" remove -n ecfw2.bin || exit 1
fi fi
if [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ]; then [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" != "y" ] || \
${cbfstool} "${romfile}" remove -n sch5545_ecfw.bin || exit 1 ${cbfstool} "${romfile}" remove -n sch5545_ecfw.bin || exit 1
fi
# TODO: replace this board-specific hack # TODO: replace this board-specific hack
if [ "${target}" = "e6400nvidia_4mb" ]; then [ "${target}" != "e6400nvidia_4mb" ] || \
${cbfstool} "${romfile}" remove \ ${cbfstool} "${romfile}" remove -n "pci10de,06eb.rom" || exit 1
-n "pci10de,06eb.rom" \
|| exit 1
fi
} }
err() err()
+8 -13
View File
@@ -77,12 +77,10 @@ create_release_directory()
download_modules() download_modules()
{ {
for modname in ${trees_fetch_list}; do for modname in ${trees_fetch_list}; do
[ ! -d "${modname}" ] && \ [ ! -d "${modname}" ] && ./fetch_trees ${modname}
./fetch_trees ${modname}
done done
for modname in ${simple_fetch_list}; do for modname in ${simple_fetch_list}; do
[ ! -d "${modname}/" ] && \ [ ! -d "${modname}/" ] && ./fetch ${modname}
./fetch ${modname}
done done
} }
@@ -110,12 +108,10 @@ copy_blobs()
for i in t440p xx20 xx30 hp8200sff hp_ivybridge hp_sandybridge \ for i in t440p xx20 xx30 hp8200sff hp_ivybridge hp_sandybridge \
hp8300usdt t1650; do hp8300usdt t1650; do
for j in ifd gbe 4_ifd 8_ifd 12_ifd 16_ifd; do for j in ifd gbe 4_ifd 8_ifd 12_ifd 16_ifd; do
if [ -f "blobs/${i}/${j}.bin" ]; then [ -f "blobs/${i}/${j}.bin" ] || continue
if [ ! -e "${srcdir}/blobs/${i}" ]; then [ -e "${srcdir}/blobs/${i}" ] || \
mkdir -p "${srcdir}/blobs/${i}" mkdir -p "${srcdir}/blobs/${i}"
fi cp blobs/${i}/${j}.bin "${srcdir}/blobs/${i}"
cp blobs/${i}/${j}.bin "${srcdir}/blobs/${i}"
fi
done done
done done
} }
@@ -125,8 +121,7 @@ purge_files()
( (
cd "${srcdir}/coreboot/" || err "cd1" cd "${srcdir}/coreboot/" || err "cd1"
for i in *; do for i in *; do
[ ! -d "${i}" ] && \ [ ! -d "${i}" ] && continue
continue
( (
cd "${i}/" || err "cd2" cd "${i}/" || err "cd2"
make distclean || err "make-distclean1" make distclean || err "make-distclean1"
@@ -148,7 +143,7 @@ purge_files()
rm -Rf coreboot/coreboot/ || err "rm-rf1" rm -Rf coreboot/coreboot/ || err "rm-rf1"
rm -Rf .git .gitignore */.git* coreboot/*/.git* \ rm -Rf .git .gitignore */.git* coreboot/*/.git* \
coreboot/*/3rdparty/*/.git* || err "rm-rf2" coreboot/*/3rdparty/*/.git* || err "rm-rf2"
rm -Rf coreboot/*/util/nvidia/cbootimage/.git* || err "rm-rf3" rm -Rf coreboot/*/util/nvidia/cbootimage/.git* || err "rm-rf3"
rm -Rf u-boot/u-boot/ u-boot/*/.git* || err "rm-rf4" rm -Rf u-boot/u-boot/ u-boot/*/.git* || err "rm-rf4"
) )
+2 -2
View File
@@ -44,8 +44,8 @@ main()
[ -z "${project}" ] && err "project name not specified" [ -z "${project}" ] && err "project name not specified"
[ "${project}" = "ich9utils" ] && project="util/ich9utils" [ "${project}" = "ich9utils" ] && project="util/ich9utils"
[ -d "${project}" ] || ./fetch "${project}" \ [ -d "${project}" ] || ./fetch "${project}" || \
|| err "Cannot download project, ${project}" err "Cannot download project, ${project}"
[ -d "${project}" ] || err "Project, ${project}, not downloaded" [ -d "${project}" ] || err "Project, ${project}, not downloaded"
if [ "${project}" = "uefitool" ]; then if [ "${project}" = "uefitool" ]; then
+5 -12
View File
@@ -89,9 +89,8 @@ main()
target="${x}" target="${x}"
printf "Running 'make %s' for project '%s, target '%s''\n" \ printf "Running 'make %s' for project '%s, target '%s''\n" \
"${mode}" "${project}" "${target}" "${mode}" "${project}" "${target}"
if [ "${project}" = "coreboot" ] && [ "${mode}" = "all" ]; then [ "${project}" != "coreboot" ] || [ "${mode}" != "all" ] || \
./update blobs download ${target} || err "blobutil" ./update blobs download ${target} || err "blobutil"
fi
handle_defconfig || exit 1 handle_defconfig || exit 1
done done
@@ -166,35 +165,29 @@ check_cross_compiler()
err "check_cross_compiler" err "check_cross_compiler"
if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then
if [ ! -d "${cbdir}/util/crossgcc/xgcc/i386-elf/" ]; then [ -d "${cbdir}/util/crossgcc/xgcc/i386-elf/" ] || \
# Even for 64-bit machines, coreboot builds 32-bit ROM
# images, so we only need to worry about i386-elf
make -C "${cbdir}" crossgcc-i386 CPUS=$(nproc) || \ make -C "${cbdir}" crossgcc-i386 CPUS=$(nproc) || \
return 1 return 1
fi
case "$(uname -m)" in case "$(uname -m)" in
x86*|i*86|amd64) : ;; x86*|i*86|amd64) : ;;
*) export CROSS_COMPILE=i386-elf- ;; *) export CROSS_COMPILE=i386-elf- ;;
esac esac
elif [ "${arch}" = "ARMv7" ]; then elif [ "${arch}" = "ARMv7" ]; then
if [ ! -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ]; then [ -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ] || \
make -C "${cbdir}" crossgcc-arm CPUS=$(nproc) || \ make -C "${cbdir}" crossgcc-arm CPUS=$(nproc) || \
return 1 return 1
fi
case "$(uname -m)" in case "$(uname -m)" in
arm|arm32|armv6*|armv7*) : ;; arm|arm32|armv6*|armv7*) : ;;
*) export CROSS_COMPILE=arm-eabi- ;; *) export CROSS_COMPILE=arm-eabi- ;;
esac esac
elif [ "${arch}" = "AArch64" ]; then elif [ "${arch}" = "AArch64" ]; then
if [ ! -d "${cbdir}/util/crossgcc/xgcc/aarch64-elf/" ]; then [ -d "${cbdir}/util/crossgcc/xgcc/aarch64-elf/" ] || \
make -C "${cbdir}" crossgcc-aarch64 CPUS=$(nproc) || \ make -C "${cbdir}" crossgcc-aarch64 CPUS=$(nproc) || \
return 1 return 1
fi
# aarch64 also needs armv7 toolchain for arm-trusted-firmware # aarch64 also needs armv7 toolchain for arm-trusted-firmware
if [ ! -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ]; then [ -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ] || \
make -C "${cbdir}" crossgcc-arm CPUS=$(nproc) || \ make -C "${cbdir}" crossgcc-arm CPUS=$(nproc) || \
return 1 return 1
fi
case "$(uname -m)" in case "$(uname -m)" in
arm64|aarch64) : ;; arm64|aarch64) : ;;
*) export CROSS_COMPILE=aarch64-elf- ;; *) export CROSS_COMPILE=aarch64-elf- ;;
+7 -11
View File
@@ -20,24 +20,20 @@
set -u -e set -u -e
version="version-unknown" version="version-unknown"
if [ -f version ]; then [ -f version ] && version="$(cat version)"
version="$(cat version)"
fi
version_="${version}" version_="${version}"
if [ -e ".git" ]; then if [ -e ".git" ]; then
version="$(git describe --tags HEAD 2>&1)" \ version="$(git describe --tags HEAD 2>&1)" || \
|| version="git-$(git rev-parse HEAD 2>&1)" \ version="git-$(git rev-parse HEAD 2>&1)" || \
|| version="${version_}" version="${version_}"
printf "%s\n" "${version}" > version printf "%s\n" "${version}" > version
fi fi
versiondate="version-date-unknown" versiondate="version-date-unknown"
if [ -f versiondate ]; then [ -f versiondate ] && versiondate="$(cat versiondate)"
versiondate="$(cat versiondate)"
fi
versiondate_="${versiondate}" versiondate_="${versiondate}"
if [ -e ".git" ]; then if [ -e ".git" ]; then
versiondate="$(git show --no-patch --no-notes --pretty='%ct' HEAD)" \ versiondate="$(git show --no-patch --no-notes --pretty='%ct' HEAD)" || \
|| versiondate="${versiondate_}" versiondate="${versiondate_}"
printf "%s\n" "${versiondate}" > versiondate printf "%s\n" "${versiondate}" > versiondate
fi fi
+76 -162
View File
@@ -54,15 +54,13 @@ main()
boarddir="${cbcfgsdir}/${board}" boarddir="${cbcfgsdir}/${board}"
[ ! -d "${boarddir}" ] && \ [ ! -d "${boarddir}" ] && \
fail "Board target, ${board}, not defined" fail "Board target, ${board}, not defined"
[ ! -f "${boarddir}/target.cfg" ] && \ [ ! -f "${boarddir}/target.cfg" ] && \
fail "Target missing target.cfg" fail "Target missing target.cfg"
no_config="printf \"No config for target, %s\\n\" ${board} 1>&2; exit 0" no_config="printf \"No config for target, %s\\n\" ${board} 1>&2; exit 0"
for x in "${boarddir}"/config/*; do for x in "${boarddir}"/config/*; do
if [ -f "${x}" ]; then [ -f "${x}" ] && no_config=""
no_config=""
fi
done done
eval "${no_config}" eval "${no_config}"
@@ -79,34 +77,19 @@ detect_firmware()
. ${1} 2>/dev/null . ${1} 2>/dev/null
. "${boarddir}/target.cfg" . "${boarddir}/target.cfg"
if [ "${CONFIG_HAVE_MRC}" = "y" ]; then [ "${CONFIG_HAVE_MRC}" = "y" ] && needs="${needs} MRC"
needs="${needs} MRC" [ "${CONFIG_HAVE_IFD_BIN}" = "y" ] && needs="${needs} IFD"
fi [ "${CONFIG_HAVE_ME_BIN}" = "y" ] && needs="${needs} ME"
if [ "${CONFIG_HAVE_IFD_BIN}" = "y" ]; then [ "${CONFIG_HAVE_GBE_BIN}" = "y" ] && needs="${needs} GBE"
needs="${needs} IFD" [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ] && needs="${needs} EC"
fi [ "${CONFIG_BOARD_DELL_E6400}" = "y" ] && \
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then [ "${CONFIG_VGA_BIOS_FILE}" != "" ] && needs="${needs} E6400VGA"
needs="${needs} ME" [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ] && \
fi needs="${needs} SCH5545EC"
if [ "${CONFIG_HAVE_GBE_BIN}" = "y" ]; then [ -z ${needs+x} ] && \
needs="${needs} GBE" printf 'No binary blobs needed for this board\n' && \
fi
if [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ]; then
needs="${needs} EC"
fi
if [ "${CONFIG_BOARD_DELL_E6400}" = "y" ] \
&& [ "${CONFIG_VGA_BIOS_FILE}" != "" ]; then
needs="${needs} E6400VGA"
fi
if [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ]; then
needs="${needs} SCH5545EC"
fi
if [ -z ${needs+x} ]; then
printf 'No binary blobs needed for this board\n'
return 1 return 1
fi printf "Firmware needed for board '%s':\n%s\n" ${board} ${needs}
printf "Firmware needed for board '%s':\n" ${board}
printf "%s\n" ${needs}
} }
scan_sources_config() scan_sources_config()
@@ -120,60 +103,46 @@ scan_sources_config()
case ${line} in case ${line} in
EC_url_bkup*) EC_url_bkup*)
set ${line} set ${line}
ec_url_bkup=${2} ec_url_bkup=${2} ;;
;;
EC_url*) EC_url*)
set ${line} set ${line}
ec_url=${2} ec_url=${2} ;;
;;
EC_hash*) EC_hash*)
set ${line} set ${line}
ec_hash=${2} ec_hash=${2} ;;
;;
DL_hash*) DL_hash*)
set ${line} set ${line}
dl_hash=${2} dl_hash=${2} ;;
;;
DL_url_bkup*) DL_url_bkup*)
set ${line} set ${line}
dl_url_bkup=${2} dl_url_bkup=${2} ;;
;;
DL_url*) DL_url*)
set ${line} set ${line}
dl_url=${2} dl_url=${2} ;;
;;
E6400_VGA_DL_hash*) E6400_VGA_DL_hash*)
set ${line} set ${line}
e6400_vga_dl_hash=${2} e6400_vga_dl_hash=${2} ;;
;;
E6400_VGA_DL_url_bkup*) E6400_VGA_DL_url_bkup*)
set ${line} set ${line}
e6400_vga_dl_url_bkup=${2} e6400_vga_dl_url_bkup=${2} ;;
;;
E6400_VGA_DL_url*) E6400_VGA_DL_url*)
set ${line} set ${line}
e6400_vga_dl_url=${2} e6400_vga_dl_url=${2} ;;
;;
E6400_VGA_offset*) E6400_VGA_offset*)
set ${line} set ${line}
e6400_vga_offset=${2} e6400_vga_offset=${2} ;;
;;
E6400_VGA_romname*) E6400_VGA_romname*)
set ${line} set ${line}
e6400_vga_romname=${2} e6400_vga_romname=${2} ;;
;;
SCH5545EC_DL_hash*) SCH5545EC_DL_hash*)
set ${line} set ${line}
sch5545ec_dl_hash=${2} sch5545ec_dl_hash=${2} ;;
;;
SCH5545EC_DL_url_bkup*) SCH5545EC_DL_url_bkup*)
set ${line} set ${line}
sch5545ec_dl_url_bkup=${2} sch5545ec_dl_url_bkup=${2} ;;
;;
SCH5545EC_DL_url*) SCH5545EC_DL_url*)
set ${line} set ${line}
sch5545ec_dl_url=${2} sch5545ec_dl_url=${2} ;;
;;
esac esac
done << EOF done << EOF
$(eval "awk '${awkstr}' resources/blobs/sources") $(eval "awk '${awkstr}' resources/blobs/sources")
@@ -182,44 +151,18 @@ EOF
build_dependencies() build_dependencies()
{ {
if [ ! -d me_cleaner ]; then [ -d ${cbdir} ] || \
printf "downloading me_cleaner\n" ./fetch_trees coreboot ${cbdir##*/} || \
./fetch me_cleaner || fail "could not download me_cleaner" fail "can't download to ${cbdir}"
fi for d in uefitool biosutilities bios_extract me_cleaner; do
if [ ! -d ${cbdir} ]; then [ -d "${d}" ] && continue
printf "downloading coreboot\n" ./fetch ${d} || fail "can't download ${d}"
./fetch_trees coreboot default \ done
|| fail "could not download coreboot" [ -f uefitool/uefiextract ] || \
fi ./build src for -b uefitool || fail "can't build uefitool"
if [ ! -d bios_extract ]; then [ -f ${cbdir}/util/kbc1126/kbc1126_ec_dump ] || \
printf "downloading bios_extract\n" make -BC ${cbdir}/util/kbc1126 || \
./fetch bios_extract \ fail "can't build kbc1126_ec_dump"
|| fail "could not download bios_extract"
fi
if [ ! -d biosutilities ]; then
printf "downloading biosutilities\n"
./fetch biosutilities \
|| fail "could not download biosutilities"
fi
if [ ! -d uefitool ]; then
printf "download uefitool (for UEFIExtract)\n"
./fetch uefitool \
|| fail "could not download uefitool"
fi
if [ ! -f uefitool/uefiextract ]; then
./build src for -b uefitool \
|| fail "could not build uefitool"
fi
if [ ! -f ${cbdir}/util/kbc1126/kbc1126_ec_dump ]; then
printf "Building kbc1126_ec_dump from coreboot\n"
make -BC ${cbdir}/util/kbc1126 \
|| fail "could not build kbc1126_ec_dump"
fi
if [ ! -f "${cbdir}/util/ifdtool/ifdtool" ]; then
printf "building ifdtool from coreboot\n"
make -C ${cbdir}/util/ifdtool \
|| fail 'could not build ifdtool'
fi
} }
download_blobs() download_blobs()
@@ -227,26 +170,20 @@ download_blobs()
for need in ${needs}; do for need in ${needs}; do
case ${need} in case ${need} in
*ME*) *ME*)
download_blob_intel_me || _failed="${_failed} me" download_blob_intel_me || _failed="${_failed} me" ;;
;;
*SCH5545EC*) *SCH5545EC*)
download_sch5545ec || failed="${_failed} sch5545ec" download_sch5545ec || failed="${_failed} sch5545ec" ;;
;;
*EC*) *EC*)
download_ec || _failed="${_failed} ec" download_ec || _failed="${_failed} ec" ;;
;;
*E6400VGA*) *E6400VGA*)
download_e6400vga || _failed="${_failed} e6400vga" download_e6400vga || _failed="${_failed} e6400vga" ;;
;;
*MRC*) *MRC*)
./update blobs mrc || _failed="${_failed} mrc" ./update blobs mrc || _failed="${_failed} mrc" ;;
;;
esac esac
done done
if [ ! -z ${_failed+x} ]; then [ -z ${_failed+x} ] || \
fail "failed to obtain ${_failed}\nTry manual extraction?" fail "failed to obtain ${_failed}\nTry manual extraction?"
fi
} }
download_blob_intel_me() download_blob_intel_me()
@@ -263,12 +200,10 @@ extract_blob_intel_me()
_me_destination=${CONFIG_ME_BIN_PATH#../../} _me_destination=${CONFIG_ME_BIN_PATH#../../}
if [ ! -d "${_me_destination%/*}" ]; then [ -d "${_me_destination%/*}" ] || \
mkdir -p ${_me_destination%/*} mkdir -p ${_me_destination%/*}
fi [ -d "${appdir}" ] && \
if [ -d "${appdir}" ]; then rm -Rf ${appdir}
rm -r ${appdir}
fi
if [ -f "${_me_destination}" ]; then if [ -f "${_me_destination}" ]; then
printf 'me already downloaded\n' printf 'me already downloaded\n'
return 0 return 0
@@ -276,14 +211,13 @@ extract_blob_intel_me()
printf "Extracting and stripping Intel ME firmware\n" printf "Extracting and stripping Intel ME firmware\n"
innoextract ${dl_path} -d ${appdir} \ innoextract ${dl_path} -d ${appdir} || \
|| 7z x ${dl_path} -o${appdir} \ 7z x ${dl_path} -o${appdir} || \
|| unar "${dl_path}" -o "${appdir}" \ unar "${dl_path}" -o "${appdir}" || \
|| fail 'Could not extract vendor update' fail "Could not extract vendor update"
bruteforce_extract_blob_intel_me "$(pwd)/${_me_destination}" \ bruteforce_extract_blob_intel_me "$(pwd)/${_me_destination}" \
"$(pwd)/${appdir}" \ "$(pwd)/${appdir}" || fail "Could not extract Intel ME firmware"
|| fail "Could not extract Intel ME firmware"
printf "Truncated and cleaned me output to ${_me_destination}\n" printf "Truncated and cleaned me output to ${_me_destination}\n"
} }
@@ -294,9 +228,7 @@ bruteforce_extract_blob_intel_me()
_me_destination="${1}" _me_destination="${1}"
cdir="${2}" # must be an absolute path, not relative cdir="${2}" # must be an absolute path, not relative
if [ -f "${_me_destination}" ]; then [ -f "${_me_destination}" ] && return 0
return 0
fi
sdir="$(mktemp -d)" sdir="$(mktemp -d)"
mkdir -p "${sdir}" || return 1 mkdir -p "${sdir}" || return 1
@@ -321,9 +253,9 @@ bruteforce_extract_blob_intel_me()
&& break # (we found me.bin) && break # (we found me.bin)
_7ztest="${_7ztest}a" _7ztest="${_7ztest}a"
7z x "${i}" -o${_7ztest} \ 7z x "${i}" -o${_7ztest} \
|| innoextract "${i}" -d "${_7ztest}" \ || innoextract "${i}" -d "${_7ztest}" \
|| unar "${i}" -o "${_7ztest}" \ || unar "${i}" -o "${_7ztest}" \
|| continue || continue
bruteforce_extract_blob_intel_me "${_me_destination}" \ bruteforce_extract_blob_intel_me "${_me_destination}" \
"${cdir}/${_7ztest}" "${cdir}/${_7ztest}"
elif [ -d "$i" ]; then elif [ -d "$i" ]; then
@@ -351,21 +283,19 @@ download_ec()
printf "Downloading KBC1126 EC firmware for HP laptop\n" printf "Downloading KBC1126 EC firmware for HP laptop\n"
fetch_update ec || return 1 fetch_update ec || return 1
extract_ec || return 1 extract_blob_kbc1126_ec || return 1
} }
extract_ec() extract_blob_kbc1126_ec()
{ {
printf "Extracting KBC1126 EC firmware for board: %s\n" ${board} printf "Extracting KBC1126 EC firmware for board: %s\n" ${board}
_ec_destination=${CONFIG_KBC1126_FW1#../../} _ec_destination=${CONFIG_KBC1126_FW1#../../}
if [ ! -d "${_ec_destination%/*}" ]; then [ -d "${_ec_destination%/*}" ] || \
mkdir -p "${_ec_destination%/*}" mkdir -p "${_ec_destination%/*}"
fi [ -d "${appdir}" ] && \
if [ -d "${appdir}" ]; then
rm -Rf "${appdir}" rm -Rf "${appdir}"
fi
if [ -f "${_ec_destination}" ]; then if [ -f "${_ec_destination}" ]; then
printf "ec already downloaded\n" printf "ec already downloaded\n"
return 0 return 0
@@ -383,23 +313,15 @@ extract_ec()
unar -D 68*.CAB Rom.bin unar -D 68*.CAB Rom.bin
mv Rom.bin ec.bin mv Rom.bin ec.bin
fi fi
if [ ! -f ec.bin ]; then
printf "could not extract ec.bin for board '%s'" ${board} \
1>&2
fail "aborting the build. please audit lbmk carefully."
fi
[ -f ec.bin ] || fail "could not extract ec.bin for board, ${board}"
"${kbc1126_ec_dump}" ec.bin "${kbc1126_ec_dump}" ec.bin
) )
for i in 1 2; do for i in 1 2; do
if [ -f "${appdir}/${dl_path##*/}/ec.bin.fw${i}" ]; then [ -f "${appdir}/${dl_path##*/}/ec.bin.fw${i}" ] && continue
continue
fi
printf "Not found: %s/%s/ec.bin.fw%s\n" \
${appdir} ${dl_path##*/} ${i}
printf "Could not extract EC firmware for: %s\n" \ printf "Could not extract EC firmware for: %s\n" \
${board} ${board}
return 1 return 1
done done
@@ -424,12 +346,10 @@ extract_e6400vga()
printf 'vga rom already downloaded\n' printf 'vga rom already downloaded\n'
return 0 return 0
fi fi
if [ ! -d "${_vga_destination%/*}" ]; then [ -d "${_vga_destination%/*}" ] || \
mkdir -p ${_vga_destination%/*} mkdir -p ${_vga_destination%/*}
fi [ -d "${appdir}" ] && \
if [ -d "${appdir}" ]; then rm -Rf ${appdir}
rm -r ${appdir}
fi
mkdir -p "${appdir}" mkdir -p "${appdir}"
mv "${dl_path}" "${appdir}" mv "${dl_path}" "${appdir}"
@@ -446,13 +366,11 @@ extract_e6400vga()
cd "${appdir}" cd "${appdir}"
tail -c +${e6400_vga_offset} "${dl_path##*/}" \ tail -c +${e6400_vga_offset} "${dl_path##*/}" \
| gunzip > bios.bin | gunzip > bios.bin
if [ ! -f "bios.bin" ]; then [ -f "bios.bin" ] || \
fail 'Could not extract bios.bin from Dell E6400 update' fail "Could not extract bios.bin from Dell E6400 update"
fi
"${e6400_unpack}" bios.bin || printf "TODO: fix dell extract util\n" "${e6400_unpack}" bios.bin || printf "TODO: fix dell extract util\n"
if [ ! -f "${e6400_vga_romname}" ]; then [ -f "${e6400_vga_romname}" ] || \
fail 'Could not extract VGA ROM from Dell E6400 BIOS update' fail "Could not extract VGA ROM from Dell E6400 BIOS update"
fi
) )
cp "${appdir}"/"${e6400_vga_romname}" "${_vga_destination}" cp "${appdir}"/"${e6400_vga_romname}" "${_vga_destination}"
@@ -482,11 +400,9 @@ extract_sch5545ec()
return 0 return 0
fi fi
if [ -d "${appdir}" ]; then [ -d "${appdir}" ] rm -Rf "${appdir}"
rm -Rf "${appdir}"
fi
mkdir -p "${appdir}/"
mkdir -p "${appdir}/"
cp "${dl_path}" "${appdir}/" cp "${dl_path}" "${appdir}/"
python "${pfs_extract}" "${appdir}/${dlsum}" -e || exit 1 python "${pfs_extract}" "${appdir}/${dlsum}" -e || exit 1
@@ -545,9 +461,7 @@ fetch_update()
dl_fail="y" dl_fail="y"
vendor_checksum ${dlsum} && dl_fail="n" vendor_checksum ${dlsum} && dl_fail="n"
for x in "${dl}" "${dl_bkup}"; do for x in "${dl}" "${dl_bkup}"; do
if [ "${dl_fail}" = "n" ]; then [ "${dl_fail}" = "n" ] && break
break
fi
rm -f "${dl_path}" rm -f "${dl_path}"
wget -U "${agent}" ${x} -O ${dl_path} wget -U "${agent}" ${x} -O ${dl_path}
vendor_checksum ${dlsum} && dl_fail="n" vendor_checksum ${dlsum} && dl_fail="n"
+20 -48
View File
@@ -29,13 +29,10 @@ _ifd_destination=""
main() main()
{ {
sname=${0} sname=${0}
if [ $# -lt 2 ]; then [ $# -lt 2 ] && fail "Missing arguments (fewer than two)."
fail "Missing arguments (less than two)."
fi
board="${1}" board="${1}"
vendor_rom="${2}" vendor_rom="${2}"
boarddir="${cbcfgsdir}/${board}" boarddir="${cbcfgsdir}/${board}"
check_board check_board
@@ -45,39 +42,22 @@ main()
check_board() check_board()
{ {
if [ ! -f "${vendor_rom}" ] ; then [ -f "${vendor_rom}" ] || \
fail "file does not exist: ${vendor_rom}" fail "file does not exist: ${vendor_rom}"
elif [ ! -d "${boarddir}" ]; then [ -d "${boarddir}" ] || \
fail "build/roms ${board}: target not defined" fail "build/roms ${board}: target not defined"
elif [ ! -f "${boarddir}/target.cfg" ]; then [ -f "${boarddir}/target.cfg" ] || \
fail "build/roms ${board}: missing target.cfg" fail "build/roms ${board}: missing target.cfg"
fi
} }
build_dependencies() build_dependencies()
{ {
if [ ! -d me_cleaner ]; then [ -d me_cleaner ] || \
printf "downloading me_cleaner\n" ./fetch me_cleaner || fail "can't fetch me_cleaner"
./fetch me_cleaner || fail 'could not download me_cleaner' [ -d ${cbdir} ] || \
else ./fetch_trees coreboot default || fail "can't fetch coreboot"
printf "me_cleaner already downloaded. Skipping.\n" [ -f ${ifdtool} ] || \
printf "run ./fetch me_cleaner to manually overwrite\n" make -C "${ifdtool%/ifdtool}" || fail "can't build ifdtool"
fi
if [ ! -d ${cbdir} ]; then
printf "downloading coreboot\n"
./fetch_trees coreboot default \
|| fail "could not download coreboot"
else
printf "coreboot already downloaded. Skipping.\n"
printf "run ./fetch_trees coreboot to manually overwrite\n"
fi
if ! [ -f ${ifdtool} ]; then
printf "building ifdtool from coreboot\n"
make -C "${ifdtool%/ifdtool}" \
|| fail "could not build ifdtool"
fi
} }
extract_blobs() extract_blobs()
@@ -88,10 +68,8 @@ extract_blobs()
. ${1} 2>/dev/null . ${1} 2>/dev/null
. "${boarddir}/target.cfg" . "${boarddir}/target.cfg"
if [ "$CONFIG_HAVE_MRC" = "y" ]; then [ "$CONFIG_HAVE_MRC" != "y" ] || \
printf 'haswell board detected, downloading mrc\n'
./update blobs mrc || fail "could not download mrc" ./update blobs mrc || fail "could not download mrc"
fi
_me_destination=${CONFIG_ME_BIN_PATH#../../} _me_destination=${CONFIG_ME_BIN_PATH#../../}
_gbe_destination=${CONFIG_GBE_BIN_PATH#../../} _gbe_destination=${CONFIG_GBE_BIN_PATH#../../}
@@ -103,13 +81,9 @@ extract_blobs()
# Cleans up other files extracted with ifdtool # Cleans up other files extracted with ifdtool
rm -f flashregion*.bin 2> /dev/null rm -f flashregion*.bin 2> /dev/null
if [ -f ${_ifd_destination} ]; then [ -f ${_ifd_destination} ] || fail "Could not extract IFD"
printf "gbe, ifd, and me extracted to %s\n" \ printf "gbe, ifd, and me extracted to %s\n" \
${_me_destination%/*} ${_me_destination%/*}
else
printf "WARNING: Intel firmware descriptor could not "
printf "be extracted with modified me\n"
fi
} }
extract_blob_intel_me() extract_blob_intel_me()
@@ -117,25 +91,23 @@ extract_blob_intel_me()
printf "extracting clean ime and modified ifd\n" printf "extracting clean ime and modified ifd\n"
${mecleaner} -D ${_ifd_destination} \ ${mecleaner} -D ${_ifd_destination} \
-M ${_me_destination} ${vendor_rom} -t -r -S \ -M ${_me_destination} ${vendor_rom} -t -r -S || \
|| ${me7updateparser} \ ${me7updateparser} \
-O ${_me_destination} ${vendor_rom} \ -O ${_me_destination} ${vendor_rom} || \
|| fail \ fail "me_cleaner failed to extract blobs from rom"
"me_cleaner failed to extract blobs from rom"
} }
extract_blob_intel_gbe_nvm() extract_blob_intel_gbe_nvm()
{ {
printf "extracting gigabit ethernet firmware" printf "extracting gigabit ethernet firmware"
./${ifdtool} -x ${vendor_rom} ./${ifdtool} -x ${vendor_rom}
mv flashregion*gbe.bin ${_gbe_destination} \ mv flashregion*gbe.bin ${_gbe_destination} || \
|| fail 'could not extract gbe' fail 'could not extract gbe'
} }
fail() fail()
{ {
print_help print_help
printf "\n%s: ERROR: %s\n" ${sname} $@ printf "\n%s: ERROR: %s\n" ${sname} $@
exit 1 exit 1
} }
+50 -105
View File
@@ -41,12 +41,8 @@ main()
{ {
sname="${0}" sname="${0}"
if [ $# -lt 1 ]; then [ $# -lt 1 ] && fail "No options specified."
fail "No options specified." [ "${1}" = "listboards" ] && listboards && exit 0
elif [ "${1}" = "listboards" ]; then
listboards
exit 0
fi
archive="${1}" archive="${1}"
@@ -54,15 +50,12 @@ main()
do do
case "${option}" in case "${option}" in
r) r)
rom=${OPTARG} rom=${OPTARG} ;;
;;
b) b)
board=${OPTARG} board=${OPTARG} ;;
;;
m) m)
modifygbe=true modifygbe=true
new_mac=${OPTARG} new_mac=${OPTARG} ;;
;;
esac esac
done done
@@ -78,39 +71,29 @@ main()
check_board() check_board()
{ {
if ! check_release ${archive} ; then if ! check_release ${archive} ; then
if [ ! -f "${rom}" ]; then [ -f "${rom}" ] || \
fail "${rom} is not a valid path" fail "${rom} is not a valid path"
elif [ -z ${rom+x} ]; then [ -z ${rom+x} ] && \
fail 'no rom specified' fail 'no rom specified'
elif [ -z ${board+x} ]; then [ ! -z ${board+x} ] || \
board=$(detect_board ${rom}) \ board=$(detect_board ${rom}) || \
|| fail 'no board specified' fail 'no board specified'
fi
else else
release=true release=true
releasearchive="${archive}" releasearchive="${archive}"
board=$(detect_board ${archive}) \ board=$(detect_board ${archive}) || \
|| fail 'Could not detect board type' fail 'Could not detect board type'
fi fi
boarddir="${cbcfgsdir}/${board}" boarddir="${cbcfgsdir}/${board}"
if [ ! -d "${boarddir}" ]; then [ -d "${boarddir}" ] || fail "board ${board} not found"
fail "board ${board} not found"
fi
} }
check_release() check_release()
{ {
if [ ! -f "${archive}" ]; then [ -f "${archive}" ] || return 1
return 1 [ "${archive##*.}" = "xz" ] || return 1
fi printf "%s\n" "Release archive ${archive} detected"
if [ "${archive##*.}" = "xz" ]; then
printf "%s\n" "Release archive ${archive} detected"
return 0
else
return 1
fi
} }
# This function tries to determine the board from the filename of the rom. # This function tries to determine the board from the filename of the rom.
@@ -121,38 +104,25 @@ detect_board()
filename=$(basename ${path}) filename=$(basename ${path})
case ${filename} in case ${filename} in
grub_*) grub_*)
board=$(echo "${filename}" | cut -d '_' -f2-3) board=$(echo "${filename}" | cut -d '_' -f2-3) ;;
;;
seabios_withgrub_*) seabios_withgrub_*)
board=$(echo "${filename}" | cut -d '_' -f3-4) board=$(echo "${filename}" | cut -d '_' -f3-4) ;;
;;
*.tar.xz) *.tar.xz)
_stripped_prefix=${filename#*_} _stripped_prefix=${filename#*_}
board="${_stripped_prefix%.tar.xz}" board="${_stripped_prefix%.tar.xz}" ;;
;;
*) *)
return 1 return 1
esac esac
[ -d "${boarddir}/" ] || return 1
if [ -d "${boarddir}/" ]; then printf '%s\n' "${board}"
printf '%s\n' "${board}"
return 0
else
return 1
fi
} }
build_dependencies() build_dependencies()
{ {
if [ ! -d ${cbdir} ]; then [ -d "${cbdir}" ] || ./fetch_trees coreboot default
printf "downloading coreboot\n"
./fetch_trees coreboot default
fi
./build coreboot utils default || fail "could not build cbutils" ./build coreboot utils default || fail "could not build cbutils"
./update blobs download ${board} || \ ./update blobs download ${board} || \
fail "Could not download blobs for ${board}" fail "Could not download blobs for ${board}"
} }
inject_blobs() inject_blobs()
@@ -188,12 +158,9 @@ patch_release_roms()
done done
fi fi
if ! [ -d bin/release ]; then [ -d bin/release ] || mkdir -p bin/release
mkdir -p bin/release
fi
mv ${_tmpdir}/bin/* bin/release/ && \ mv ${_tmpdir}/bin/* bin/release/ && \
printf '%s\n' 'Success! Your ROMs are in bin/release' printf '%s\n' 'Success! Your ROMs are in bin/release'
rm -r "${_tmpdir}" rm -r "${_tmpdir}"
} }
@@ -206,31 +173,20 @@ patch_rom()
. ${1} 2>/dev/null . ${1} 2>/dev/null
. "${boarddir}/target.cfg" . "${boarddir}/target.cfg"
if [ "$CONFIG_HAVE_MRC" = "y" ]; then [ "$CONFIG_HAVE_MRC" = "y" ] && \
inject_blob_intel_mrc "${rom}" inject_blob_intel_mrc "${rom}"
fi [ "${CONFIG_HAVE_ME_BIN}" = "y" ] && \
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
inject_blob_intel_me "${rom}" inject_blob_intel_me "${rom}"
fi [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ] && \
if [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ]; then
inject_blob_hp_kbc1126_ec "${rom}" inject_blob_hp_kbc1126_ec "${rom}"
fi [ "${CONFIG_VGA_BIOS_FILE}" != "" ] && \
[ "${CONFIG_VGA_BIOS_ID}" != "" ] && \
if [ "${CONFIG_VGA_BIOS_FILE}" != "" ] \
&& [ "${CONFIG_VGA_BIOS_ID}" != "" ]; then
inject_blob_dell_e6400_vgarom_nvidia inject_blob_dell_e6400_vgarom_nvidia
fi [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ] && \
[ "${CONFIG_SMSC_SCH5545_EC_FW_FILE}" != "" ] && \
if [ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" = "y" ] \
&& [ "${CONFIG_SMSC_SCH5545_EC_FW_FILE}" != "" ]; then
inject_blob_smsc_sch5545_ec "${rom}" inject_blob_smsc_sch5545_ec "${rom}"
fi [ "${modifygbe}" = "true" ] && ! [ "${release}" = "true" ] && \
if [ "${modifygbe}" = "true" ] && ! [ "${release}" = "true" ]; then
modify_gbe ${rom} modify_gbe ${rom}
fi
} }
inject_blob_intel_mrc() inject_blob_intel_mrc()
@@ -266,16 +222,12 @@ inject_blob_intel_me()
printf 'adding intel management engine\n' printf 'adding intel management engine\n'
rom="${1}" rom="${1}"
[ -z ${CONFIG_ME_BIN_PATH} ] && \
if [ -z ${CONFIG_ME_BIN_PATH} ]; then
fail "CONFIG_ME_BIN_PATH not set" fail "CONFIG_ME_BIN_PATH not set"
fi
_me_location=${CONFIG_ME_BIN_PATH#../../} _me_location=${CONFIG_ME_BIN_PATH#../../}
[ ! -f "${_me_location}" ] && \
if [ ! -f "${_me_location}" ]; then
fail "CONFIG_ME_BIN_PATH points to missing file" fail "CONFIG_ME_BIN_PATH points to missing file"
fi
${ifdtool} -i me:${_me_location} ${rom} -O ${rom} || exit 1 ${ifdtool} -i me:${_me_location} ${rom} -O ${rom} || exit 1
} }
@@ -293,23 +245,23 @@ inject_blob_hp_kbc1126_ec()
if [ "${_ec1_offset}" = "" ] || [ "${_ec1_offset}" = "" ]; then if [ "${_ec1_offset}" = "" ] || [ "${_ec1_offset}" = "" ]; then
printf "EC offsets not declared for board: %s\n" \ printf "EC offsets not declared for board: %s\n" \
"${board}" "${board}"
exit 1 exit 1
fi fi
if [ "${_ec1_location}" = "" ] || [ "${_ec2_location}" = "" ]; then if [ "${_ec1_location}" = "" ] || [ "${_ec2_location}" = "" ]; then
printf "EC firmware path not declared for board: %s\n" \ printf "EC firmware path not declared for board: %s\n" \
"${board}" "${board}"
fi fi
if [ ! -f "${_ec1_location}" ] || [ ! -f "${_ec2_location}" ]; then if [ ! -f "${_ec1_location}" ] || [ ! -f "${_ec2_location}" ]; then
printf "EC firmware not downloaded for board: %s\n" \ printf "EC firmware not downloaded for board: %s\n" \
"${board}" "${board}"
exit 1 exit 1
fi fi
${cbfstool} "${rom}" add -f ${_ec1_location} -n ecfw1.bin \ ${cbfstool} "${rom}" add -f ${_ec1_location} -n ecfw1.bin \
-b ${_ec1_offset} -t raw || exit 1 -b ${_ec1_offset} -t raw || exit 1
${cbfstool} "${rom}" add -f ${_ec2_location} -n ecfw2.bin \ ${cbfstool} "${rom}" add -f ${_ec2_location} -n ecfw2.bin \
-b ${_ec2_offset} -t raw || exit 1 -b ${_ec2_offset} -t raw || exit 1
} }
inject_blob_dell_e6400_vgarom_nvidia() inject_blob_dell_e6400_vgarom_nvidia()
@@ -332,8 +284,8 @@ inject_blob_dell_e6400_vgarom_nvidia()
fi fi
${cbfstool} ${rom} add -f "${_vga_location}" \ ${cbfstool} ${rom} add -f "${_vga_location}" \
-n "pci${CONFIG_VGA_BIOS_ID}.rom" \ -n "pci${CONFIG_VGA_BIOS_ID}.rom" \
-t optionrom || exit 1 -t optionrom || exit 1
} }
inject_blob_smsc_sch5545_ec() inject_blob_smsc_sch5545_ec()
@@ -357,27 +309,22 @@ modify_gbe()
rom=${1} rom=${1}
if [ -z ${CONFIG_GBE_BIN_PATH} ]; then [ -z ${CONFIG_GBE_BIN_PATH} ] && \
fail "CONFIG_GBE_BIN_PATH not set" fail "CONFIG_GBE_BIN_PATH not set"
fi
_gbe_location=${CONFIG_GBE_BIN_PATH#../../} _gbe_location=${CONFIG_GBE_BIN_PATH#../../}
if [ ! -f "${_gbe_location}" ]; then [ -f "${_gbe_location}" ] || \
fail "CONFIG_GBE_BIN_PATH points to missing file" fail "CONFIG_GBE_BIN_PATH points to missing file"
fi [ -f ${nvmutil} ] || \
if [ ! -f ${nvmutil} ]; then
make -C util/nvmutil || fail 'failed to build nvmutil' make -C util/nvmutil || fail 'failed to build nvmutil'
fi
_gbe_tmp=$(mktemp -t gbeXXXX.bin) _gbe_tmp=$(mktemp -t gbeXXXX.bin)
cp ${_gbe_location} ${_gbe_tmp} cp ${_gbe_location} ${_gbe_tmp}
${nvmutil} "${_gbe_tmp}" setmac ${new_mac} \ ${nvmutil} "${_gbe_tmp}" setmac ${new_mac} || \
|| fail 'failed to modify mac address' fail 'failed to modify mac address'
${ifdtool} -i GbE:${_gbe_tmp} "${rom}" \ ${ifdtool} -i GbE:${_gbe_tmp} "${rom}" -O "${rom}" || exit 1
-O "${rom}" || exit 1
rm -f ${_gbe_tmp} rm -f ${_gbe_tmp}
} }
@@ -385,7 +332,7 @@ modify_gbe()
listboards() listboards()
{ {
for boarddir in ${cbcfgsdir}/*; do for boarddir in ${cbcfgsdir}/*; do
if [ ! -d "${boarddir}" ]; then continue; fi [ -d "${boarddir}" ] || continue
board="${boarddir##${cbcfgsdir}/}" board="${boarddir##${cbcfgsdir}/}"
board="${board%/}" board="${board%/}"
printf '%s\n' "${board##*/}" printf '%s\n' "${board##*/}"
@@ -394,10 +341,8 @@ listboards()
fail() fail()
{ {
if [ ! -z ${@+x} ]; then [ -z ${@+x} ] || \
printf "\n%s: ERROR: ${@}\n" ${sname} printf "\n%s: ERROR: ${@}\n" ${sname}
fi
usage usage
exit 1 exit 1
} }
+24 -34
View File
@@ -57,25 +57,19 @@ main()
check_existing() check_existing()
{ {
if [ ! -f ${_mrc_complete} ]; then [ -f ${_mrc_complete} ] || \
return 1 return 1
fi printf 'found existing mrc.bin\n'
printf 'found existing mrc.bin, checking its hash\n' [ "$(sha1sum ${_mrc_complete} | awk '{print $1}')" \
if [ "$(sha1sum ${_mrc_complete} | awk '{print $1}')" \ = "${_mrc_complete_hash}" ] && \
= "${_mrc_complete_hash}" ]; then
printf 'checksums matched, skipping downloading\n'
return 0 return 0
else printf 'hashes did not match, starting over\n'
printf 'hashes did not match, starting over\n' return 1
return 1
fi
} }
build_dependencies() build_dependencies()
{ {
if [ ! -d "${cbdir}/" ]; then [ -d "${cbdir}/" ] || ./fetch_trees coreboot default || return 1
./fetch_trees coreboot default || return 1
fi
./build coreboot utils default || return 1 ./build coreboot utils default || return 1
return 0 return 0
} }
@@ -88,23 +82,20 @@ fetch_mrc()
cd mrc/haswell/ cd mrc/haswell/
download_image ${_url} ${_file} ${_sha1sum} download_image ${_url} ${_file} ${_sha1sum}
if [ ! -f ${_file} ]; then [ -f ${_file} ] || \
download_image ${_url2} ${_file} ${_sha1sum} download_image ${_url2} ${_file} ${_sha1sum}
fi [ -f $_file ] || \
if [ ! -f $_file ]; then
fail "%{_file} not downloaded / verification failed." fail "%{_file} not downloaded / verification failed."
fi
extract_partition ROOT-A ${_file} root-a.ext2 extract_partition ROOT-A ${_file} root-a.ext2
extract_shellball root-a.ext2 chromeos-firmwareupdate-${_board} extract_shellball root-a.ext2 chromeos-firmwareupdate-${_board}
extract_coreboot chromeos-firmwareupdate-${_board} extract_coreboot chromeos-firmwareupdate-${_board}
../../${cbfstool} coreboot-*.bin extract -f mrc.bin \ ../../${cbfstool} coreboot-*.bin extract -f mrc.bin -n mrc.bin \
-n mrc.bin -r RO_SECTION \ -r RO_SECTION || fail "Could not fetch mrc.bin"
|| fail "Could not fetch mrc.bin"
rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin \ rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin \
"${_file}" "root-a.ext2" "${_file}" "root-a.ext2"
printf "\n\nmrc.bin saved to ${_mrc_complete}\n\n" printf "\n\nmrc.bin saved to ${_mrc_complete}\n\n"
) )
@@ -118,19 +109,18 @@ download_image()
_file=${2} _file=${2}
_sha1sum=${3} _sha1sum=${3}
echo "Downloading recovery image" printf "Downloading recovery image\n"
curl "$url" > "$_file.zip" curl "$url" > "$_file.zip"
printf "Verifying recovery image checksum\n"
if [ "$(sha1sum ${_file}.zip | awk '{print $1}')" = "${_sha1sum}" ] if [ "$(sha1sum ${_file}.zip | awk '{print $1}')" = "${_sha1sum}" ]
then then
unzip -q "${_file}.zip" unzip -q "${_file}.zip"
rm "${_file}.zip" rm "${_file}.zip"
echo "Checksum verification passed for recovery image."
return 0 return 0
else
rm "${_file}.zip"
echo "Bad checksum. Recovery image deleted."
return 1
fi fi
rm "${_file}.zip"
printf "Bad checksum. Recovery image deleted.\n"
return 1
} }
extract_partition() extract_partition()
@@ -140,15 +130,15 @@ extract_partition()
ROOTFS=${3} ROOTFS=${3}
_bs=1024 _bs=1024
echo "Extracting ROOT-A partition" printf "Extracting ROOT-A partition\n"
ROOTP=$( printf "unit\nB\nprint\nquit\n" | \ ROOTP=$( printf "unit\nB\nprint\nquit\n" | \
parted ${FILE} 2>/dev/null | grep ${NAME} ) parted ${FILE} 2>/dev/null | grep ${NAME} )
START=$(( $( echo ${ROOTP} | cut -f2 -d\ | tr -d "B" ) )) START=$(( $( echo ${ROOTP} | cut -f2 -d\ | tr -d "B" ) ))
SIZE=$(( $( echo ${ROOTP} | cut -f4 -d\ | tr -d "B" ) )) SIZE=$(( $( echo ${ROOTP} | cut -f4 -d\ | tr -d "B" ) ))
dd if=${FILE} of=${ROOTFS} bs=${_bs} skip=$(( ${START} / ${_bs} )) \ dd if=${FILE} of=${ROOTFS} bs=${_bs} skip=$(( ${START} / ${_bs} )) \
count=$(( ${SIZE} / ${_bs} )) > /dev/null count=$(( ${SIZE} / ${_bs} )) > /dev/null
} }
extract_shellball() extract_shellball()
@@ -156,9 +146,9 @@ extract_shellball()
ROOTFS=${1} ROOTFS=${1}
SHELLBALL=${2} SHELLBALL=${2}
echo "Extracting chromeos-firmwareupdate" printf "Extracting chromeos-firmwareupdate\n"
printf "cd /usr/sbin\ndump chromeos-firmwareupdate ${SHELLBALL}\nquit" \ printf "cd /usr/sbin\ndump chromeos-firmwareupdate ${SHELLBALL}\nquit" \
| debugfs ${ROOTFS} > /dev/null 2>&1 | debugfs ${ROOTFS} > /dev/null 2>&1
} }
extract_coreboot() extract_coreboot()
@@ -166,11 +156,11 @@ extract_coreboot()
_shellball=${1} _shellball=${1}
_unpacked=$( mktemp -d ) _unpacked=$( mktemp -d )
echo "Extracting coreboot image" printf "Extracting coreboot image\n"
sh ${_shellball} --unpack ${_unpacked} > /dev/null sh ${_shellball} --unpack ${_unpacked} > /dev/null
_version=$( cat ${_unpacked}/VERSION | grep BIOS\ version: | \ _version=$( cat ${_unpacked}/VERSION | grep BIOS\ version: | \
cut -f2 -d: | tr -d \ ) cut -f2 -d: | tr -d \ )
cp ${_unpacked}/bios.bin coreboot-${_version}.bin cp ${_unpacked}/bios.bin coreboot-${_version}.bin
rm -r "${_unpacked}" rm -r "${_unpacked}"