NFS and TFTP Boot
1 Introduction
This document explains the required steps to boot Linux Kernel and mount a NFS on your target.
2 Requirements
- A functional Yocto environment (Images generated for your target).
- Your preferred target. (SABRE-AI, SABRE-SD)
- 1 Ethernet Cable
- 1 Micro USB cable
- USB to Serial converter depending on your target features.
3 Yocto Folders
When you develop your Linux kernel and Root File System with Yocto, different folders are created and each folder contains different information.
{YOCTO_BUILD_DIR}/tmp/deploy/images/ {TARGET}/
This directory contains the output images, like Kernel, U-Boot and the File System in a tar file. This directory will be used to fetch the kernel and device tree blob file only.
{YOCTO_BUILD_DIR}/tmp/sysroot/{TARGET}/
This folder contains all the development files used to generate our Yocto images. Here we can find all the dynamic libraries and headers used for development. This folder is used as parameter for cross-compilation.
{YOCTO_BUILD_DIR}/tmp/work/{TARGET}-poky-linux-gnueabi/{IMAGE}/1.0-r0/rootfs
This folder contains the uncompressed rootfs of our target. This folder will be used as entry in the host NFS server.
4 IP Address and Network Setup
This section covers how to boot Linux that mounts the root file system (RFS) over the network. Remember that in this scenario, the RFS exists on the laptop hard drive, and the kernel that runs on the target board will mount the RFS over Ethernet. This setup is used for developing and debugging Linux applications. It allows for applications to be loaded and run without having to re-boot the kernel each time.
First some packages on your host need to be installed:
# apt-get install xinetd tftp tftpd isc-dhcp-server nfs-kernel-server portmap
For development, it is best to have a static IP setup for the board and Linux environment. This way U-Boot options won’t change between reboots as you get a new IP address as you would using DHCP.
4.1 Linux Host Setup
This section describes how to setup a static IP in your Linux host environment. This is not required but will allow the IP address of your virtual host system to remain unchanged. Because u-boot parameters use specific IP addresses, this step is recommended because u-boot parameters may need to be updated in the future to match your virtual IP address if it should ever change.
You could take the existing IP address and make it static, but you would lose the Internet connection in your virtual machine. Instead we want to make use of the virtual environment and add a secondary Ethernet port that is tied to your wired Internet connection, while keeping the original Ethernet port which can use the wireless connection on your laptop.
- In the Linux virtual environment, type sudo ifconfig and note that you should have one Ethernet adapter (eth0). The other item listed (lo) is a virtual port for loopback mode.
- Shutdown the Linux virtual machine
- In VMware Player, go to Edit virtual machine settings. And add a Bridged Network Adapter, choosing only the wired Ethernet port.
- And click on OK. See below for example:

- Start up the Linux VM.
- Open a terminal and type:
sudo ifconfig
You should have a new entry (eth1). This is the new Ethernet port you created in the virtual machine, and it is bridged to your wired Ethernet port. This is the port we want to make a static IP address.
- To set eth1 to a static IP, open /etc/nework/interfaces
sudo gedit /etc/network/interfaces
- Add the following to set eth1 to your desired IP address.
auto eth1
iface eth1 inet static
address 192.168.0.100 <-- Your HOST IP
netmask 255.255.255.0
gateway 192.168.0.1
- Save the file
- Restart eth1
sudo ifdown eth1
sudo ifup eth1
4.2 Target Setup
We need to setup the network IP address of our target.
- Power On the board and hit a key to stop the U-Boot from continuing.
- Set the below parameters:
setenv serverip 192.168.0.100 <-- This must be your Host IP address
setenv ipaddr 192.168.1.102 <-- This must be your target IP addres
setenv ip_dyn no
The path where the rootfs is placed in our host has to be indicated in the U-Boot:
setenv nfsroot /home/usuario/fsl-release-bsp/buildimx6q/tmp/work/imx6qsabresd-poky-linux-gnueabi/fsl-image-gui/1.0-r0/rootfs
setenv image zImage
setenv fdt_file uImage-imx6q-sabresd.dtb
setenv netargs 'setenv bootargs console=${console},${baudrate} ${smp} root=/dev/nfs ip={ipaddr} nfsroot=${serverip}:${nfsroot},v3,tcp'
4.3 TFTP and NFS Configuration
Now configure the Trivial File Transfer Protocol (TFTP) server and Networked File System (NFS) server. This is how U-Boot will download (via TFTP) the Linux kernel, and then the kernel will mount (via NFS) its root file system on the computer hard drive.
4.3.1 TFTP Setup
Next setup the TFTP server. The following commands show that we are logged in as root (#). If you are not root ($) then precede each instruction with “sudo”.
- Edit /etc/xinetd.conf
gedit /etc/xinetd.conf
- Add and save the following lines in the file
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s {YOCTO_BUILD_DIR}/tmp/deploy/images/ {TARGET}/
disable = no
}
Notice that {YOCTO_BUILD_DIR}/tmp/deploy/images/ {TARGET}/ has to be written as absolute path.
- Restart the xinetd service
service xinetd restart
- Test that TFTP is working
tftp localhost
tftp> get {An Image found in the tftp folder}
tftp> quit
4.3.2 NFS Setup
- Edit the /etc/exports file
gedit /etc/exports
- Add the path where the rootfs is found in your host.
- {YOCTO_BUILD_DIR}/tmp/work/{TARGET}-poky-linux-gnueabi/{IMAGE}/1.0-r0/rootfs *(rw,no_root_squash)
NOTE:
{YOCTO_BUILD_DIR}/tmp/work/{TARGET}-poky-linux-gnueabi/{IMAGE}/1.0-r0/rootfs may work most of the times,
but it is recommended to untar the {IMAGE}.bz2 in an exported
folder keeping using sudoand keeping the chmod of each file.
3. Restart the NFS service
sudo service portmap stop
sudo service nfs-kernel-server stop
sudo service portmap start
sudo service nfs-kernel-server start
5 Host Final Configuration and Booting Linux over NFS
- In your host, under the images folder {YOCTO_BUILD_DIR}/tmp/deploy/images/ {TARGET}/ create the below links
ln -s zImage_imx_v7_defconfig zImage
2. In U-boot type the below command:
run netboot
After a pair of minutes you should get a Linux working system on your target.