Skip to content

Commit 67cace7

Browse files
committed
initrd: Route runtime CBFS reads via flashprog
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
1 parent faa0a50 commit 67cace7

4 files changed

Lines changed: 50 additions & 10 deletions

File tree

doc/starlabs.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Star Labs builds
2+
3+
Star Labs Cezanne boards require the maintained AMD binary tree in addition to
4+
the files carried by the Heads tree. The binary tree is not committed here.
5+
6+
Mount the maintained tree read-only at the build path before configuring or
7+
building either Cezanne target:
8+
9+
```sh
10+
mkdir -p build/x86/amd_binaries
11+
mount --bind /path/to/starlabs/amd_binaries build/x86/amd_binaries
12+
mount -o remount,bind,ro build/x86/amd_binaries
13+
```
14+
15+
The mounted tree must contain the paths listed in
16+
`config/starlabs-amd-binaries.sha256`, including:
17+
18+
```text
19+
CZN/APCB/
20+
CZN/PSP/
21+
FSP/CEZANNE_M.fd
22+
FSP/CEZANNE_S.fd
23+
```
24+
25+
The build verifies the mounted files against
26+
`config/starlabs-amd-binaries.sha256` before coreboot configuration and build
27+
steps run. Update that manifest when the maintained binary input changes.

initrd/bin/cbfs.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,20 @@ set -e -o pipefail
55

66
TRACE_FUNC
77

8+
cbfs_has_rom_arg() {
9+
for arg in "$@"; do
10+
if [ "$arg" = "-o" ]; then
11+
return 0
12+
fi
13+
done
14+
return 1
15+
}
16+
817
if pnor "$2" -r HBI > /tmp/pnor.part 2>/dev/null; then
9-
cbfs "$@" -o /tmp/pnor.part && pnor "$2" -w HBI < /tmp/pnor.part
18+
cbfs "$@" -o /tmp/pnor.part && pnor "$2" -w HBI < /tmp/pnor.part
19+
elif [ "$CONFIG_CBFS_VIA_FLASHPROG" = "y" ] && ! cbfs_has_rom_arg "$@"; then
20+
/bin/flashprog -p internal --fmap -i COREBOOT -i FMAP -r /tmp/cbfs-current.rom >/dev/null
21+
cbfs "$@" -o /tmp/cbfs-current.rom
1022
else
11-
cbfs "$@"
23+
cbfs "$@"
1224
fi

initrd/bin/inject_firmware.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ mkdir "$INITRD_ROOT"
4040
unpack_initramfs.sh "$ORIG_INITRD" "$INITRD_ROOT" init
4141

4242
# Copy the firmware into the initrd
43-
for f in $(cbfs -l | grep firmware); do
43+
for f in $(cbfs.sh -l | grep firmware); do
4444
mkdir -p "$INITRD_ROOT/$(dirname "$f")"
45-
cbfs -r "$f" > "$INITRD_ROOT/$f"
45+
cbfs.sh -r "$f" > "$INITRD_ROOT/$f"
4646
if [[ "$f" == *.lzma ]]; then
4747
lzma -d "$INITRD_ROOT/$f"
4848
fi

initrd/etc/functions.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,9 @@ preserve_rom() {
489489
# based on the --clean / -c flag passed by the user or calling script.
490490
# Files preserved: all CBFS type-50 entries under the 'heads/' prefix.
491491
new_rom="$1"
492-
old_files=$(cbfs -t 50 -l 2>/dev/null | grep "^heads/")
492+
all_old_files=$(cbfs.sh -t 50 -l 2>/dev/null) ||
493+
DIE "preserve_rom: failed to list current CBFS"
494+
old_files=$(echo "$all_old_files" | grep "^heads/" || true)
493495
old_file_count=$(echo "$old_files" | wc -w)
494496

495497
if [ "$old_file_count" -eq 0 ]; then
@@ -502,13 +504,13 @@ preserve_rom() {
502504
DEBUG "preserve_rom: scanning $new_rom for existing heads/* entries to skip"
503505

504506
for old_file in $(echo $old_files); do
505-
new_file=$(cbfs.sh -o $1 -l | grep -Fx "$old_file")
507+
new_file=$(cbfs.sh -o "$new_rom" -l | grep -Fx "$old_file" || true)
506508
if [ -z "$new_file" ]; then
507509
DEBUG "preserve_rom: $old_file not found in new ROM — copying from current CBFS"
508-
cbfs -t 50 -r $old_file >/tmp/rom.$$ ||
510+
cbfs.sh -t 50 -r "$old_file" >/tmp/rom.$$ ||
509511
DIE "preserve_rom: failed to read $old_file from current CBFS"
510-
cbfs.sh -o $1 -a $old_file -f /tmp/rom.$$ ||
511-
DIE "preserve_rom: failed to write $old_file to $1"
512+
cbfs.sh -o "$new_rom" -a "$old_file" -f /tmp/rom.$$ ||
513+
DIE "preserve_rom: failed to write $old_file to $new_rom"
512514
else
513515
DEBUG "preserve_rom: $old_file already present in new ROM — skipped"
514516
fi
@@ -3638,4 +3640,3 @@ _build_final_cmdline() {
36383640
DEBUG "_build_final_cmdline: final='$_combined'"
36393641
echo "$_combined"
36403642
}
3641-

0 commit comments

Comments
 (0)