Tools for support to boot Android over nfs

linaro-android-nfs-tool.sh is a tool to provide various support for boot android images over nfs. Like the help of creating the nfs root file system, setting up the nfs server, starting and stopping the nfs server.

  • source
    • This tools is started with the support for Jelly Bean4.3, here is the source:

      http://android.git.linaro.org/gitweb?p=platform/external/linaro-android-tools.git;a=shortlog;h=refs/heads/linaro_android_4.3

Precondition

  • linaro-image-tools
    • $ sudo add-apt-repository ppa:linaro-maintainers/tools
      $ sudo apt-get update
      $ sudo apt-get install linaro-image-tools
  • Linaro images after Jelly Bean4.3, or with this patch for installd
    • http://review.android.git.linaro.org/#/c/4330/
  • nfs service package installed
    • $ sudo apt-get install nfs-kernel-server nfs-common
  • Kernel with NFS nad network support enabled during boot.
    • Linaro images supports these config by default, so you don't need to do this step if you use Linaro images. But if you use other images, please make sure to enable the configs like these:

      CONFIG_IP_PNP=y
      CONFIG_IP_PNP_DHCP=y
      CONFIG_IP_PNP_BOOTP=y
      CONFIG_IP_PNP_RARP=y
      CONFIG_USB_USBNET=y
      CONFIG_USB_NET_SMSC95XX=y
      CONFIG_USB=y
      CONFIG_USB_SUPPORT=y
      CONFIG_USB_ARCH_HAS_EHCI=y
      CONFIG_NETWORK_FILESYSTEMS=y
      CONFIG_NFS_FS=y
      CONFIG_NFS_V3=y
      CONFIG_NFS_V3_ACL=y
      CONFIG_ROOT_NFS=y

Practice Scenario(pandaboard as example)

  1. download images

    $ wget http://snapshots.linaro.org/android/~linaro-android-member-ti/panda-linaro/lastSuccessful/boot.tar.bz2
    $ wget http://snapshots.linaro.org/android/~linaro-android-member-ti/panda-linaro/lastSuccessful/system.tar.bz2
    $ wget http://snapshots.linaro.org/android/~linaro-android-member-ti/panda-linaro/lastSuccessful/userdata.tar.bz2
  2. update ./nfs-sample.sh
    • Please see the Sample -- nfs-sample.sh section below for details description.

  3. run ./nfs-sample.sh
  4. run linaro-android-media-create

    linaro-android-media-create --mmc /dev/sdc --dev panda --boot boot.tar.bz2 --system system.tar.bz2 --userdata userdata.tar.bz2
  5. copy the boot.scr to the boot partition or deploy it to the right place of that board.

    TBD: need to describe how to deploy boot.src for other boards like Arndale
  6. connect your board with network cables, plug in the sdcard, and boot it.

Description of sub commands

create-rootfs

This sub command will merge the android artifacts from android-build to create an android file system, with necessary tweaks like disable the mounting of partitions, that can be used as the root file system for boot over nfs.

linaro-android-nfs-tool.sh create-rootfs [--rootfs-dir <rootfs-dir>] [--install-binaries] --nfs-entry-option <options> --boot <boot.tar.bz2> --system <system.tar.bz2> --userdata <userdata.tar.bz2> 
  • --rootfs-dir
    • The directory path where the nfs root file system will be saved, and also this path will be used as the entry for the nfs export. If not specified, it will create one directory under /srv/linaro/android/nfs_root
  • --install-binaries
    • specify if need to install the hardware binaries into the android file system. Please Note That it only supports for the pandaboad build now.
  • --nfs-entry-option
    • The nfs option will be used when export the android root file system directory. By default it will be "*(rw,sync,no_root_squash,no_subtree_check)"
  • --boot
    • Please specify the path of the boot.tar.bz2 image with this option
  • --system
    • Please specify the path of the system.tar.bz2 image with this option
  • --userdata
    • Please specify the path of the userdata.tar.bz2 image with this option

delete-rootfs

This sub command will help to delete the directory and its nfs export entry in /etc/exports for the specified <rootfs-dir> value

delete-rootfs --rootfs-dir <rootfs-dir>
  • --rootfs-dir
    • Please specify the directory path of the android root file system with this --rootfs-dir option

create-boot-scr

This sub command will help to create the boot.scr script with the necessary configuration specified for booting over nfs.

create-boot-scr --device <device-type> --board-ip <ip-addr>|dhcp [--server-ip <server-ip>] [--gateway <gateway>] [--netmask <netmask>]
  • --device
    • specify the device of the build is for, it should be one of the following: vexpress,snowball_emmc,mx6qsabrelite,vexpress--9,origen_quad,panda,iMX53,smdkv310,arndale,snowball_sd,beagle,origen,mx53loco

  • --board-ip
    • specify the ip address will be used for the board. it can be dhcp or the static ip address like 192.168.9.110

  • --server-ip
    • the server ip address where the android root file system is located, and is exported via nfs service. If not specified, will use the ip address of the eth0 interface as default.
  • --gateway
    • specify the gateway information which will be used for the board. This is unnecessary when dhcp is specified for the --board-ip option
  • --netmask
    • specify the netmask information which will be used for the board. This is unnecessary when dhcp is specified for the --board-ip option

manage-nfs-service

This sub command is used to start, stop or restart the nfs service.

manage-nfs-service start|stop|restart

manage-nfs-entry

This sub command has some function on operations of nfs export entry.

list

Help to list all of the nfs export entries that added.

manage-nfs-entry list

add

Help to add one nfs export entry to the /etc/exports file with the specified value.

manage-nfs-entry add --nfs-entry-path <nfs-entry-path> [--nfs-entry-option <options>]
  • --nfs-entry-path
    • The path that will be added to the /etc/exports as the nfs export entry.
  • --nfs-entry-option
    • The nfs option that will be used for the nfs export entry. By default it will be "*(rw,sync,no_root_squash,no_subtree_check)"

delete

Help to delete the nfs export entry in the /etc/exports file with the value specified.

manage-nfs-entry delete --nfs-entry-path <nfs-entry-path>
  • --nfs-entry-path
    • Specified the path of the nfs export entry what you want to delete

batch

This command will help to do the steps of create-rootfs/create-boot-scr/manage-nfs-entry add/manage-nfs-service start together with one step

batch [--rootfs-dir <rootfs-dir>] [--nfs-entry-option <options>] \
         --boot <boot.tar.bz2> --system <system.tar.bz2> --userdata <userdata.tar.bz2> \
         --device <device-type> --board-ip <ip>|dhcp [--server-ip <server-ip>] [--gateway <gateway>] [--netmask <netmask>]
  • --rootfs-dir
    • Please see the description in create-rootfs section.

  • --nfs-entry-option
    • Please see the description in create-rootfs section.

  • --boot
    • Please see the description in create-rootfs section.

  • --system
    • Please see the description in create-rootfs section.

  • --userdata
    • Please see the description in create-rootfs section.

  • --device
    • Please see the description in create-boot-scr section.

  • --board-ip
    • Please see the description in create-boot-scr section.

  • --server-ip
    • Please see the description in create-boot-scr section.

  • --gateway
    • Please see the description in create-boot-scr section.

  • --netmask
    • Please see the description in create-boot-scr section.

Sample -- nfs-sample.sh

There is a ./nfs-sample.sh in the source repository, you can use it as a template, and update the setting according to your environment:

##the path where the boot/system/userdata image files are located.
images_dir="/data/linaro/linaro-android/tracking/stable/out/target/product/pandaboard"
##the ip address of the nfs server
server_ip="192.168.9.109"
#board_ip="dhcp"

#The static ip address for the board
board_ip="192.168.9.110"
##the gateway for the board when use static ip
gateway="192.168.9.1"
##the netmask for the board when use static ip
netmask="255.255.255.0"

rootfs_dir="/srv/linaro/android/nfs_root/test"

./linaro-android-nfs-tool.sh delete-rootfs --rootfs-dir "${rootfs_dir}"
if [ $? -ne 0 ]; then
    echo "Faild to remove the old ${rootfs_dir}"
    exit 1
fi
if [ "X${board_ip}" = "Xdhcp" ]; then
   ./linaro-android-nfs-tool.sh batch \
            --rootfs-dir "${rootfs_dir}" \
            --boot "${images_dir}/boot.tar.bz2" \
            --system "${images_dir}/system.tar.bz2" \
            --userdata "${images_dir}/userdata.tar.bz2" \
            --device "panda" \
            --board-ip "dhcp" \
            --server-ip "${server_ip}"
else
   ./linaro-android-nfs-tool.sh batch \
            --rootfs-dir "${rootfs_dir}" \
            --boot "${images_dir}/boot.tar.bz2" \
            --system "${images_dir}/system.tar.bz2" \
            --userdata "${images_dir}/userdata.tar.bz2" \
            --device "panda" \
            --board-ip "${board_ip}" --gateway "${gateway}" --netmask "${netmask}" \
            --server-ip "${server_ip}"
fi

NOTE: Bootargs for Arndale Platforms where boot.scr needs to be flashed rather than in boot partition

setenv initrd_high "0xffffffff"
setenv fdt_high "0xffffffff"
setenv bootargs "console=tty0 console=ttySAC2,115200n8 androidboot.hardware=exynos5250-arndale fbdev=/dev/graphics/fb2 ip=dhcp root=/dev/nfs nfsroot=192.168.1.8:/srv/linaro/android/nfs_root/test init=/init"

setenv bootcmd " fatload mmc 0:2 0x40007000 uImage; fatload mmc 0:2 0x41f00000 board.dtb; bootm 0x40007000 - 0x41f00000"
boot

Platform/Android/NfsBootSupportTools (last modified 2013-08-30 10:10:13)