Monday 23 April 2018

HI3518 Camera Module - Part 4 - NFS Root Filesystem

Introduction

In previous blog posts on the HI3518 I used an initramfs image, which combines the root filesystem (rootfs) and the Linux kernel into a single image. Instead of doing this you can also keep the root filesystem separate from the kernel and use the command line parameters passed to the kernel at boot to tell it how to mount the root filesystem. One option for where to store the root filesystem is on a network file share (NFS).

Mounting an NFS Root Filesystem

When the HI3518 module boots the first thing that gets run is U-Boot. If you have connected to the serial port on the module, you can press CTRL+C to drop into the U-Boot prompt.

From there you can boot a kernel by:

  • Loading the kernel into RAM, usually from FLASH or TFTP
  • Setting the bootargs
  • Running the bootm command

An example of booting a kernel stored on a TFTP server and mounting an NFS root filesystem would be:

tftp 0x82000000 uImage
setenv bootargs mem=40M console=ttyAMA0,115200 root=/dev/nfs rw nfsroot=192.168.2.1:/srv/nfs/hi3518-rootfs,v3,tcp ip=192.168.2.2::192.168.2.1:255.255.255.0:camera:eth0:off
bootm 0x82000000

Notes:

  • The kernel will need to have been compiled with support for an NFS root filesystem. If using buildroot run "make linux-menuconfig" and check File systems > Network File Systems > Root file system on NFS
  • You need to set the nfsroot argument to point to the location of the NFS.
  • The kernel needs to have been compiled with support for auto configuring the network. You can confirm this by checking: Networking support > Networking options > IP: kernel level autoconfiguration
  • In this example the IP address of the HI3518 module has been set to a static address of 192.168.2.2, it is also possible to use DHCP (see the kernel configuration in the previous bullet point).
  • Attention needs to the paid to the comma separated list of NFS options specified at the end of the nfsroot argument (i.e. "v3, tcp"). Getting these wrong will cause the kernel to fail to mount the root filesystem. You may need to use different options.

No comments:

Post a Comment