boot2

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

boot1.sh (2859B)


      1 #!/bin/sh
      2 ## boot1.sh — build the self-hosted M1pp + hex2pp pair.
      3 ##
      4 ## Stage 1 of the README's chain: produces M1pp and hex2pp from their
      5 ## .P1 sources via the seed M0 + hex2 chain. catm is rebuilt later in
      6 ## boot2 from catm.P1pp.
      7 ##
      8 ## ─── Inputs (sources, from canonical tree) ───────────────────────────
      9 ##   build/$ARCH/src/src/M1pp/M1pp.P1
     10 ##   build/$ARCH/src/src/hex2pp/hex2pp.P1
     11 ##   build/$ARCH/src/src/P1/P1-$ARCH.M1
     12 ##   build/$ARCH/src/src/stage0-posix/ELF.hex2
     13 ##
     14 ## ─── Inputs (binaries from prior stages) ──────────────────────────────
     15 ##   build/$ARCH/$DRIVER/boot0/{hex2, M0, catm}
     16 ##
     17 ## ─── Outputs ──────────────────────────────────────────────────────────
     18 ##   build/$ARCH/$DRIVER/boot1/{M1pp, hex2pp}
     19 ##
     20 ## Usage: boot/boot1.sh <arch>
     21 ##   <arch> ∈ {aarch64, amd64, riscv64} for either DRIVER (default podman).
     22 
     23 set -eu
     24 
     25 . boot/lib-arch.sh
     26 bootlib_init boot1 "${1:-}"
     27 driver_init busybox
     28 require_src
     29 
     30 BOOT0=build/$ARCH/$DRIVER/boot0
     31 require_prev "$BOOT0" hex2 M0 catm
     32 
     33 . boot/lib-pipeline.sh
     34 pipeline_init "$STAGE" "$OUT" "$DRIVER"
     35 
     36 # ─── inputs ───────────────────────────────────────────────────────────
     37 pipeline_input hex2     "$BOOT0/hex2"
     38 pipeline_input M0       "$BOOT0/M0"
     39 pipeline_input catm     "$BOOT0/catm"
     40 pipeline_input_from_src "P1/P1-$ARCH.M1"   P1.M1
     41 pipeline_input_from_src stage0-posix/ELF.hex2
     42 pipeline_input_from_src M1pp/M1pp.P1
     43 pipeline_input_from_src hex2pp/hex2pp.P1
     44 
     45 # ─── pipeline ─────────────────────────────────────────────────────────
     46 # .P1 -> ELF, applied to each of M1pp.P1 and hex2pp.P1:
     47 #   catm  P1.M1 + <src>                  -> combined.M1
     48 #   M0    combined.M1                    -> prog.hex2
     49 #   catm  ELF.hex2 + prog.hex2           -> linked.hex2
     50 #   hex2  linked.hex2                    -> ELF binary
     51 build_p1() {  # $1 = source .P1, $2 = output binary name
     52     stage catm combined.M1 P1.M1 "$1"           -- P1.M1 "$1"            -- combined.M1
     53     stage M0   combined.M1 prog.hex2            -- combined.M1           -- prog.hex2
     54     stage catm linked.hex2 ELF.hex2 prog.hex2   -- ELF.hex2 prog.hex2    -- linked.hex2
     55     stage hex2 linked.hex2 "$2"                 -- linked.hex2           -- "$2"
     56 }
     57 
     58 echo "[$BOOT_TAG] M1pp.P1 + hex2pp.P1 -> M1pp + hex2pp"
     59 build_p1 M1pp.P1   M1pp
     60 build_p1 hex2pp.P1 hex2pp
     61 
     62 pipeline_export M1pp hex2pp
     63 pipeline_run
     64 
     65 echo "[$BOOT_TAG] OK -> $OUT/{M1pp, hex2pp}"