Files
scripts/coreboot-t440p/steps/flash_bios.sh
T
2026-04-14 01:16:13 -07:00

59 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
# Step: Flash coreboot to the T440p
step_flash_bios() {
section "Flash Coreboot"
cd "$COREBOOT_DIR/build" || return 1
if [ ! -f "coreboot.rom" ]; then
error "coreboot.rom not found. Run the build step first."
return 1
fi
# Split the ROM
info "Splitting ROM for 8MB (bottom) and 4MB (top) chips..."
run_cmd "dd if=coreboot.rom of=bottom.rom bs=1M count=8" || return 1
run_cmd "dd if=coreboot.rom of=top.rom bs=1M skip=8" || return 1
_bottom_size=$(wc -c < bottom.rom)
_top_size=$(wc -c < top.rom)
info "bottom.rom: $_bottom_size bytes"
info "top.rom: $_top_size bytes"
echo ""
warn "You are about to flash coreboot onto your T440p."
warn "Make sure your laptop is powered off and the battery is removed."
warn "DO NOT interrupt the flashing process!"
echo ""
if ! prompt_yes_no "Ready to flash?"; then
info "Flash cancelled."
return 0
fi
# Flash 4MB (top) chip
echo ""
info "Attach the programmer to the 4MB (top) chip."
prompt_continue
info "Flashing 4MB chip..."
run_cmd "sudo flashrom --programmer ch341a_spi -w top.rom" || return 1
success "4MB chip flashed."
# Flash 8MB (bottom) chip
echo ""
info "Now attach the programmer to the 8MB (bottom) chip."
prompt_continue
info "Flashing 8MB chip..."
run_cmd "sudo flashrom --programmer ch341a_spi -w bottom.rom" || return 1
success "8MB chip flashed."
echo ""
success "Coreboot has been flashed successfully!"
echo ""
info "Reassemble your laptop and power it on."
info "If everything went well, you should see coreboot boot!"
}