NFS Boot
Environment Setup
Hardware: Neardi LPA3588 development board, Ubuntu 20.04 PC
Software: LPA3588 latest SDK
Adding NFS Support to the Kernel
--- a/kernel/arch/arm64/configs/rockchip_linux_defconfig
+++ b/kernel/arch/arm64/configs/rockchip_linux_defconfig
@@ -24,7 +24,6 @@ CONFIG_CGROUP_CPUACCT=y
CONFIG_CGROUP_PERF=y
CONFIG_NAMESPACES=y
CONFIG_USER_NS=y
-CONFIG_BLK_DEV_INITRD=y
CONFIG_EMBEDDED=y
# CONFIG_COMPAT_BRK is not set
CONFIG_PROFILING=y
@@ -91,6 +90,10 @@ CONFIG_NET_KEY=y
CONFIG_INET=y
CONFIG_IP_MULTICAST=y
CONFIG_IP_ADVANCED_ROUTER=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
CONFIG_IP_MROUTE=y
CONFIG_SYN_COOKIES=y
CONFIG_INET_ESP=y
@@ -118,6 +121,7 @@ CONFIG_IP_NF_TARGET_NETMAP=y
CONFIG_IP_NF_TARGET_REDIRECT=y
CONFIG_IP_NF_MANGLE=y
CONFIG_BRIDGE=y
+CONFIG_DNS_RESOLVER=y
CONFIG_CGROUP_NET_PRIO=y
CONFIG_CAN=y
CONFIG_CAN_ROCKCHIP=y
@@ -228,9 +232,11 @@ CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
CONFIG_USB_RTL8150=y
CONFIG_USB_RTL8152=y
+CONFIG_USB_NET_QMI_WWAN=y
CONFIG_WL_ROCKCHIP=y
CONFIG_WIFI_BUILD_MODULE=y
CONFIG_AP6XXX=m
+CONFIG_USB_NET_RNDIS_WLAN=y
CONFIG_INPUT_FF_MEMLESS=y
CONFIG_INPUT_EVDEV=y
CONFIG_KEYBOARD_ADC=y
@@ -637,6 +643,19 @@ CONFIG_NFS_FS=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=y
CONFIG_NFS_SWAP=y
+CONFIG_NFS_V4_1=y
+CONFIG_NFS_V4_2=y
+CONFIG_NFS_V4_1_MIGRATION=y
+CONFIG_ROOT_NFS=y
+CONFIG_NFS_USE_LEGACY_DNS=y
+CONFIG_NFS_V4_2_READ_PLUS=y
+CONFIG_NFSD=y
+CONFIG_NFSD_V3_ACL=y
+CONFIG_NFSD_V4=y
+CONFIG_NFSD_BLOCKLAYOUT=y
+CONFIG_NFSD_SCSILAYOUT=y
+CONFIG_NFSD_FLEXFILELAYOUT=y
+CONFIG_NFSD_V4_2_INTER_SSC=y
CONFIG_NLS_DEFAULT="utf8"
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_CODEPAGE_936=y
@@ -670,11 +689,3 @@ CONFIG_RCU_CPU_STALL_TIMEOUT=60
CONFIG_FUNCTION_TRACER=y
CONFIG_BLK_DEV_IO_TRACE=y
CONFIG_LKDTM=y
-CONFIG_USB_NET_DRIVERS=y
-CONFIG_USB_USBNET=y
-CONFIG_USB_NET_QMI_WWAN=y
-CONFIG_USB_WDM=y
-CONFIG_USB_SERIAL_WWAN=y
-CONFIG_USB_NET_CDCETHER=y
-CONFIG_USB_NET_CDC_NCM=y
-CONFIG_USB_NET_RNDIS_WLAN=y
Updating the Kernel
./build.sh kernel
Generated path SDK/rockdev/boot.img
Refer to the corresponding model to burn the boot partition separately
Creating NFS Server
sudo apt update
sudo apt install nfs-kernel-server
After installation, modify the following file and add the last line (note that the NFS directory may not be /home/neardi/nfs
):
neardi@ubuntu2004:~$ cat /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
/home/neardi/nfs *(rw,sync,no_root_squash,no_subtree_check)
/home/neardi/nfs
directory is the root filesystem, which corresponds to the contents of rockdev/rootfs.img
.
After configuring NFS, restart the NFS server with the following command:
sudo systemctl restart nfs-kernel-server
Verify NFS Server Configuration
mkdir nfs
sudo mount -t nfs -o nfsvers=3 192.168.0.103:/home/neardi/nfs ./nfs/
The IP address 192.168.0.103 corresponds to the host where NFS server is installed. If successful, the nfs directory contents will mirror /home/neardi/nfs
from the NFS server.
Verifying NFS Boot
Connect the LPA3588 development board via UART for debugging and interrupt the u-boot during startup by pressing ctrl + c
Hit key to stop autoboot('CTRL+C'): 0
=>
Set u-boot environment variables as follows:
=> setenv ipaddr 192.168.0.100
=> setenv nfsroot /home/neardi/nfs
=> setenv nfsserverip 192.168.0.103
=> setenv bootargs console=ttyS2,1500000 root=/dev/nfs rw nfsroot=${nfsserverip}:${nfsroot},v3,tcp ip=${ipaddr}
Modify the IP address according to your setup.
Finally, input the boot command (if you want to save these settings, then input saveenv):
=> boot
During boot to mount NFS, it may take some time. Due to the large size of the NFS directory (approximately 3-4 GB), mounting will require time.
Once successfully mounted on the LPA3588 board, you will see logs similar to:
[ 510.528586] #0: rockchip,es8388
[ 510.528593] #1: rockchip-hdmi0
[ 510.548504] VFS: Mounted root (nfs filesystem) on device 0:17.
[ 510.549499] devtmpfs: mounted
[ 510.565141] Freeing unused kernel memory: 7104K
[ 510.594388] Run /sbin/init as init process
Once fully booted, you can create a file on the LPA3588 board and check if it appears in the NFS server directory. For example:
root@LPA3588:/# echo "neardi nfs test" > test.log
Check the NFS server directory:
neardi@ubuntu2004:~/nfs$ ls
bin boot.img dev firmware lib media opt rockchip-test run sdcard sys test.log udisk var
boot data etc home Lost+found mnt proc root sbin srv system tmp usr vendor
neardi@ubuntu2004:~/nfs$ cat test.log
neardi nfs test
To copy the rootfs system from eMMC, first mount /dev/mmcblk0p7
, as shown:
root@LPA3588:/# mount -t ext4 /dev /mmcblk0p7 /mnt
root@LPA3588:/# ls /mnt
bin dev home media proc run srv tmp var
boot etc lib mnt rockchip-test sbin sys udisk vendor
data fireware lost+found opt root sdcard system usr
Finally, copy /mnt/* to the USB drive.