The device scripts say what they do, and the bring-up no longer needs a deploy key

A read-through of scripts/ ahead of the public release, applying only what could
be verified from the code. The setup script clones over public HTTPS when no
deploy key sits at KEY_PATH and keeps the SSH path when one does, and its
timezone is a TIMEZONE knob rather than a hardcoded city. The flasher recognises
the plain XIAO nRF52840's bootloader (PID 0x0044) as well as the Sense's
(0x0045), both from Adafruit's board.h. The mux unit was After= the very target
that WantedBy= pulls it into, an ordering cycle; it now orders on basic.target,
which still wants a check on the device. The console-font header stopped
claiming a default run installs /etc/vtrgb (it removes the custom remap), and
states that the font it builds is an OFL-1.1 Terminus derivative that must not
be called Terminus and that the optional 6x8 candidate embeds a GPL-2.0 kernel
bitmap. The radio-bridge header describes the four phases the script actually
runs instead of a pin-routing phase it never contained. Personal remarks in
comments are reworded impersonally.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jean-Pierre MartineauandClaude Fable 5.1 committed 2026-09-12 19:02:02 -04:00
1 parent 72fc0665c5
commit 9ebc4bd2be
5 files changed
+79 -54

No files matched your search

+15 -9
View File
@@ -12,6 +12,10 @@
# * meshterm.psf.gz 6x12 (Terminus base) -> 53x26 -- the installed default
# * meshterm8.psf.gz 6x8 (kernel font_6x8) -> 53x40 -- the A/B candidate
#
# meshterm.psf.gz is a derivative of Terminus Font (OFL-1.1) and must not itself be called
# "Terminus" -- the stock ter-u12n.psf.gz base keeps its own OFL-1.1 licence, distinct from
# this repository's Apache-2.0.
#
# Flip live with `setfont /usr/share/consolefonts/meshterm8.psf.gz` (and back with
# meshterm.psf.gz); persist the winner via FONT= in /etc/vconsole.conf.
#
@@ -25,16 +29,18 @@
#
# The 6x8 base is the Linux kernel's own font_6x8 (lib/fonts/font_6x8.c, GPL-2.0),
# embedded below -- CP437 coverage, so unlike the Terminus base it has NO Cyrillic;
# its keeper list drops the Cyrillic canary accordingly.
# its keeper list drops the Cyrillic canary accordingly. Note: this bitmap's GPL-2.0
# licence differs from this repository's own (Apache-2.0); it is embedded as data.
#
# Everything else is pure geometry, generated on-device; only the stock Terminus font and
# python3 are required. Run as root on the Lyra (serial console is fine):
#
# sh calculinux-console-font.sh
#
# Idempotent -- safe to re-run after a MeshTerm update or a font tweak. Also installs
# /etc/vtrgb + the meshterm-vtrgb boot oneshot (the 16-slot palette; see
# meshterm/ui/theme._VT_SLOTS -- a repo test pins the two to each other).
# Idempotent -- safe to re-run after a MeshTerm update or a font tweak. Also manages the
# 16-slot palette: a default run restores the stock VT palette (theme._VT_SLOTS) and
# removes any custom remap; MESHTERM_CUSTOM_PALETTE=1 installs the archived remap
# (theme._VT_SLOTS_CUSTOM, pinned to theme.vtrgb_lines() by a test).
set -eu
FONT_NAME=meshterm
@@ -147,8 +153,8 @@ MARKS = {
"##..##", "##..##", "######", "######", "......", "......"]),
}
# The same 18 marks redrawn for the 6x8 cell (first-draft art; the P5 tweak round and
# JP's eyeball pass refine whichever font wins the A/B).
# The same 18 marks redrawn for the 6x8 cell (first-draft art; a later tweak round
# refines whichever font wins the A/B).
MARKS8 = {
0x25CF: art([ # BLACK CIRCLE
"......", "..##..", ".####.", "######", "######", ".####.", "..##..", "......"]),
@@ -346,10 +352,10 @@ echo "persisted FONT=$FONT_NAME in $VCONSOLE (loads on every boot)"
echo "A/B: 'setfont $OUT8' for 53x40, 'setfont $OUT' for 53x26; persist the winner in $VCONSOLE"
# --- palette -----------------------------------------------------------------------------
# JP's decision (2026-08-01): the console keeps its STANDARD kernel palette -- black
# By design, the console keeps its STANDARD kernel palette -- black
# background, stock hues -- and meshterm/ui/theme.MESH_THEME_16 is designed against those
# (theme._VT_SLOTS). The custom tailwind-family remap P3 originally shipped is ARCHIVED,
# one environment variable away in case he changes his mind:
# (theme._VT_SLOTS). The custom tailwind-family remap originally shipped is ARCHIVED,
# one environment variable away for anyone who wants it back:
#
# MESHTERM_CUSTOM_PALETTE=1 sh calculinux-console-font.sh
#
+10 -14
View File
@@ -21,25 +21,21 @@
# It is idempotent -- safe to re-run; each phase checks before it acts.
#
# 1. UART sanity /dev/ttyS1 exists, the console isn't on it, no getty owns it.
# 2. pin routing Route UART1 to its physical pads. The Calculinux DT enables the
# UART1 *controller* (hence /dev/ttyS1) but never applies its pinctrl
# (the node carries pinctrl-0 with no pinctrl-names), so TX/RX reach no
# pad at all -- verified live: the port's tx counter climbs while rx
# stays 0 forever. Worse, the only pads the RK3506 IO matrix can carry
# UART1 on -- RM_IO28 (rx, pin gpio1-19) and RM_IO30 (tx, gpio1-26) --
# are claimed by SPI1 (ff130000.spi) for the PicoCalc's front SD slot
# (mmc-spi-slot): the radio and that slot share nets. So a boot-time
# helper unbinds SPI1 (the front SD slot goes dark while the radio owns
# the pads) and muxes the two pads to UART1 through debugfs.
# 3. bridge A stdlib-only python UART<->TCP pump (no pyserial, no venv) installed
# 2. bridge A stdlib-only python UART<->TCP pump (no pyserial, no venv) installed
# as /etc/meshterm-radio-bridge.py + a systemd service, enabled at boot.
# It serves ONE client at a time -- two clients would interleave
# companion frames -- which is why this isn't a `socat ... fork` line.
# The pin-routing helper runs as its ExecStartPre, every boot.
# 4. profile A `[profiles.radio]` TCP profile (127.0.0.1:5000) in the deploy
# 3. profile A `[profiles.radio]` TCP profile (127.0.0.1:5000) in the deploy
# user's ~/.meshterm/config.toml, made the default profile, so a bare
# `meshterm` lists the radio on the splash and `-p radio` connects.
# 5. report Service state and how to connect, locally and over the LAN.
# 4. report Service state and how to connect, locally and over the LAN.
#
# What this script does NOT do: it never routes UART1 to physical pads. On stock
# Calculinux the DT enables the UART1 controller (hence /dev/ttyS1 existing) without
# applying its pinctrl, so TX/RX reach no pad and this pump would faithfully serve a port
# that is electrically dead. Pin routing now lives in xiao-radio/uart1-mux.py, which uses
# a different pad pair (header GP4/GP5) than this script's header once assumed -- run that
# (via xiao-radio/lyra-setup.sh) first if you need the radio actually wired up.
set -eu
# --- knobs (override via the environment) ----------------------------------------------
+47 -29
View File
@@ -21,13 +21,16 @@
# until then, which is fatal for "heard" ordering, TTL, etc. A oneshot
# service waits for a real route, then steps the clock once (NTP client
# if the image has one, else an HTTPS Date-header fallback).
# 4. timezone Eastern (America/Toronto, same rules as America/Montreal) via
# 4. timezone `$TIMEZONE`, Eastern (America/Toronto) unless you say otherwise, via
# timedatectl if tzdata's opkg feed is reachable, else a POSIX TZ rule
# in /etc/environment -- glibc honours it with no zoneinfo database.
# The POSIX fallback rule is only known for the default zone; a custom
# $TIMEZONE without tzdata is set via timedatectl only, with a warning.
# 5. deploy user The `$DEPLOY_USER` login MeshTerm runs under, `meshterm` unless you
# say otherwise (created if absent; no password is set here -- run
# `passwd` for it yourself).
# 6. clone Pull MeshTerm with the READ-ONLY GitHub deploy key over SSH.
# 6. clone Pull MeshTerm over SSH with the read-only GitHub deploy key if one
# is present at $KEY_PATH, else a public HTTPS clone of $REPO_URL.
# 7. venv + install A venv + `pip install -e .`. pip's C builds hit ENOSPC because /tmp
# is a tiny RAM tmpfs, so TMPDIR is redirected to $HOME/tmp on /data.
# 8. PATH Put the venv's `meshterm` on that user's login PATH via ~/.profile.
@@ -35,7 +38,8 @@
# rounded frame corners + the list cursor the bare console can't draw).
#
# Two prerequisites this script cannot safely embed and will check for / guide you through:
# * the read-only deploy key at $KEY_PATH (never commit a private key);
# * the read-only deploy key at $KEY_PATH, if you want the SSH clone (never commit a
# private key) -- omit it and the clone falls back to public HTTPS;
# * Wi-Fi credentials known to iwd. The kick only nudges an ALREADY-known network. Either
# provision it once by hand (`iwctl station wlan0 connect <SSID>`), or export
# WIFI_SSID and WIFI_PSK before running and this script writes the iwd config for you.
@@ -43,7 +47,9 @@ set -eu
# --- knobs (override via the environment) ----------------------------------------------
DEPLOY_USER="${DEPLOY_USER:-meshterm}"
TIMEZONE="${TIMEZONE:-America/Toronto}"
REPO_SSH="${REPO_SSH:-git@github.com:jpmartineau/MeshTerm.git}"
REPO_URL="${REPO_URL:-https://github.com/jpmartineau/MeshTerm.git}" # used when no deploy key is present
KEY_PATH="${KEY_PATH:-/home/$DEPLOY_USER/.ssh/id_ed25519}"
CHECKOUT="/home/$DEPLOY_USER/MeshTerm"
WIFI_SSID="${WIFI_SSID:-}" # optional: set both to have iwd credentials written
@@ -227,16 +233,16 @@ systemctl daemon-reload
systemctl enable time-sync.service >/dev/null 2>&1 || info "could not enable time-sync.service"
info "installed /etc/time-sync.sh + time-sync.service (enabled)"
# --- 4. timezone (America/Toronto -- Eastern, same rules as America/Montreal) ----------
log "4/9 timezone (Eastern)"
# --- 4. timezone ($TIMEZONE -- America/Toronto/Eastern by default) ---------------------
log "4/9 timezone ($TIMEZONE)"
opkg install tzdata-americas tzdata-core >/dev/null 2>&1 || true
if [ -f /usr/share/zoneinfo/America/Toronto ]; then
if [ "$(timedatectl show -p Timezone --value 2>/dev/null)" != "America/Toronto" ]; then
timedatectl set-timezone America/Toronto && info "set via timedatectl (tzdata present)"
if [ -f "/usr/share/zoneinfo/$TIMEZONE" ]; then
if [ "$(timedatectl show -p Timezone --value 2>/dev/null)" != "$TIMEZONE" ]; then
timedatectl set-timezone "$TIMEZONE" && info "set via timedatectl (tzdata present)"
else
info "already America/Toronto (timedatectl)"
info "already $TIMEZONE (timedatectl)"
fi
else
elif [ "$TIMEZONE" = "America/Toronto" ] || [ "$TIMEZONE" = "America/Montreal" ]; then
# opkg.calculinux.org's feed has been observed fully empty (404 at the index, not just
# this package) -- no zoneinfo database reaches the device then. glibc still honours a
# POSIX TZ rule without one, so fall back to the exact US/Canada Eastern DST rule
@@ -255,6 +261,14 @@ else
runas "printf '\n# Eastern time (America/Toronto == America/Montreal); POSIX rule -- no tzdata feed\nexport TZ=$TZ_POSIX\n' >> ~/.profile"
info "added TZ export to $DEPLOY_USER's ~/.profile (belt-and-suspenders for non-PAM logins)"
fi
else
# No POSIX DST rule is known here for a non-default $TIMEZONE without a tzdata feed;
# set it via timedatectl if it takes, otherwise warn and move on rather than guess.
if timedatectl set-timezone "$TIMEZONE" 2>/dev/null; then
info "set via timedatectl"
else
info "warning: no tzdata for $TIMEZONE and no POSIX fallback rule known -- clock stays UTC"
fi
fi
# --- 5. deploy user --------------------------------------------------------------------
@@ -268,41 +282,45 @@ else
else
adduser -D -s /bin/bash "$DEPLOY_USER" || die "adduser failed"
fi
# wheel -> sudo, matching the working device; harmless if the group is absent.
# wheel -> sudo; harmless if the group is absent.
(usermod -aG wheel "$DEPLOY_USER" 2>/dev/null || adduser "$DEPLOY_USER" wheel 2>/dev/null) || true
info "no password set -- run: passwd $DEPLOY_USER"
fi
# input -> the F-key lane's Shift watcher reads /dev/input (services/modifier_watch);
# dialout/video match the working device (serial radios, framebuffer). All idempotent.
# dialout/video are needed for serial radios and the framebuffer. All idempotent.
for grp in input dialout video; do
(usermod -aG "$grp" "$DEPLOY_USER" 2>/dev/null || adduser "$DEPLOY_USER" "$grp" 2>/dev/null) || true
done
# --- 5. clone MeshTerm (read-only deploy key over SSH) ---------------------------------
# --- 5. clone MeshTerm (SSH deploy key if present at $KEY_PATH, else public HTTPS) -----
log "6/9 clone MeshTerm"
[ -f "$KEY_PATH" ] || die "deploy key not found at $KEY_PATH
place the READ-ONLY GitHub deploy key there first, e.g.:
install -d -m700 -o $DEPLOY_USER -g $DEPLOY_USER /home/$DEPLOY_USER/.ssh
cp id_ed25519 $KEY_PATH && chmod 600 $KEY_PATH
chown $DEPLOY_USER:$DEPLOY_USER $KEY_PATH"
KNOWN_HOSTS="/home/$DEPLOY_USER/.ssh/known_hosts"
SSH_CMD="ssh -i $KEY_PATH -o IdentitiesOnly=yes -o UserKnownHostsFile=$KNOWN_HOSTS"
# Pin github.com's host key up front so the clone never blocks on an interactive prompt.
if ! runas "test -f $KNOWN_HOSTS && grep -q github.com $KNOWN_HOSTS"; then
info "recording github.com host key"
runas "ssh-keyscan -t ed25519 github.com >> $KNOWN_HOSTS 2>/dev/null" || info "ssh-keyscan failed (offline?)"
if [ -f "$KEY_PATH" ]; then
CLONE_URL="$REPO_SSH"
KNOWN_HOSTS="/home/$DEPLOY_USER/.ssh/known_hosts"
SSH_CMD="ssh -i $KEY_PATH -o IdentitiesOnly=yes -o UserKnownHostsFile=$KNOWN_HOSTS"
# Pin github.com's host key up front so the clone never blocks on an interactive prompt.
if ! runas "test -f $KNOWN_HOSTS && grep -q github.com $KNOWN_HOSTS"; then
info "recording github.com host key"
runas "ssh-keyscan -t ed25519 github.com >> $KNOWN_HOSTS 2>/dev/null" || info "ssh-keyscan failed (offline?)"
fi
CLONE_ENV="GIT_SSH_COMMAND='$SSH_CMD' "
else
info "no deploy key at $KEY_PATH -- cloning $REPO_URL over public HTTPS instead"
CLONE_URL="$REPO_URL"
CLONE_ENV=""
fi
if [ -d "$CHECKOUT/.git" ]; then
info "already cloned -- pulling"
runas "git -C ~/MeshTerm pull --ff-only" || info "pull failed (offline?) -- continuing"
else
info "cloning $REPO_SSH"
runas "GIT_SSH_COMMAND='$SSH_CMD' git clone $REPO_SSH ~/MeshTerm" \
info "cloning $CLONE_URL"
runas "${CLONE_ENV}git clone $CLONE_URL ~/MeshTerm" \
|| die "clone failed (key not authorized, or offline)"
# Bake the deploy key into the checkout so later pulls just work.
runas "git -C ~/MeshTerm config core.sshCommand '$SSH_CMD'"
if [ -f "$KEY_PATH" ]; then
# Bake the deploy key into the checkout so later pulls just work.
runas "git -C ~/MeshTerm config core.sshCommand '$SSH_CMD'"
fi
fi
# --- 6. venv + editable install (TMPDIR off the RAM tmpfs) -----------------------------
+3 -1
View File
@@ -72,7 +72,9 @@ def bootloader_port():
return None
for p in lp.comports():
hwid = (p.hwid or "").upper()
if "2886" in hwid and "0045" in hwid: # Seeed VID + bootloader PID
# Seeed VID + bootloader PID: 0x0045 (Sense) or 0x0044 (plain nRF52840), both from
# Adafruit's UF2 bootloader board.h for this chip family.
if "2886" in hwid and ("0045" in hwid or "0044" in hwid):
return p.device
return None
+4 -1
View File
@@ -33,7 +33,10 @@ echo ">> installing + enabling systemd service"
cat > "$UNIT" <<EOF
[Unit]
Description=Route RK3506 UART1 to GP4/GP5 for the MeshCore XIAO radio
After=multi-user.target
# Ordered on basic.target, not multi-user.target: WantedBy=multi-user.target below already
# pulls this in as part of reaching multi-user.target, so After=multi-user.target would be
# an ordering cycle. The mux should still run early enough to precede login/MeshTerm start.
After=basic.target
[Service]
Type=oneshot