Add an initramfs-framework module (83-netsetup) that brings up an Ethernet interface via DHCP before mounting an NFS root, polling for the interface to allow the driver's deferred-probe chain to settle after udev loads modules. Pull it into the initramfs packagegroup under bsp-next and bsp-ti-6_12, matching the kernel-module CPSW driver sets those brandings need for the direct (non-proxy) CPSW path.
Signed-off-by: Moteen Shah <[email protected]> --- .../initramfs-module-netsetup/83-netsetup | 54 +++++++++++++++++++ .../initramfs-module-netsetup_1.0.bb | 30 +++++++++++ .../packagegroup-ti-core-initramfs.bb | 3 ++ 3 files changed, 87 insertions(+) create mode 100755 meta-ti-bsp/recipes-ti/initramfs/initramfs-module-netsetup/83-netsetup create mode 100644 meta-ti-bsp/recipes-ti/initramfs/initramfs-module-netsetup_1.0.bb diff --git a/meta-ti-bsp/recipes-ti/initramfs/initramfs-module-netsetup/83-netsetup b/meta-ti-bsp/recipes-ti/initramfs/initramfs-module-netsetup/83-netsetup new file mode 100755 index 00000000..8e76bac4 --- /dev/null +++ b/meta-ti-bsp/recipes-ti/initramfs/initramfs-module-netsetup/83-netsetup @@ -0,0 +1,54 @@ +#!/bin/sh +# Configure network via DHCP before NFS root mount. Polls for an Ethernet +# interface with sleep 1 per iteration to allow the Ethernet driver deferred +# probe chain to settle after udev loads the modules. + +netsetup_enabled() { + [ "${bootparam_root}" = "/dev/nfs" ] || return 1 + return 0 +} + +netsetup_run() { + local iface timeout devtype + + # Extract interface from ip= kernel param (format: client:server:gw:mask:host:device:autoconf) + iface="" + case "${bootparam_ip}" in + dhcp|on|any|"") + ;; + *) + iface=$(echo "${bootparam_ip}" | cut -d: -f6) + ;; + esac + + udevadm trigger --action=add --subsystem-match=net + udevadm settle --timeout=10 + + # Poll up to 60 seconds for an Ethernet interface (ARPHRD_ETHER = type 1). + msg "netsetup: waiting for ethernet interface..." + timeout=60 + while [ "${timeout}" -gt 0 ]; do + if [ -n "${iface}" ] && [ -d "/sys/class/net/${iface}" ]; then + break + fi + for dev in /sys/class/net/*; do + [ -f "${dev}/type" ] || continue + devtype=$(cat "${dev}/type") + [ "${devtype}" = "1" ] || continue + iface=$(basename "${dev}") + break + done + [ -n "${iface}" ] && [ -d "/sys/class/net/${iface}" ] && break + sleep 1 + timeout=$((timeout - 1)) + done + + if [ -z "${iface}" ] || [ ! -d "/sys/class/net/${iface}" ]; then + msg "netsetup: no ethernet interface found after 60s, skipping DHCP" + return + fi + + msg "netsetup: configuring ${iface} via DHCP" + + udhcpc -q -i "${iface}" +} diff --git a/meta-ti-bsp/recipes-ti/initramfs/initramfs-module-netsetup_1.0.bb b/meta-ti-bsp/recipes-ti/initramfs/initramfs-module-netsetup_1.0.bb new file mode 100644 index 00000000..6b465462 --- /dev/null +++ b/meta-ti-bsp/recipes-ti/initramfs/initramfs-module-netsetup_1.0.bb @@ -0,0 +1,30 @@ +SUMMARY = "initramfs support for DHCP network configuration before NFS root mount" + +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" + +SRC_URI = "file://83-netsetup" + +S = "${WORKDIR}" + +do_install() { + install -d ${D}/init.d + install -m 0755 ${WORKDIR}/83-netsetup ${D}/init.d/83-netsetup +} + +FILES:${PN} = "/init.d/83-netsetup" + +RDEPENDS:${PN} = "\ + initramfs-framework-base \ +" + +RDEPENDS:${PN}:append:bsp-next = " \ + kernel-module-ti-am65-cpsw-nuss \ + kernel-module-k3-cppi-desc-pool \ + kernel-module-davinci-mdio \ + kernel-module-ti-cpsw-ale \ + kernel-module-ti-cpsw-sl \ + kernel-module-phylink \ + kernel-module-mdio-bitbang \ + kernel-module-phy-gmii-sel \ +" diff --git a/meta-ti-bsp/recipes-ti/initramfs/packagegroup-ti-core-initramfs.bb b/meta-ti-bsp/recipes-ti/initramfs/packagegroup-ti-core-initramfs.bb index a9eff847..e1d75327 100644 --- a/meta-ti-bsp/recipes-ti/initramfs/packagegroup-ti-core-initramfs.bb +++ b/meta-ti-bsp/recipes-ti/initramfs/packagegroup-ti-core-initramfs.bb @@ -23,3 +23,6 @@ RDEPENDS:${PN} += "\ initramfs-module-nfsrootfs \ nfs-utils-mount \ " + +RDEPENDS:${PN}:append:bsp-next = " initramfs-module-netsetup" +RDEPENDS:${PN}:append:bsp-ti-6_12 = " initramfs-module-netsetup" -- 2.34.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#20226): https://lists.yoctoproject.org/g/meta-ti/message/20226 Mute This Topic: https://lists.yoctoproject.org/mt/120638764/21656 Group Owner: [email protected] Unsubscribe: https://lists.yoctoproject.org/g/meta-ti/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
