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>
btrfsvols
Leah Rowe 2023-10-14 03:30:52 +01:00
parent 2ebadb7ffd
commit ec0b38afb3
3 changed files with 51 additions and 67 deletions

View File

@ -24,7 +24,7 @@ eval "$(setvars "" EC_url EC_url_bkup EC_hash DL_hash DL_url DL_url_bkup _dest \
E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \ E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \
E6400_VGA_romname SCH5545EC_DL_url SCH5545EC_DL_url_bkup SCH5545EC_DL_hash \ E6400_VGA_romname SCH5545EC_DL_url SCH5545EC_DL_url_bkup SCH5545EC_DL_hash \
MRC_url MRC_url_bkup MRC_hash MRC_board archive rom board modifygbe _dl \ MRC_url MRC_url_bkup MRC_hash MRC_board archive rom board modifygbe _dl \
new_mac release releasearchive _b boarddir)" new_mac release releasearchive _b boarddir nukemode)"
eval "$(setvars "" CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \ eval "$(setvars "" CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \
CONFIG_ME_BIN_PATH CONFIG_KBC1126_FIRMWARE CONFIG_KBC1126_FW1 \ CONFIG_ME_BIN_PATH CONFIG_KBC1126_FIRMWARE CONFIG_KBC1126_FW1 \

View File

@ -135,7 +135,7 @@ handle_rom_archive()
x_ mkdir -p "${romdir}" x_ mkdir -p "${romdir}"
x_ cp "${builddir}/"* "${romdir}" x_ cp "${builddir}/"* "${romdir}"
handle_vendorfiles nukerom
printf "Generating release/%s/roms/%s-%s_%s.tar.xz\n" \ printf "Generating release/%s/roms/%s-%s_%s.tar.xz\n" \
"${version}" "${projectname}" "${version}" "${target##*/}" "${version}" "${projectname}" "${version}" "${target##*/}"
@ -146,30 +146,12 @@ handle_rom_archive()
mkrom_tarball mkrom_tarball
} }
handle_vendorfiles() nukerom()
{ {
microcode_required="y" microcode_required="y"
. "config/coreboot/${target}/target.cfg" . "config/coreboot/${target}/target.cfg"
if [ "${microcode_required}" != "y" ] && \ if [ "${microcode_required}" != "y" ] && \
[ "${microcode_required}" != "n" ]; then microcode_required="y"; fi [ "${microcode_required}" != "n" ]; then microcode_required="y"; fi
for x in CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN CONFIG_KBC1126_FIRMWARE \
CONFIG_INCLUDE_SMSC_SCH5545_EC_FW; do
eval "${x}=\"y\""
grep "${x}=y" "config/coreboot/${target}/config/"* || \
eval "${x}=\"n\""
done
# remove ME/MRC/EC firmware from ROM images
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ] || \
[ "${target}" = "e6400_4mb" ] || \
[ "${microcode_required}" = "n" ]; then
strip_archive
fi
}
strip_archive()
{
if [ "${microcode_required}" = "n" ]; then if [ "${microcode_required}" = "n" ]; then
for romfile in "${romdir}"/*.rom; do for romfile in "${romdir}"/*.rom; do
[ -f "${romfile}" ] || continue [ -f "${romfile}" ] || continue
@ -181,16 +163,18 @@ strip_archive()
done done
fi fi
# Hash the rom before removing vendor files # Hash the images before removing vendor files
# which ./update vendor inject uses for verification
x_ rm -f "${romdir}/vendorhashes" x_ rm -f "${romdir}/vendorhashes"
x_ touch "${romdir}/vendorhashes" x_ touch "${romdir}/vendorhashes"
( (
x_ cd "${romdir}" x_ cd "${romdir}"
x_ sha512sum *.rom >> vendorhashes x_ sha512sum *.rom >> vendorhashes
) )
for romfile in "${romdir}"/*.rom; do for romfile in "${romdir}"/*.rom; do
[ -f "${romfile}" ] || continue [ -f "${romfile}" ] || continue
strip_rom_image "${romfile}" x_ ./update vendor inject -r "${romfile}" -b ${target} -n nuke
done done
} }
@ -208,24 +192,6 @@ strip_ucode()
x_ mv "${romfile}" "${_newrom_b}" x_ mv "${romfile}" "${_newrom_b}"
} }
strip_rom_image()
{
[ -f "${1}" ] || return 0
[ "${CONFIG_HAVE_ME_BIN}" != "y" ] || \
x_ "${ifdtool}" --nuke me "${1}" -O "${1}"
[ "${CONFIG_HAVE_MRC}" != "y" ] || \
x_ "${cbfstool}" "${1}" remove -n mrc.bin
[ "${CONFIG_INCLUDE_SMSC_SCH5545_EC_FW}" != "y" ] || \
x_ "${cbfstool}" "${1}" remove -n sch5545_ecfw.bin
if [ "${CONFIG_KBC1126_FIRMWARE}" = "y" ]; then
x_ "${cbfstool}" "${1}" remove -n ecfw1.bin
x_ "${cbfstool}" "${1}" remove -n ecfw2.bin
fi
# TODO: replace this board-specific hack
[ "${target}" = "e6400_4mb" ] || return 0
x_ "${cbfstool}" "${1}" remove -n "pci10de,06eb.rom"
}
insert_copying_files() insert_copying_files()
{ {
x_ rm -Rf "${1}/licenses" x_ rm -Rf "${1}/licenses"

View File

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