Add recipes to build initramfs image
v4 cover Add recipes to build initramfs image
The series aims to add a new recipe which will package boot essential and some other modules in image which can later be used in the boot process of all K3 platforms. This will result in the addition of ~20MB initramfs image in the bootflow.
The motivation behind the work is to probe modules(in boot time) which could not be built in the upstream Linux kernel image, as using it as inbuilt drivers will increase the kernel image size, which is undesirable by the upstream folks.
Hence, build those drivers as modules and package it inside initramfs and later get it probed through initramfs-udev(device manager).
The series will introduce an additional 20MB initramfs image in the bootflow of all K3 platforms regardless of whether any platform chooses to add modules to it or not, so as to keep the bootflow for all devices uniform. Hence, the build/packaging of initrd image is being triggered in k3.inc.
Boot tests for am64xx:
[0] https://gist.github.com/Jamm02/0abbba19ff27272a9945dd7f3035b603
Changes since V3:
- Move initramfs build from k3.inc to ti-soc.inc so that legacy platforms like am57 also includes the initramfs image.
- Change BUILD_CORE_INITRD_IMAGE -> BUILD_CORE_INITRAMFS_IMAGE
Link to V2: https://lists.yoctoproject.org/g/meta-ti/message/19043
Link to V1: https://lists.yoctoproject.org/g/meta-ti/topic/115128108
Moteen Shah (4):
meta-ti-bsp: conf: machine: include: Add common module variable for TI
Initramfs image
recipes-ti: initramfs: Make minimal initramfs image
meta-ti-bsp: wic: Add initramfs path to to grub config
meta-ti-bsp: conf: machine: include: Build initramfs for all TI
SoC's
meta-ti-bsp/conf/machine/include/am62axx.inc | 3 ++ meta-ti-bsp/conf/machine/include/j721e.inc | 3 ++ meta-ti-bsp/conf/machine/include/j784s4.inc | 3 ++ meta-ti-bsp/conf/machine/include/ti-soc.inc | 10 ++++++ .../packagegroup-ti-core-initramfs.bb | 15 +++++++++ .../recipes-ti/initramfs/ti-core-initramfs.bb | 33 +++++++++++++++++++ meta-ti-bsp/wic/sdimage-2part-efi.wks.in | 2 +- 7 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 meta-ti-bsp/recipes-ti/initramfs/packagegroup-ti-core-initramfs.bb create mode 100644 meta-ti-bsp/recipes-ti/initramfs/ti-core-initramfs.bb
Signature · 1 line
2.34.1
PATCH v4 1/4 meta-ti-bsp: conf: machine: include: Add common module variable for TI Initramfs image
Add a new variable in ti-soc.inc which would be populated by individual platforms with the required modules which would later be packaged inside the initramfs image.
--- meta-ti-bsp/conf/machine/include/am62axx.inc | 3 +++ meta-ti-bsp/conf/machine/include/j721e.inc | 3 +++ meta-ti-bsp/conf/machine/include/j784s4.inc | 3 +++ meta-ti-bsp/conf/machine/include/ti-soc.inc | 2 ++ 4 files changed, 11 insertions(+)
meta-ti-bsp/conf/machine/include/am62axx.inc +3 -0
@@ -11,3 +11,6 @@ TFA_BOARD = "lite" OPTEEMACHINE = "k3-am62x" MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "cnm-wave-fw" + +TI_INITRAMFS_KERNEL_MODULES:append:bsp-mainline = "kernel-module-tps6594-i2c" +TI_INITRAMFS_KERNEL_MODULES:append:bsp-next = "kernel-module-tps6594-i2c"
meta-ti-bsp/conf/machine/include/j721e.inc +3 -0
@@ -19,3 +19,6 @@ TI_VXE_VXD_DRIVER = "ti-vxe-vxd-driver" TI_VXE_VXD_DRIVER:bsp-ti-6_6 = "" MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "cadence-mhdp-fw vxd-dec-fw ti-eth-fw-j721e ${TI_VXE_VXD_DRIVER}" + +TI_INITRAMFS_KERNEL_MODULES:append:bsp-mainline = " kernel-module-cdns-pltfrm kernel-module-ti-j721e-ufs" +TI_INITRAMFS_KERNEL_MODULES:append:bsp-next = " kernel-module-cdns-pltfrm kernel-module-ti-j721e-ufs"
meta-ti-bsp/conf/machine/include/j784s4.inc +3 -0
@@ -13,3 +13,6 @@ TFA_BOARD = "j784s4" OPTEEMACHINE = "k3-j784s4" MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "cadence-mhdp-fw cnm-wave-fw ti-eth-fw-j784s4" + +TI_INITRAMFS_KERNEL_MODULES:append:bsp-mainline = " kernel-module-cdns-pltfrm kernel-module-ti-j721e-ufs" +TI_INITRAMFS_KERNEL_MODULES:append:bsp-next = " kernel-module-cdns-pltfrm kernel-module-ti-j721e-ufs"
meta-ti-bsp/conf/machine/include/ti-soc.inc +2 -0
@@ -27,3 +27,5 @@ CLASS_DEVICETREE_PREFIX = "${@ 'ti-devicetree-prefix' if d.getVar('KERNEL_DEVICE KERNEL_CLASSES += "${CLASS_DEVICETREE_PREFIX}" IMAGE_CLASSES += "${CLASS_DEVICETREE_PREFIX}" + +TI_INITRAMFS_KERNEL_MODULES ?= ""
Signature · 1 line
2.34.1
PATCH v4 2/4 recipes-ti: initramfs: Make minimal initramfs image
In reply to Moteen ShahIntroduce a new minimal initramfs image which will be used for all K3 devices in the boot flow. The image will package boot essential and other modules which will be modprobed by initramfs-udev once the inbuilt drivers gets probed.
--- .../packagegroup-ti-core-initramfs.bb | 15 +++++++++ .../recipes-ti/initramfs/ti-core-initramfs.bb | 33 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 meta-ti-bsp/recipes-ti/initramfs/packagegroup-ti-core-initramfs.bb create mode 100644 meta-ti-bsp/recipes-ti/initramfs/ti-core-initramfs.bb
meta-ti-bsp/recipes-ti/initramfs/packagegroup-ti-core-initramfs.bb new file +15 -0
@@ -0,0 +1,15 @@ +SUMMARY = "Minimal initramfs for boot requirements" + +require recipes-core/packagegroups/packagegroup-core-boot.bb + +RDEPENDS:${PN} += "\ + ${TI_INITRAMFS_KERNEL_MODULES} \ + initramfs-framework-base \ + initramfs-module-udev \ + initramfs-module-nfsrootfs \ + cifs-utils \ + nfs-utils \ + nfs-utils-client \ +" + +RDEPENDS:${PN}:remove = "grub-efi kernel"
meta-ti-bsp/recipes-ti/initramfs/ti-core-initramfs.bb new file +33 -0
@@ -0,0 +1,33 @@ +SUMMARY = "TI SDK minimal initramfs image" + +DESCRIPTION = "Image meant to probe boot essential modules\ + and other modules to reach the userspace, which cannot be\ + built inside the upstream linux kernel image.\ +" + +LICENSE = "MIT" + +inherit core-image + +IMAGE_NAME = "ti-core-initramfs" + +IMAGE_NAME_SUFFIX = "" + +IMAGE_FEATURES:remove = "package-management" + +INITRAMFS_FSTYPES = "cpio cpio.xz" + +IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}" + +PACKAGE_INSTALL = "packagegroup-ti-core-initramfs" + +export IMAGE_BASENAME = "${IMAGE_NAME}" + +# To further reduce the size of the rootfs, remove the /boot directory from +# the final image this is usually done by adding RDEPENDS_kernel-base = "" +# in the configuration file. In our case we can't use this method. Instead we +# just wipe out the content of "/boot" before creating the image. +ROOTFS_POSTPROCESS_COMMAND += "empty_boot_dir; " +empty_boot_dir () { + rm -rf ${IMAGE_ROOTFS}/boot/* +}
Signature · 1 line
2.34.1
PATCH v4 3/4 meta-ti-bsp: wic: Add initramfs path to to grub config
In reply to Moteen ShahAdd initrd path to grub.cfg config so that it picks up the initramfs image from the boot partition and includes it in the boot process.
--- meta-ti-bsp/wic/sdimage-2part-efi.wks.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta-ti-bsp/wic/sdimage-2part-efi.wks.in +1 -1
@@ -4,5 +4,5 @@ # reserved space. We cannot use a GPT here. bootloader --timeout=3 --append="rootfstype=ext4 ${TI_WKS_BOOTLOADER_APPEND}" -part --source bootimg-efi --sourceparams="loader=${EFI_PROVIDER}" --fstype=vfat --label boot --active --align 1024 --use-uuid --fixed-size 128M +part --source bootimg-efi --sourceparams="loader=${EFI_PROVIDER},initrd=ti-core-initramfs.cpio.xz" --fstype=vfat --label boot --active --align 1024 --use-uuid --fixed-size 128M part / --source rootfs --fstype=ext4 --label root --align 1024 --use-uuid
Signature · 1 line
2.34.1
Re: [master][PATCH v4 3/4] meta-ti-bsp: wic: Add initramfs path to to grub config
Quoted 14 lines · Moteen Shah
Add initrd path to grub.cfg config so that it picks up the initramfs image from the boot partition and includes it in the boot process.
Signed-off-by Moteen Shah <[email protected]>--- meta-ti-bsp/wic/sdimage-2part-efi.wks.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)meta-ti-bsp/wic/sdimage-2part-efi.wks.in +0
-0
meta-ti-bsp/wic/sdimage-2part-efi.wks.in line 7
Quoted 5 lines
meta-ti-bsp/wic/sdimage-2part-efi.wks.in +1
-1@@ -4,5 +4,5 @@ # reserved space. We cannot use a GPT here. bootloader --timeout=3 --append="rootfstype=ext4 ${TI_WKS_BOOTLOADER_APPEND}" -part --source bootimg-efi --sourceparams="loader=${EFI_PROVIDER}" --fstype=vfat --label boot --active --align 1024 --use-uuid --fixed-size 128M +part --source bootimg-efi --sourceparams="loader=${EFI_PROVIDER},initrd=ti-core-initramfs.cpio.xz" --fstype=vfat --label boot --active --align 1024 --use-uuid --fixed-size 128M
After some initial build testing we need to change one more thing, we cannot hard code the initrd in the above. When building NOT on bsp-mainline, or bsp-next the builds were failing because this w.ks file is hard-coded to always need the initramfs file to exist.
Change it to:
--sourceparams="loader=${EFI_PROVIDER}${TI_WKS_INITRAMFS}"
That way we can set the TI_WKS_INITRAMFS variable to either "", or ",initrd=ti-core-initramfs.cpio.xz" in the ti-soc.inc based on if we are needing it or not.
Quoted 1 line
meta-ti-bsp/wic/sdimage-2part-efi.wks.in +0
-0part / --source rootfs --fstype=ext4 --label root --align 1024 --use-uuid
Signature · 3 lines
Ryan Eatmon [email protected] ----------------------------------------- Texas Instruments, Inc. - LCPD - MGTS
PATCH v4 4/4 meta-ti-bsp: conf: machine: include: Build initramfs for all TI SoC's
In reply to Moteen ShahTrigger build for initramfs image and package it in the boot partition of all TI SoC's whenever an image recipe is built with upstream kernel(mainline or mainline-next).
--- meta-ti-bsp/conf/machine/include/ti-soc.inc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
meta-ti-bsp/conf/machine/include/ti-soc.inc +9 -1
@@ -28,4 +28,12 @@ CLASS_DEVICETREE_PREFIX = "${@ 'ti-devicetree-prefix' if d.getVar('KERNEL_DEVICE KERNEL_CLASSES += "${CLASS_DEVICETREE_PREFIX}" IMAGE_CLASSES += "${CLASS_DEVICETREE_PREFIX}" -TI_INITRAMFS_KERNEL_MODULES ?= "" +TI_INITRAMFS_KERNEL_MODULES ?= "" + +BUILD_CORE_INITRAMFS_IMAGE ?= "" +BUILD_CORE_INITRAMFS_IMAGE:bsp-mainline = "ti-core-initramfs:do_image_complete" +BUILD_CORE_INITRAMFS_IMAGE:bsp-next = "ti-core-initramfs:do_image_complete" +do_image_complete[depends] += "${BUILD_CORE_INITRAMFS_IMAGE}" + +IMAGE_BOOT_FILES:append:bsp-mainline = " ti-core-initramfs.cpio.xz" +IMAGE_BOOT_FILES:append:bsp-next = " ti-core-initramfs.cpio.xz"
Signature · 1 line
2.34.1
Re: [master][PATCH v4 4/4] meta-ti-bsp: conf: machine: include: Build initramfs for all TI SoC's
Quoted 14 lines · Moteen Shah
Trigger build for initramfs image and package it in the boot partition of all TI SoC's whenever an image recipe is built with upstream kernel(mainline or mainline-next).
Signed-off-by Moteen Shah <[email protected]>--- meta-ti-bsp/conf/machine/include/ti-soc.inc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)meta-ti-bsp/conf/machine/include/ti-soc.inc +0
-0
meta-ti-bsp/conf/machine/include/ti-soc.inc CLASS_DEVICETREE_PREFIX = "${@ 'ti-devicetree-prefix' if d.getVar('KERNEL_DEVICE · line 35
Quoted 10 lines
meta-ti-bsp/conf/machine/include/ti-soc.inc +5
-1@@ -28,4 +28,12 @@ CLASS_DEVICETREE_PREFIX = "${@ 'ti-devicetree-prefix' if d.getVar('KERNEL_DEVICE KERNEL_CLASSES += "${CLASS_DEVICETREE_PREFIX}" IMAGE_CLASSES += "${CLASS_DEVICETREE_PREFIX}" -TI_INITRAMFS_KERNEL_MODULES ?= "" +TI_INITRAMFS_KERNEL_MODULES ?= "" + +BUILD_CORE_INITRAMFS_IMAGE ?= "" +BUILD_CORE_INITRAMFS_IMAGE:bsp-mainline = "ti-core-initramfs:do_image_complete" +BUILD_CORE_INITRAMFS_IMAGE:bsp-next = "ti-core-initramfs:do_image_complete"
To avoid hard-coding "ti-core-initramfs" in so many places, let's use variables to contain the variations of the string. That way we onyl have to change a single variable to update the name in all places (not that I think we will ever want to change it...)
BUILD_CORE_INITRAMFS_IMAGE = "ti-core-initramfs" BUILD_CORE_INITRAMFS_IMAGE_FILE = "${BUILD_CORE_INITRAMFS_IMAGE}.cpio.xz"
BUILD_CORE_INITRAMFS_IMAGE_STEP ?= "" BUILD_CORE_INITRAMFS_IMAGE_STEP:bsp-mainline = "${BUILD_CORE_INITRAMFS_IMAGE}:do_image_complete" BUILD_CORE_INITRAMFS_IMAGE_STEP:bsp-next = "${BUILD_CORE_INITRAMFS_IMAGE}:do_image_complete"
meta-ti-bsp/conf/machine/include/ti-soc.inc CLASS_DEVICETREE_PREFIX = "${@ 'ti-devicetree-prefix' if d.getVar('KERNEL_DEVICE · line 36
Quoted 1 line
meta-ti-bsp/conf/machine/include/ti-soc.inc +1
-0+do_image_complete[depends] += "${BUILD_CORE_INITRAMFS_IMAGE}"
This needs to change to do_image_wic since the initramfs file needs to be complete for the wic step:
do_image_wic[depends] += "${BUILD_CORE_INITRAMFS_IMAGE_STEP}"
meta-ti-bsp/conf/machine/include/ti-soc.inc CLASS_DEVICETREE_PREFIX = "${@ 'ti-devicetree-prefix' if d.getVar('KERNEL_DEVICE · line 39
Quoted 3 lines
meta-ti-bsp/conf/machine/include/ti-soc.inc +3
-0+ +IMAGE_BOOT_FILES:append:bsp-mainline = " ti-core-initramfs.cpio.xz" +IMAGE_BOOT_FILES:append:bsp-next = " ti-core-initramfs.cpio.xz"
Change these to use the new variable:
IMAGE_BOOT_FILES:append:bsp-mainline = " ${BUILD_CORE_INITRAMFS_IMAGE_FILE}" IMAGE_BOOT_FILES:append:bsp-next = " ${BUILD_CORE_INITRAMFS_IMAGE_FILE}"
And finally, define the TI_WKS_INITRAMFS variable that patch 3 now references.
TI_WKS_INITRAMFS ?= ""
TI_WKS_INITRAMFS:bsp-mainline = ",initrd=${BUILD_CORE_INITRAMFS_IMAGE_FILE}" TI_WKS_INITRAMFS:bsp-next = ",initrd=${BUILD_CORE_INITRAMFS_IMAGE_FILE}"
I think that with all of this in place, we can start doing some builds and working with the test team to update the board configs to start picking them up (if available) and using them in the test farm.
Signature · 3 lines
Ryan Eatmon [email protected] ----------------------------------------- Texas Instruments, Inc. - LCPD - MGTS
meta-ti / na / 20251006115010.1530509-1-m-shah
PRC Results: FAIL
=========================================================
check-yocto-patches: FAIL
=========================================================
Patches
----------------------------------------
FAIL - [master][PATCH v4 1/4] meta-ti-bsp: conf: machine: include: Add common module variable for TI Initramfs image
ERROR: Commit message too long (> 80 chars): meta-ti-bsp: conf: machine: include: Add common module variable for TI Initramfs image. (COMMIT-MESSAGE-1)
patch:44
Subject: [master][PATCH v4 1/4] meta-ti-bsp: conf: machine: include: Add common module variable for TI Initramfs image
WARN: Commit message does not include file/recipe name: meta-ti-bsp: conf: machine: include: Add common module variable for TI Initramfs image. (COMMIT-MESSAGE-2)
patch
WARN: Commit message should not include directory path to recipe: meta-ti-bsp: conf: machine: include: Add common module variable for TI Initramfs image.
meta-ti-bsp:
conf:
machine:
include: (COMMIT-MESSAGE-3)
patch
WARN: Revised patch missing a comment. (REVISION-1)
patch
WARN - [master][PATCH v4 2/4] recipes-ti: initramfs: Make minimal initramfs image
WARN: Commit message does not include file/recipe name: recipes-ti: initramfs: Make minimal initramfs image. (COMMIT-MESSAGE-2)
patch
WARN: Commit message should not include directory path to recipe: recipes-ti: initramfs: Make minimal initramfs image.
recipes-ti: (COMMIT-MESSAGE-3)
patch
WARN: Revised patch missing a comment. (REVISION-1)
patch
WARN - [master][PATCH v4 3/4] meta-ti-bsp: wic: Add initramfs path to to grub config
WARN: Commit message does not include file/recipe name: meta-ti-bsp: wic: Add initramfs path to to grub config. (COMMIT-MESSAGE-2)
patch
WARN: Commit message should not include directory path to recipe: meta-ti-bsp: wic: Add initramfs path to to grub config.
meta-ti-bsp:
wic: (COMMIT-MESSAGE-3)
patch
WARN: Revised patch missing a comment. (REVISION-1)
patch
WARN - [master][PATCH v4 4/4] meta-ti-bsp: conf: machine: include: Build initramfs for all TI SoC's
WARN: Commit message does not include file/recipe name: meta-ti-bsp: conf: machine: include: Build initramfs for all TI SoC's. (COMMIT-MESSAGE-2)
patch
WARN: Commit message should not include directory path to recipe: meta-ti-bsp: conf: machine: include: Build initramfs for all TI SoC's.
meta-ti-bsp:
conf:
machine:
include: (COMMIT-MESSAGE-3)
patch
WARN: Revised patch missing a comment. (REVISION-1)
patch