How to use root NFS file system
When you are developing applications, it is convenient to rebuild and deploy the application without having to update NAND flash or the SD card file system image. This can be done using a technology called NFS root file system.
Target refers to the hardware with the Soc. Host refers to the Linux desktop machine.
[Setting Up A NFS Service] explains how to configure your Linux desktop machine to support being an NFS server.
Set target IP address
You can either use DHCP or a fixed IP address. Run
make -C $DEVDIR config
and in the Generic SDK configuration menu select or unselect Use DHCP and set fixed IP address parameters as necessary.
NFS root configuration
You File System Configuration need to tell the SDK to build the kernel command line specifying the NFS root file system path. Run
make -C $DEVDIR config
and in the File System Configuration menu set the File system image target to NFS root file system.
Now you can rebuild the target image and install to the target hardware.
cd $DEVDIR make cmdline make make install
Verifying proper configuration
bspconfig file contents
The following configuration items should be set in your bspconfig file.
CONFIG_BSP_NET_ETH0_USE_DHCP=y CONFIG_IP_PNP_DHCP=y CONFIG_BSP_NET_HAS_ETH0=y CONFIG_FS_TARGET_NFSROOT=y CONFIG_FEATURE_MOUNT_NFS=y CONFIG_NFS_FS=y CONFIG_NFS_V3=y CONFIG_ROOT_NFS=y CONFIG_NFS_COMMON=y
CONFIG_BSP_NET_HAS_NET=y CONFIG_BSP_NET_ETH0_IPADDR="18.104.22.168" CONFIG_BSP_NET_ETH0_GATEWAY_IPADDR="10.111.0.1" CONFIG_BSP_NET_ETH0_NETMASK="255.255.255.0" CONFIG_BSP_NET_HAS_ETH0=y CONFIG_FS_TARGET_NFSROOT=y CONFIG_FEATURE_MOUNT_NFS=y CONFIG_NFS_FS=y CONFIG_NFS_V3=y CONFIG_ROOT_NFS=y CONFIG_NFS_COMMON=y
In addition, the target file system file /etc/network/interfaces should contain something similar to:
auto eth0 iface eth0 inet static address 10.111.0.176 netmask 255.255.255.0 gateway 10.111.0.1 post-up /sbin/route add -net 10.111.0.0/24 dev $IFACE
Kernel command line
You can view the Linux kernel command line that will be passed by uboot to the kernel on boot. Run
You will get a kernel command that includes the root being set to /dev/nfs, nfsroot being set to your Linux desktop with the path set to your development directory fs/fs target directory.
If you have selected fixed IP, it will contain something similar to
root=/dev/nfs nfsroot=10.111.0.4:/local/home/tfischer/work/devdir/fs/fs rw ip=22.214.171.124:::255.255.255.0::eth0
If you selected DHCP, it will contain something similar to
root=/dev/nfs nfsroot=10.111.0.4:/local/home/tfischer/work/devdir/fs/fs rw ip=dhcp
In both examples above, everything in the kernel command line not related to root NFS was stripped out.
Regular NFS mount
You can also do a regular NFS mount after your device has booted. You are not limited to only doing a root NFS mount.
HOST_IP=10.111.0.4 HOST_NFS_SHARE_DIR=/local/home/tfischer/work/sdk mkdir /tmp/nfs mount -t nfs -n -o nolock,rsize=1024,wsize=1024 $HOST_IP:$HOST_NFS_SHARE_DIR /tmp/nfs