From fdefea451f43061df5d2ea979cf8a27f1ebb3d6a Mon Sep 17 00:00:00 2001 From: Kari Hormi Date: Tue, 29 Jan 2019 13:58:21 +0200 Subject: Implement NFS mounting for Intel NUCs This commit includes the following changes: - Implement NFS mounting support to initramfs - Load network card driver and configure it with dhcp in initramfs Change-Id: If9c6d30050713cdfc844b198e67dfba316c5a719 Reviewed-by: Samuli Piippo --- .../images/core-image-minimal-initramfs.bbappend | 10 ++- .../initrdscripts/initramfs-framework/network | 47 +++++++++++++ .../initrdscripts/initramfs-framework/rootfs | 79 ++++++++++++++++++++++ .../initrdscripts/initramfs-framework_1.0.bbappend | 17 ++++- 4 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 meta-intel-extras/recipes/initrdscripts/initramfs-framework/network create mode 100755 meta-intel-extras/recipes/initrdscripts/initramfs-framework/rootfs diff --git a/meta-intel-extras/recipes/images/core-image-minimal-initramfs.bbappend b/meta-intel-extras/recipes/images/core-image-minimal-initramfs.bbappend index c1918ba..fd7559a 100644 --- a/meta-intel-extras/recipes/images/core-image-minimal-initramfs.bbappend +++ b/meta-intel-extras/recipes/images/core-image-minimal-initramfs.bbappend @@ -27,5 +27,11 @@ ## ############################################################################ -INITRAMFS_SCRIPTS += "initramfs-module-rtsx-pci-sdmmc" -PACKAGE_INSTALL += "kernel-module-rtsx-pci-sdmmc" +INITRAMFS_SCRIPTS += "\ + initramfs-module-rtsx-pci-sdmmc \ + initramfs-module-r8169 \ + " +PACKAGE_INSTALL += "\ + kernel-module-rtsx-pci-sdmmc \ + kernel-module-r8169 \ + " diff --git a/meta-intel-extras/recipes/initrdscripts/initramfs-framework/network b/meta-intel-extras/recipes/initrdscripts/initramfs-framework/network new file mode 100644 index 0000000..134a70a --- /dev/null +++ b/meta-intel-extras/recipes/initrdscripts/initramfs-framework/network @@ -0,0 +1,47 @@ +#!/bin/sh + +############################################################################ +## +## Copyright (C) 2019 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the Boot to Qt meta layer. +## +## $QT_BEGIN_LICENSE:GPL$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 or (at your option) any later version +## approved by the KDE Free Qt Foundation. The licenses are as published by +## the Free Software Foundation and appearing in the file LICENSE.GPL3 +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################ + +network_enabled() { + return 0 +} + +network_run() { + if [ -n "$bootparam_ip" ]; then + load_kernel_module r8169 + if [ "${bootparam_ip}" -ne "dhcp" ]; then + echo "WARN: DHCP only supported at this time." + fi + ip link set dev eth0 up + udhcpc + fi +} + + diff --git a/meta-intel-extras/recipes/initrdscripts/initramfs-framework/rootfs b/meta-intel-extras/recipes/initrdscripts/initramfs-framework/rootfs new file mode 100755 index 0000000..c93c9c2 --- /dev/null +++ b/meta-intel-extras/recipes/initrdscripts/initramfs-framework/rootfs @@ -0,0 +1,79 @@ +#!/bin/sh +# Copyright (C) 2011 O.S. Systems Software LTDA. +# Licensed on MIT + +rootfs_enabled() { + return 0 +} + +rootfs_run() { + if [ -z "$ROOTFS_DIR" ]; then + return + fi + C=0 + delay=${bootparam_rootdelay:-1} + timeout=${bootparam_roottimeout:-5} + while [ ! -d $ROOTFS_DIR/dev ]; do + if [ $(( $C * $delay )) -gt $timeout ]; then + fatal "root '$bootparam_root' doesn't exist or does not contain a /dev." + fi + + if [ -n "$bootparam_root" ]; then + debug "No e2fs compatible filesystem has been mounted, mounting $bootparam_root..." + + if [ "`echo ${bootparam_root} | cut -c1-5`" = "UUID=" ]; then + root_uuid=`echo $bootparam_root | cut -c6-` + bootparam_root="/dev/disk/by-uuid/$root_uuid" + fi + + if [ "`echo ${bootparam_root} | cut -c1-9`" = "PARTUUID=" ]; then + root_uuid=`echo $bootparam_root | cut -c10-` + bootparam_root="/dev/disk/by-partuuid/$root_uuid" + fi + + if [ "`echo ${bootparam_root} | cut -c1-6`" = "LABEL=" ]; then + root_label=`echo $bootparam_root | cut -c7-` + bootparam_root="/dev/disk/by-label/$root_label" + fi + + if [ "${bootparam_root}" = "/dev/nfs" ]; then + bootparam_rootfstype="nfs" + bootparam_root=`echo $bootparam_nfsroot | cut -f1 -d","` + bootparam_nfsopts=`echo $bootparam_nfsroot | cut -f2- -d","` + fi + + if [ -e "$bootparam_root" ] || [ "${bootparam_rootfstype}" = "nfs" ]; then + flags="" + if [ -n "$bootparam_ro" ] && ! echo "$bootparam_rootflags" | grep -w -q "ro"; then + if [ -n "$bootparam_rootflags" ]; then + bootparam_rootflags="$bootparam_rootflags," + fi + bootparam_rootflags="${bootparam_rootflags}ro" + fi + if [ -n "$bootparam_nfsopts" ]; then + if [ -n "$bootparam_rootflags" ]; then + bootparam_rootflags="$bootparam_rootflags," + fi + bootparam_rootflags="${bootparam_rootflags}${bootparam_nfsopts}" + fi + if [ -n "$bootparam_rootflags" ]; then + flags="$flags -o$bootparam_rootflags" + fi + if [ -n "$bootparam_rootfstype" ]; then + flags="$flags -t$bootparam_rootfstype" + fi + mount $flags $bootparam_root $ROOTFS_DIR + if [ -d $ROOTFS_DIR/dev ]; then + break + else + # It is unlikely to change, but keep trying anyway. + # Perhaps we pick a different device next time. + umount $ROOTFS_DIR + fi + fi + fi + debug "Sleeping for $delay second(s) to wait root to settle..." + sleep $delay + C=$(( $C + 1 )) + done +} diff --git a/meta-intel-extras/recipes/initrdscripts/initramfs-framework_1.0.bbappend b/meta-intel-extras/recipes/initrdscripts/initramfs-framework_1.0.bbappend index cfd05cd..2a8ac89 100644 --- a/meta-intel-extras/recipes/initrdscripts/initramfs-framework_1.0.bbappend +++ b/meta-intel-extras/recipes/initrdscripts/initramfs-framework_1.0.bbappend @@ -1,6 +1,6 @@ ############################################################################ ## -## Copyright (C) 2018 The Qt Company Ltd. +## Copyright (C) 2019 The Qt Company Ltd. ## Contact: https://www.qt.io/licensing/ ## ## This file is part of the Boot to Qt meta layer. @@ -29,14 +29,25 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" -SRC_URI += "file://rtsx_pci_sdmmc" +SRC_URI += "\ + file://rtsx_pci_sdmmc \ + file://network \ + " do_install_append() { install -m 0755 ${WORKDIR}/rtsx_pci_sdmmc ${D}/init.d/20-rtsx_pci_sdmmc + install -m 0755 ${WORKDIR}/network ${D}/init.d/30-network } -PACKAGES += "initramfs-module-rtsx-pci-sdmmc" +PACKAGES += "\ + initramfs-module-rtsx-pci-sdmmc \ + initramfs-module-r8169 \ + " SUMMARY_initramfs-module-rtsx-pci-sdmmc = "initramfs support for rtsx_pci_sdmmc" RDEPENDS_initramfs-module-rtsx-pci-sdmmc = "${PN}-base" FILES_initramfs-module-rtsx-pci-sdmmc = "/init.d/20-rtsx_pci_sdmmc" + +SUMMARY_initramfs-module-r8169 = "initramfs support for Realtek LAN driver" +RDEPENDS_initramfs-module-r8169 = "${PN}-base" +FILES_initramfs-module-r8169 = "/init.d/30-network" -- cgit v1.2.3-54-g00ecf