boot1.sh (1601B)
1 #!/bin/sh 2 ## boot1.sh — stage 1 of the bootstrap chain. 3 ## 4 ## In-container script. Brings up M0/hex2-0/catm from the ~400-byte 5 ## hex0-seed by chaining stage0-posix's first three phases. All produced 6 ## binaries are target-arch Linux ELF. 7 ## 8 ## Inputs (read): vendor/seed/$ARCH/{hex0-seed,hex0.hex0,hex1.hex0, 9 ## hex2.hex1,catm.hex2,M0.hex2,ELF.hex2} 10 ## Outputs: build/$ARCH/tools/{hex0,hex1,hex2-0,catm,M0} 11 ## 12 ## Phase map (stage0-posix mescc-tools-{seed,mini}-kaem.kaem phases 0-3): 13 ## 0) hex0-seed + hex0.hex0 -> hex0 14 ## 1) hex0 + hex1.hex0 -> hex1 15 ## 2) hex1 + hex2.hex1 -> hex2-0 16 ## 2b) hex2-0 + catm.hex2 -> catm 17 ## 3a) catm : ELF.hex2 + M0.hex2 -> M0.combined.hex2 18 ## 3b) hex2-0 : M0.combined.hex2 -> M0 19 ## 20 ## Env: ARCH=aarch64|amd64|riscv64 21 22 set -eu 23 24 : "${ARCH:?ARCH must be set}" 25 26 case "$ARCH" in 27 aarch64|amd64|riscv64) ;; 28 *) echo "boot1.sh: unsupported arch '$ARCH'" >&2 ; exit 1 ;; 29 esac 30 31 S=vendor/seed/$ARCH 32 OUT=build/$ARCH/tools 33 mkdir -p "$OUT" 34 35 ## Build everything in /tmp (RAM tmpfs — see PODMAN macro in Makefile), 36 ## then cp the final binaries to the bind-mounted $OUT. Stage0 tools do 37 ## one syscall per byte; staying off virtiofs for intermediates is ~5x. 38 "$S/hex0-seed" "$S/hex0.hex0" /tmp/hex0 39 /tmp/hex0 "$S/hex1.hex0" /tmp/hex1 40 /tmp/hex1 "$S/hex2.hex1" /tmp/hex2-0 41 /tmp/hex2-0 "$S/catm.hex2" /tmp/catm 42 /tmp/catm /tmp/M0.combined.hex2 "$S/ELF.hex2" "$S/M0.hex2" 43 /tmp/hex2-0 /tmp/M0.combined.hex2 /tmp/M0 44 45 cp /tmp/hex0 /tmp/hex1 /tmp/hex2-0 /tmp/catm /tmp/M0 "$OUT/"