wip(kernel): Artemis grows to fill the stick at its first boot -- metadata only, capped at 256 GiB (#92, Task 2) [skip ci]

Not yet accepted (plan 2026-10-29-stick-5, Task 2, step 3).
- gpt.c: the writer, gpt_grow_last() -- the backup entry array and header to
  the disk's end, the last partition to the last usable sector (whole MiB,
  capped), both headers' CRCs, the backup before the primary, the
  protective MBR's size; gpt_alternate_lba().
- sk_v4_grow.c: the volume grown to its partition -- its fence (the Artemis
  signature, Zuse's genesis marker) moved to the new top, the header last;
  the partition grown no further than the BAM tracks (the block subsystem
  places the fence by the device's size, so a volume must fill it).
- sk_v4_identity.c: a stick of 8 GB or more whose GPT ends short of the disk
  is grown before its partitions are opened; "Artemis: grown to fill the
  stick" / "under 8 GB -- not grown" / "past 256 GiB ... left unused".
- block_subsystem: blk_volume_compute_totals() (compute_totals_from_B,
  public) and blk_subsys_set_format_bam_for(); v3's behaviour unchanged.
- mkartemis --bam-for, mkdiskimage.sh --bam-for, kernel/Makefile
  STICK_GROW_MIN_BYTES / STICK_ARTEMIS_CAP_GIB: the stick's and data stick's
  Artemis BAM sized for 256 GiB (6144 devblocks). STICK.md 5a: 256 GiB (R1).

After: stick_grow PASS (16 GiB: 12129370 user blocks, 8 s POST to prompt;
second boot not grown, recognised; sfdisk --verify: no errors), stick_small
PASS, check_images.sh PASS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GE3SDvQn5EoxdGufk84zz2
This commit is contained in:
Claude
2026-11-08 12:03:46 +00:00
parent 4e935e4825
commit 5bb247d678
17 changed files with 889 additions and 22 deletions
+16 -5
View File
@@ -270,6 +270,14 @@ STICK_IMAGE_MIB := 2048
STICK_ESP_MIB := 64
STICK_IDENT_MIB := 500
DATASTICK_MIB := 1536
# Growth (STICK.md 5a; plan 2026-10-29-stick-5, R1: "256 GiB is ruled"): a stick of at least
# STICK_GROW_MIN_BYTES grows its Artemis partition to fill it, at most STICK_ARTEMIS_CAP_GIB; the
# stick's and data stick's Artemis are formatted with a BAM sized for that cap, so growth writes
# metadata only. The kernel is built with both (-D, below).
STICK_GROW_MIN_BYTES := 8000000000
STICK_ARTEMIS_CAP_GIB := 256
STICK_ARTEMIS_CAP_SECTORS := 536870912
# (256 GiB in 512-byte sectors: keep the two in step)
DATASTICK_IMG = $(BUILD_DIR)/datastick.img
# STICK_PAIR -- a minted pair (e.g. disk/zuse-scratch) whose identity and Artemis images become
# the PC stick's partitions, byte for byte, instead of a blank identity and a fresh Artemis.
@@ -706,7 +714,8 @@ endif
V4_DEFAULT ?= 1
ifeq ($(STARFORTH_V4),1)
V4_DEFS := -DSTARFORTH_V4=1 -DSK_V4_DEFAULT=$(V4_DEFAULT) -Iv4/include \
-DV4_CELL_BITS=64 -DV4_NODE_WORDS=16384 -DV4_DATA_RING=30 -DV4_RET_RING=31 -DV4_ROM_WORDS=4096
-DV4_CELL_BITS=64 -DV4_NODE_WORDS=16384 -DV4_DATA_RING=30 -DV4_RET_RING=31 -DV4_ROM_WORDS=4096 \
-DSTICK_GROW_MIN_BYTES=$(STICK_GROW_MIN_BYTES)ULL -DSTICK_ARTEMIS_CAP_GIB=$(STICK_ARTEMIS_CAP_GIB)ULL
KERNEL_CFLAGS += $(V4_DEFS)
LOADER_CFLAGS += $(V4_DEFS)
@@ -714,8 +723,8 @@ V4_ENGINE_SRCS := $(addprefix v4/src/,node.c exec.c stack.c iword.c heat.c guard
V4_ROM_C := $(BUILD_DIR)/v4_rom_64.c
V4_MAP_C := $(BUILD_DIR)/v4_map_64.c
LOADER_EXTRA_SRCS += $(KERNEL_SRC)/v4/sk_v4.c $(KERNEL_SRC)/v4/sk_v4_identity.c $(KERNEL_SRC)/v4/sk_v4_marker.c
KERNEL_EXTRA_SRCS += $(KERNEL_SRC)/v4/sk_v4.c $(KERNEL_SRC)/v4/sk_v4_identity.c $(KERNEL_SRC)/v4/sk_v4_marker.c
LOADER_EXTRA_SRCS += $(KERNEL_SRC)/v4/sk_v4.c $(KERNEL_SRC)/v4/sk_v4_identity.c $(KERNEL_SRC)/v4/sk_v4_marker.c $(KERNEL_SRC)/v4/sk_v4_grow.c
KERNEL_EXTRA_SRCS += $(KERNEL_SRC)/v4/sk_v4.c $(KERNEL_SRC)/v4/sk_v4_identity.c $(KERNEL_SRC)/v4/sk_v4_marker.c $(KERNEL_SRC)/v4/sk_v4_grow.c
# v4/system/boot.c is the boot the hosted v4 system runs too: the ROM
# assembles the system, then the capsules from this kernel's own capsule
# directory, then the prompt.
@@ -816,7 +825,8 @@ $(MKARTEMIS_BIN): $(MKARTEMIS_SRC) $(wildcard v3/include/*.h) kernel/include/sta
.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
--label DATASTICK --starship $(STICK_IDENT_MIB) --mkartemis $(MKARTEMIS_BIN) --esp-mib 0 \
--bam-for $(STICK_ARTEMIS_CAP_SECTORS)
# zusestick -- Zuse's minted pair as a stick, fresh every time it is made (the ZUSEDISK default).
.PHONY: zusestick
@@ -1493,7 +1503,8 @@ boot_image: all $(if $(BOARD_STICK),$(MKARTEMIS_BIN))
@bash scripts/mkdiskimage.sh --out $(BOARD_OUT)/$(BOARD_IMAGE) --table gpt \
$(if $(BOARD_STICK),$(if $(STICK_PAIR),--esp-mib $(STICK_ESP_MIB) --starship-from \
$(STICK_PAIR)/zuse-thumb-ident.img $(STICK_PAIR)/artemis.img,--size-mib $(STICK_IMAGE_MIB) \
--starship $(STICK_IDENT_MIB) --mkartemis $(MKARTEMIS_BIN) --esp-mib $(STICK_ESP_MIB)), \
--starship $(STICK_IDENT_MIB) --mkartemis $(MKARTEMIS_BIN) --esp-mib $(STICK_ESP_MIB) \
--bam-for $(STICK_ARTEMIS_CAP_SECTORS)), \
--size-mib $(BOOT_IMAGE_SIZE_MIB)) \
--label LITHOS \
$(LOADER_EFI):/EFI/BOOT/$(EFI_BOOTNAME) \