From 12136ccf72f6c95119b2ee8fe39d5398e145d6c5 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 2 Dec 2024 17:10:06 +0100 Subject: [PATCH 01/14] llext: add configuration for packing modules into libraries Add a parameter to sof_llext_build() to support adding modules to libraries. Specifying a LIB parameter in that function with a single value adds that module to a library with that name if packing modules into libraries is enabled. Signed-off-by: Guennadi Liakhovetski --- src/library_manager/Kconfig | 8 ++++++++ zephyr/CMakeLists.txt | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/library_manager/Kconfig b/src/library_manager/Kconfig index 7791e8839ac2..598551a6c650 100644 --- a/src/library_manager/Kconfig +++ b/src/library_manager/Kconfig @@ -41,6 +41,14 @@ config LIBRARY_DEFAULT_MODULAR code has tristate Kconfig entries, they will default to "m" if this option is selected. +config LIBRARY_BUILD_LIB + bool "Pack LLEXT modules into a library" + depends on LLEXT + help + The first option to build LLEXT modules is to pack one module per + file. This option enables packing of all enabled modules into a single + module library. + config LIBRARY_BASE_ADDRESS hex "Base address for memory, dedicated to loadable modules" default 0 diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 2e96668e119b..c876d8c08ad3 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -62,6 +62,7 @@ endfunction() # of the .text section as arguments. function(sof_llext_build module) set(multi_args SOURCES) + set(single_args LIB) cmake_parse_arguments(PARSE_ARGV 1 SOF_LLEXT "${options}" "${single_args}" "${multi_args}") cmake_path(SET SOF_BASE NORMALIZE ${APPLICATION_SOURCE_DIR}/..) @@ -73,6 +74,10 @@ function(sof_llext_build module) SOURCES ${SOF_LLEXT_SOURCES} ) + if(CONFIG_LIBRARY_BUILD_LIB AND NOT("${SOF_LLEXT_LIB}" STREQUAL "")) + file(WRITE ${PROJECT_BINARY_DIR}/${module}_llext/lib_name.txt ${SOF_LLEXT_LIB}) + endif() + target_include_directories(${module}_llext_lib PRIVATE "${SOF_BASE}/xtos/include" "${SOF_BASE}/src/include" From 8967f3b25848890d2c938b88fa3486124f026c25 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Mon, 2 Dec 2024 17:04:57 +0100 Subject: [PATCH 02/14] llext: mtl: build libraries when using modules Add a FORCE_ALL_MODULES macro to mtl.toml.h. When this header is then preprocessed with that macro defined, all module TOML files will be included. This then can be used to generate module libraries, which we also enable in this patch. Note, that by default MTL doesn't enable modular build, only if it's enabled by the user, modules will be packed into a library. Signed-off-by: Guennadi Liakhovetski --- app/boards/intel_adsp_ace15_mtpm.conf | 1 + tools/rimage/config/mtl.toml.h | 48 +++++++++++++-------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/app/boards/intel_adsp_ace15_mtpm.conf b/app/boards/intel_adsp_ace15_mtpm.conf index 5341d14e4ddd..6c33d91626cd 100644 --- a/app/boards/intel_adsp_ace15_mtpm.conf +++ b/app/boards/intel_adsp_ace15_mtpm.conf @@ -52,6 +52,7 @@ CONFIG_INTEL_MODULES=y CONFIG_LIBRARY_MANAGER=y CONFIG_LIBRARY_AUTH_SUPPORT=y CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000 +CONFIG_LIBRARY_BUILD_LIB=y # SOF / logging CONFIG_SOF_LOG_LEVEL_INF=y diff --git a/tools/rimage/config/mtl.toml.h b/tools/rimage/config/mtl.toml.h index b549c76c3658..a902a351790c 100644 --- a/tools/rimage/config/mtl.toml.h +++ b/tools/rimage/config/mtl.toml.h @@ -24,31 +24,31 @@ index = __COUNTER__ -#ifdef CONFIG_COMP_MIXIN_MIXOUT +#if defined(CONFIG_COMP_MIXIN_MIXOUT) || defined(LLEXT_FORCE_ALL_MODULAR) #include