Netbooting

Boot-up in a netboot system is shown in the following block diagram:

digraph { node [ shape=box,style=filled,fillcolor=gray90 ]; rankdir = LR; por[style="rounded,filled", label="Power-On\nReset"]; rom[label="Boot ROM"]; por -> rom; rom -> sdcard [style=dashed]; rom -> spi; spi[label="SPI Flash\nBootloader"]; sdcard[label="SD Card\n(If Present)", style="dashed,filled"]; uboot[label="U-Boot\nBootloader\n(u-boot.bin)"]; linux[label="Linux\nKernel\n(uImage)"]; userspace[style="rounded,filled", label="Boot\nComplete"]; spi -> uboot [label="DHCP &\nTFTP"]; uboot -> linux [label="DHCP &\nTFTP"]; linux -> userspace[label="DHCP &\nNFS"]; }

Firmware Boot Flowchart

Each block represents a stage of software boot-up. The edges connecting blocks show the network services required to transition from stage to stage. A complete netboot requires all of these stages, and all of the network services they entail, to be correctly configured and operating.

Configuring Network Services

In order to correctly netboot, you must set up three network services:

  • DHCP,
  • TFTP, and
  • NFS.

Some deployments have found it necessary to set up static DNS entries for boards as well, which would require an additional DNS server not described here.

Configuration for each of these services depends slightly on the operating system. The steps shown are what worked for me (on Debian).

DHCP

Important

You may already have a DHCP daemon on your network. You probably don’t want to install two!

  1. Install the DHCP daemon:

    $ sudo apt-get install isc-dhcp-server
    
  2. Tell the startup script which interfaces to listen on. You will need to identify the correct Ethernet device (e.g. eth0) and modify /etc/default/isc-dhcp-server.

  3. Configure the DHCP daemon by editing /etc/dhcp/dhcpd.conf. An excerpt from mine follows.

    option domain-name "threespeedlogic.com";
    option domain-name-servers 192.168.1.1;
    
    default-lease-time 600;
    max-lease-time 7200;
    ddns-update-style none;
    authoritative;
    
    subnet 192.168.1.0 netmask 255.255.255.0 {
      allow bootp;
      range dynamic-bootp 192.168.1.10 192.168.1.255;
      option routers 192.168.1.1;
      option root-path "192.168.1.2:/srv/nfs/r10.0_128x,nfsvers=3";
    }
    
    group {
      next-server 192.168.1.2;
      server-name "pizza";
    
      host iceboard0309 { hardware ethernet 84:7e:40:6d:70:1c; }
      host iceboard004 { hardware ethernet 84:7e:40:6f:5c:72; }
    }
    

    You will need to understand and adapt this configuration to your network. In my case, the network DNS server and Internet gateway is 192.168.1.1, and the DHCP + NFS server is 192.168.2.1.

  4. Start the daemon

    $ sudo service isc-dhcp-server restart
    

TFTP

  1. Install the TFTP daemon:

    $ sudo apt-get install tftpd
    
  2. Enable the service by editing /etc/inetd.conf or similar (xinetd.conf). My inetd.conf file contains the following line:

    tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /srv/tftp
    

    The last entry corresponds to the directory used for TFTP files. You will need to create /srv/tftp if it doesn’t exist. This is where you will copy your u-boot.bin and uImage files.

  3. Restart the inetd server.

    $ sudo service inted restart
    

NFS

  1. Install the NFS server:

    $ sudo apt-get install nfs-kernel-server
    
  2. Configure NFS root path, by editing /etc/exports and adding the following:

    /srv/iceboard 192.168.2.0/24(ro,sync,no_root_squash,no_subtree_check,no_all_squash)
    

    You will need to create the /srv/iceboard directory (if it does not exist).

  3. Restart the NFS server.

    $ sudo service nfs-kernel-server restart
    

Tips, Tricks, and Gotchas

Spanning Tree Protocol (STP)

Disable Spanning Tree Protocol (STP; 802.1D) on your network switches. STP prevents DHCP packets from being forwarded across the switch for the first minute or so of power-up. This greatly slows down netboot (when it works), or causes it to enter an indefinite timeout/retry loop.

Plain (“classic”) STP is obsolete. If STP behaviour is desirable, RSTP should be used instead.