Booting using NFS and TFTP (updated)

Posted by Doug on Sat 17 October 2009

Rather than slowly wearing out your NAND flash you can boot the mini2440 over a network by loading the kernel using TFTP and the OS from an NFS share. This also makes it much faster to test changes. Using Fedora 11 you can use YUM to install tftp, tftp-server and nfs-utils.

yum install tftp tftp-server nfs-utils

I created a folder /home/doug/mini2440/root_fs and added the following line to /etc/exports to allow r/w access from 192.168.1.*:

/home/doug/mini2440/root_fs 192.168.1.1/24(rw,sync,no_root_squash)

..and extracted the Angstrom file system as root to /home/doug/mini2440/root_fs

You'll need to edit /etc/xinetd.d/tftp to setup TFTP. Mine is posted below for reference, you at least need to set disable = no.

# default: off
# description: The tftp server serves files using the trivial file transfer
# protocol. The tftp protocol is often used to boot diskless
# workstations, download configuration files to network-aware printers,
# and to start the installation process for some operating systems.
service tftp
{
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /home/doug/mini2440/kernel
per_source = 11
cps = 100 2
flags = IPv4
}

I then started the services :

/etc/init.d/nfs start

/sbin/service xinetd start

To automate these i think you can do:

chkconfig tftp on

chkconfig xinetd on

chkconfig nfs on

Next i edited the uboot environment. Use the command setenv to modify or add entries and savenev when you're finished. I ended up with the following:

MINI2440 # printenv
bootdelay=3
baudrate=115200
ethaddr=08:08:11:18:12:27
usbtty=cdc_acm
mtdparts=mtdparts=mini2440-nand:256k@0(u-boot),128k(env),5m(kernel),-(root)
mini2440=mini2440=0tb
bootargs_base=console=ttySAC0,115200 noinitrd
bootargs_init=init=/sbin/init
root_nand=root=/dev/mtdblock3 rootfstype=jffs2
root_mmc=root=/dev/mmcblk0p2 rootdelay=2
root_nfs=/mnt/nfs
set_root_nfs=setenv root_nfs root=/dev/nfs rw nfsroot=${serverip}:${root_nfs}
ifconfig_static=run setenv ifconfig ip=${ipaddr}:${serverip}::${netmask}:mini2440:eth0
ifconfig_dhcp=run setenv ifconfig ip=dhcp
ifconfig=ip=dhcp
set_bootargs_mmc=setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_mmc}
set_bootargs_nand=setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_nand}
set_bootargs_nfs=run set_root_nfs; setenv bootargs ${bootargs_base} ${bootargs_init} ${mini2440} ${root_nfs} ${ifconfig}
mtdids=nand0=mini2440-nand
bootargs=console=ttySAC0,115200 noinitrd init=/sbin/init mini2440=0tb ip=192.168.1.85 root=/dev/nfs rw nfsroot=192.168.1.10:/home/doug/mini2440/root_fs
bootfile="uImage"
filesize=1E9088
fileaddr=32000000
gatewayip=192.168.1.100
netmask=255.255.255.0
ipaddr=192.168.1.85
serverip=192.168.1.10
bootcmd=tftp;bootm 32000000
partition=nand0,0
mtddevnum=0
mtddevname=u-boot

Note when you setenv you have to omit the = sign. Obviously you'll want to change some of this to suit your network setup. Here my laptop is 192.168.1.10 and 192.168.1.100 is my pfsense box which is assigning 192.168.1.85 to the mini2440 by DHCP.

When you boot the system uboot will download the kernel over TFTP and then mount the NFS share.

If you have DHCP on your network Angstrom should automatically get an IP. You can skip the rest in this case!

If you want a static address you can change /etc/network/interfaces. I simply changed dhcp to static for eth0:

iface eth0 inet static

And after this the system booted up fine. Lastly i have a note which says I deleted the symlink /etc/resolve.conf and replaced it with:

domain local
search local
nameserver 192.168.1.100

Be warned that the the entire of above needs to be compliant with your firewall and selinux, it won't work otherwise!

I found the following Links helpful:

TFTP

NFS

U-boot NFS / TFTP boot