Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/boards/intel_adsp_ace15_mtpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ CONFIG_MEMORY_WIN_2_SIZE=12288
CONFIG_LLEXT=y
CONFIG_LLEXT_STORAGE_WRITABLE=y
CONFIG_MODULES=y
CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000

# Temporary disabled options
CONFIG_TRACE=n
Expand Down
2 changes: 1 addition & 1 deletion app/boards/intel_adsp_ace20_lnl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ CONFIG_MEMORY_WIN_2_SIZE=12288
CONFIG_LLEXT=y
CONFIG_LLEXT_STORAGE_WRITABLE=y
CONFIG_MODULES=y

CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000

# Temporary disabled options
CONFIG_TRACE=n
Expand Down
2 changes: 2 additions & 0 deletions app/configs/lnl/modules.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
CONFIG_COMP_MIXIN_MIXOUT=m
CONFIG_COMP_IIR=m
CONFIG_SAMPLE_SMART_AMP=m
CONFIG_COMP_DRC=m
17 changes: 15 additions & 2 deletions scripts/llext_link_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def parse_args():
help='Object file name')
parser.add_argument("-t", "--text-addr", required=True, type=str,
help='.text section address')
parser.add_argument("-s", "--size-file", required=True, type=str,
help='File with stored accumulated size')

args = parser.parse_args()

Expand All @@ -43,11 +45,20 @@ def max_alignment(addr, align1, align2):
return upper - (upper % align1)

def main():
global args

parse_args()

elf = ELFFile(open(args.file, 'rb'))
# Get the size of the previous module, if this isn't the first one.
# It is used to automatically calculate starting address of the current
# module.
try:
with open(args.size_file, 'r') as f_size:
size = int(f_size.read().strip(), base = 0)
except OSError:
size = 0

text_addr = int(args.text_addr, 0)
text_addr = int(args.text_addr, 0) + size
text_size = 0

# File names differ when building shared or relocatable objects
Expand All @@ -65,6 +76,8 @@ def main():
writable = []
readonly = []

elf = ELFFile(open(args.file, 'rb'))

# Create an object file with sections grouped by their properties,
# similar to how program segments are created: all executable sections,
# then all read-only data sections, and eventually all writable data
Expand Down
47 changes: 47 additions & 0 deletions scripts/llext_offset_calc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause

# Add rounded new file size to accumulated module size cache

import argparse
import pathlib
import os

args = None

def parse_args():
global args

parser = argparse.ArgumentParser(description='Add a file size to a sum in a file')

parser.add_argument("-i", "--input", required=True, type=str,
help='Object file name')
parser.add_argument("-s", "--size-file", required=True, type=str,
help='File to store accumulated size')

args = parser.parse_args()

def main():
global args

parse_args()

f_output = pathlib.Path(args.size_file)

try:
with open(f_output, 'r') as f_size:
size = int(f_size.read().strip(), base = 0)
except OSError:
size = 0

# Failure will raise an exception
f_size = open(f_output, "w")

# align to a page border
size += os.path.getsize(args.input) + 0xfff
size &= ~0xfff

f_size.write(f'0x{size:x}\n')

if __name__ == "__main__":
main()
2 changes: 0 additions & 2 deletions src/audio/drc/llext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Copyright (c) 2024 Intel Corporation.
# SPDX-License-Identifier: Apache-2.0

# Hard-coded .text address to be moved to a common place
sof_llext_build("drc"
SOURCES ../drc.c
../drc_generic.c
../drc_math_generic.c
../drc_hifi3.c
../drc_hifi4.c
../drc_math_hifi3.c
TEXT_ADDR 0xa068a000
)
1 change: 1 addition & 0 deletions src/audio/eq_iir/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
config COMP_IIR
tristate "IIR component"
select COMP_BLOB
default m if LIBRARY_DEFAULT_MODULAR
default y
depends on COMP_MODULE_ADAPTER
select MATH_IIR_DF1
Expand Down
2 changes: 0 additions & 2 deletions src/audio/eq_iir/llext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Copyright (c) 2024 Intel Corporation.
# SPDX-License-Identifier: Apache-2.0

# Hard-coded .text address to be moved to a common place
sof_llext_build("eq_iir"
SOURCES ../eq_iir.c
../eq_iir_ipc4.c
../eq_iir_generic.c
TEXT_ADDR 0xa06ea000
)
1 change: 1 addition & 0 deletions src/audio/mixin_mixout/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
config COMP_MIXIN_MIXOUT
tristate "Mixin_mixout component"
depends on IPC_MAJOR_4
default m if LIBRARY_DEFAULT_MODULAR
default y
help
Select for Mixin_mixout component
Expand Down
2 changes: 0 additions & 2 deletions src/audio/mixin_mixout/llext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Copyright (c) 2024 Intel Corporation.
# SPDX-License-Identifier: Apache-2.0

# Hard-coded .text address to be moved to a common place
sof_llext_build("mixin_mixout"
SOURCES ../mixin_mixout.c
../mixin_mixout_hifi3.c
../mixin_mixout_hifi5.c
../mixin_mixout_generic.c
TEXT_ADDR 0xa06aa000
)
17 changes: 17 additions & 0 deletions src/library_manager/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,21 @@ config LIBRARY_AUTH_SUPPORT
could be used if enabled.
If unsure say N.

config LIBRARY_DEFAULT_MODULAR
bool "Build LLEXT modules by default"
depends on LLEXT
help
Build code, that can be built as LLEXT modules as such. Usually such
code has tristate Kconfig entries, they will default to "m" if this
option is selected.

config LIBRARY_BASE_ADDRESS
hex "Base address for memory, dedicated to loadable modules"
default 0
help
When initializing modules SOF will allocate memory for them and map
it to a predefined per-module address. Those addresses are calculated
automatically but the beginning of that area is platform-specific and
should be set by this option.

endmenu
1 change: 1 addition & 0 deletions src/samples/audio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ menu "Audio component samples"

config SAMPLE_SMART_AMP
tristate "Smart amplifier test component"
default m if LIBRARY_DEFAULT_MODULAR
default y
help
Select for test smart amplifier component
Expand Down
2 changes: 0 additions & 2 deletions src/samples/audio/smart_amp_test_llext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Copyright (c) 2023 Intel Corporation.
# SPDX-License-Identifier: Apache-2.0

# Hard-coded .text address to be moved to a common place
sof_llext_build("smart_amp_test"
SOURCES ../smart_amp_test_ipc4.c
TEXT_ADDR 0xa06ca000
)
28 changes: 25 additions & 3 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ function(sof_append_relative_path_definitions target)
endforeach()
endfunction()

define_property(GLOBAL PROPERTY SOF_LLEXT_LAST_TARGET
BRIEF_DOCS "Last LLEXT target"
FULL_DOCS "\
Building LLEXT targets must be serialized. This property contains the \
previously added LLEXT module for the establishment of a dependency chain."
)

# Used by LLEXT modules to create a file with module UUIDs
function(sof_llext_write_uuids module)
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/../${module}.toml uuids REGEX "^[ \t]*uuid *=")
Expand All @@ -54,7 +61,6 @@ endfunction()
# Build an LLEXT module. Provice a module name, a list of sources and an address
# of the .text section as arguments.
function(sof_llext_build module)
set(single_args TEXT_ADDR)
set(multi_args SOURCES)
cmake_parse_arguments(PARSE_ARGV 1 SOF_LLEXT "${options}" "${single_args}" "${multi_args}")

Expand Down Expand Up @@ -91,13 +97,29 @@ function(sof_llext_build module)

get_target_property(proc_in_file ${module} lib_output)
get_target_property(proc_out_file ${module} pkg_input)
get_target_property(proc_pkg_file ${module} pkg_output)
set(size_file ${PROJECT_BINARY_DIR}/module_size)

get_property(last_target GLOBAL PROPERTY SOF_LLEXT_LAST_TARGET)
if(NOT "${last_target}" STREQUAL "")
add_dependencies(${module}_llext_proc ${last_target})
endif()
set_property(GLOBAL PROPERTY SOF_LLEXT_LAST_TARGET ${module})

add_llext_command(TARGET ${module}
POST_BUILD
COMMAND ${PYTHON_EXECUTABLE} ${SOF_BASE}scripts/llext_link_helper.py
--text-addr="${SOF_LLEXT_TEXT_ADDR}" -f ${proc_in_file} ${CMAKE_C_COMPILER} --
COMMAND ${PYTHON_EXECUTABLE} ${SOF_BASE}scripts/llext_link_helper.py -s ${size_file}
--text-addr=${CONFIG_LIBRARY_BASE_ADDRESS}
-f ${proc_in_file} ${CMAKE_C_COMPILER} --
-o ${proc_out_file} ${EXTRA_LINKER_PARAMS}
$<TARGET_OBJECTS:${module}_llext_lib>
)

add_llext_command(TARGET ${module}
POST_PKG
COMMAND ${PYTHON_EXECUTABLE} ${SOF_BASE}scripts/llext_offset_calc.py
-i ${proc_pkg_file} -s ${size_file}
)
endfunction()

# Initial SOF module will contain
Expand Down