update scripts
This commit is contained in:
@@ -21,7 +21,7 @@ step_attach_ch341a() {
|
|||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Show reference image (cached locally, rendered inline if possible)
|
# Show reference image (cached locally, rendered inline if possible)
|
||||||
show_image "spi_flasher_assembly.png" "Reference: CH341A + SOIC-8 clip assembly"
|
show_image "spi_flasher_assembly.webp" "Reference: CH341A + SOIC-8 clip assembly"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
prompt_continue
|
prompt_continue
|
||||||
|
|||||||
@@ -46,15 +46,13 @@ step_extract_bios() {
|
|||||||
info "Each chip is read twice so we can diff the results and catch flaky reads."
|
info "Each chip is read twice so we can diff the results and catch flaky reads."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Show reference image for chip locations
|
|
||||||
show_image "eeprom_chips_location.png" "Reference: EEPROM chip locations on T440p mainboard"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
cd "$WORK_DIR" || return 1
|
cd "$WORK_DIR" || return 1
|
||||||
|
|
||||||
# --- 4MB chip (do first: smaller = faster iteration on setup) ---
|
# --- 4MB chip (do first: smaller = faster iteration on setup) ---
|
||||||
echo ""
|
echo ""
|
||||||
info "Clip the CH341A onto the ${BOLD}4MB (top)${NC} chip."
|
show_image "eeprom_chip_4mb.webp" "Reference: 4MB (top) chip location on T440p"
|
||||||
|
echo ""
|
||||||
|
info "Clip the CH341A onto the ${BOLD}4MB (top)${NC} chip shown above."
|
||||||
info "Align the red ribbon wire with the dot/notch on the chip (pin 1)."
|
info "Align the red ribbon wire with the dot/notch on the chip (pin 1)."
|
||||||
prompt_continue
|
prompt_continue
|
||||||
|
|
||||||
@@ -64,7 +62,9 @@ step_extract_bios() {
|
|||||||
|
|
||||||
# --- 8MB chip ---
|
# --- 8MB chip ---
|
||||||
echo ""
|
echo ""
|
||||||
info "Now move the clip to the ${BOLD}8MB (bottom)${NC} chip."
|
show_image "eeprom_chip_8mb.webp" "Reference: 8MB (bottom) chip location on T440p"
|
||||||
|
echo ""
|
||||||
|
info "Now move the clip to the ${BOLD}8MB (bottom)${NC} chip shown above."
|
||||||
info "Re-check pin 1 alignment before pressing down."
|
info "Re-check pin 1 alignment before pressing down."
|
||||||
prompt_continue
|
prompt_continue
|
||||||
|
|
||||||
|
|||||||
@@ -7,24 +7,24 @@ install_dependencies() {
|
|||||||
case "$DISTRO" in
|
case "$DISTRO" in
|
||||||
arch)
|
arch)
|
||||||
info "Installing packages via pacman..."
|
info "Installing packages via pacman..."
|
||||||
run_cmd "sudo pacman -S --needed base-devel curl git gcc-ada ncurses zlib nasm sharutils unzip flashrom usbutils chafa"
|
run_cmd "sudo pacman -S --needed base-devel curl git gcc-ada ncurses zlib nasm sharutils unzip flashrom usbutils chafa libwebp"
|
||||||
;;
|
;;
|
||||||
debian)
|
debian)
|
||||||
info "Installing packages via apt..."
|
info "Installing packages via apt..."
|
||||||
run_cmd "sudo apt update"
|
run_cmd "sudo apt update"
|
||||||
run_cmd "sudo apt install -y build-essential curl git gnat libncurses-dev zlib1g-dev nasm sharutils unzip flashrom usbutils chafa"
|
run_cmd "sudo apt install -y build-essential curl git gnat libncurses-dev zlib1g-dev nasm sharutils unzip flashrom usbutils chafa webp"
|
||||||
;;
|
;;
|
||||||
fedora)
|
fedora)
|
||||||
info "Installing packages via dnf..."
|
info "Installing packages via dnf..."
|
||||||
run_cmd "sudo dnf install -y @development-tools curl git gcc-gnat ncurses-devel zlib-devel nasm sharutils unzip flashrom usbutils chafa"
|
run_cmd "sudo dnf install -y @development-tools curl git gcc-gnat ncurses-devel zlib-devel nasm sharutils unzip flashrom usbutils chafa libwebp-tools"
|
||||||
;;
|
;;
|
||||||
gentoo)
|
gentoo)
|
||||||
info "Installing packages via emerge..."
|
info "Installing packages via emerge..."
|
||||||
run_cmd "sudo emerge --ask sys-devel/base-devel net-misc/curl dev-vcs/git sys-devel/gcc ncurses dev-libs/zlib dev-lang/nasm app-arch/sharutils app-arch/unzip sys-apps/flashrom sys-apps/usbutils media-gfx/chafa"
|
run_cmd "sudo emerge --ask sys-devel/base-devel net-misc/curl dev-vcs/git sys-devel/gcc ncurses dev-libs/zlib dev-lang/nasm app-arch/sharutils app-arch/unzip sys-apps/flashrom sys-apps/usbutils media-gfx/chafa media-libs/libwebp"
|
||||||
;;
|
;;
|
||||||
nix)
|
nix)
|
||||||
info "Installing packages via nix-env..."
|
info "Installing packages via nix-env..."
|
||||||
run_cmd "nix-env -i stdenv curl git gcc gnat ncurses zlib nasm sharutils unzip flashrom usbutils chafa"
|
run_cmd "nix-env -i stdenv curl git gcc gnat ncurses zlib nasm sharutils unzip flashrom usbutils chafa libwebp"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
warn "Could not detect your distribution."
|
warn "Could not detect your distribution."
|
||||||
|
|||||||
+43
-2
@@ -113,9 +113,36 @@ _render_image() {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Transcode a webp file to png next to it. Echoes the png path on success.
|
||||||
|
_webp_to_png() {
|
||||||
|
_webp="$1"
|
||||||
|
_png="${_webp%.webp}.png"
|
||||||
|
|
||||||
|
[ -f "$_png" ] && { printf '%s' "$_png"; return 0; }
|
||||||
|
|
||||||
|
if check_command dwebp; then
|
||||||
|
dwebp "$_webp" -o "$_png" >/dev/null 2>&1 && {
|
||||||
|
printf '%s' "$_png"; return 0;
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
if check_command magick; then
|
||||||
|
magick "$_webp" "$_png" >/dev/null 2>&1 && {
|
||||||
|
printf '%s' "$_png"; return 0;
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
if check_command convert; then
|
||||||
|
convert "$_webp" "$_png" >/dev/null 2>&1 && {
|
||||||
|
printf '%s' "$_png"; return 0;
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# show_image <filename> [caption]
|
# show_image <filename> [caption]
|
||||||
# Downloads $IMAGE_BASE_URL/<filename> into $WORK_DIR/.images/,
|
# Downloads $IMAGE_BASE_URL/<filename> into $WORK_DIR/.images/,
|
||||||
# renders inline if possible, otherwise prints the URL.
|
# renders inline if possible, otherwise prints the URL.
|
||||||
|
# If the image is webp and the renderer can't decode it, transcodes to png.
|
||||||
show_image() {
|
show_image() {
|
||||||
_name="$1"
|
_name="$1"
|
||||||
_caption="$2"
|
_caption="$2"
|
||||||
@@ -134,15 +161,29 @@ show_image() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# First attempt: render the file as-is.
|
||||||
if _render_image "$_local"; then
|
if _render_image "$_local"; then
|
||||||
[ -n "$_caption" ] && printf " ${DIM}%s${NC}\n" "$_caption"
|
[ -n "$_caption" ] && printf " ${DIM}%s${NC}\n" "$_caption"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# No renderer available
|
# Fallback: if webp, try to transcode to png and re-render.
|
||||||
|
case "$_name" in
|
||||||
|
*.webp)
|
||||||
|
_png=$(_webp_to_png "$_local")
|
||||||
|
if [ -n "$_png" ] && _render_image "$_png"; then
|
||||||
|
[ -n "$_caption" ] && printf " ${DIM}%s${NC}\n" "$_caption"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# No renderer / transcode available — degrade to URL.
|
||||||
info "Reference image: $_url"
|
info "Reference image: $_url"
|
||||||
if ! check_command chafa; then
|
if ! check_command chafa; then
|
||||||
info "(Install 'chafa' for inline image previews: sudo pacman -S chafa)"
|
info "(Install 'chafa' for inline image previews)"
|
||||||
|
elif case "$_name" in *.webp) true ;; *) false ;; esac; then
|
||||||
|
info "(Install 'libwebp' (dwebp) or 'imagemagick' to preview webp inline)"
|
||||||
fi
|
fi
|
||||||
[ -n "$_caption" ] && info "$_caption"
|
[ -n "$_caption" ] && info "$_caption"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user