70 lines
2.0 KiB
Bash
Executable File
70 lines
2.0 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 (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."
|
|
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
|
|
|
|
if [ -z "$CHIP_4MB" ]; then
|
|
_resolve_chip CHIP_4MB || return 1
|
|
fi
|
|
info "Flashing 4MB chip ($CHIP_4MB)..."
|
|
run_cmd "sudo flashrom --programmer ch341a_spi -c \"$CHIP_4MB\" -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
|
|
|
|
if [ -z "$CHIP_8MB" ]; then
|
|
_resolve_chip CHIP_8MB || return 1
|
|
fi
|
|
info "Flashing 8MB chip ($CHIP_8MB)..."
|
|
run_cmd "sudo flashrom --programmer ch341a_spi -c \"$CHIP_8MB\" -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!"
|
|
}
|