interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / scripts / pi5-8 / pi_run.sh

41 lines · 2718 bytes Raw Blame History
1#!/usr/bin/env bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# PI5-8: put one model on the card's raw AIENOS-MODEL partition (p3), run the measurement image once, clean up.
18# pi_run.sh MODEL.gguf MODEL.MAP BOOTAA64.EFI TAG [--no-write | --write-only]
19# --no-write: p3 already holds the model (only verify it); --write-only: write and verify p3, do not run.
20# Steps: wait until no other Pi run is going (hold file + pi5-run processes), write the model to /dev/mmcblk0p3 on
21# the hub and read it back (sha256 must equal the model's), run ~/workspace/pi5/pi5-run.sh with KLOG=1 and the
22# map, then remove MODEL.MAP from the ESP (the harness does not). Evidence: ~/workspace/pi5-runs/TAG/.
23# The hub is the house server: one ssh at a time, no fast retries, never `find /` on it.
24set -euo pipefail
25model="${1:?model}"; map="${2:?map}"; efi="${3:?efi}"; tag="${4:?tag}"; nowrite="${5:-}"
26hold="${PI5_HOLD_FILE:-$HOME/.claude/jobs/9974574d/tmp/pi-hold}"
27hs() { ssh -o BatchMode=yes -o ConnectTimeout=15 hub "$@"; }
28until [[ ! -e "$hold" ]] && [[ -z "$(ps -eo pid,args | grep -E ' bash [^ ]*/pi5-run[^ ]*\.sh' | grep -v grep || true)" ]]; do sleep 30; done
29size=$(stat -c %s "$model"); sha=$(sha256sum "$model" | cut -d' ' -f1)
30if [[ "$nowrite" != --no-write ]]; then
31 echo "[$(date -u +%H:%M:%SZ)] writing $size bytes to p3"
32 hs 'sudo dd of=/dev/mmcblk0p3 bs=4M conv=fsync status=none' < "$model"
33 hs 'sync; echo 3 | sudo tee /proc/sys/vm/drop_caches >/dev/null'
34fi
35got=$(hs "sudo dd if=/dev/mmcblk0p3 bs=4M status=none | head -c ${size} | sha256sum" | cut -d' ' -f1)
36echo "[$(date -u +%H:%M:%SZ)] p3 readback sha256=$got want=$sha"
37[[ "$got" == "$sha" ]] || { echo "p3 readback MISMATCH; stopping"; exit 1; }
38[[ "$nowrite" == --write-only ]] && { echo "write-only: p3 verified, no run"; exit 0; }
39KLOG=1 MODEL_MAP="$map" "$HOME/workspace/pi5/pi5-run.sh" "$efi" "$tag"
40hs 'set -e; sudo mount /dev/mmcblk0p1 /mnt/aienos; trap "sudo umount /mnt/aienos" EXIT; sudo rm -f /mnt/aienos/EFI/AIENOS/MODEL.MAP; sync; test ! -e /mnt/aienos/EFI/AIENOS/MODEL.MAP; echo model_map_removed'
41echo "[$(date -u +%H:%M:%SZ)] done $tag"