Table of contents
No headers NFS server setup, login as root on server,
- mkdir /home/nios2. And edit /etc/exports, add a line of the dir to share, /home/nios2 192.168.1.0/255.255.255.0(rw,no_root_squash,sync)
- restart or reload nfs server, "service nfs restart"
- verify nfs server is running with, "showmount -e"
Nios II client setup,
In Kernel Settings, check
File systems -> Network File Systems -->
[*] NFS file system support
[*] Provide NFSv3 client support
In Application/Library Settings, check
Network Applications -->
[*] portmap
First way:
Run portmap before mount command:
portmap &
mkdir /mnt/nfs
mount -t nfs -n -o nolock,rsize=1024,wsize=1024 192.168.1.2:/home/nios2 /mnt/nfs ( eg, server ip 192.168.1.2)
Second way:
add fstab in [/nios2-linux]/uClinux-dist/vendors/Altera/nios2/ and edit the Makefile to have a copy in /etc in kernel image.
Content of fstab:
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
192.168.1.2:/home/nios2 /mnt/nfs nfs rsize=1024,wsize=1024,noauto,nolock 0 0
Now you can access the mount point with:
portmap &
mkdir /mnt/nfs
mount /mnt/nfs
Or you could add these lines in [/nios2-linux]/uClinux-dist/vendors/Altera/nios2/rc to mount it automatically at startup
Then Nios II client can access files on /home/nios2 of server through /mnt/nfs mount point.
The mount command in sash does not support nfs mount.
You may use the busybox "mount", and enable the "nfs support" in busybox "mount". You may enable "cp" in busybox, which can support recursive copy. You need to clean up busybox, with "make -C user/busybox clean" , "make" "make romfs" and "make linux image" to rebuild kernel image.
Rootfs for NFS setup
To create a rootfs for NFS, login as a root on your PC host,
cp -a /home/hippo/uClinux-dist/romfs/* /home/nios2
rm /home/nios2/init
mkdir /home/nios2/dev
on your Nios2, mount /home/nios2 as /mnt/nfs as above.
cp -a /dev/* /mnt/nfs/dev
NFS root, read kernel Documentation/nfsroot.txt
Before you try NFS root, you should start with initramfs and test a nfs mount. If the nfs mount works without problem, then you can disable initramfs by empty the initfamfs path in kernel config. There is a bug in SYSFS, so you must disable SYSFS.
Networking --> Networking options -->
[*] TCP/IP networking
[*] IP: kernel level autoconfiguration
[*] IP: DHCP support
[ ] IP: BOOTP support
[ ] IP: RARP support
File systems -> Network File Systems -->
[*] Root file system on NFS
File systems -> Pseudo filesystems -->
[ ] sysfs file system support
You need to add a command line in kernel config. ( eg, server ip = 192.168.1.2 , nios2 client ip 192.168.1.10/255.255.255.0 , gateway 192.168.1.254, hostname nios2 )
root=/dev/nfs rw nfsroot=192.168.1.2:/home/nios2/roofs ip=192.168.1.10:192.168.1.2:192.168.1.254:255.255.255.0:nios2:eth0:off
Or if you setup to use DHCP , (with those parameters in dhcpd.conf) . the kernel command line is simple,
root=/dev/nfs rw ip=dhcp
Note, the new smc91x and dm9000 driver do not have ethernet MAC address programmed. You need to hack the driver code to add them or use the old smc91111 drivers.
Sample /etc/dhcpd.conf ,
ddns-update-style none;
default-lease-time 21600;
max-lease-time 21600;
option subnet-mask 255.255.255.0;
option option-128 code 128 = string;
option option-129 code 129 = text;
use-host-decl-names on;
subnet 192.168.1.0 netmask 255.255.255.0 {
option log-servers 192.168.1.2;
option broadcast-address 192.168.1.255;
option routers 192.168.1.254;
option domain-name-servers 192.168.1.254;
range 192.168.1.10 192.168.1.100;
}
group {
host nios2 {
hardware ethernet 00:07:ed:0a:03:29;
fixed-address 192.168.1.10;
option root-path "192.168.1.2:/home/nios2";
}
}