diff mbox series

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

Message ID 20250423080246.128723-2-mikko.rapeli@linaro.org
State New
Headers show
Series [1/3] kern-tools-native: update to support modular kernel builds | expand

Commit Message

Mikko Rapeli April 23, 2025, 8:02 a.m. UTC
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.

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
---
 meta/classes-recipe/kernel-yocto.bbclass | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Bruce Ashfield April 23, 2025, 12:30 p.m. UTC | #1
I already have patches for this, and they have not been sent on purpose.

Please do not apply this patch, consider this a nack.

Bruce

On Wed, Apr 23, 2025 at 4:03 AM Mikko Rapeli via lists.yoctoproject.org
<mikko.rapeli=linaro.org@lists.yoctoproject.org> wrote:

> 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.
>
> Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
> ---
>  meta/classes-recipe/kernel-yocto.bbclass | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/meta/classes-recipe/kernel-yocto.bbclass
> b/meta/classes-recipe/kernel-yocto.bbclass
> index cef6b9ec3f..f98720bcec 100644
> --- a/meta/classes-recipe/kernel-yocto.bbclass
> +++ b/meta/classes-recipe/kernel-yocto.bbclass
> @@ -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
> --
> 2.43.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#13599):
> https://lists.yoctoproject.org/g/poky/message/13599
> Mute This Topic: https://lists.yoctoproject.org/mt/112410521/1050810
> Group Owner: poky+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/poky/unsub [
> bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
index cef6b9ec3f..f98720bcec 100644
--- a/meta/classes-recipe/kernel-yocto.bbclass
+++ b/meta/classes-recipe/kernel-yocto.bbclass
@@ -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