summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Suvorov <oleksandr.suvorov@toradex.com>2020-11-05 14:00:15 +0200
committerMax Krummenacher <max.krummenacher@toradex.com>2020-12-08 15:00:01 +0100
commitb45c0e92c0c9f6a271f32272c3a2994109e51d12 (patch)
treed3969b4f043d49942187fe7b0426a12134b2014e
parentd196201e85ecf67fcba67e2a8a5622cfaaa73aa1 (diff)
boot.cmd: add an ability to use static ip for nfs-root
The kernel is able to use predefined IP address of NFS server. Add special values of root_devtype "nfs-dhcp" and "nfs-static" and proceed them accordingly to make the script able to boot the system from a network without dhcp-server. To boot the system from the particular server, just set the "serverip" to the proper IP address of an TFTP/NFS server and set "devtype" to "tftp". To use the particular NFS server for mouting the root-fs only, set the "serverip" to the proper IP address of an NFS server and set "root_devtype" to "nfs-static". Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@toradex.com> (cherry picked from commit 2532dc8de4b43287a7f031858355b5c93f280791)
-rw-r--r--recipes-bsp/u-boot/u-boot-distro-boot/boot.cmd.in32
1 files changed, 24 insertions, 8 deletions
diff --git a/recipes-bsp/u-boot/u-boot-distro-boot/boot.cmd.in b/recipes-bsp/u-boot/u-boot-distro-boot/boot.cmd.in
index 21d298c..fa9b378 100644
--- a/recipes-bsp/u-boot/u-boot-distro-boot/boot.cmd.in
+++ b/recipes-bsp/u-boot/u-boot-distro-boot/boot.cmd.in
@@ -9,7 +9,7 @@
# - boot device type: boot_devtype := {mmc, usb, tftp, dhcp}
# - boot device num (for mmc, usb types): boot_devnum := {0 .. MAX_DEV_NUM}
# - boot partition (for mmc, usb types): boot_part := {1 .. MAX_PART_NUM}
-# - root device type: root_devtype := {mmc, usb}
+# - root device type: root_devtype := {mmc, usb, nfs-dhcp, nfs-static}
# - root device num (for mmc, usb types): root_devnum := {0 .. MAX_DEV_NUM}
# - root partition (for mmc, usb types): root_part := {1 .. MAX_PART_NUM}
#
@@ -23,9 +23,7 @@
# - Static/dynamic IP mode: ip_dyn := {yes, no}
# - Static IP-address of TFTP/NFS server: serverip := {legal IPv4 address}
# - Static IP-address of the module: ipaddr := {legal IPv4 address}
-#
-# TODO:
-# - support NFS in root_devtype
+# - Root-path on NFS-server: rootpath := {legal path, exported by an NFS-server}
if test ${devtype} = "ubi"; then
echo "This script is not meant to distro boot from raw NAND flash."
@@ -40,7 +38,6 @@ test -n ${boot_devnum} || env set boot_devnum ${devnum}
test -n ${root_devnum} || env set root_devnum ${devnum}
test -n ${kernel_image} || env set kernel_image @@KERNEL_IMAGETYPE@@
test -n ${boot_devtype} || env set boot_devtype ${devtype}
-test -n ${root_devtype} || env set root_devtype ${devtype}
test -n ${overlays_file} || env set overlays_file "overlays.txt"
test ${boot_devtype} = "mmc" && env set load_cmd 'load ${boot_devtype} ${boot_devnum}:${boot_part}'
@@ -48,6 +45,21 @@ test ${boot_devtype} = "usb" && env set load_cmd 'load ${boot_devtype} ${boot_de
test ${boot_devtype} = "tftp" && env set load_cmd 'tftp'
test ${boot_devtype} = "dhcp" && env set load_cmd 'dhcp'
+# Set Root source type properly.
+# devtype tftp => nfs-static
+# devtype ghcp => nfs-dhcp
+if test "${root_devtype}" = ""; then
+ if test ${devtype} = "tftp"; then
+ env set root_devtype "nfs-static"
+ else
+ if test ${devtype} = "dhcp"; then
+ env set root_devtype "nfs-dhcp"
+ else
+ env set root_devtype ${devtype}
+ fi
+ fi
+fi
+
if test -n ${setup}; then
run setup
else
@@ -70,11 +82,15 @@ env set set_load_overlays_file 'env set load_overlays_file "${load_cmd} \\${load
env set set_apply_overlays 'env set apply_overlays "for overlay_file in \\${fdt_overlays}; do echo Applying Overlay: \\${overlay_file} && ${load_cmd} \\${loadaddr} \\${overlay_file} && fdt apply \\${loadaddr}; env set overlay_file; done; true"'
# Set static commands
-if test ${root_devtype} = "dhcp"; then
+if test ${root_devtype} = "nfs-dhcp"; then
env set rootfsargs_set 'env set rootfsargs "root=/dev/nfs ip=dhcp nfsroot=${rootpath}"'
else
- env set uuid_set 'part uuid ${root_devtype} ${root_devnum}:${root_part} uuid'
- env set rootfsargs_set 'run uuid_set && env set rootfsargs root=PARTUUID=${uuid} ro rootwait'
+ if test ${root_devtype} = "nfs-static"; then
+ env set rootfsargs_set 'env set rootfsargs "root=/dev/nfs nfsroot=${serverip}:${rootpath}"'
+ else
+ env set uuid_set 'part uuid ${root_devtype} ${root_devnum}:${root_part} uuid'
+ env set rootfsargs_set 'run uuid_set && env set rootfsargs root=PARTUUID=${uuid} ro rootwait'
+ fi
fi
env set bootcmd_args 'run rootfsargs_set && env set bootargs ${defargs} ${rootfsargs} ${setupargs} ${vidargs} ${tdxargs}'