boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

mk-seed-tools.sh (1675B)


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