# Running a Debian distribution on the ZedBoard using tftp and NFS
This page explains how to run a regular Debian distribution on the ZedBord with:
* A minimal boot image on the SD card, containing only the First Stage Boot Loader (FSBL) and U-Boot
* Loading the kernel image and the device tree blob from a remote tftp server
* Mounting the root file system from a remote NFS server
This is not specific to SecBus and can be used for any development project on the ZedBoard.
This setup is extremely convenient as it almost completely avoids SD card manipulations. The Linux kernel and its device tree blob can be re-built any time, copied on the tftp server and re-loaded by the ZedBoard through its Ethernet link at the price of a single reboot. The Debian root file system can also be updated from the NFS server (thanks to Qemu and chroot) using the regular Debian tools. The changes are immediately reflected on the ZedBoard and, in most cases, without rebooting.
In the following we assume that:
*`<host>` is the hostname of the workstation we will use and to which the UART USB cable of the ZedBoard is attached
* The Xilinx tool chain is installed on `<host>` and it is on the PATH
*`<bistream>.bit` is the bistream file used to configure the Programmable Logic (PL), if any
*`<server>` is the hostname of the remote tftp and NFS server (can be the same as `<host>`)
*`<server_ip_address>` is the IP address of `<server>`
*`<zedboard_mac_address>` is the Ethernet MAC address of the ZedBoard
*`<zedboard_ip_address>` is the IP address of the ZedBoard
*`<gateway_ip_address>` is the IP address of the gateway through which the ZedBoard connects to `<server>` (if it connects directly `<gateway_ip_address>` = `<server_ip_address>`)
*`<tftproot>` is the absolute path on `<server>` of the root directory of the tftp server
*`<tftproot>/<tftpdir>` is the absolute path on `<server>` of the directory containing the tftp-served files
*`<nfsdir>` is the absolute path on `<server>` of the directory containing the NFS-served file systems
* We are root on `<server>` which runs a Debian variant, has access to Internet and has Qemu installed
Note: there are several ways to configure the Programmable Logic (PL). In the following we present three of them:
* Copy the bitstream somewhere in the NFS share on `<server>` and send it to the `/dev/xdevcfg` device after the Linux kernel booted. This method is very convenient because it allows to reconfigure the PL at run time without rebooting. On the other hand, it cannot be used when the PL must be configured before booting the Linux kernel.
* Let U-Boot download the bitstream from the tftp server and configure the PL. This method is less flexible because the system must be rebooted to change the PL configuration. However, it can be used when the PL must be configured prior booting the Linux kernel.
* Include the bitstream in the boot image on the SD card and let the First Stage Boot Loader (FSBL) do the job. This method is the less flexible of all because changing the PL configuration not only requires to reboot but also to regenerate the boot image and store it on the SD card. But it is the only one that can be used if U-Boot needs the PL to be already configured when it boots.
Please adapt the following instructions to your own settings.
## On `<server>`, the NFS server, prepare the root file system
### Create an empty image for the Debian root file system and mount it
host> bootgen -image ./boot.bif -o ./boot.bin -w on
host> cp boot.bin /media/SDCARD
host> sync
```
## On the ZedBoard, set U-Boot environment variables and boot the Linux kernel
Unmount the SD card, insert it in the SD card slot of the ZedBoard, configure the jumpers to boot from the SD Card, connect the Ethernet cable, the USB UART cable, the power cable and power on. Launch `minicom` (or equivalent) on `<host>`:
```bash
host> minicom -D /dev/ttyACM0
```
and stop U-Boot by pressing a key before the end of the countdown.
Set the following U-Boot environment variables (please pay attention to the simple and double quotes):
To avoid leaving your NFS root file system in an unstable state, always shut down properly:
```bash
root@MyZedBoard:~# poweroff
...
[info] Will now halt.
reboot: System halted
```
before turning the power off. Remember that the root file system is on `<server>` and that resetting the ZedBoard or powering it off without a proper shut down can definitively compromise your NFS share.
## Maintaining the NFS share
If the NFS share on `<server>` still appears busy after the client ZedBoard has been properly shut down, as happens sometimes, it can be unmounted with: