@@ -287,6 +287,7 @@ RECIPE_MAINTAINER:pn-initramfs-live-install = "Unassigned <unassigned@yoctoproje
RECIPE_MAINTAINER:pn-initramfs-live-install-efi = "Unassigned <unassigned@yoctoproject.org>"
RECIPE_MAINTAINER:pn-initramfs-live-install-efi-testfs = "Unassigned <unassigned@yoctoproject.org>"
RECIPE_MAINTAINER:pn-initramfs-live-install-testfs = "Unassigned <unassigned@yoctoproject.org>"
+RECIPE_MAINTAINER:pn-initramfs-module-earlyesp = "Unassigned <unassigned@yoctoproject.org>"
RECIPE_MAINTAINER:pn-initramfs-module-install = "Unassigned <unassigned@yoctoproject.org>"
RECIPE_MAINTAINER:pn-initramfs-module-install-efi = "Unassigned <unassigned@yoctoproject.org>"
RECIPE_MAINTAINER:pn-initramfs-module-setup-live = "Unassigned <unassigned@yoctoproject.org>"
new file mode 100644
@@ -0,0 +1,54 @@
+#!/bin/sh
+# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
+# SPDX-License-Identifier: MIT
+# Enable with initramfs.esp-partlabel=<GPT partition label>.
+
+earlyesp_enabled() {
+ earlyesp_label=${bootparam_initramfs_esp_partlabel:-off}
+ # Keep the label safe to embed literally in a udev rule.
+ case "$earlyesp_label" in
+ ""|off|*[!A-Za-z0-9_.-]*) return 1 ;;
+ esac
+ [ "${#earlyesp_label}" -le 36 ]
+}
+
+earlyesp_trigger() {
+ if ! udevadm trigger --type=devices --action=add "$earlyesp_path"; then
+ msg "WARNING: Could not trigger early ESP processing; continuing normal boot."
+ fi
+ return 0
+}
+
+earlyesp_run() {
+ earlyesp_path=
+ # Read the kernel PARTNAME, without needing a udev database, filesystem
+ # scan, efivarfs mount or a fixed disk name.
+ for earlyesp_candidate in /sys/class/block/*; do
+ [ -r "$earlyesp_candidate/partition" ] || continue
+ [ -r "$earlyesp_candidate/uevent" ] || continue
+ earlyesp_candidate_label=
+ while IFS='=' read -r earlyesp_key earlyesp_value; do
+ [ "$earlyesp_key" = "PARTNAME" ] && earlyesp_candidate_label=$earlyesp_value
+ done < "$earlyesp_candidate/uevent"
+ [ "$earlyesp_candidate_label" = "$earlyesp_label" ] || continue
+ # Never choose an arbitrary disk when partition labels are duplicated.
+ [ -z "$earlyesp_path" ] || return 0
+ earlyesp_path=$earlyesp_candidate
+ done
+ [ -n "$earlyesp_path" ] || return 0
+
+ # Install before udevd starts so no rule reload is needed. /etc here
+ # belongs to the initramfs; only the resulting /run/udev state survives
+ # switch_root. Let blkid validate both the GPT type and filesystem.
+ mkdir -p /etc/udev/rules.d || return 0
+ if ! printf '%s\n' \
+ 'ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", \' \
+ "ENV{PARTNAME}==\"$earlyesp_label\", \\" \
+ 'ENV{ID_PART_ENTRY_TYPE}=="c12a7328-f81f-11d2-ba4b-00a0c93ec93b", \' \
+ 'ENV{ID_FS_TYPE}=="vfat", TAG+="systemd"' \
+ > /etc/udev/rules.d/99-early-esp.rules; then
+ return 0
+ fi
+ # Enqueue the ESP before the udev module's existing coldplug wait.
+ add_udev_trigger_hook earlyesp_trigger
+}
new file mode 100644
@@ -0,0 +1,21 @@
+SUMMARY = "Prepare an EFI System Partition for systemd in initramfs"
+DESCRIPTION = "Optional initramfs-framework module that processes an EFI \
+System Partition selected by initramfs.esp-partlabel and tags it for \
+the real-root systemd manager."
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
+
+SRC_URI = "file://earlyesp"
+S = "${UNPACKDIR}"
+
+inherit features_check
+
+REQUIRED_DISTRO_FEATURES = "systemd"
+
+RDEPENDS:${PN} = "initramfs-module-udev util-linux-libblkid"
+
+do_install() {
+ install -D -m 0755 ${S}/earlyesp ${D}/init.d/00-earlyesp
+}
+
+FILES:${PN} = "/init.d/00-earlyesp"
With root-only coldplug, the ESP can remain unprocessed until the real root coldplug, delaying systemd units that require it. Add an optional module selected by initramfs.esp-partlabel that validates the GPT type and vfat filesystem through udev before the shared queue wait. AI-Generated: OpenAI Codex (GPT-6) Signed-off-by: Wenwen Fu <wenwfu@qti.qualcomm.com> --- meta/conf/distro/include/maintainers.inc | 1 + .../initramfs-module-earlyesp/earlyesp | 54 +++++++++++++++++++ .../initramfs-module-earlyesp_1.0.bb | 21 ++++++++ 3 files changed, 76 insertions(+) create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-earlyesp/earlyesp create mode 100644 meta/recipes-core/initrdscripts/initramfs-module-earlyesp_1.0.bb