only remove microcode in build/release/roms

libreboot's build system, lbmk, *is* available to use
in releases aswell (use the _src tarball), but it is
mostly intended for development, in lbmk.git

well, there's not much point wasting time / disk space
generating no-microcode roms within lbmk

they should be generated only at release time, alongside
the default ones

this patch implements that, thus speeding up the build
process and saving disk usage during development

the other alternative was to add a new option in
build/boot/roms, -m, that would opt in to removing them,
but this is extra complexity for something that is ill
advised and only provided to appease certain people

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-08-31 22:00:13 +01:00
parent bf774acf1d
commit 225e2609fa
2 changed files with 67 additions and 44 deletions

View File

@ -33,7 +33,6 @@ projectname="$(cat projectname)"
cfgsdir="resources/coreboot" cfgsdir="resources/coreboot"
blobs_required="" blobs_required=""
microcode_required=""
board="" board=""
ubdir="" ubdir=""
@ -150,9 +149,6 @@ configure_target()
[ "${payload_uboot}" = "y" ] && [ "${uboot_config}" = "undefined" ] && \ [ "${payload_uboot}" = "y" ] && [ "${uboot_config}" = "undefined" ] && \
uboot_config="default" uboot_config="default"
[ "${microcode_required}" != "n" ] && \
[ "${microcode_required}" != "y" ] && \
microcode_required="y"
[ "${blobs_required}" != "n" ] && [ "${blobs_required}" != "y" ] && \ [ "${blobs_required}" != "n" ] && [ "${blobs_required}" != "y" ] && \
blobs_required="y" blobs_required="y"
@ -530,28 +526,13 @@ mkUbootRom() {
moverom() { moverom() {
rompath="${1}" rompath="${1}"
newrompath="${2}" newrompath="${2}"
[ "${blobs_required}" = "n" ] && \
newrompath="${newrompath%.rom}_noblobs.rom"
printf "\nCreating new ROM image: %s\n" "${newrompath}" printf "\nCreating new ROM image: %s\n" "${newrompath}"
cp "${rompath}" "${newrompath}" || err "moverom: can't copy rom" [ "${blobs_required}" = "n" ] && \
newrompath="${newrompath%.rom}_noblobs.rom"
if [ "${microcode_required}" = "n" ]; then cp "${rompath}" "${newrompath}" || err "moverom: can't copy rom"
_newrom_b="${newrompath%.rom}_nomicrocode.rom"
cp "${newrompath}" "${_newrom_b}" || \
err "moverom: cp \"${newrompath}\" \"${_newrom_b}\""
microcode_present="y"
"${cbfstool}" "${_newrom_b}" remove -n \
cpu_microcode_blob.bin 2>/dev/null || microcode_present="n"
if [ "${microcode_present}" = "n" ]; then
printf "REMARK: '%s' already lacks microcode\n" \
"${newrompath}"
printf "Renaming default ROM file instead.\n"
mv "${newrompath}" "${_newrom_b}" || \
err "moverom: mv \"${newrompath}\" \"${_newrom_b}\""
fi
fi
} }
main $@ main $@

View File

@ -34,6 +34,7 @@ CONFIG_KBC1126_FIRMWARE=""
CONFIG_INCLUDE_SMSC_SCH5545_EC_FW="" CONFIG_INCLUDE_SMSC_SCH5545_EC_FW=""
ifdtool="cbutils/${tree}/ifdtool" ifdtool="cbutils/${tree}/ifdtool"
cbfstool="cbutils/${tree}/cbfstool" cbfstool="cbutils/${tree}/cbfstool"
microcode_required="y"
main() main()
{ {
@ -42,6 +43,7 @@ main()
init_check init_check
for romdir in bin/*; do for romdir in bin/*; do
[ -d "${romdir}" ] || continue
make_archive "${romdir}" make_archive "${romdir}"
done done
@ -74,11 +76,25 @@ init_check()
make_archive() make_archive()
{ {
romdir=${1} builddir="${1}"
target="${romdir##*/}" romdir="$(mktemp -d -t coreboot_rom.XXXXXXXXXX)" || \
err "make_archive: cannot create tmpdir"
rm -Rf "${romdir}" || err "make_archive: can't remove tmpdir"
target="${builddir##*/}"
romdir="${romdir}/bin/${target}"
mkdir -p "${romdir}" || \
err "make_archive: can't mkdir tmpdir"
cp "${builddir}"/* "${romdir}" || \
err "make_archive: cannot copy ROM images directory -> ${romdir}"
echo ${target} echo ${target}
[ -d "${romdir}/" ] || continue
[ -f "resources/coreboot/${target}/target.cfg" ] || \
err "make_archive: ${target}: target.cfg is missing"
. "resources/coreboot/${target}/target.cfg"
[ "${microcode_required}" = "y" ] || \
[ "${microcode_required}" = "n" ] || microcode_required="y"
CONFIG_HAVE_MRC="y" CONFIG_HAVE_MRC="y"
CONFIG_HAVE_ME_BIN="y" CONFIG_HAVE_ME_BIN="y"
@ -97,7 +113,8 @@ make_archive()
# 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" ] || \
[ "${target}" = "e6400nvidia_4mb" ]; then [ "${target}" = "e6400nvidia_4mb" ] || \
[ "${microcode_required}" = "n" ]; then
strip_archive "${romdir}" strip_archive "${romdir}"
fi fi
@ -110,15 +127,17 @@ make_archive()
printf "%s\n" "${projectname}" > "${romdir}/projectname" || \ printf "%s\n" "${projectname}" > "${romdir}/projectname" || \
err "make_archive: can't create ${romdir}/projectname" err "make_archive: can't create ${romdir}/projectname"
f="release/${version}/roms/${projectname}-${version}_${target##*/}" archivename="${projectname}-${version}_${target##*/}"
tar -c "${romdir}/" | xz -9e > "${f}.tar.xz" || \ f="release/${version}/roms/${archivename}"
err "make_archive: can't create ${f}.tar.xz" (
cd "${romdir%/bin/${target}}" || err "make_archive: can't cd to tmpdir"
if [ -d "${romdir}_tmp" ]; then tar -c "bin/${target}/" | xz -9e > "${archivename}.tar.xz" || \
rm -Rf "${romdir}" || err "make_archive: !rm -Rf ${romdir}" err "make_archive:cant make ${projectname}-${version}_${target##*/}"
mv "${romdir}_tmp" "${romdir}" || \ )
err "make_archive: !mv \"${romdir}_tmp\" \"${romdir}\"" cp "${romdir%/bin/${target}}/${archivename}.tar.xz" "${f}.tar.xz" || \
fi err "make_archive: can't copy tarball"
rm -Rf "${romdir%/bin/${target}}" || \
err "make_archive: can't delete tmpdir"
} }
strip_archive() strip_archive()
@ -131,10 +150,17 @@ strip_archive()
./build coreboot utils ${tree} || \ ./build coreboot utils ${tree} || \
err "strip_archive: coreboot/${tree}: can't build utils" err "strip_archive: coreboot/${tree}: can't build utils"
# dirty hack, to reduce disk io later if [ "${microcode_required}" = "n" ]; then
# rather than using /tmp, which might not be tmpfs for romfile in "${romdir}"/*.rom; do
rm -Rf "${romdir}_tmp" || err "strip_archive: !rm -Rf ${romdir}_tmp" [ -f "${romfile}" ] || continue
mkdir "${romdir}_tmp" || err "strip_archive: !mkdir ${romdir}_tmp" strip_ucode "${romfile}"
done
for romfile in "${romdir}"/*.tmprom; do
[ -f "${romfile}" ] || continue
mv "${romfile}" "${romfile%.tmprom}.rom" || \
err "can't make no-u rom: ${romfile%.tmprom}.rom"
done
fi
# Hash the rom before removing blobs # Hash the rom before removing blobs
rm -f "${romdir}/blobhashes" || \ rm -f "${romdir}/blobhashes" || \
@ -149,10 +175,30 @@ strip_archive()
) )
for romfile in "${romdir}"/*.rom; do for romfile in "${romdir}"/*.rom; do
[ -f "${romfile}" ] || continue
strip_rom_image "${romfile}" strip_rom_image "${romfile}"
done done
} }
strip_ucode()
{
romfile=${1}
_newrom_b="${romfile%.rom}_nomicrocode.tmprom"
cp "${romfile}" "${_newrom_b}" || \
err "strip_rom_image: cp \"${romfile}\" \"${_newrom_b}\""
microcode_present="y"
"${cbfstool}" "${_newrom_b}" remove -n \
cpu_microcode_blob.bin 2>/dev/null || microcode_present="n"
if [ "${microcode_present}" = "n" ]; then
printf "REMARK: '%s' already lacks microcode\n" \
"${romfile}"
printf "Renaming default ROM file instead.\n"
mv "${romfile}" "${_newrom_b}" || \
err "strip_rom_image: can't rename no-u ${romfile}"
fi
}
strip_rom_image() strip_rom_image()
{ {
romfile=${1} romfile=${1}
@ -160,12 +206,8 @@ strip_rom_image()
[ -f "${romfile}" ] || return 0 [ -f "${romfile}" ] || return 0
if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then
"${ifdtool}" --nuke me "${romfile}" || \ "${ifdtool}" --nuke me "${romfile}" -O "${romfile}" || \
err "strip_rom_images: ${romfile}: cannot nuke Intel ME" err "strip_rom_images: ${romfile}: cannot nuke Intel ME"
mv "${romfile}" "${romdir}_tmp" || \
err "strip_rom_images: !mv ${romfile} ${romdir}_tmp"
mv "${romfile}.new" "${romfile}" || \
err "strip_rom_images: !mv ${romfile}.new ${romfile}"
fi fi
if [ "${CONFIG_HAVE_MRC}" = "y" ]; then if [ "${CONFIG_HAVE_MRC}" = "y" ]; then