boot.cfg timeout -- what the documentation says and what this tree does
======================================================================
Source: the tree at /home/lotherk/src/makronix, import src/ pinned at
e523df740 (NetBSD 11.99.9), read 2026-11-04.

1. The keyword and its meaning
------------------------------
src/share/man/man5/boot.cfg.5:153-162 (boot.cfg(5)):

  .It Sy timeout
  If the value is greater than zero, this specifies the time in seconds
  that the boot loader will wait for the end-user to choose a menu item.
  During the countdown period, they may press Return to choose the default
  option or press a number key corresponding to a menu option.
  ...
  If the timeout value is set to zero, the default option will be booted
  immediately.

So the wait is per medium, it is a line in that medium's boot.cfg, and the
loader reads it at boot time.

2. Where the loader's own default comes from
--------------------------------------------
src/sys/arch/i386/stand/lib/boot_params.S:10

  .long   5   /* timeout in seconds */

That is the compiled-in value the loader uses when there is no boot.cfg; it
is 5, not 30.

3. The installed system
-----------------------
src/etc/etc.amd64/boot.cfg:5 says timeout=5, i.e. an installed Makronix
already waits 5 seconds. (It is installed into /boot.cfg by src/etc's
etc_pkg; src/distrib/sets/lists/etc/mi does not list /boot.cfg, so the file
comes from the etc_pkg install step of src/etc/Makefile.)

4. The media, as upstream ships them
------------------------------------
Upstream's amd64 media carry 30 (build/pristine/src, the unpatched import):

  distrib/amd64/installimage/boot.cfg.in:8            timeout=30
  distrib/amd64/installimage-bios/boot.cfg.in:8       timeout=30
  distrib/amd64/cdroms/bootcd/boot.cfg.in:12          timeout=30
  distrib/amd64/cdroms/installcd/boot.cfg.in:8        timeout=30
  distrib/amd64/cdroms/installdvd/boot.cfg.in:8       timeout=30

Each medium's Makefile sed-generates boot.cfg from its boot.cfg.in:

  distrib/amd64/installimage/installimage.mk:22-23    sed @@MACHINE@@/@@VERSION@@
                                                      < boot.cfg.in > boot.cfg
  distrib/amd64/cdroms/bootcd/Makefile:16-18          prepare_md_post, same for bootcd
  distrib/amd64/cdroms/installcd/Makefile (via ../Makefile.cdrom)

There is no central knob: the value is per medium, in the medium's .in file.

5. What this tree changes
-------------------------
patches/src/0007-boot-cfg-timeout-5s.patch sets those five files to
timeout=5. Scope: the media this tree builds (amd64, both install images and
the three CDs). distrib/i386 and distrib/evbarm keep upstream's value; this
tree builds neither.

AGENTS.md:156-161 still says "distrib/amd64/installimage/boot.cfg.in stays as
upstream wrote it"; that sentence predates the patch and now needs the timeout
line as the one exception (console settings do stay upstream's).  Left as is:
AGENTS.md is a protected file for an unattended worker, so the correction is
recorded here for a run that can ask.


6. Where each medium gets the boot.cfg the loader reads
-------------------------------------------------------
- install image (distrib/amd64/installimage/installimage.mk:27-32): the
  generated boot.cfg is an IMGFILE_EXTRA entry ("${.OBJDIR}/boot.cfg ."), i.e.
  the FFS root's /boot.cfg.  installimage-bios does the same.
- install CD / DVD (distrib/common/Makefile.bootcd:250-278): the generated
  boot.cfg is CDBUILDEXTRA and is installed into ${CUROBJDIR}/cdrom, which
  makefs turns into the ISO root.
- installed system: /boot.cfg from src/etc/etc.amd64/boot.cfg.

7. The medium's own boot.cfg is then overwritten by the etc set
---------------------------------------------------------------
/src/boot.cfg belongs to the etc set --
src/distrib/sets/lists/etc/md.amd64:3

  ./boot.cfg                       etc-sys-etc

-- and Makefile.bootcd installs the sets into the medium after the
CDBUILDEXTRA copy: the media log shows "Copying boot.cfg to .../cdrom ..."
and, twenty lines later, the extraction of base, etc and gpufw into the same
directory (distrib/common/Makefile.bootcd:250-290).  The etc set's copy has
the mtime of src/etc/etc.amd64/boot.cfg and wins.

Measured on the medium as built (build/obj/releasedir/amd64/installation/
cdrom/boot.iso, built 2026-11-04 22:12 by `build.sh ... release` after the
tree's build-stamp):

  7z e ... boot.iso boot.cfg  ->  172 bytes, mtime 2026-11-02 22:26,
  content = src/etc/etc.amd64/boot.cfg (menu=Boot normally ..., timeout=5)

while the file generated from the patched .in file is 561 bytes and carries
the bootcd banner (build/obj/distrib/amd64/cdroms/bootcd/boot.cfg).  The same
in the install image's work directory:
build/obj/distrib/amd64/installimage/work/boot.cfg is the 172-byte etc file.

So the timeout a medium actually boots with is the etc set's value, and
upstream's 30 in the .in files is shadowed today.  Nothing in this tree causes
that; Makefile.bootcd is unmodified.

8. What the tree's media do, measured
-------------------------------------
build/logs/boottimeout-bootcd.log (tools/boottimeout-probe.py, screenshot per
0.5 s, OCR of the loader's countdown line, boot.iso booted in qemu as a CD):

  0.0 countdown=5 | chosen in 5 second
  1.3 countdown=4 | chosen in 4 second
  2.6 countdown=3 | chosen in 3 second
  3.2 countdown=2 | chosen in 2 second
  4.5 countdown=1 | chosen in 1 second
  (menu gone at 5.8 s, kernel output on screen)

The menu waits 5 seconds, and it is the etc set's value that does it.

Counterfactual (build/logs/boottimeout-byte9.log): the same ISO with one byte
changed -- the '5' of the root boot.cfg's timeout line written to '9' in a
copy of the image, nothing else touched -- counts down from 9 and leaves the
menu at ~16.5 s instead of ~5.8 s.  So the loader takes the number from the
root boot.cfg, and the number there is the 5 the etc set brings.


9. Open finding: install-image does not build in this tree
-----------------------------------------------------------
`build.sh ... install-image` fails with "*** [imgroot.fs] Error code 1" after
nbmakefs and nbinstallboot, at `mv work.rootfs imgroot.fs` -- the same failure
in build/logs/op-install-image.log (2026-11-04 20:12, before this patch) and in
build/logs/t-d1972f2e-media.log (22:19).  The install image is therefore not
available for a boot measurement; the CD stands in for it, and both take
/boot.cfg from the same etc set.
