script fixes

This commit is contained in:
2026-04-14 08:55:33 -07:00
parent aaa53d6a09
commit 21af45674e
6 changed files with 100 additions and 26 deletions
+34 -7
View File
@@ -1,5 +1,36 @@
#!/bin/sh
# Step: Verify BIOS backup integrity
# Step: Verify BIOS backup integrity (with per-chip retry)
# Re-read a single chip until two reads match or user gives up
_reread_chip() {
_label="$1" # "4mb" or "8mb"
_desc="$2" # human-readable description
while true; do
warn "$_desc reads do NOT match. The chip may not be reading reliably."
echo ""
echo " 1) Re-seat programmer on $_desc chip and retry"
echo " 2) Abort"
echo ""
printf "${CYAN}Choice [1-2]:${NC} "
read -r _choice
case "$_choice" in
1)
info "Re-reading $_desc chip (read 1 of 2)..."
run_cmd "sudo flashrom --programmer ch341a_spi -r ${_label}_backup1.bin" || return 1
info "Re-reading $_desc chip (read 2 of 2)..."
run_cmd "sudo flashrom --programmer ch341a_spi -r ${_label}_backup2.bin" || return 1
if diff "${_label}_backup1.bin" "${_label}_backup2.bin" >/dev/null 2>&1; then
success "$_desc reads now match."
return 0
fi
;;
*)
return 1
;;
esac
done
}
step_backup_bios() {
section "Verify BIOS Backups"
@@ -10,18 +41,14 @@ step_backup_bios() {
if diff 4mb_backup1.bin 4mb_backup2.bin >/dev/null 2>&1; then
success "4MB chip reads are identical."
else
error "4MB chip reads do NOT match!"
warn "The chip may not be reading reliably. Re-seat the programmer and try again."
return 1
_reread_chip "4mb" "4MB (top)" || return 1
fi
info "Verifying 8MB chip reads match..."
if diff 8mb_backup1.bin 8mb_backup2.bin >/dev/null 2>&1; then
success "8MB chip reads are identical."
else
error "8MB chip reads do NOT match!"
warn "The chip may not be reading reliably. Re-seat the programmer and try again."
return 1
_reread_chip "8mb" "8MB (bottom)" || return 1
fi
# Validate file sizes
+5
View File
@@ -30,5 +30,10 @@ step_build_bios() {
fi
_size=$(wc -c < "$COREBOOT_DIR/build/coreboot.rom")
if [ "$_size" -ne "$SIZE_12MB" ]; then
error "coreboot.rom size is $_size bytes, expected $SIZE_12MB (12MB)."
error "Flashing a wrong-sized ROM will brick the board. Check your config."
return 1
fi
success "Build complete: $COREBOOT_DIR/build/coreboot.rom ($_size bytes)"
}
+32 -8
View File
@@ -23,6 +23,17 @@ step_configure() {
return 1
fi
# Warn before overwriting existing .config
if [ -f "$COREBOOT_DIR/.config" ]; then
echo ""
warn "An existing .config was found in $COREBOOT_DIR."
if ! prompt_yes_no "Overwrite it?"; then
info "Keeping existing .config. Opening nconfig for review..."
make nconfig
return $?
fi
fi
echo ""
info "Choose a payload for your coreboot build:"
echo ""
@@ -46,10 +57,19 @@ step_configure() {
done
_has_dgpu="n"
_dgpu_vbios=""
if [ "$_payload" != "custom" ]; then
echo ""
if prompt_yes_no "Does your T440p have the GT730M dGPU?"; then
_has_dgpu="y"
echo ""
info "dGPU support needs a VGA option ROM (VBIOS) for the GT730M."
info "Extract it from your original ROM, dump from live Windows, or obtain separately."
_dgpu_vbios=$(prompt_value "Path to GT730M VBIOS file (leave empty to skip auto-set)" "")
if [ -n "$_dgpu_vbios" ] && [ ! -f "$_dgpu_vbios" ]; then
warn "File not found: $_dgpu_vbios. Will set flags only; fill path in nconfig."
_dgpu_vbios=""
fi
fi
fi
@@ -75,7 +95,7 @@ step_configure() {
cat > .config << COREBOOT_CONFIG
# Mainboard
CONFIG_VENDOR_LENOVO=y
CONFIG_BOARD_LENOVO_HASWELL=y
CONFIG_BOARD_LENOVO_THINKPAD_T440P=y
# Firmware blobs
CONFIG_HAVE_IFD_BIN=y
@@ -98,7 +118,6 @@ CONFIG_PAYLOAD_GRUB2=y
CONFIG_GRUB2_INCLUDE_RUNTIME_CONFIG_FILE=y
# Secondary payloads
CONFIG_PAYLOAD_FILE_IS_GRUB2=y
CONFIG_MEMTEST_SECONDARY_PAYLOAD=y
CONFIG_NVRAMCUI_SECONDARY_PAYLOAD=y
CONFIG_COREINFO_SECONDARY_PAYLOAD=y
@@ -115,21 +134,26 @@ SEABIOS_CONFIG
edk2)
cat >> .config << 'EDK2_CONFIG'
# Payload
CONFIG_PAYLOAD_EDK2=y
# Payload (tianocore/edk2)
CONFIG_PAYLOAD_TIANOCORE=y
EDK2_CONFIG
;;
esac
# dGPU option ROM
# dGPU option ROM (GT730M)
if [ "$_has_dgpu" = "y" ]; then
cat >> .config << 'DGPU_CONFIG'
cat >> .config << DGPU_CONFIG
# dGPU (GT730M) VGA option ROM
CONFIG_VGA_BIOS=y
CONFIG_VGA_BIOS_DGPU=y
CONFIG_VGA_BIOS_DGPU_FILE="$_dgpu_vbios"
CONFIG_VGA_BIOS_DGPU_ID="10de,1292"
DGPU_CONFIG
info "dGPU option ROM support enabled."
if [ -z "$_dgpu_vbios" ]; then
warn "dGPU VBIOS path empty — set CONFIG_VGA_BIOS_DGPU_FILE in nconfig before building."
else
info "dGPU option ROM configured: $_dgpu_vbios"
fi
fi
# Fill in remaining defaults
+7 -2
View File
@@ -18,8 +18,13 @@ step_flash_bios() {
_bottom_size=$(wc -c < bottom.rom)
_top_size=$(wc -c < top.rom)
info "bottom.rom: $_bottom_size bytes"
info "top.rom: $_top_size bytes"
info "bottom.rom: $_bottom_size bytes (expected $SIZE_8MB)"
info "top.rom: $_top_size bytes (expected $SIZE_4MB)"
if [ "$_bottom_size" -ne "$SIZE_8MB" ] || [ "$_top_size" -ne "$SIZE_4MB" ]; then
error "Split ROM sizes wrong. Refusing to flash."
return 1
fi
echo ""
warn "You are about to flash coreboot onto your T440p."
+7
View File
@@ -38,6 +38,13 @@ _revert_external() {
run_cmd "dd if=t440p-original.rom of=bottom.rom bs=1M count=8" || return 1
run_cmd "dd if=t440p-original.rom of=top.rom bs=1M skip=8" || return 1
_b=$(wc -c < bottom.rom)
_t=$(wc -c < top.rom)
if [ "$_b" -ne "$SIZE_8MB" ] || [ "$_t" -ne "$SIZE_4MB" ]; then
error "Split sizes wrong (bottom=$_b, top=$_t). Aborting."
return 1
fi
# Flash 4MB (top) chip
info "Attach the programmer to the 4MB (top) chip."
prompt_continue