update/release: nuke roms using the inject script

This way, the handling of configs is unified into one
script, which reduces the possibility of bugs later,
and it reduces the repetition of code.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2023-10-14 03:30:52 +01:00
parent 2ebadb7ffd
commit ec0b38afb3
3 changed files with 51 additions and 67 deletions
+44 -26
View File
@@ -18,9 +18,10 @@ main()
archive="${1}"
while getopts r:b:m: option
while getopts n:r:b:m: option
do
case "${option}" in
n) nukemode="${OPTARG}" ;;
r) rom=${OPTARG} ;;
b) board=${OPTARG} ;;
m) modifygbe=true
@@ -31,7 +32,7 @@ main()
check_board
build_dependencies
inject_vendorfiles
[ "${nukemode}" = "nuke" ] && return 0
printf "Friendly reminder (this is *not* an error message):\n"
printf "Please always ensure that the files were inserted correctly.\n"
}
@@ -91,6 +92,7 @@ build_dependencies()
if [ ! -f "${cbfstool}" ] || [ ! -f "${ifdtool}" ]; then
x_ ./update project trees -b coreboot utils default
fi
[ "${nukemode}" = "nuke" ] && return 0
x_ ./update vendor download ${board}
}
@@ -126,7 +128,8 @@ patch_release_roms()
x_ cd "${_tmpdir}/bin/"*
# NOTE: For compatibility with older rom releases, defer to sha1
sha512sum --status -c vendorhashes || \
[ "${nukemode}" = "nuke" ] || \
sha512sum --status -c vendorhashes || \
sha1sum --status -c vendorhashes || \
sha512sum --status -c blobhashes || \
sha1sum --status -c blobhashes || \
@@ -188,8 +191,6 @@ inject_vendorfile_intel_mrc()
{
rom="${1}"
printf "adding mrc\n"
# mrc.bin must be inserted at a specific offset
# in cbfstool, -b values above 0x80000000 are interpreted as
@@ -207,23 +208,28 @@ inject_vendorfile_intel_mrc()
# source code, and it is *always* correct for haswell platform.
# TODO: this logic should be tweaked to handle more platforms
x_ "${cbfstool}" "${rom}" add -f mrc/haswell/mrc.bin -n mrc.bin \
-t mrc -b 0xfffa0000
if [ "${nukemode}" != "nuke" ]; then
x_ "${cbfstool}" "${rom}" add -f mrc/haswell/mrc.bin \
-n mrc.bin -t mrc -b 0xfffa0000
else
x_ "${cbfstool}" "${rom}" remove -n mrc.bin
fi
}
inject_vendorfile_intel_me()
{
printf "adding intel me firmware\n"
rom="${1}"
[ -z "${CONFIG_ME_BIN_PATH}" ] && \
err "inject_vendorfile_intel_me: CONFIG_ME_BIN_PATH not set"
_me_location=${CONFIG_ME_BIN_PATH##*../}
[ ! -f "${_me_location}" ] && \
[ ! -f "${_me_location}" ] && [ "${nukemode}" != "nuke" ] && \
err "inject_vendorfile_intel_me: per CONFIG_ME_BIN_PATH: file missing"
x_ "${ifdtool}" -i me:"${_me_location}" "${rom}" -O "${rom}"
if [ "${nukemode}" != "nuke" ]; then
x_ "${ifdtool}" -i me:"${_me_location}" "${rom}" -O "${rom}"
else
x_ "${ifdtool}" --nuke me "${rom}" -O "${rom}"
fi
}
inject_vendorfile_hp_kbc1126_ec()
@@ -235,20 +241,25 @@ inject_vendorfile_hp_kbc1126_ec()
_ec2_location="${CONFIG_KBC1126_FW2##*../}"
_ec2_offset="${CONFIG_KBC1126_FW2_OFFSET}"
printf "adding hp kbc1126 ec firmware\n"
if [ "${_ec1_offset}" = "" ] || [ "${_ec1_offset}" = "" ]; then
err "inject_vendorfile_hp_kbc1126_ec: ${board}: offset not declared"
elif [ "${_ec1_location}" = "" ] || [ "${_ec2_location}" = "" ]; then
err "inject_vendorfile_hp_kbc1126_ec: ${board}: EC path not declared"
elif [ ! -f "${_ec1_location}" ] || [ ! -f "${_ec2_location}" ]; then
[ "${nukemode}" != "nuke" ] && \
err "inject_vendorfile_hp_kbc1126_ec: ${board}: ecfw not downloaded"
fi
x_ "${cbfstool}" "${rom}" add -f "${_ec1_location}" -n ecfw1.bin \
-b ${_ec1_offset} -t raw
x_ "${cbfstool}" "${rom}" add -f "${_ec2_location}" -n ecfw2.bin \
-b ${_ec2_offset} -t raw
if [ "${nukemode}" != "nuke" ]; then
printf "adding hp kbc1126 ec firmware\n"
x_ "${cbfstool}" "${rom}" add -f "${_ec1_location}" \
-n ecfw1.bin -b ${_ec1_offset} -t raw
x_ "${cbfstool}" "${rom}" add -f "${_ec2_location}" \
-n ecfw2.bin -b ${_ec2_offset} -t raw
else
x_ "${cbfstool}" "${rom}" remove -n ecfw1.bin
x_ "${cbfstool}" "${rom}" remove -n ecfw2.bin
fi
}
inject_vendorfile_dell_e6400_vgarom_nvidia()
@@ -259,26 +270,33 @@ inject_vendorfile_dell_e6400_vgarom_nvidia()
_vga_dir="${_vga_location%/*}"
_vga_filename="${_vga_location##*/}"
printf "adding pci option rom\n"
[ "${_vga_dir}" = "${pciromsdir}" ] || \
err "inject_vendorfile_dell_e6400vga: invalid pcirom dir: ${_vga_dir}"
[ -f "${_vga_location}" ] || \
[ ! -f "${_vga_location}" ] && [ "${nukemode}" != "nuke" ] && \
err "inject_vendorfile_dell_e6400vga: ${_vga_location} doesn't exist"
x_ "${cbfstool}" "${rom}" add -f "${_vga_location}" \
-n "pci${CONFIG_VGA_BIOS_ID}.rom" -t optionrom
if [ "${nukemode}" != "nuke" ]; then
x_ "${cbfstool}" "${rom}" add -f "${_vga_location}" \
-n "pci${CONFIG_VGA_BIOS_ID}.rom" -t optionrom
else
x_ "${cbfstool}" "${rom}" remove \
-n "pci${CONFIG_VGA_BIOS_ID}.rom"
fi
}
inject_vendorfile_smsc_sch5545_ec()
{
rom="${1}"
_sch5545ec_location="${CONFIG_SMSC_SCH5545_EC_FW_FILE##*../}"
[ -f "${_sch5545ec_location}" ] || \
[ ! -f "${_sch5545ec_location}" ] && [ "${nukemode}" != "nuke" ] && \
err "inject_vendorfile_smsc_sch5545_ec: SCH5545 fw missing"
x_ "${cbfstool}" "${rom}" add -f "${_sch5545ec_location}" \
-n sch5545_ecfw.bin -t raw
if [ "${nukemode}" != "nuke" ]; then
x_ "${cbfstool}" "${rom}" add -f "${_sch5545ec_location}" \
-n sch5545_ecfw.bin -t raw
else
x_ "${cbfstool}" "${rom}" remove -n sch5545_ecfw.bin
fi
}
modify_gbe()