Skip to content

Pi Auto-Discovery: TFTP fallback for unknown serial numbers #102

@mrveiss

Description

@mrveiss

Overview

Enable automatic discovery of Raspberry Pi devices without pre-registration. Currently, Pi network boot fails if the serial number directory doesn't exist in TFTP.

Problem

  1. Pi powers on, requests /<serial>/start4.elf via TFTP
  2. If /<serial>/ directory doesn't exist, TFTP returns "file not found"
  3. Pi fails to boot - no discovery possible

Proposed Solution

Option A: TFTP Fallback Directory (Recommended)

Create a pi-discovery/ directory that serves as fallback for unknown serials:

/srv/tftp/
├── pi-nodes/
│   ├── d83add36/     # Known Pi (registered)
│   └── a1b2c3d4/     # Known Pi
└── pi-discovery/     # Fallback for unknown
    ├── bootcode.bin
    ├── start4.elf
    ├── start.elf
    ├── fixup*.dat
    ├── *.dtb
    ├── kernel8.img
    ├── initramfs.img
    ├── config.txt    # Generic discovery config
    └── cmdline.txt   # pureboot.mode=discover

Modify TFTP server to:

  1. Check if /<serial>/ exists
  2. If not, serve files from pi-discovery/
  3. Pi boots, runs deploy environment, calls API to register

Option B: Dynamic Directory Creation

TFTP server creates directory on-the-fly when unknown serial requests files:

  1. Unknown serial requests /<serial>/start4.elf
  2. TFTP server creates /<serial>/ with default files
  3. Serves the requested file
  4. Pi boots and registers via API

Implementation Tasks

  • Create pi-discovery/ directory structure
  • Add TFTP fallback logic for unknown serials
  • Create generic config.txt for discovery mode
  • Create cmdline.txt with pureboot.mode=discover
  • Update deploy environment to handle discover mode
  • Auto-register Pi via API on first boot
  • Create node directory after successful registration
  • Add setting to enable/disable auto-discovery
  • Document setup process

Discovery Boot Flow

Pi powers on
    ↓
DHCP provides TFTP IP (192.168.168.66)
    ↓
Pi requests /<serial>/start4.elf
    ↓
TFTP checks: /<serial>/ exists?
    ├── Yes → Serve from node directory
    └── No → Serve from pi-discovery/
    ↓
Pi boots kernel + initramfs
    ↓
Deploy env runs, detects pureboot.mode=discover
    ↓
Calls POST /api/v1/nodes/register-pi
    ↓
PureBoot creates /<serial>/ directory
    ↓
Node appears in UI as "discovered"

Test Hardware Available

  • Raspberry Pi 3B+
  • Raspberry Pi 4

Related

Acceptance Criteria

  • Unknown Pi can network boot without pre-registration
  • Pi appears in PureBoot UI after first boot
  • Existing registered nodes continue to work
  • Works with Pi 3B+, Pi 4, Pi 5
  • Auto-discovery can be disabled via settings

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions