diff options
author | Leah Rowe <leah@libreboot.org> | 2025-07-10 03:15:18 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-07-10 04:26:31 +0100 |
commit | 6f7525a5b35e373dc4496cd4c6af4e61cb3b534c (patch) | |
tree | 680b2ea0fc4a275b9fd3b7632f6b61fc653d70ae /include | |
parent | 7c6c9ff5470c049d055133776a4e7baee8c842fd (diff) |
cache coreboot builds in elf/ again
This was a problem when I did it before, because individual
target builds weren't automatically re-compiled when needed.
The recent design improvements in lbmk enable this to be
done again.
Cached images in elf/ have no payloads, so they are a liability,
therefore they are padded by one byte to prevent flashing. This
solves the problem that the previous caching had.
With this change, modifying payloads can be tested without
needing to re-build coreboot each time.
The cached coreboot builds are also automatically re-built when
needed, which is another improvement this time, compared to
the last time coreboot builds were cached in this manner.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/lib.sh | 18 | ||||
-rw-r--r-- | include/rom.sh | 25 |
2 files changed, 42 insertions, 1 deletions
diff --git a/include/lib.sh b/include/lib.sh index 911d9c4d..6fc3bd1e 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -95,6 +95,24 @@ findpath() done } +pad_one_byte() +{ + paddedfile="`mktemp`" || err "mktemp pad_one_byte" + x_ cp "$1" "$paddedfile" + cat "$paddedfile" config/data/coreboot/0 > "$1" || err "!pad $1"; : + x_ rm "$paddedfile" +} + +unpad_one_byte() +{ + xromsize="$(expr $(stat -c '%s' "$1") - 1)" || err "!int" + [ $xromsize -lt 524288 ] && err "too small, $xromsize: $1" + + unpaddedfile="`mktemp`" || err "mktemp unpad_one_byte" + x_ dd if="$1" of="$unpaddedfile" bs=$xromsize count=1 + x_ mv "$unpaddedfile" "$1" +} + fx_() { fd="`mktemp`" && x_ rm -f "$fd" && x_ touch "$fd" diff --git a/include/rom.sh b/include/rom.sh index c88d0c69..65149ce5 100644 --- a/include/rom.sh +++ b/include/rom.sh @@ -74,12 +74,28 @@ check_coreboot_util() x_ cp "$utilsrcdir/rmodtool" "$utilelfdir" } +coreboot_pad_one_byte() +{ + $dry pad_one_byte "$srcdir/build/coreboot.rom" +} + mkcorebootbin() { + fx_ check_coreboot_util printf "cbfstool\nifdtool\n" + + for y in "$target_dir/config"/*; do + defconfig="$y" + mkcorebootbin_real + done + + mkcoreboottar +} + +mkcorebootbin_real() +{ [ "$target" = "$tree" ] && return 0 tmprom="$xbtmp/coreboot.rom" - $dry x_ cp "$srcdir/build/coreboot.rom" "$tmprom" initmode="${defconfig##*/}" displaymode="${initmode##*_}" @@ -87,6 +103,13 @@ mkcorebootbin() initmode="${initmode%%_*}" cbfstool="elf/coreboot/$tree/cbfstool" + elfrom="elf/coreboot/$tree/$target/$initmode" + [ -n "$displaymode" ] && elfrom="${elfrom}_$displaymode" + elfrom="$elfrom/coreboot.rom" + + $dry x_ cp "$elfrom" "$tmprom" + $dry unpad_one_byte "$tmprom" + [ -z "$payload_uboot" ] || [ "$payload_uboot" = "amd64" ] || \ [ "$payload_uboot" = "i386" ] || [ "$payload_uboot" = "arm64" ] \ || err "'$target' defines bad u-boot type '$payload_uboot'" |