Rework programmer detection; add image support

This commit is contained in:
2026-04-14 09:08:44 -07:00
parent 21af45674e
commit 52999f4799
5 changed files with 166 additions and 42 deletions
+37 -15
View File
@@ -1,31 +1,53 @@
#!/bin/sh
# Step: Verify CH341A programmer connection
# Step: Confirm CH341A programmer is connected to USB
# CH341A USB vendor:product ID
CH341A_USB_ID="1a86:5512"
step_attach_ch341a() {
section "Verify CH341A Programmer"
section "Connect CH341A Programmer"
info "Make sure your CH341A programmer is:"
echo " 1. Connected to your computer via USB"
echo " 2. Set to 3.3V (NOT 5V!)"
echo " 3. Ribbon cable seated in the correct orientation"
info "Before continuing:"
echo " 1. Plug the CH341A into a USB port"
echo " 2. Set the voltage jumper to 3.3V (NEVER 5V)"
echo " 3. Leave the SOIC-8 clip UNATTACHED for now"
echo ""
warn "Using 5V WILL permanently damage the BIOS chips on the T440p."
echo ""
info "Clip orientation rules (applies later when reading/writing chips):"
echo " - The red wire on the ribbon = pin 1"
echo " - The dot/notch on the EEPROM chip = pin 1"
echo " - These MUST align, or the chip will be misread or damaged"
echo ""
# Show reference image (cached locally, rendered inline if possible)
show_image "spi_flasher_assembly.png" "Reference: CH341A + SOIC-8 clip assembly"
echo ""
warn "Using 5V WILL damage your BIOS chip permanently!"
prompt_continue
info "Checking if flashrom detects the CH341A programmer..."
if run_cmd "flashrom --programmer ch341a_spi"; then
success "CH341A programmer detected!"
info "Checking USB for CH341A (id $CH341A_USB_ID)..."
if ! check_command lsusb; then
warn "lsusb not found. Install usbutils to enable programmer detection."
if prompt_yes_default "Continue without USB verification?"; then
return 0
fi
return 1
fi
if lsusb | grep -qi "$CH341A_USB_ID"; then
success "CH341A detected on USB bus."
return 0
fi
error "CH341A programmer not detected."
error "CH341A not found on USB bus."
echo ""
echo " Troubleshooting:"
echo " - Ensure the programmer is plugged in"
echo " - Try a different USB port"
echo " - Check the driver: lsusb | grep 1a86:5512"
echo " - Make sure you have permissions (try with sudo)"
echo " - Re-plug the programmer (try a different USB port)"
echo " - Check with: lsusb | grep $CH341A_USB_ID"
echo " - If lsusb sees it under a different ID, the device may be"
echo " a clone with different firmware — note the ID and retry"
echo ""
if prompt_yes_no "Retry detection?"; then