|
STAR
Cal STAR — firmware, DAQ server, and engine design
|
Files | |
| generate_dhcp_config.py | |
| test_generate_dhcp_config.py | |
The DAQ server hands out board IP addresses over DHCP on the isolated board LAN, so boards no longer need their IP hardcoded in firmware. Each board gets a static reservation keyed by its MAC; the IP it receives is exactly the one it had before (192.168.2.<board_id>), so nothing downstream changes — this replaces how a board gets its address, not which address.
| Range | Use |
|---|---|
| .20 | DAQ server (static, set outside DHCP) |
| .11–.61 | Board static reservations (ip == board_id) |
| .81 | LabJack T7 (boards.labjack_1, board_id 81) |
| .100–.150 | Board discovery range (reserved, not DHCP) |
| .200–.250 | Dynamic pool for unknown boards (2h lease) |
A board that gets no DHCP answer at boot (server down, or the board booted before the switch) takes 169.254.<1 + mac[4] % 254>.<mac[5]> and asks again every 15 s. Nothing runs there; it exists so the board can still be reflashed:
star-dhcp.service gives the board NIC 169.254.0.20/16 so the server can reach them (.0.x is outside the range boards use). The address is derived from the MAC, which no flash erase can touch, so it needs no per-board firmware. Two boards whose MACs end alike would share one: the config editor and the generator both refuse that. When DHCP comes back the board moves to its reserved address by itself, without a reboot.
Flight (192.168.3.0/24) uses the same last-octet layout; the generator derives the subnet from the active config.
bootstrap_daq.sh already installs dnsmasq and disables the distro instance. Then:
This generates /etc/star-dhcp/{star-dhcp.conf,star-dhcp.hosts} from the deployed config.toml, installs star-dhcp-sync.{service,path} (which keep the reservations following that file from then on), and enables star-dhcp.service. The board NIC is found by its address in the board subnet; set DHCP_INTERFACE=... only to override. If the service is already running it is restarted on the new config; otherwise it is not started, because starting it makes this host the DHCP authority on the board LAN:
Boards have no MACs recorded yet, so the first time you see a board you learn its MAC from the pool, then pin it:
The Test-GUI carries its own DHCP server (Test-GUI/boardgui/dhcp.py) for benches with no DAQ host — a switch, a board and a laptop. dnsmasq here is the authority; that one is the fallback, and they must never serve the same wire at once. Two servers on one segment is a race: a board takes whichever OFFER arrives first, so it can come up on a different address every boot.
Two things keep them from fighting:
The sync only rewrites reservations. Changes to the pool range, subnet, bound interface or handed-out options are in the base conf; re-run the installer, which regenerates everything and restarts a running service:
Re-run it too after pulling a change to generate_dhcp_config.py: the sync runs a root-owned copy in /usr/local/lib/star-dhcp/, never the checkout's.
generate_dhcp_config.py --check prints the config it would write to stdout and validates it (duplicate/malformed MACs, IPs outside the subnet, reservations that collide with the pool) without writing files:
| File | Role |
|---|---|
| generate_dhcp_config.py | Reads [boards.*], emits star-dhcp.conf + star-dhcp.hosts, and with --gui-reservations the Test-GUI's table too. |
| install_dhcp.sh | One-time install: dnsmasq + generate + the units below. Safe to re-run. |
| reload_dhcp.sh | Regenerate reservations by hand from a config other than the deployed one. |
| ../systemd/star-dhcp.service | Root system unit running dnsmasq on the board NIC; adds the recovery address. |
| ../systemd/star-dhcp-sync.{service,path} | Regenerate + reload reservations whenever config.toml changes. |
| test_generate_dhcp_config.py | python3 -m pytest daq-server/deploy/dhcp -q |
| /etc/star-dhcp/star-dhcp.conf | Generated base config (interface, pool, options). |
| /etc/star-dhcp/star-dhcp.hosts | Generated MAC→IP reservations. |
| /var/lib/misc/star-dhcp.leases | dnsmasq lease table (read board MACs here). |
| Test-GUI/config/reservations.json | Generated table for the GUI's bench server; never hand-edited. |