mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-26 13:59:02 +02:00
This results in much cleaner copyright and license declarations. SPDX headers are legally recognised and make auditing easier. Also, remove descriptions of each script, from each script. Libreboot documentation at docs/maintain/ describes them. Signed-off-by: Leah Rowe <leah@libreboot.org>
92 lines
2.5 KiB
Bash
Executable File
92 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
|
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
|
|
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
|
|
|
|
. "include/err.sh"
|
|
. "include/defconfig.sh"
|
|
. "include/blobutil.sh"
|
|
|
|
main()
|
|
{
|
|
sname=${0}
|
|
[ $# -lt 2 ] && err "Missing arguments (fewer than two)."
|
|
|
|
board="${1}"
|
|
vendor_rom="${2}"
|
|
boarddir="${cbcfgsdir}/${board}"
|
|
|
|
[ -f "${vendor_rom}" ] || \
|
|
err "${board}: file does not exist: ${vendor_rom}"
|
|
build_dependencies
|
|
extract_blobs
|
|
}
|
|
|
|
build_dependencies()
|
|
{
|
|
if [ ! -d me_cleaner ]; then
|
|
./update project repo me_cleaner || \
|
|
err "build_dependencies: can't fetch me_cleaner"
|
|
elif [ ! -d "${cbdir}" ]; then
|
|
./update project trees coreboot default || \
|
|
err "build_dependencies: can't fetch coreboot"
|
|
elif [ ! -f "${ifdtool}" ]; then
|
|
./build coreboot utils || \
|
|
err "build_dependencies: can't build ifdtool"
|
|
fi
|
|
}
|
|
|
|
extract_blobs()
|
|
{
|
|
printf "extracting blobs for %s from %s\n" ${board} ${vendor_rom}
|
|
|
|
check_defconfig "${boarddir}" || exit 1
|
|
set -- "${boarddir}/config/"*
|
|
. "${1}" 2>/dev/null
|
|
|
|
[ "$CONFIG_HAVE_MRC" != "y" ] || \
|
|
./update blobs mrc || err "extract_blobs: can't fetch mrc"
|
|
|
|
_me_destination=${CONFIG_ME_BIN_PATH#../../}
|
|
_gbe_destination=${CONFIG_GBE_BIN_PATH#../../}
|
|
_ifd_destination=${CONFIG_IFD_BIN_PATH#../../}
|
|
|
|
extract_blob_intel_me
|
|
extract_blob_intel_gbe_nvm
|
|
|
|
# Cleans up other files extracted with ifdtool
|
|
rm -f flashregion*.bin || err "extract_blobs: !rm -f flashregion*.bin"
|
|
|
|
[ -f "${_ifd_destination}" ] || err "extract_blobs: Cannot extract IFD"
|
|
printf "gbe, ifd, and me extracted to %s\n" "${_me_destination%/*}"
|
|
}
|
|
|
|
extract_blob_intel_me()
|
|
{
|
|
printf "extracting clean ime and modified ifd\n"
|
|
|
|
"${mecleaner}" -D "${_ifd_destination}" \
|
|
-M "${_me_destination}" "${vendor_rom}" -t -r -S || \
|
|
"${me7updateparser}" \
|
|
-O "${_me_destination}" "${vendor_rom}" || \
|
|
err "extract_blob_intel_me: cannot extract from vendor rom"
|
|
}
|
|
|
|
extract_blob_intel_gbe_nvm()
|
|
{
|
|
printf "extracting gigabit ethernet firmware"
|
|
./"${ifdtool}" -x "${vendor_rom}" || \
|
|
err "extract_blob_intel_gbe_nvm: cannot extract gbe.bin from rom"
|
|
mv flashregion*gbe.bin "${_gbe_destination}" || \
|
|
err "extract_blob_intel_gbe_nvm: cannot move gbe.bin"
|
|
}
|
|
|
|
print_help()
|
|
{
|
|
printf "Usage: ./update blobs extract {boardname} {path/to/vendor_rom}\n"
|
|
printf "Example: ./update blobs extract x230 12mb_flash.bin\n"
|
|
printf "\nYou need to specify exactly 2 arguments\n"
|
|
}
|
|
|
|
main $@
|