Yocto NFS & TFTP boot

Document created by alejandrolozano Employee on Feb 13, 2015Last modified by alejandrolozano Employee on Jun 9, 2015
Version 2Show Document
  • View in full screen mode

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.



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.



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.



  1. 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.
  2. Shutdown the Linux virtual machine
  3. In VMware Player, go to Edit virtual machine settings. And add a Bridged Network Adapter, choosing only the wired Ethernet port.
  4. And click on OK.  See below for example:



  1. Start up the Linux VM.
  2. 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.


  1. To set eth1 to a static IP, open /etc/nework/interfaces

sudo gedit /etc/network/interfaces

  1. Add the following to set eth1 to your desired IP address.

auto eth1

iface eth1 inet static

address      <-- Your HOST IP



  1. Save the file
  2. Restart eth1

sudo ifdown eth1

sudo ifup eth1



4.2 Target Setup


We need to setup the network IP address of our target.

  1. Power On the board and hit a key to stop the U-Boot from continuing.
  2. Set the below parameters:


setenv serverip <-- This must be your Host IP address

setenv ipaddr  <-- 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”.


  1. Edit /etc/xinetd.conf


gedit /etc/xinetd.conf


  1. 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.


  1. Restart the xinetd service

service xinetd restart

  1. Test that TFTP is working

tftp localhost

tftp> get {An Image found in the tftp folder}

tftp> quit



4.3.2 NFS Setup


  1. Edit the /etc/exports file

gedit /etc/exports

  1. Add the path where the rootfs is found in your host.
  2. {YOCTO_BUILD_DIR}/tmp/work/{TARGET}-poky-linux-gnueabi/{IMAGE}/1.0-r0/rootfs *(rw,no_root_squash)


     {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


  1. 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.

9 people found this helpful