Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions os/mini/1bit-menu
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,12 @@ pick() {
p_hint=${p_it#*|}
[ "$p_hint" = "$p_it" ] && p_hint=
if [ "$p_k" = "$p_i" ]; then
printf ' %s> %s %-10s%s' "$REV" "$p_k" "$p_lab" "$RESET"
printf ' %s%s\033[K\n' "$BOLD" "$p_hint"
# #707: the bar covers the whole row, not just " > 1 Chat ". Pad the row to the
# terminal width BEFORE inverse video, so the number, the label and the description are
# one bar (the c18 screenshots showed a short box offset from the menu text).
p_txt=$(printf '> %s %-10s %s' "$p_k" "$p_lab" "$p_hint")
while [ "${#p_txt}" -lt $((COLS - 2)) ]; do p_txt="$p_txt "; done
printf ' %s%s%s\033[K\n' "$REV" "$p_txt" "$RESET"
else
printf ' %s %-10s' "$p_k" "$p_lab"
printf ' %s%s%s\033[K\n' "$GREY" "$p_hint" "$RESET"
Expand Down
70 changes: 58 additions & 12 deletions os/mini/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,24 @@ fi
# bring the USB4 ports up (they were in the image but nothing loaded them until now). realtek is the
# PHY driver the wired NIC needs and must load first: without it r8169 fails with -49 and the machine
# comes up with no network at all, which looks exactly like a hang.
for m in realtek r8169 mt7925e virtio_net xhci_pci usb_storage uas sd_mod nvme ahci vfat nls_cp437 nls_iso8859_1 nls_ascii ext4 phy-generic typec typec_ucsi ucsi_acpi typec_displayport thunderbolt usbhid hid_generic evdev k10temp i2c_piix4 amd_pmc psmouse serio_raw btusb snd_hda_intel snd_usb_audio sdhci_pci intel_rapl_msr spd5118 thunderbolt_net roles r8152 ax88179_178a cdc_ether cdc_ncm usbnet; do modprobe -q "$m"; done
for m in realtek r8169 mt7925e virtio_net xhci_pci usb_storage uas sd_mod nvme ahci vfat nls_cp437 nls_iso8859_1 nls_ascii ext4 phy-generic typec typec_ucsi ucsi_acpi typec_displayport thunderbolt usbhid hid_generic evdev k10temp i2c_piix4 amd_pmc psmouse serio_raw btusb sdhci_pci intel_rapl_msr spd5118 thunderbolt_net roles r8152 ax88179_178a cdc_ether cdc_ncm usbnet; do modprobe -q "$m"; done
mdev -s 2>/dev/null

# #705: one flow. Every wait says what it is waiting for, on the screen, on the serial line and (once
# /data is mounted) in /data/boot.log - the c18 dry run had a 12 s chooser, then a blank "starting" while
# DHCP and lemond came up, and no way to tell a wait from a hang. Defined here, before the first wait.
say() { echo "$*"; echo "$*" >> /data/boot.log 2>/dev/null
for c in /dev/console /dev/tty1; do [ -w "$c" ] && echo "$*" > "$c" 2>/dev/null; done; }

# network: DHCP on every wired interface
ip link set lo up
for n in /sys/class/net/e*; do
[ -e "$n" ] || continue
i=${n##*/}; ip link set "$i" up
say " network: waiting for DHCP on $i ($(cat /sys/class/net/$i/operstate 2>/dev/null || echo unknown))"
udhcpc -i "$i" -b -q -t 5 -s /etc/udhcpc.script >/dev/null 2>&1
a=$(ip -4 -o addr show dev "$i" scope global 2>/dev/null | awk '{print $4}' | cut -d/ -f1 | head -1)
say " network: ${a:-no address yet} on $i"
done

# models: the stick's 1BIT-DATA partition, if present (the internal disk is left alone)
Expand Down Expand Up @@ -87,11 +96,7 @@ fi
stage "stick mounted at ${data:-nothing}"

# Every message goes to the screen, the serial line and the stick: a live boot must never be a blank
# screen you have to guess about. Defined before its first use: it used to sit below the kernel link
# line, so the console lost that line to "say: not found" (seen in the VM's serial log).
say() { echo "$*"; echo "$*" >> /data/boot.log 2>/dev/null
for c in /dev/console /dev/tty1; do [ -w "$c" ] && echo "$*" > "$c" 2>/dev/null; done; }

# screen you have to guess about. Defined above the first wait (#705).
# The engine's own llama-server and the HSA runtime it loads are on the DATA PARTITION, not in the RAM
# image (mkimage.sh: grub will not load an initrd over ~103 MB and this one is at 89.5 MB, so anything
# added to the image after it is packed never reaches the stick - which is why 1bit.check said
Expand Down Expand Up @@ -179,21 +184,36 @@ grep -q " /data " /proc/mounts && [ -e /data/.installed ] && INSTALLED=1
# below was silently lost (the installed boot reported INSTALLED on screen and no marker in /etc/1bit)
mkdir -p /etc/1bit 2>/dev/null
MODE=live
# #704: the version on the banner comes from the image itself. /etc/1bit/release-identity is written by
# mkimage.sh out of the Lemonade package that is being shipped and the tree the image was built from, so
# a banner can never again say v2026.43 on a stick carrying Lemonade 2026.46.0 - and 1bit-release-check
# reports the same file instead of SKIPping a missing identity.
ident() { sed -n "s/^$1: *//p" /etc/1bit/release-identity 2>/dev/null | head -n 1; }
TAG=$(ident tag); TAG=${TAG:-dev}
LEMVER=$(ident lemonade)
if [ -c /dev/console ] && [ "$INSTALLED" = 0 ]; then
{
echo
echo " 1bit OS, Lemonade Server appliance v2026.43 - LIVE: runs from RAM, nothing is installed, disks are never touched"
echo " 1bit OS, Lemonade Server appliance $TAG${LEMVER:+ (Lemonade $LEMVER)} - LIVE: runs from RAM, nothing is installed, disks are never touched"
echo " Lemonade Server by AMD, running on the 1bit engine"
echo " ------------------------------------------------------------------------------"
echo " 1) Lemonade appliance (default, starts in 12s)"
echo " 1) Lemonade appliance (default)"
echo " 2) Lemonade, verbose, no GPU driver"
echo " 3) Root shell (no services)"
echo " 4) Power off"
echo
} | mc
printf " choice: " | mc
i=0
while [ $i -lt 12 ]; do
# #705: the selection timer is on the choice line itself - one screen, a countdown you can watch,
# instead of a menu that sits there for 12 s and then drops into a blank "starting". Any key picks.
repaint_choice() {
for c in /dev/console /dev/tty1; do
[ -w "$c" ] && printf '\r choice [1] starts in %2d s ' "$i" > "$c" 2>/dev/null
done
}
i=12
while [ "$i" -gt 0 ]; do
repaint_choice
if read -r -t 1 -n 1 c < /dev/console 2>/dev/null; then
case "$c" in
2) MODE=nogpu; break ;;
Expand All @@ -202,9 +222,12 @@ if [ -c /dev/console ] && [ "$INSTALLED" = 0 ]; then
1|"") break ;;
esac
fi
i=$((i+1))
i=$((i-1))
done
printf "\n" | mc
for c in /dev/console /dev/tty1; do
[ -w "$c" ] && printf '\r choice [%s] starting\n' "$MODE" > "$c" 2>/dev/null
done
unset -f repaint_choice
fi
case "$MODE" in
off) say "powering off (choice 4)"; sync; poweroff -f ;;
Expand Down Expand Up @@ -318,6 +341,7 @@ if [ -f "$kf" ] && ! grep -q '^LEMONADE_API_KEY=..*' "$kf" 2>/dev/null; then
} >> "$kf" && chmod 600 "$kf"
fi
# Lemonade's environment file (LEMONADE_API_KEY, LEMONADE_ADMIN_API_KEY, HF_TOKEN), for lemond only
say " Lemonade: starting"
( cd "$lem" || exit 1
if [ -f lemond.conf ]; then set -a; . ./lemond.conf; set +a; fi
exec lemond "$lem/cache" "$lem/config" ) > /tmp/lemond.log 2>&1 &
Expand All @@ -328,6 +352,28 @@ key=off; setkey LEMONADE_API_KEY && key=on
[ "$key" = off ] && setkey LEMONADE_ADMIN_API_KEY && key="off, admin key only: /api and /v1 are open"
lhost=$(cfg host); lport=$(cfg port); lhost=${lhost:-localhost}; lport=${lport:-13305}
echo "Lemonade: http://$lhost:$lport (API key: $key; log: /tmp/lemond.log)"
# #705: say when it actually answers, so the wait for lemond is visible rather than a screen that says
# "starting" until it happens. lemond binds localhost by default; ask the address it was configured with
# first, then 127.0.0.1, so a host of 0.0.0.0 is not a 20 s false negative.
lup=0
for i in $(seq 1 20); do
for a in "$lhost" 127.0.0.1; do
case "$a" in 0.0.0.0|::|'') continue ;; esac
if wget -q -O /dev/null -T 1 "http://$a:$lport/" 2>/dev/null; then lup=1; break 2; fi
done
sleep 1
done
[ "$lup" = 1 ] && say " Lemonade: up on http://$lhost:$lport/ (API key: $key)" ||
say " Lemonade: not answering yet after 20 s (log: /tmp/lemond.log; API key: $key)"
# and the engine behind it: the HRX device the onebit recipe needs, or the reason it is not there
if [ -x /opt/1bit-llama/llama-server ]; then
say " engine: probing the HRX device"
dev=$(timeout 20 /opt/1bit-llama/llama-server --list-devices 2>&1 | grep -m1 -i 'HRX' || true)
[ -n "$dev" ] && say " engine: HRX0 ready - $(echo "$dev" | cut -c1-60)" ||
say " engine: no HRX device listed (a GPU-less boot still serves on the CPU path; 1bit-release-check says why)"
else
say " engine: no llama-server on /data on this boot"
fi
[ -f /data/1bit.conf ] && echo "note: /data/1bit.conf is no longer read; Lemonade serves at boot (/data/lemonade, os/README.md)"

if [ "$INSTALLED" = 1 ]; then
Expand Down
60 changes: 55 additions & 5 deletions os/mini/mkimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ if [ -f "$vmlinuz" ]; then
if [ -n "$vkver" ]; then echo "== the image kernel ($vkver, from $vmlinuz)"; fi
fi
here=$(cd "$(dirname "$0")" && pwd)
# #704: the release name this image carries, in one place. No page or banner hard-codes a version (the
# c18 dry run read "v2026.43" on a stick shipping Lemonade 2026.46.0): IMAGE_TAG is what the candidate
# build passes (WEEKLY_TAG), and a hand-built image falls back to the engine tree's own describe.
repo=$(cd "$here/../.." && pwd)
tagv=${IMAGE_TAG:-$(git -C "$repo" describe --always --dirty 2>/dev/null || echo dev)}
tools=$HOME/.cache/1bit-os/tools/x
# Dropbear, mtools and the EFI stub come from their Debian packages, unpacked here on first use. A
# cleaned ~/.cache used to stop the weekly release at "SSH (Dropbear)" (2026-10-01 rehearsal).
Expand Down Expand Up @@ -144,9 +149,12 @@ echo "== kernel modules ($kver)"
# carries (r8152, ax88179_178a, cdc_ether, cdc_ncm, usbnet). Wi-Fi: mt7925e pulls mt76/mac80211/cfg80211.
# Every module the board binds on the build machine (os/mini/hwprobe.py, 26 Oct 2026): CPU temperature
# (k10temp, what the fan logic and the checks read), SMBus and the DIMM sensors, the power controller,
# the PS/2 path and raw serio, Bluetooth (its MT7925 firmware is already shipped), audio (HDA and the
# KVM's USB audio), the SD reader, RAPL power readings. BusyBox init has no udev: init.sh loads them.
mods="nvme ahci amd_pmf amdgpu amdxdna r8169 realtek mt7925e xhci_pci usb_storage uas sd_mod vfat ext4 nls_iso8859_1 nls_cp437 nls_ascii virtio_net virtio_blk thunderbolt thunderbolt_net typec ucsi_acpi typec_displayport usbhid hid_generic evdev k10temp i2c_piix4 amd_pmc psmouse serio_raw btusb snd_hda_intel snd_usb_audio sdhci_pci intel_rapl_msr spd5118 typec_ucsi roles r8152 ax88179_178a cdc_ether cdc_ncm usbnet"
# the PS/2 path and raw serio, Bluetooth (its MT7925 firmware is already shipped), the SD reader, RAPL
# power readings. BusyBox init has no udev: init.sh loads them.
# #708: no sound modules. The appliance has no audio, and on the c18 live boot snd_usbmidi_lib was refused
# (its signing key is not the kernel's) and then eleven "Unknown symbol snd_ctl_new1 (err -2)" lines
# scrolled over the screen for every user. Dropping them is the whole fix: nothing else loads them.
mods="nvme ahci amd_pmf amdgpu amdxdna r8169 realtek mt7925e xhci_pci usb_storage uas sd_mod vfat ext4 nls_iso8859_1 nls_cp437 nls_ascii virtio_net virtio_blk thunderbolt thunderbolt_net typec ucsi_acpi typec_displayport usbhid hid_generic evdev k10temp i2c_piix4 amd_pmc psmouse serio_raw btusb sdhci_pci intel_rapl_msr spd5118 typec_ucsi roles r8152 ax88179_178a cdc_ether cdc_ncm usbnet"
for m in $mods; do
modprobe -S "$kver" --show-depends "$m" 2>/dev/null | awk '$1 == "insmod" {print $2}'
done | sort -u | while read -r ko; do mkdir -p "$root$(dirname "$ko")"; cp "$ko" "$root$ko"; done
Expand Down Expand Up @@ -249,6 +257,26 @@ else
fi
depmod -b "$root" "$kver"

# #708: refuse an unsigned module, the same way this script refuses a module built for another kernel.
# Secure Boot is on for the owner, so an unsigned module is not a line in a log: it is a rejection and then
# every symbol error of the module that depended on it. The signers are printed either way, because "the
# module is signed" is not the question - signed by a key this kernel trusts is.
unsigned=0
while IFS= read -r ko; do
signer=$(modinfo -F signer "$ko" 2>/dev/null)
if [ -z "$signer" ]; then
echo " UNSIGNED: ${ko#"$root"}"
unsigned=$((unsigned + 1))
fi
done < <(find "$root/lib/modules" -type f \( -name '*.ko' -o -name '*.ko.xz' -o -name '*.ko.zst' \))
if [ "$unsigned" != 0 ]; then
echo "this image would ship $unsigned unsigned module(s) (named above) into a Secure Boot machine; stopping"
exit 1
fi
while IFS= read -r ko; do modinfo -F signer "$ko" 2>/dev/null; done \
< <(find "$root/lib/modules" -type f \( -name '*.ko' -o -name '*.ko.xz' -o -name '*.ko.zst' \)) |
sort | uniq -c | sed 's/^/ signer: /'

echo "== firmware (only what these chips load)"
fw() { # a pattern that matches nothing on this machine is skipped
(cd /lib/firmware && for p in "$@"; do ls -d $p 2>/dev/null || true; done) | while read -r f; do
Expand Down Expand Up @@ -390,6 +418,25 @@ cp "$here/release-check.sh" "$root/bin/1bit-release-check"; chmod +x "$root/bin/
install -m 0755 "$here/board.sh" "$root/usr/sbin/1bit-board"
mkdir -p "$root/etc/1bit"
install -m 0644 "$here/power.conf.example" "$root/etc/1bit/power"
# #704: what this image is, measured at build time, written where the boot banner and 1bit-release-check
# read it (os/mini/init.sh, os/mini/release-check.sh). The Lemonade version comes from the package that
# is being shipped - `lemond --version` - never from a constant; the engine commit and the HRX pin come
# from the tree this image was built out of. The artifact's own sha256 cannot be in the image it hashes,
# so it stays in the release table beside the .img.zst and 1bit-release-check reports the tag.
lemver=$("$lem/bin/lemond" --version 2>/dev/null | sed -n 's/^lemond version \([^ ~]*\).*/\1/p' | head -n 1)
[ -n "$lemver" ] || lemver=unknown
{
echo "tag: $tagv"
echo "lemonade: $lemver"
echo "engine: $(git -C "$repo" rev-parse --short=12 HEAD 2>/dev/null || echo unknown)"
# the pin the release actually ships: the gitlink recorded in this tree. `git -C third_party/hrx-system
# rev-parse HEAD` walks UP to the parent repository when the submodule is not checked out - which is how
# the release lane builds - and silently reported the ENGINE commit as the HRX pin (review of #720).
hrx=$(git -C "$repo" ls-tree HEAD third_party/hrx-system 2>/dev/null | awk '{print substr($3, 1, 12)}')
echo "hrx-system: ${hrx:-unknown}"
echo "kernel: $kver"
echo "built: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
} > "$root/etc/1bit/release-identity"
# The onebit entries this image ships, so 1bit-release-check can prove Lemonade registers them. The
# catalogue Lemonade reads at runtime is server_models.json; the check needs the *shipped* subset on
# paper, because on a machine without a GPU or NPU Lemonade hides those entries and their absence there
Expand Down Expand Up @@ -600,7 +647,10 @@ stub=$tools/usr/lib/systemd/boot/efi/linuxx64.efi.stub
# because the cmdline carried ignore_loglevel + loglevel=7. The serial console (ttyS0) is what the QEMU
# gates read and it keeps the verbose log - init.sh's first act raises it there, per console. Level 4
# is "warnings and errors only": a boot that goes wrong still says why on the VT.
cmdline="console=tty0 console=ttyS0,115200 loglevel=4 panic=600 oops=panic fbcon=nodefer vt.global_cursor_default=1 rdinit=/init"
# #707: the appliance menu was unreadable from the chair - the VT's default 8x16 font on a panel that
# is not 80x25 puts the whole menu in one corner. The image kernel is built with CONFIG_FONT_TER16x32=y,
# so the console takes a 16x32 font at boot; no font file, no setfont and nothing to keep in the image.
cmdline="console=tty0 console=ttyS0,115200 loglevel=4 panic=600 oops=panic fbcon=font:TER16x32 fbcon=nodefer vt.global_cursor_default=1 rdinit=/init"
printf '%s' "$cmdline" > "$out/cmdline.txt"
# section layout after the stub's own sections, each aligned to 64 KiB
align() { echo $(( ($1 + 65535) / 65536 * 65536 )); }
Expand Down Expand Up @@ -670,7 +720,7 @@ if [ "$BOOT_LAYOUT" = grub ]; then
cat > "$out/esp/EFI/BOOT/grub.cfg" <<GRUBCFG
set timeout=12
set default=0
menuentry "1bit OS, Lemonade Server appliance v2026.43 - LIVE (runs from RAM, nothing installed)" {
menuentry "1bit OS, Lemonade Server appliance ${tagv} - LIVE (runs from RAM, nothing installed)" {
linux /1bit/vmlinuz $cmdline
initrd /1bit/initramfs.img
}
Expand Down
Loading