summaryrefslogtreecommitdiffstats
path: root/meta-agl/meta-netboot
diff options
context:
space:
mode:
authortakeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp>2020-10-22 14:58:56 +0900
committertakeshi_hoshina <takeshi_hoshina@mail.toyota.co.jp>2020-10-22 14:58:56 +0900
commit4204309872da5cb401cbb2729d9e2d4869a87f42 (patch)
treec7415e8600205e40ff7e91e8e5f4c411f30329f2 /meta-agl/meta-netboot
parent5b80bfd7bffd4c20d80b7c70a7130529e9a755dd (diff)
Diffstat (limited to 'meta-agl/meta-netboot')
-rw-r--r--meta-agl/meta-netboot/README11
-rw-r--r--meta-agl/meta-netboot/classes/netboot.bbclass34
-rw-r--r--meta-agl/meta-netboot/recipes-core/initramfs-netboot/files/init.sh32
3 files changed, 56 insertions, 21 deletions
diff --git a/meta-agl/meta-netboot/README b/meta-agl/meta-netboot/README
index b571186b..dc545b2f 100644
--- a/meta-agl/meta-netboot/README
+++ b/meta-agl/meta-netboot/README
@@ -8,11 +8,20 @@ Content and usage
This layer creates a new supplementary initrd image which can be downloaded through TFTP with the kernel.
At boot time, the init script will try to mount the rootfs based on the following kernel command line parameters:
+
* nbd.server: IP address to reach the NBD server
-* nbd.port: TCP port on which server is listening (default: 10809)
* nbd.dev: nbd device to use (default: /dev/nbd0)
* nbd.debug: activate debug mode (init script is then interruptible)
+For nbd v2:
+
+* nbd.port: TCP port on which server is listening (default: 10809)
+
+For nbd v3:
+
+* nbd.namev3: The name of the image served by nbd-server.
+
+
The layer meta-netboot contains recipes for the following components:
* busybox: activate the built-in NBD client
* initramfs-netboot: contains the init script started by the kernel: basically, this script mounts the real root filesystem, then pivot_root on it and finally exec systemd.
diff --git a/meta-agl/meta-netboot/classes/netboot.bbclass b/meta-agl/meta-netboot/classes/netboot.bbclass
index 363e6bcc..63369285 100644
--- a/meta-agl/meta-netboot/classes/netboot.bbclass
+++ b/meta-agl/meta-netboot/classes/netboot.bbclass
@@ -1,22 +1,22 @@
# Enable network bootable image and initrd/initramfs
python () {
- if (bb.utils.contains_any("IMAGE_FSTYPES",["live","wic.vmdk"],True,False,d)):
- # typical case for Minnowboard Max
- d.setVar("INITRD_IMAGE","initramfs-netboot-image")
- d.setVar("INITRD_IMAGE_LIVE",d.getVar("INITRD_IMAGE",True))
- d.setVar("INITRD_LIVE","%s/%s-%s.ext4.gz" % (
- d.getVar("DEPLOY_DIR_IMAGE",True),
- d.getVar("INITRD_IMAGE_LIVE",True),
- d.getVar("MACHINE",True)
- ))
- else:
- d.setVar("INITRAMFS_IMAGE","initramfs-netboot-image")
- if (d.getVar("KERNEL_IMAGETYPE",True) == "uImage"):
- # case for "old" u-boot images, like Porter board
- d.setVar("NETBOOT_FSTYPES", "ext4.gz.u-boot");
- else:
- # case for new u-boot images which don't require uImage format
- d.setVar("NETBOOT_FSTYPES", "ext4.gz");
+ if (bb.utils.contains("IMAGE_FSTYPES","live",True,False,d)):
+ # typical case for Minnowboard Max
+ d.setVar("INITRD_IMAGE","initramfs-netboot-image")
+ d.setVar("INITRD_IMAGE_LIVE",d.getVar("INITRD_IMAGE",True))
+ d.setVar("INITRD_LIVE","%s/%s-%s.ext4.gz" % (
+ d.getVar("DEPLOY_DIR_IMAGE",True),
+ d.getVar("INITRD_IMAGE_LIVE",True),
+ d.getVar("MACHINE",True)
+ ))
+ else:
+ d.setVar("INITRAMFS_IMAGE","initramfs-netboot-image")
+ if (d.getVar("KERNEL_IMAGETYPE",True) == "uImage"):
+ # case for "old" u-boot images, like Porter board
+ d.setVar("NETBOOT_FSTYPES", "ext4.gz.u-boot");
+ else:
+ # case for new u-boot images which don't require uImage format
+ d.setVar("NETBOOT_FSTYPES", "ext4.gz");
}
diff --git a/meta-agl/meta-netboot/recipes-core/initramfs-netboot/files/init.sh b/meta-agl/meta-netboot/recipes-core/initramfs-netboot/files/init.sh
index 7b8fbb51..50d62472 100644
--- a/meta-agl/meta-netboot/recipes-core/initramfs-netboot/files/init.sh
+++ b/meta-agl/meta-netboot/recipes-core/initramfs-netboot/files/init.sh
@@ -57,6 +57,29 @@ check_debug() {
esac
}
+find_active_interface() {
+ [[ ! -d /sys/class/net ]] && { log_error "find_active_interface: /sys/class/net doesn't exist"; return 2; }
+ local iface
+ for x in $(ls -d /sys/class/net/* 2>/dev/null); do
+ iface=$(basename $x)
+ # find interfaces with:
+ # - type == 1 (ethernet)
+ # - not wireless
+ # - with state up
+
+ [[ $(cat $x/type) != 1 ]] && continue
+ [[ -d $x/wireless ]] && continue
+ [[ $(cat $x/operstate) != "up" ]] && continue
+
+ log_info "find_active_interface: first active interface is $iface"
+ echo $iface
+ return 0
+ done
+
+ log_error "Unable to find any active network interface."
+ return 1
+}
+
# -------------------------------------------
export PATH=/sbin:/usr/sbin:/bin:/usr/bin
@@ -131,9 +154,12 @@ pivot_root . boot/initramfs || bail_out "pivot_root failed."
# workaround for connman (avoid bringing down the network interface used for booting, disable DNS proxy)
if [[ -f /lib/systemd/system/connman.service ]]; then
- log_info "Adjusting Connman configuration"
- iface=$(ip -o link show up | tr ':' ' ' | awk '{print $2}' | grep -v -e "^lo$" | head -1)
- sed -i "s|connmand -n\$|connmand -r -n -I $iface|g" /lib/systemd/system/connman.service
+ newopts="-r -n"
+ iface=$(find_active_interface)
+ [[ -n "$iface" ]] && newopts="$newopts -I $iface"
+
+ log_info "Adjusting Connman command line. Will be: 'connmand $newopts'"
+ sed -i "s|connmand -n\$|connmand $newopts|g" /lib/systemd/system/connman.service
fi
# also use /proc/net/pnp to generate /etc/resolv.conf