Recently I was trying to boot my new beaglebone black (http://beagleboard.org/black) from NFS for some application development. It is a pretty popular dev board, so not surprisingly there are already many tutorials and quick start guides online. Unfortunately most of them boot the board from sdcard only. So I have decided to write up the steps I have followed to boot from NFS.
Get yocto and prerequisites
$ git clone http://git.yoctoproject.org/git/poky
$ cd poky
$ git checkout -b fido origin/fido
# ~/build will be the build directory for beaglebone
$ source oe-init-build-env ~/build
Configure for Beaglebone-black
$ cd ~/build
$ vim conf/local.conf
In local.conf, you need to uncomment this line.
MACHINE ?= "beaglebone"
Also make sure debug-tweaks is added to IMAGE_FEATURES
EXTRA_IMAGE_FEATURES = "debug-tweaks"
Now save the file and run
$bitbake core-image-minimal
It will take several hours to download and compile everything. When it finishes, you would have got all the files need for NFS-boot
Set up tftp server
# Create the directory for tftp server
$mkdir -p ~/tftpboot/boot
# Make it readable by anyone
$sudo chmod 777 -R ~/tftpboot
$sudo apt-get install tftpd-hpa
$cp ~/build/tmp/deploy/image/beaglebone/beagle/zImage ~/tftpboot/boot
$cp ~/build/tmp/deploy/image/beaglebone/beagle/zImage-am335x-boneblack.dtb ~/tftpboot/boot/am335x-boneblack.dtb
$vim /etc/defaults/tftpd-hpa
Change the directory to
TFTP_DIRECTORY="/home/user/tftpbot"
Set up NFS server
Download and install unfsd from http://unfs3.sourceforge.net
$wget http://downloads.sourceforge.net/unfs3/unfs3-0.9.22.tar.gz
$tar xvf unfs3-0.9.22.tar.gz
$cd unfs3-0.9.22
$./configure
$make
$sudo make install
# This exports file can sit anywhere including /etc/exports
$vim ~/exports
Change the content of the exports file to
# This folder is created by bitbake core-image-minimal
# 192.168.1.0 can be changed to your own subnetwork ip like 10.0.0.0
~/build/tmp/work/beaglebone-poky-linux-gnueabi/core-image-minimal/1.0-r0/rootfs 192.168.1.0/24(rw,no_root_squash)
Now run both tftp and NFS servers
# This is the IP beaglebone-black is going to look for
$sudo ifcofig eth0 192.168.1.11
$sudo service tftpd-hpa restart
$sudo unfsd -e ~/exports -d
Set up u-boot on beaglebone-black board
Follow this to prepare the SD card (http://git.yoctoproject.org/cgit.cgi/poky/tree/README.hardware)
Then update the content of uEnv.txt on your SD card to
https://github.com/clarkli86/beagleboneblack_uEnv
optargs=
loadfdt=tftp ${fdtaddr} /boot/${fdtfile}
loaduimage=mw.l 4804c134 fe1fffff; set loadaddr 0x82000000; set ipaddr 192.168.1.100; set serverip 192.168.1.11; tftp ${loadaddr} boot/zImage
mmcboot=run mmcargs; bootz ${loadaddr} - ${fdtaddr}
uenvcmd=i2c mw 0x24 1 0x3e; run findfdt; if test $board_name = A335BNLT; then setenv mmcdev 1; mmc dev ${mmcdev}; if mmc rescan; then setenv mmc1 1; else setenv mmc1 0; fi; fi; setenv mmcdev 0; mmc dev ${mmcdev}; if mmc rescan; then setenv mmc0 1; else setenv mmc0 0; fi; run loaduimage && run loadfdt && run mmcboot
mmcroot="/dev/nfs rw ip=192.168.1.100 nfsroot=192.168.1.11:/home/clark/beagle/tmp/work/beaglebone-poky-linux-gnueabi/core-image-minimal/1.0-r0/rootfs,v3,tcp"; set mmcrootfstype nfs; boot
Now you can insert the SD card to beagle and boot it!
Troubleshooting
My beaglebone-black is not booting from SD card
Follow http://elinux.org/Beagleboard:MicroSD_As_Extra_Storage
U-boot fails to get kernel from tftp
Check if your host IP is set to 192.168.1.11. Also check if the ethernet connection is setup correctly.
I can see the login prompt but I can’t login as root
This is due to the permission of some files in the rootfs folder. On the host, do
sudo chown user -R ~/build/tmp/work/beaglebone-poky-linux-gnueabi/core-image-minimal/1.0-r0/rootfs
sudo chgrp user -R ~/build/tmp/work/beaglebone-poky-linux-gnueabi/core-image-minimal/1.0-r0/rootfs
If this still does not work, do
sudo rm ~/build/tmp/work/beaglebone-poky-linux-gnueabi/core-image-minimal/1.0-r0/rootfs/* -rf
# Re-create the rootfs content
$tar x -C ~/build/tmp/work/beaglebone-poky-linux-gnueabi/core-image-minimal/1.0-r0/rootfs/ -f ~/build/tmp/deploy/image/beaglebone/beagle/modules-beaglaebone.tgz
$tar x -C ~/build/tmp/work/beaglebone-poky-linux-gnueabi/core-image-minimal/1.0-r0/rootfs/ -f ~/build/tmp/deploy/image/beaglebone/beagle/core-image-minimal-beaglebone.tar.bz2