feat(build): make write_stick DEVICE=/dev/sdX -- the PC stick onto a USB stick, checked and read back

scripts/write_stick.sh refuses a device that is not a whole, removable USB disk, that holds the
running system, that is smaller than the image, or that has a mounted partition (it prints the
udisksctl lines); shows the stick and asks for its name typed back; writes with conv=fsync,
flushes, reads the stick back and compares it with the image byte for byte; powers it off. On
Windows/macOS it points to balenaEtcher or Rufus. Captain Bob, 2026-10-28, after a terminal line
break dropped dd's bs=4M conv=fsync on the first SER5 stick.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-29 06:22:26 -04:00
co-authored by Claude Opus 5.5
parent 954b4d5f70
commit 0a31e558be
2 changed files with 77 additions and 1 deletions
+11 -1
View File
@@ -20,6 +20,9 @@
# (build/boards/<board>/*.spdx*) and a fresh
# source SBOM -- needs syft
# make boot_images every board that has a kernel port
# make write_stick DEVICE=/dev/sdX write the PC stick image to a USB stick, checked
# first, read back and compared after
# (scripts/write_stick.sh; Linux, sudo)
# make docs [TARGET=<board>] the book; a board adds its appendix
#
# make clean all of build/ except build/cache/
@@ -59,7 +62,7 @@ BOARD_DIR := $(if $(TARGET),$(BOARD_DIR_$(TARGET)))
SUBMAKE := $(MAKE) --no-print-directory
.DEFAULT_GOAL := all
.PHONY: all boot_image boot_images docs clean clean-docs kernel boards help help-hosted sbom sbom-board \
.PHONY: all boot_image boot_images write_stick docs clean clean-docs kernel boards help help-hosted sbom sbom-board \
qemu qemu-esp qemu-gdb
# ARCH given on the command line and no TARGET: `clean` is the kernel's for that
@@ -222,6 +225,13 @@ boards:
@$(foreach b,$(BOARDS),printf ' %-9s %-8s %s\n' "$(b)" \
"$(if $(call board_ready,$(b)),ready,no port)" "$(call board_field,$(b),BOARD_DESC)";)
# write_stick -- the PC stick image (make boot_image TARGET=PC) onto a USB stick, safely:
# scripts/write_stick.sh refuses anything but a whole, removable, unmounted USB disk big enough,
# asks for the device to be typed back, writes, flushes, reads back and compares.
write_stick:
@[ -n "$(DEVICE)" ] || { echo "Usage: make write_stick DEVICE=/dev/sdX (lsblk lists the disks)"; exit 1; }
@bash scripts/write_stick.sh build/boards/pc/lithos-pc.img $(DEVICE)
help:
@sed -n '/^# TARGET is/,/^# =====/p' Makefile | sed '$$d; s/^# \{0,1\}//'