Skip to contentSkip to conversation

kern-tools-native: update to support modular kernel builds

PATCH New Mikko Rapeli 1 participant 3 messages Apr 22, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 kern-tools-native: update to support modular kernel builds

After this update scc tool can compile options as modules conditionally without duplicating config fragments when the options contain a comment like:

CONFIG_LEDS_GPIO=y # OVERRIDE:$MODULE_OR_Y

Then "scc -DMODULE_OR_Y=m" converts these into

CONFIG_LEDS_GPIO=m

---
 meta/recipes-kernel/kern-tools/kern-tools-native_git.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-kernel/kern-tools/kern-tools-native_git.bb +1 -1
index 6dd19f1f09..20b1bcaf37 100644
@@ -11,7 +11,7 @@ LIC_FILES_CHKSUM = "\
 
 DEPENDS += "git-replacement-native"
 
-SRCREV = "c8c1f17867d0cc7d04be225ba4901f2373428be2"
+SRCREV = "fe67c98d2e9b74af44d0c4b660fa18e3a95e7edd"
 PV = "0.3+git"
 
 inherit native
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/3 kernel-yocto.bbclass: support modular kernel configs

Compile many kernel drivers as modules when recipe sets

MODULAR_KERNEL = "true"

This likely requires support for initramfs which includes kernel modules needed to mount the rootfs.

SCC_OPTS can be used to add arguments to scc kernel config generation call.

---
 meta/classes-recipe/kernel-yocto.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
meta/classes-recipe/kernel-yocto.bbclass +7 -1
index cef6b9ec3f..f98720bcec 100644
@@ -26,6 +26,12 @@ KCONF_BSP_AUDIT_LEVEL ?= "0"
 KMETA_AUDIT ?= "yes"
 KMETA_AUDIT_WERROR ?= ""
 
+# most drivers as built in (default), or as modules
+MODULAR_KERNEL = "false"
+
+# options to scc
+SCC_OPTS ?= "${@bb.utils.contains('MODULAR_KERNEL', 'true', '-DMODULE_OR_Y=m', '', d)}"
+
 # returns local (absolute) path names for all valid patches in the
 # src_uri
 def find_patches(d,subdir):
@@ -298,7 +304,7 @@ do_kernel_metadata() {
 		elements="`echo -n ${bsp_definition} $sccs_defconfig ${sccs} ${patches} $KERNEL_FEATURES_FINAL`"
 		if [ -n "${elements}" ]; then
 			echo "${bsp_definition}" > ${S}/${meta_dir}/bsp_definition
-			scc --force -o ${S}/${meta_dir}:cfg,merge,meta ${includes} $sccs_defconfig $bsp_definition $sccs $patches $KERNEL_FEATURES_FINAL
+			scc ${SCC_OPTS} --force -o ${S}/${meta_dir}:cfg,merge,meta ${includes} $sccs_defconfig $bsp_definition $sccs $patches $KERNEL_FEATURES_FINAL
 			if [ $? -ne 0 ]; then
 				bbfatal_log "Could not generate configuration queue for ${KMACHINE}."
 			fi
Signature · 1 line
2.43.0
#2 lore raw

PATCH 3/3 linux-yocto: build modular kernel on genericarm64

In reply to Mikko Rapeli

genericarm64 inteds to support many devices which are not even know at compile time and uses initramfs by default. Thus many drivers can be build as modules to reduce kernel binary size and boot time.

---
 meta-yocto-bsp/recipes-kernel/linux/linux-yocto_6.12.bbappend | 2 ++
 1 file changed, 2 insertions(+)
meta-yocto-bsp/recipes-kernel/linux/linux-yocto_6.12.bbappend +2 -0
index 831cb556be..cda7fef449 100644
@@ -9,3 +9,5 @@ KMACHINE:genericx86-64 ?= "common-pc-64"
 
 FILESEXTRAPATHS:prepend:genericarm64 := "${THISDIR}/files:"
 SRC_URI:append:genericarm64 = " file://0001-Revert-serial-8250_omap-Drop-pm_runtime_irq_safe.patch"
+
+MODULAR_KERNEL:genericarm64 = "true"
Signature · 1 line
2.43.0