feat(build): the stick and the data stick, Artemis formatted and signed at build

The stick's increment 3, Task 1 (docs/v4.0.0/plans/2026-10-27-stick-3-images.md;
STICK.md 4). make boot_image TARGET=PC now writes the 2 GiB stick: ESP 64 MiB
(BOOTX64.EFI, startup.nsh, starforth.cfg), StarshipOS identity 500 MiB (zeros),
StarshipOS Artemis to the end. make -f kernel/Makefile ARCH=<arch> datastick
writes the 1.5 GiB data stick, identity and Artemis, fresh every time. Sizes in
kernel/Makefile; every partition on whole MiB.

tools/mkartemis formats and signs an Artemis partition at build with the
kernel's own code -- v3's block_subsystem.c (blk_subsys_confirm_format) and
artemis_sig.c (artemis_sig_genesis_stamp) -- through a blkio device over a byte
range of the image; --check reads one back the same way (read-only). disk_uuid
from getrandom(2): each image its own. mkdiskimage.sh gains --starship,
--mkartemis, --esp-mib; Milk-V and the Pi images are unchanged. The kernel is
not changed.

Red: scripts/check_images.sh FAIL (no datastick, the PC image one partition).
Green: 23/23. Mutation: --check on a range shifted by one block fails.
Accepted: suite EXIT 0; 133146, 133417, 133815, POST 538/538, dict_hash
0xfec8c47cfc6f437f; test-32, 0 failures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rajames
2026-10-27 13:46:59 -04:00
co-authored by Claude Opus 5.5
parent a4221d8b8c
commit e177c5c6b3
12 changed files with 869 additions and 7 deletions
+32 -2
View File
@@ -180,6 +180,12 @@ MKCAPSULE_SRC = tools/mkcapsule.c tools/pkcs8_ed25519.c \
kernel/src/crypto/scalar25519.c \
kernel/src/crypto/sha512.c
MKCAPSULE_BIN = $(BUILD_DIR)/tools/mkcapsule
# mkartemis: formats and signs an Artemis partition at build with the kernel's own
# block-subsystem and artemis_sig code (tools/mkartemis.c), built as v4/Makefile builds them.
MKARTEMIS_SRC = tools/mkartemis.c kernel/src/artemis_sig.c \
$(addprefix v3/src/,block_subsystem.c blkio_ram.c blkio_file.c log.c \
platform/platform_init.c platform/linux/time.c)
MKARTEMIS_BIN = $(BUILD_DIR)/tools/mkartemis
# Milestone 6 (Phase 8): the snakeoil intermediate's private key, generated
# offline outside this repo entirely (see FABRIC-2.md's Phase 8 §Milestone 6
# writeup) -- not present in CI or a fresh checkout, so signing is skipped
@@ -213,6 +219,17 @@ BOARD_OUT := build/boards/$(BOARD)
endif
BOOT_IMAGE_SIZE_MIB ?= 128
# The StarshipOS stick and data stick (docs/v4.0.0/STICK.md 4, "sizes: a minimum, and dynamic
# above it"; set here and nowhere else). A board whose board.mk sets BOARD_STICK := 1 (the PC)
# gets the stick: an ESP, the StarshipOS identity partition, and Artemis to the end, formatted
# and signed at build. The data stick -- identity and Artemis, no ESP -- is what the `qemu`
# targets attach with DATASTICK=1 (docs/v4.0.0/plans/2026-10-27-stick-3-images.md).
STICK_IMAGE_MIB := 2048
STICK_ESP_MIB := 64
STICK_IDENT_MIB := 500
DATASTICK_MIB := 1536
DATASTICK_IMG = $(BUILD_DIR)/datastick.img
# ==============================================================================
# TOOLCHAIN
# ==============================================================================
@@ -740,6 +757,17 @@ $(MKCAPSULE_BIN): $(MKCAPSULE_SRC)
@echo "HOSTCC $(MKCAPSULE_SRC)"
@cc -std=c99 -Wall -Wextra -O2 -Iv3/include -Ikernel/include -Itools -o $@ $(MKCAPSULE_SRC)
$(MKARTEMIS_BIN): $(MKARTEMIS_SRC) $(wildcard v3/include/*.h) kernel/include/starkernel/artemis_sig.h
@mkdir -p $(dir $@)
@echo "HOSTCC tools/mkartemis.c"
@cc -std=gnu99 -Wall -O2 -Iv3/include -Ikernel/include -o $@ $(MKARTEMIS_SRC)
# datastick -- the data stick, fresh every time it is made (STICK.md 9: "fresh for each boot").
.PHONY: datastick
datastick: $(MKARTEMIS_BIN)
@bash scripts/mkdiskimage.sh --out $(DATASTICK_IMG) --table gpt --size-mib $(DATASTICK_MIB) \
--label DATASTICK --starship $(STICK_IDENT_MIB) --mkartemis $(MKARTEMIS_BIN) --esp-mib 0
# Generate capsule_generated.c from capsules/
CAPSULE_SRCS := $(shell find $(CAPSULES_DIR) -type f ! -name '.*' 2>/dev/null)
$(CAPSULE_GENERATED): $(MKCAPSULE_BIN) $(CAPSULE_SRCS)
@@ -1316,7 +1344,7 @@ boot_image:
@echo " make boot_image TARGET=PC|RASPI|MILKV|ZYNQ7020"
@exit 1
else ifeq ($(BOARD_BOOT),uefi-esp)
boot_image: all
boot_image: all $(if $(BOARD_STICK),$(MKARTEMIS_BIN))
@mkdir -p $(BOARD_OUT)
@printf 'FS0:\\EFI\\BOOT\\%s\r\n' "$(EFI_BOOTNAME)" > $(BOARD_OUT)/startup.nsh
@# The boot arguments, always written: system=v4 first -- v4 is the
@@ -1324,7 +1352,9 @@ boot_image: all
@# stick (A6); KERNEL_ARGS after it, and a later system= wins.
@printf '%s\n' 'system=v4 $(KERNEL_ARGS)' > $(BOARD_OUT)/starforth.cfg
@bash scripts/mkdiskimage.sh --out $(BOARD_OUT)/$(BOARD_IMAGE) --table gpt \
--size-mib $(BOOT_IMAGE_SIZE_MIB) --label LITHOS \
$(if $(BOARD_STICK),--size-mib $(STICK_IMAGE_MIB) --starship $(STICK_IDENT_MIB) \
--mkartemis $(MKARTEMIS_BIN) --esp-mib $(STICK_ESP_MIB),--size-mib $(BOOT_IMAGE_SIZE_MIB)) \
--label LITHOS \
$(LOADER_EFI):/EFI/BOOT/$(EFI_BOOTNAME) \
$(BOARD_OUT)/startup.nsh:/startup.nsh \
$(BOARD_OUT)/starforth.cfg:/starforth.cfg