# NETBSD-USERLAND.md -- Makronix on a Linux kernel Plan, written 2026-11-11. The work is cut into items that one agent can take, do and finish alone, most of them in parallel. Read this file, the root `AGENTS.md`, `mobile/AGENTS.md` and the `AGENTS.md` of the directory you work in before you start. ## 0. The goal, in Konrad's words (2026-11-11) - "I would love to replace runit for the phone and port netbsd's rc system over." - "I would love to use as much as possible from our makronix/netbsd source ontop of the linux kernel that we need." - Then, the decisive one: "fuck voidlinux from now on. everything that we can not use from our ../src makronix netbsd stuff, we use from LFS. linux from scratch where, if possible, we choose packages/sources/recipes from pkgsrc. i want the _complete_ system, even with linux kernel, under our control. why not even then use also _a_ desktop version with linux kernel?" -- glibc "for now" (our own libc is the goal), the NetBSD way for the network (no NetworkManager), bluez "for now". So this is **Makronix/Linux**: the Linux kernel (kernel.org + our series) as the driver layer, the toolchain of `src/` (build.sh tools), and on it, in this order of preference: our `src/` (userland, init, rc, openssh, dhcpcd, wpa, ntp ...); pkgsrc recipes; and only for what neither has, LFS-style from upstream in `ext/src//` with an `mx/` recipe (glibc, kmod, udev, util-linux's mount, iproute2, bluez, the Qualcomm daemons, a curated firmware subset). No Void: the Void image on the phone today is a bridge until the image is built from these parts (phase L). The phone is the first device; a desktop variant on the Linux kernel follows with the same base. The Makronix userland of the desktop (Xorg, MCDE, `packages.list`) comes from the same pkgsrc into `/usr/pkg`. Prior art: Chimera Linux ships FreeBSD's userland on Linux. Ours is NetBSD's on glibc. ## 1. What is measured already (the ground this plan stands on) - **NetBSD programs build on Linux/glibc today.** The desktop build (`build.sh tools`) compiles about 70 of them for this Linux host through NetBSD's own portability layer `src/tools/compat` (`libnbcompat`): `ls build/obj/tooldir.*/bin` shows nbcat, nbdate, nbsed, nbawk, nbgrep, nbmake, nbpax, nbmtree, nbhexdump, nbm4, nbyacc, nblex, nbfile, nbstat, nbxz, nbgzip, nbmktemp, nbjoin, nbtsort, nbmandoc and more. The recipe is `src/tools/Makefile.host`: it takes `src//Makefile` (PROG, SRCS) and builds it with `libnbcompat` for the host. **This is the building block for every port below: the same, with the aarch64 compiler.** - `libnbcompat` (`src/tools/compat/Makefile`, `compat_defs.h`) already gives efun (emalloc, estrdup, ecalloc, erealloc, efopen), fparseln, strtoi, strtou, strtonum, strsuftoll, strmode, setmode/getmode, pwcache (user_from_uid, group_from_gid), vis/unvis, fts, reallocarr, errc/warnc, lchmod, lchflags, getline, mkdtemp, issetugid, strlcpy/strlcat. - The BSD functions it does not give are in our own tree: `src/lib/libc/gen/` has humanize_number.c, dehumanize_number.c, getbsize.c, devname.c, setproctitle.c, getmntinfo.c; `src/lib/libutil/` has login_cap.c, pidfile.c, efun.c. - NetBSD's own tests exist for many programs (`src/tests/bin`: cat cp date dd df expr pax ps sh sleep tar; `src/tests/usr.bin`: awk basename cmp col cut diff dirname find grep gzip id ... ), with atf and kyua in `src/external/bsd`. - `src/external/bsd` also carries NetBSD's versions of things Void provides today: cron, dhcpcd, wpa (wpa_supplicant), ntp, openresolv, less, nvi, top, tmux, libarchive, file, mdocml, flex, byacc, bc, openpam. - The host runs aarch64 binaries: qemu-aarch64 is registered in binfmt_misc (2026-11-11). `qemu-aarch64 -L prog` runs a phone binary on the host -- every agent can test without the phone. - The toolchain that builds the kernel, `aarch64-linux-gnu-gcc` (Debian), is the compiler; the sysroot is our own Void rootfs (`build/rootfs-void-hotdogb.tar`, `make rootfs`). - The phone today (2026-11-11, `7.0.14-makronix-unstable`): `/sbin/init` is runit-init, `/bin/sh` is dash, 20 runit services (NetworkManager, agetty-tty1..6, agetty-ttyGS0, bluetoothd, bt-address, chronyd, dbus, elogind, rmtfs, slot-successful, sshd, tqftpserv, udevd, usb0-dhcp, zram-swap), 19 core-service hooks and 12 shutdown hooks in `/etc/runit` (lists in section 6), 187 Void packages. ### API scan (2026-11-11) `grep` over the sources of each candidate for BSD-only interfaces (LOC = lines of .c). "nbcompat" means covered by libnbcompat; the rest needs `libmxlinux` (section 4). | program | LOC | BSD interfaces found | |---|---|---| | bin/cat | 319 | none | | bin/chmod | 243 | lchmod, fts, setmode (nbcompat) | | bin/cp | 1129 | chflags, fchflags, lchmod, fts | | bin/date | 782 | utmpx (glibc has it) | | bin/dd | 2366 | strsuftoll (nbcompat), humanize_number | | bin/df | 669 | getmntinfo, getbsize, humanize_number, mount | | bin/ed | 3339 | reallocarr (nbcompat) | | bin/ls | 1712 | humanize_number, getbsize, strmode, pwcache, vis, fts | | bin/mkdir | 223 | setmode (nbcompat) | | bin/mv | 430 | fchflags, strmode, pwcache | | bin/pax | 15427 | fts, pwcache, strmode, lchmod, chflags, mount | | bin/ps | 3179 | sysctl, kvm_* (kvm_getlwps, kvm_openfiles), devname, efun | | bin/rm | 614 | fts, arc4random (glibc 2.36+), strmode, pwcache | | bin/sh | 23494 | sysctl (3), setproctitle, setmode, reallocarr | | bin/ksh | 25019 | setproctitle | | bin/csh | 15503 | setproctitle, strvis, reallocarr | | bin/stty | 1261 | none (termios) | | bin/test | 904 | none | | bin/echo, sleep, sync, pwd, rmdir, ln, kill, hostname, domainname | < 400 each | none | | sbin/init | 1862 | sysctl (12), sysctlbyname, utmpx, wtmpx, reboot, getttyent, mount | | sbin/rcorder | 1239 | efun, fparseln (nbcompat) -- nothing else | | sbin/reboot | 259 | reboot (12), utmpx | | sbin/shutdown | 617 | reboot | | sbin/dmesg | 449 | kvm_*, sysctl | | sbin/sysctl | 3080 | sysctl, sysctlbyname | | sbin/mount / umount | 1056 / 523 | mount, unmount, getmntinfo | | sbin/swapctl | 1218 | swapctl (18), humanize_number | | sbin/ping | 2045 | arc4random | | sbin/chown | 317 | fts | | sbin/mknod | 683 | sysctl (3), setmode | | usr.bin/find | 3257 | efun, fts, pwcache, strmode, chflags, mount | | usr.bin/tail | 1246 | kqueue, kevent (only for -f) | | usr.bin/sort | 2581 | efun, lchmod | | usr.bin/sed | 2559 | efun, errc | | usr.bin/grep | 1969 | fts | | usr.bin/m4 | 3799 | strtoi | | usr.bin/diff | 2692 | errc, warnc, reallocarr | | usr.bin/sdiff | 1246 | strtonum, fparseln | | usr.bin/make | 26101 | sysctl (3), mount | | usr.bin/login | 2319 | utmpx, wtmpx, lastlogx, login_cap, ttyaction, setproctitle | | usr.bin/su / passwd | 1236 / 1724 | login_cap, efun | | usr.bin/w | 823 | utmpx, sysctl, kvm_getlwps | | usr.bin/who / last | 715 / 723 | utmpx, wtmpx | | usr.bin/pkill | 721 | kvm, sysctl | | usr.bin/vmstat | 2867 | sysctl (36), kvm (many) | | usr.bin/stat | 1242 | vis, devname, strmode | | usr.bin/xargs, tr, cmp, time, patch, ftp, ldd | | none | | usr.bin/head, wc, uniq, tee, env, basename, dirname, tty, comm, fold, nl, paste, rev, split, touch, yes, seq, id, logname, nohup, nice, getopt, realpath, mktemp, expand, unexpand, fmt, look, lam, jot, printenv | < 600 each | none or strlcpy/getprogname only | | usr.bin/du | 362 | fts, humanize_number, getbsize | | usr.bin/column | 307 | efun | | usr.bin/calendar | 733 | fparseln | | usr.sbin/syslogd | 8197 | kqueue, kevent, sysctl | | usr.sbin/inetd | 5054 | kqueue, kevent (16) | | usr.sbin/powerd | 435 | kqueue (envsys: no Linux equivalent) | | usr.sbin/user | 2667 | login_cap, fparseln, master.passwd format | | libexec/getty | 1527 | ttyaction, efun | ## 2. Rules for every item 1. **Read first** (root `AGENTS.md`, "The rule before all others"): the program's man page in `src/`, the comment at the top of the source, its `Makefile`. Quote the line that settles a question. 2. **`src/` is shared with the desktop.** A change there must keep the NetBSD build green and must be `#ifdef __linux__` (or a new file chosen by the Makefile only on Linux), never a change of NetBSD behaviour. Prefer fixing a port in the framework (`mobile/userland/mk`), in `libnbcompat` or in `libmxlinux` over touching a program's source. A change that breaks a NetBSD convention is a finding for the report, never a quiet change. 3. **One item, one directory.** A ported program lives in `mobile/userland//` (Makefile, test.sh, AGENTS.md). The build finds the directories by itself (section 3, A6), so no agent edits a shared list. 4. **Claiming.** An item is claimed by creating its directory with an `AGENTS.md` whose first lines say `state: claimed`, the agent and the date, committed alone (`git commit -- mobile/userland//AGENTS.md`). Look before you claim: `tools/userland-status.sh` (A8) lists every item and its state. States: `claimed`, `builds`, `runs-qemu`, `runs-phone`, `done`, `blocked: `. 5. **Commit with explicit paths** (other agents share the index): `git add -- && git commit -- `. Never `git add -A`, never `git commit -a`. 6. **Done** means: builds with `make -C mobile userland PROG=` from a clean tree, `file` says ARM aarch64 ELF, `test.sh` passes under `qemu-aarch64 -L build/sysroot-hotdogb` (A2), it runs on the phone (`tools/userland-test.sh `, A8), NetBSD's atf test for it passes if one exists (C-T), the desktop build is not broken, `AGENTS.md` says `done` with the log lines that show it. 7. POSIX sh in `tools/`, `dash -n` clean. No Python in the tree. 8. Never write to the phone's slots or `/system` from an item; integration is item A7 / R10 / D*, done by one agent at a time, with Konrad's OK for flashing. ## 3. Phase A -- the frame (sequential, one agent; blocks C and R) **A1 References.** Save into `docs/reference/` (root) with source and date: `src/tools/Makefile.host`, `src/tools/compat/README` (if any) and the `configure.ac` header, `src/share/mk/bsd.prog.mk` (PROG/SRCS/BINDIR), `init(8)`, `rc(8)`, `rc.subr(8)`, `rcorder(8)`, `rc.conf(5)`, `ttys(5)`, `getty(8)`, `gettytab(5)`; pkgsrc `doc/HOWTO-use-crosscompile`. **A2 Sysroot.** `tools/mksysroot.sh`: unpack `build/rootfs-void-.tar` into `build/sysroot-/`, keep headers and libraries (`/usr/include`, `/usr/lib`), make absolute symlinks relative (the linker follows them inside `--sysroot`). Needs the Void `-devel` packages for what we link against (glibc-devel, libxcrypt-devel, ncurses-devel, pam-devel, zlib-devel, libarchive-devel, openssl-devel): add them to a build-only package list in `base/void/` that never reaches the phone image. Measure: an empty `main()` links and runs under `qemu-aarch64 -L build/sysroot-hotdogb`. **A3 Toolchain wrapper.** `build/toolchain/bin/aarch64-makronix-linux-gnu-{cc,c++,ar,ranlib,strip,ld,nm,objcopy}`: thin sh wrappers around `aarch64-linux-gnu-*` that add `--sysroot=build/sysroot-`. One name used by the frame and by pkgsrc (E1). Measure: `cc -v` shows the sysroot; `cc -print-file-name=libc.so` points into it. **A4 Host make.** The frame is driven by NetBSD make. Use the desktop's `build/obj/tooldir.*/bin/nbmake` if it exists, else build it alone from `src/tools/make` (`configure && make`, as `build.sh` does in its first step) into `build/toolchain/bin/nbmake`. `tools/lib.sh` gets `nbmake_path`. The mobile build must not need a desktop `make release`. **A5 libnbcompat for the target.** Run `src/tools/compat/configure --host=aarch64-linux-gnu` with the A3 compiler, out of tree in `build/userland//compat/`, build `libnbcompat.a` and `nbtool_config.h`. Measure: the library is aarch64, `nm` lists fparseln, strtoi, emalloc, fts_open. Note in `AGENTS.md` which configure checks ran under qemu (binfmt) -- they must, since they execute test programs. **A6 The frame: `mobile/userland/`.** Modelled on `src/tools/Makefile.host`: - `mobile/userland/mk/mx.prog.mk`: given `MX_SRCDIR=bin/cat`, includes `src/${MX_SRCDIR}/Makefile` for PROG, SRCS, MAN, BINDIR, `.PATH`s it, compiles with the A3 compiler, `-include nbtool_config.h` and `-I compat -I mxlinux/include`, links `libmxlinux.a libnbcompat.a`, writes objects to `build/userland//obj/` and installs to `build/userland//destdir` at the NetBSD BINDIR (Void is usr-merged: `/bin` and `/sbin` are links to `/usr/bin`, so /bin/cat lands on /usr/bin/cat -- intended, it replaces coreutils' file). - `mobile/userland//Makefile`: two lines, `MX_SRCDIR=` and `.include "../mk/mx.prog.mk"`, plus what the port needs (`LDADD+=`, `CPPFLAGS+=`, a `SRCS:=` correction). - `mobile/userland/Makefile`: `SUBDIR!= ls -d */Makefile` minus `mk lib`, so a new port is picked up without editing a list. - `mobile/Makefile`: `make userland [PROG=x]`. - First port end to end: `cat`. Measure: `qemu-aarch64 -L ... cat` on a file, and on the phone. - `mobile/userland/AGENTS.md` (what lives here, the claim protocol of section 2). **A7 Into the image.** `assemble-rootfs.sh` takes the userland destdir and copies it over the Void tree after the Void packages, before base/soc files. Each port has `mobile/userland//REPLACES`: the Void paths it supersedes (`/usr/bin/cat`) and the Void package that owned them (`coreutils`) -- read by D1. A port is in the image only when its `AGENTS.md` says `done` (the frame checks that), so half-ports never reach the phone. **A8 Status and phone test.** `tools/userland-status.sh`: one line per `mobile/userland/*/AGENTS.md` (prog, state, agent, date). `tools/userland-test.sh `: copies the binary and `test.sh` to `/tmp/userland-test/` on the phone (never into `/system`), runs it there with `PATH` pointing at it, prints PASS/FAIL. **A9 `libmxlinux` skeleton.** `mobile/userland/lib/mxlinux/` with Makefile, `include/mxlinux.h`, an empty test; the B items fill it. ## 4. Phase B -- `libmxlinux`, the Linux side of BSD interfaces (parallel after A9) Each item is one source file plus a test, in `mobile/userland/lib/mxlinux/`. Where NetBSD has the function in `src/lib`, **build our source** and give it only what it needs from Linux; write new code only for kernel interfaces. | id | what | from | notes | |---|---|---|---| | B1 | humanize_number, dehumanize_number, getbsize | `src/lib/libc/gen/` as is | pure C; ls, df, du, dd, swapctl | | B2 | getmntinfo, statvfs1/getvfsstat, struct statvfs fields NetBSD has | new: `/proc/self/mountinfo` + statvfs(3) | df, mount (listing), umount -a, find -fstype | | B3 | devname | `src/lib/libc/gen/devname.c` over a /dev scan (no dev.db) | ps, stat | | B4 | setproctitle | `src/lib/libc/gen/setproctitle.c` logic; Linux: overwrite argv area + prctl(PR_SET_NAME) | sh, ksh, csh, login, inetd | | B5 | sysctl / sysctlbyname, a named subset | new: kern.hostname, kern.ostype ("NetBSD"? decide), kern.osrelease, kern.boottime, kern.securelevel (always -1), hw.ncpu, hw.physmem64, hw.pagesize, hw.machine_arch, vm.loadavg, kern.maxproc; mapped to uname(2), /proc, sysinfo(2) | sh, make, init, mknod, w; ENOENT for everything else | | B6 | kvm_getproc2, kvm_getlwps, kvm_getargv2, kvm_getenvv2 over /proc//{stat,status,cmdline,environ} | new | ps, pkill/pgrep, w, top; struct kinfo_proc2 filled field by field, unknown fields 0 | | B7 | kqueue/kevent subset: EVFILT_READ/WRITE, EVFILT_VNODE (inotify), EVFILT_SIGNAL (signalfd), EVFILT_TIMER (timerfd), EVFILT_PROC (pidfd) | new, over epoll | tail -f, syslogd, inetd; libkqueue (BSD-licensed) is prior art -- read it, decide | | B8 | login_cap: login_getclass, login_getcapnum/str/bool, setusercontext | `src/lib/libutil/login_cap.c` with /etc/login.conf; setusercontext maps to setgroups/setgid/setuid/umask/setrlimit | login, su, passwd, user | | B9 | reboot(howto, bootstr) | new: RB_HALT -> LINUX_REBOOT_CMD_HALT, RB_POWERDOWN -> POWER_OFF, RB_AUTOBOOT -> RESTART2 with bootstr (our reboot-mode: "bootloader") | reboot, halt, poweroff, shutdown, init | | B10 | mount(type, dir, flags, data) for the types we use (tmpfs, procfs->proc, kernfs->sysfs?, ext2fs->ext4, msdos->vfat, null->bind, overlay) | new, over mount(2) | decide in B10 whether NetBSD mount(8) replaces util-linux mount at all; first measure what the rc scripts call | | B11 | utmpx/wtmpx/lastlogx: NetBSD names over glibc's utmpx | new, thin: glibc has getutxent etc; NetBSD-only (getlastlogx, utmpxname paths) mapped | login, who, last, w, init, date | | B12 | ttyaction, getttyent extras | `src/lib/libutil/ttyaction.c`; glibc has getttyent | getty, login, init | | B13 | chflags/lchflags/fchflags | new: map UF_IMMUTABLE/SF_IMMUTABLE/UF_APPEND to FS_IOC_SETFLAGS, rest EOPNOTSUPP silently as on file systems without flags | cp, mv, pax, find | ## 5. Phase C -- the programs (parallel after A6; one agent per row) Install path in brackets (NetBSD BINDIR). "replaces" = the Void package whose file goes away (A7 REPLACES, D4). Order inside a tier is free. ### C1 -- no BSD interface at all (good first items) | id | program | src | replaces | |---|---|---|---| | C1.1 | cat [/bin] | bin/cat | coreutils | | C1.2 | echo [/bin] | bin/echo | coreutils | | C1.3 | sleep [/bin] | bin/sleep | coreutils | | C1.4 | sync [/bin] | bin/sync | coreutils | | C1.5 | pwd [/bin] | bin/pwd | coreutils | | C1.6 | rmdir [/bin] | bin/rmdir | coreutils | | C1.7 | ln [/bin] | bin/ln | coreutils | | C1.8 | kill [/bin] | bin/kill | util-linux / procps | | C1.9 | hostname [/bin] | bin/hostname | inetutils? (check) | | C1.10 | test, [ [/bin] | bin/test | coreutils | | C1.11 | expr [/bin] | bin/expr (expr.y: yacc from A4/C3) | coreutils | | C1.12 | stty [/bin] | bin/stty | coreutils | | C1.13 | basename, dirname | usr.bin/basename, dirname | coreutils | | C1.14 | head, tail (without -f first) | usr.bin/head, tail | coreutils | | C1.15 | wc, uniq, tee, comm, fold, nl, paste, rev | usr.bin/... | coreutils, util-linux (rev) | | C1.16 | split, touch, yes, seq, env, printenv | usr.bin/... | coreutils | | C1.17 | tty, logname, nohup, nice, id, whoami (id -un link) | usr.bin/... | coreutils | | C1.18 | getopt, realpath, readlink (stat link), mktemp | usr.bin/... | util-linux, coreutils | | C1.19 | expand, unexpand, fmt, look, lam, jot, col, column | usr.bin/... | coreutils, util-linux | | C1.20 | xargs, tr, cut, cmp, time, printf | usr.bin/... | findutils, coreutils, diffutils | | C1.21 | true, false | usr.bin/true (shell scripts) | coreutils | | C1.22 | units, calendar | usr.bin/... | (new) | ### C2 -- covered by libnbcompat, or by B1/B3/B13 | id | program | src | needs | replaces | |---|---|---|---|---| | C2.1 | chmod, chown/chgrp | bin/chmod, sbin/chown | nbcompat | coreutils | | C2.2 | mkdir | bin/mkdir | nbcompat | coreutils | | C2.3 | mv, cp | bin/mv, bin/cp | B13 | coreutils | | C2.4 | rm | bin/rm | nbcompat | coreutils | | C2.5 | ls | bin/ls | B1 | coreutils | | C2.6 | du | usr.bin/du | B1 | coreutils | | C2.7 | dd | bin/dd | B1 | coreutils | | C2.8 | find | usr.bin/find | B2, B13 | findutils | | C2.9 | sort | usr.bin/sort | nbcompat | coreutils | | C2.10 | sed | usr.bin/sed | nbcompat | sed | | C2.11 | grep | usr.bin/grep | nbcompat | grep | | C2.12 | awk | external/historical/nawk (what tools/awk builds) | -- | gawk | | C2.13 | m4, yacc, lex | usr.bin/m4, external/bsd/byacc, flex | -- | (new) | | C2.14 | diff, sdiff, patch, ed | usr.bin/..., bin/ed | nbcompat | diffutils, patch | | C2.15 | hexdump, od | usr.bin/hexdump | nbcompat | util-linux | | C2.16 | join, tsort, what | usr.bin/... | -- | coreutils | | C2.17 | gzip (gunzip, zcat), xz, bzip2 | usr.bin/gzip, external/public-domain/xz, external/bsd/bzip2 | nbcompat | gzip, xz, bzip2 | | C2.18 | pax, tar, cpio | bin/pax | B13 | tar | | C2.19 | make | usr.bin/make | B5 (hw.ncpu) | (new) | | C2.20 | date | bin/date | B11 | coreutils | | C2.21 | stat, readlink | usr.bin/stat | B3 | coreutils | | C2.22 | script | usr.bin/script | -- | util-linux | | C2.23 | mtree | usr.sbin/mtree | -- | (new; also for D-checks) | | C2.24 | mandoc (man) | external/bsd/mdocml | -- | mdocml (Void's is the same upstream) | | C2.25 | less, more | external/bsd/less | -- | less | | C2.26 | nvi (vi, ex) | external/bsd/nvi | -- | nvi | | C2.27 | ftp | usr.bin/ftp (with or without openssl) | -- | (new) | | C2.28 | file | external/bsd/file | -- | file | ### C3 -- shells | id | program | notes | |---|---|---| | C3.1 | sh [/bin/sh] | NetBSD ash; B4, B5 (its 3 sysctl uses: find and decide each). Run `src/tests/bin/sh` (C-T). Becomes /bin/sh only in D5, after every rc script and every Void script that remains runs under it (dash today). | | C3.2 | ksh | B4; interactive shell for root and users | | C3.3 | csh | B4; optional | ### C4 -- system programs that need libmxlinux | id | program | needs | decision to record | |---|---|---|---| | C4.1 | df | B1, B2 | -- | | C4.2 | dmesg | B5; read via klogctl(2) instead of kvm | keep NetBSD flags (-M/-N meaningless) | | C4.3 | reboot, halt, poweroff | B9, B11 | `reboot bootloader` replaces our reboot-mode tool (reboot2) | | C4.4 | shutdown | B9; signals init (R3) | -- | | C4.5 | ps | B6, B3 | the biggest; `src/tests/bin/ps` | | C4.6 | pkill, pgrep | B6 | -- | | C4.7 | w, uptime, who, last | B6, B11 | wtmp format is glibc's; fine as long as all writers are ours | | C4.8 | top | external/bsd/top has a machine/ layer: write m_linux.c over /proc | -- | | C4.9 | sysctl(8) | B5 | read-only first; writing maps to /proc/sys? decide | | C4.10 | mount, umount | B2, B10 | maybe stays util-linux; decide from what rc.d needs | | C4.11 | swapctl | Linux swapon/swapoff(2), /proc/swaps | zram-swap (R7) uses it | | C4.12 | ping, ping6 | raw sockets; glibc netinet headers | replaces iputils | | C4.13 | login, su, passwd | B8, B11, B12; OpenPAM (external/bsd/openpam) or Linux-PAM | decide PAM; Void's pam config stays until then | | C4.14 | getty [/usr/libexec/getty] + gettytab | B12 | replaces agetty | | C4.15 | syslogd, newsyslog | B7 | replaces nothing today (Void runs none): adds logging | | C4.16 | cron | external/bsd/cron | adds cron | | C4.17 | chroot, mknod, nologin, rdate, vipw | B5 (mknod) | -- | | C4.18 | dhcpcd | external/bsd/dhcpcd (has Linux support upstream) | replaces Void dhcpcd for usb0 (R6) | | C4.19 | wpa_supplicant | external/bsd/wpa (has Linux nl80211 upstream) | NetworkManager drives it; Void's goes in D4 | | C4.20 | ntpd or ntpdate | external/bsd/ntp | replaces chrony | | C4.21 | resolvconf | external/bsd/openresolv (same upstream as Void's) | replaces openresolv | | C4.22 | inetd | B7 | optional | ### C-T -- tests | id | what | |---|---| | C-T1 | build atf (external/bsd/atf) and kyua for the target, or atf-sh only first | | C-T2 | run `src/tests/bin/` / `src/tests/usr.bin/` under qemu for every C item that has one; the C item's "done" includes it | ## 6. Phase R -- NetBSD rc instead of runit (after A6; R1-R5 one agent, R6/R7 parallel) What it replaces, the phone as of 2026-11-11: - services (`/var/service`): NetworkManager, agetty-tty1..tty6, agetty-ttyGS0, bluetoothd, bt-address, chronyd, dbus, elogind, rmtfs, slot-successful, sshd, tqftpserv, udevd, usb0-dhcp, zram-swap - core services (`/etc/runit/core-services`): 00-pseudofs, 01-acm-console, 01-firmware-partitions, 01-initcall-debug, 01-mdss-rpm-on, 01-netconsole-irqwatch, 01-netconsole, 01-static-devnodes, 02-kmods, 02-udev, 03-console-setup, 03-filesystems, 03-grow-root, 04-rtc-offset, 04-swap, 05-misc, 08-sysctl, 98-sbin-merge, 99-cleanup - shutdown (`/etc/runit/shutdown.d`): 05-wlan-before-modem, 10-sv-stop, 20-rc-shutdown, 30-seedrng, 40-hwclock, 45-rtc-offset, 50-wtmp, 60-udev, 70-pkill, 80-filesystems, 90-kexec, 95-reboot-mode | id | item | notes | |---|---|---| | R1 | read and save rc(8), rc.subr(8), rcorder(8), rc.conf(5), init(8), ttys(5), `src/etc/rc`, `src/etc/rc.subr`, `src/etc/rc.d/*` headers | list every external command rc and rc.subr call (sysctl, mount, ...) and which C/B item provides it on Linux | | R2 | rcorder | C-style port, needs only nbcompat; test against `src/etc/rc.d` | | R3 | init | B5 (securelevel -> stub), B9, B11, B12. Linux PID 1 duties: reap zombies (init does), no devfs/MAKEDEV path (the initramfs gives devtmpfs), single-user on `-s`, runs /etc/rc then the gettys of /etc/ttys, SIGTERM/SIGUSR1/SIGUSR2 -> single/halt/poweroff as NetBSD. `/etc/rc.shutdown` on shutdown. | | R4 | /etc/rc, /etc/rc.subr, /etc/rc.shutdown from `src/etc` | changes only behind a `$(uname -s) = Linux` test or in a Linux include, so the file stays one file with NetBSD | | R5 | /etc/rc.conf, /etc/defaults/rc.conf for the phone | the variables of the services below, nothing else | | R6.x | one rc.d script per service | udevd, dbus, elogind, NetworkManager, bluetoothd, bt_address, chronyd (or ntpd C4.20), sshd, rmtfs, tqftpserv, slot_successful, zram_swap, usb0_dhcp; keyword/REQUIRE/PROVIDE so rcorder gives today's order (udev before firmware users, rmtfs after tqftpserv, WLAN after rmtfs). Each is one parallel item. | | R7.x | one rc.d script per core-service hook | mountcritlocal-like for 00-pseudofs/03-filesystems; firmware_partitions, static_devnodes, kmods (modules-load.d), udev coldplug (udevadm trigger/settle), console_setup, grow_root, rtc_offset, swap (zram), sysctl (sysctl.conf -> /proc/sys), netconsole, acm_console, mdss_rpm_on, initcall_debug; 98-sbin-merge and 99-cleanup decide if still needed. One item each. | | R8 | shutdown order | rc.d `stop` order reversed by rcorder; wlan-before-modem as a REQUIRE edge (WLAN stops before rmtfs); seedrng, hwclock, rtc_offset save, wtmp, kill all, umount, reboot-mode (B9 bootstr) | | R9 | /etc/ttys | console ttyGS0 (USB ACM) and tty1..tty6 with getty (C4.14) or agetty until then | | R10 | switch | image with /sbin/init = NetBSD init, runit not started; RAM test via `fastboot boot` first, then slot a; `tools/boot-loop.sh 15` with `checks/bt-wlan.sh` and `checks/layout.sh`; Konrad's OK before slot a | | R11 | shutdown/reboot/reboot-mode measured | `shutdown -p now` powers off cleanly (no hang, docs/NEXT.md shutdown notes), `reboot`, `reboot bootloader` lands in fastboot | ## 7. Phase D -- Void out (one agent, after the items they depend on) | id | item | after | |---|---|---| | D1 | `tools/void-residue.sh`: list Void packages and files, minus everything a `done` port REPLACES; the list is what Void still provides | A7 | | D2 | xbps, xbps-triggers, libxbps and every xbps-* tool out of the phone image (they stay on the host to build the rootfs) | now -- nothing on the phone needs them | | D3 | runit, runit-void, run-parts out | R10, R11 | | D4 | coreutils, findutils, diffutils, sed, grep, gawk, tar, gzip, which, less, file, iputils, chrony, dhcpcd, wpa_supplicant ... each when D1 says nothing of it is left | the C items | | D5 | /bin/sh -> NetBSD sh | C3.1, every remaining script checked under it | | D6 | the image builds without Void's metapackages (base-container-full, base-files): our own `base/makronix/` list of the Void packages we keep (glibc, eudev, kmod, dbus, elogind, NetworkManager, bluez, mesa, linux-firmware-*, rmtfs, tqftpserv, qrtr-ns, openssh, pam, ncurses, libs) | D1-D4 | ## 7b. Phase L -- the base from our own parts (replaces D, 2026-11-11) Phase D removed Void piece by piece; since Void is dropped, the image is built from scratch instead. One item per row, parallel where marked. | id | item | from | |---|---|---| | L1 | kernel headers into build/mxsysroot- (`make headers_install` of our tree) | our kernel -- done 2026-11-11 | | L2 | glibc 2.44 into it, compiled with the tooldir's gcc 14.4 | ext/src/glibc, recipe mx/ (LFS "Glibc") | | L3 | the frame (tools/mktoolchain.sh, mxmake.sh) onto build/mxsysroot-; every port rebuilt and tested on it | -- | | L4 | libstdc++/libgcc_s of the tooldir rebuilt against our glibc (make targetlibs with the new sysroot) | -- | | L5 | src/external and src/crypto programs the base needs: openssh, dhcpcd, wpa_supplicant, ntp, cron, openresolv, libarchive, zstd, bzip2 (parallel, one each) | src/ | | L6 | what neither has, one ext/src/ with mx/ each (parallel): kmod, eudev (or systemd's udev alone), util-linux (mount, umount, swapon, fsck wrapper only), iproute2, e2fsprogs (pkgsrc has a recipe: use it), dbus (pkgsrc), bluez, qrtr, rmtfs, tqftpserv | upstream / pkgsrc | | L7 | firmware: the files our kernel actually loads (modinfo of the modules, measured on the phone) from linux-firmware, curated | upstream linux-firmware | | L8 | NetBSD init + rc + rc.d (phase R) as the only init | src/ | | L9 | the image: mtree hierarchy, then L2-L8, assembled by our own tool instead of mkrootfs-void.sh; boots on the phone from RAM, then slot a | -- | | L10 | the desktop variant: the same base for amd64 with a PC kernel config | -- | Host tools still borrowed at L2: GNU make >= 4.0 (the tooldir's is 3.81), python3, bison, gawk (glibc's build needs them). **L3, the way it went (2026-11-12): NetBSD's normal build instead of the frame.** `make src DIR=` (tools/mxsrc.sh) runs the tooldir's `nbmake-evbarm64` in `src/` with `MAKECONF=mobile/conf/mk.conf` and `DESTDIR=build/mxsysroot-` -- bsd.prog.mk and bsd.lib.mk unchanged, the objects in build/tools-obj (build.sh's `-O`), programs into the sysroot's `/bin` as on NetBSD. What glibc lacks comes from `src/lib/libmxlinux`, a normal NetBSD library: NetBSD's own sources reached over by `.PATH` (libc's getopt, vis, setmode, pwcache, fts, acl(3), extattr(3); libutil's parsedate, efun, stat_flags ...), Linux code of ours only at the kernel boundary (mx_extattr.c onto xattr(7), mx_acl.c, mx_flags.c, mx_tz.c), and the NetBSD headers glibc has no counterpart for reached over in `include/` (``, ``, ``, `` ...). libnbcompat is not used: it is the shim for host tools, and its `setmode` takes octal only (`src/tools/compat/getmode.c:37`), which made `chmod u+x` set mode 0. Measured 2026-11-12: 28 of the 34 programs of `src/bin` build, sh, ksh, ed, dd, pax and df among them (with lib/libterminfo, lib/libedit, lib/libcrypt, lib/librmt and share/terminfo by the same build; the port tests pass with it as their interpreter) (`build/logs/mxsrc-bin9-2026-11-12.log`; pax round-trips with GNU tar both ways), and the 18 with a port test pass all of it under qemu-aarch64 with the sysroot (cat chmod cp echo expr hostname kill ln ls mkdir mv pwd rm rmdir sleep stty sync test). Not yet: csh (sys/tty.h), ps (kvm(3) over /proc), date (`sin_len` in netdate.c), chio and mt (tape ioctls), rcmd (orcmd_af). ## 8. Phase E -- pkgsrc to /usr/pkg (parallel to everything; its own agent) Linux host to Linux target: `mk/tools/replace.mk:143` refuses only when `OPSYS != NATIVE_OPSYS`; Linux = Linux, so it does not. What pkgsrc lacks is `mk/tools/cross.Linux.mk` (only `cross.NetBSD.mk` exists, chosen in `mk/tools/defaults.mk:43`): its settings go into our mk.conf fragment, pkgsrc is not patched. | id | item | |---|---| | E1 | `tools/pkgsrc-cross-linux.mk.conf`: USE_CROSS_COMPILE, CROSS_DESTDIR = sysroot (A2), CC/CXX/LD and TOOLS_PATH.* = the A3 wrappers (what cross.NetBSD.mk sets from TOOLDIR), CROSS_OPSYS=Linux, CROSS_MACHINE_ARCH=aarch64, CROSS_OS_VERSION from the kernel pin, work dirs under build/pkgsrc-work-linux-aarch64 | | E2 | bootstrap: host bmake + pkg_install for the build side in build/pkg-linux-aarch64, PREFIX /usr/pkg for the target, `--prefer-native=yes` against the Void sysroot (decide per library: Void's mesa/libdrm/glibc yes) | | E3 | editors/vim, devel/flex, devel/git-base cross-built; run on the phone from a test /usr/pkg | | E4 | x11/modular-xorg-server with the modesetting driver on msm DRM (/dev/dri/card0, no GPU: glamor off, shadowfb); xinit, xterm, xauth, xrdb, xsetroot, xmodmap, xhost | | E5 | wm/mcde from ext/src/mcde (tools/mcde-dist.sh, tools/ext-sync.sh as the desktop does) | | E6 | /usr/pkg into the system tree: assemble-rootfs.sh takes the installed /usr/pkg; size check for update-root; the makronix set list analogue for the phone | | E7 | the session: rc.d/xdm or dtlogin (R6 style) on the panel, USB keyboard/mouse over OTG until touch exists (GOAL phase 5) | | E8 | packages.aarch64.list for what only the phone needs | ## 9. Milestones - **M0** A1-A9: `make -C mobile userland PROG=cat` builds, runs under qemu and on the phone. - **M1** C1 complete, C2.1-C2.11: the everyday tools on the phone are NetBSD's. - **M2** R1-R11: the phone boots with NetBSD init and rc, runit gone (D3). - **M3** C3.1 + D5: /bin/sh is NetBSD sh. - **M4** C4 and D4: Void reduced to libraries, udev, the daemons we keep. - **M5** E1-E7: Xorg and MCDE from /usr/pkg on the phone's panel. ## 9a. State (2026-11-11) Done with the first port, cat (how: `PORTING-USERLAND.md`): - A2 sysroot: `tools/mksysroot.sh`, `base/void/sysroot-packages` (glibc 2.41 = the phone's). - A3 toolchain: `tools/mktoolchain.sh` (glibc only from the sysroot; PORTING-USERLAND.md 5.1). - A4 host make: borrowed from the desktop tooldir (`tools/mxmake.sh`); a tooldir of its own is still open. - A5 libnbcompat for aarch64: step mx-compat of `userland/Makefile`. - A6 frame: `userland/Makefile`, `userland/mk/mx.prog.mk`, `mk/mx.dist`, `make userland [PROG=x]`; it reuses `src/tools/Makefile.host` unchanged instead of a Makefile.host of its own. - A8 `tools/userland-status.sh`, `tools/userland-test.sh` (`make userland-test PROG=x [QEMU=1]`), `tools/mxcheck.sh`. - C1.1 cat: done (5/5 tests under qemu and on the phone). Later the same day: - Phase T, the toolchain from src/: `make tooldir` (build.sh tools for aarch64-linux-gnu, gcc 14.4.0 of src/, c c++ objc fortran) and `make targetlibs` (gcc headers, libgcc, libstdc++); PORTING-USERLAND.md section 8. The frame uses it (A3, A4 done: no Debian cross compiler, no desktop tooldir). - C1 ports by four opencode agents: basename comm dirname echo env fold head hostname kill ln logname nice nohup paste printenv pwd rev rmdir sleep stty sync tee test tty uniq wc yes -- all done, 28/28 with cat pass under qemu and on the phone, built with the new toolchain. - A9 libmxlinux (`userland/lib/mxlinux`), forced into every port by the frame: NetBSD's getopt (glibc's broke env -i A=1), signalname/number/next with a Linux sys_signame, B1 (humanize_number, dehumanize_number, getbsize), fgetwln, LC_C_LOCALE, timespec macros, and SIGINFO = SIGPWR, named INFO (Konrad, 2026-11-11: system-wide). The ports carry only what is theirs (stty's termios names, sleep's -lm, fold's _XOPEN_SOURCE). - A7: the ports and our libstdc++/libgcc_s go into the image (tools/lib.sh userland_stage, assemble-rootfs.sh); on the phone since 2026-11-11 (/system/current): cat, sleep, kill, env, test ... are NetBSD's, WLAN, Bluetooth, battery, all 20 services up. Open in the frame: A1 (references), LINKS ("[" and friends), D1 (what Void still provides). ## 10. Briefing template for an agent taking one item You work in /home/lotherk/src/makronix (read AGENTS.md, mobile/AGENTS.md, mobile/docs/NETBSD-USERLAND.md sections 2 and 3 first). Item: , source src/. 1. tools/userland-status.sh -- is it free? Claim it (section 2.4). 2. Read its man page and Makefile in src/; quote what matters. 3. mobile/userland//Makefile (MX_SRCDIR=...), build with make -C mobile userland PROG=; fix in this order: the frame's flags, libnbcompat, libmxlinux (B item -- if it is not done, mark yourself "blocked: B"), and only last src/ behind __linux__. 4. test.sh: the man page's main cases; run under qemu-aarch64 -L build/sysroot-hotdogb; run src/tests/... if it exists. 5. tools/userland-test.sh on the phone (if reachable). 6. REPLACES, AGENTS.md state done with the log lines; commit with explicit paths. Do not touch other items' directories, the image, the phone's /system or its boot slots.