forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
smart-amp-test: make a loadable module
Convert the smart-amp-test in its IPC4 version to a loadable LLEXT module. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
- Loading branch information
Showing
6 changed files
with
224 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
file=$1 | ||
text_addr=$2 | ||
|
||
# We need to take addresses of .text, .data, .rodata and .bss and calculate | ||
# offsets, because the linker will keep everything between .data and .rodata and | ||
# between .rodata and .bss in the final image too, when we specify section | ||
# addresses. So just taking sizes of .text, .data and .rodata isn't enough. | ||
# We use file offset from the objdump command output to avoid unused sections. | ||
|
||
source <( | ||
objdump -h $file | awk '/ .text / {print "text="toupper($6)} / .rodata / {print "rodata="toupper($6)} / .data / {print "data="toupper($6)}' | ||
) | ||
|
||
# round up to 4KiB | ||
rodata_addr=$(echo "obase=16; ibase=16; upper=($rodata - $text + $text_addr + FFF); upper - (upper % 1000)" | bc) | ||
# round up to 16 bytes | ||
data_addr=$(echo "obase=16; ibase=16; upper=($data - $rodata + $rodata_addr + F); upper - (upper % 10)" | bc) | ||
|
||
echo "-Wl,-Ttext=0x$text_addr -Wl,--section-start=.rodata=0x$rodata_addr -Wl,-Tdata=0x$data_addr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# Copyright (c) 2023 Intel Corporation. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
cmake_minimum_required(VERSION 3.20.0) | ||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) | ||
project(smart_amp_test) | ||
|
||
SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) | ||
|
||
set(MODULE "smart_amp_test") | ||
cmake_path(SET SOF_BASE NORMALIZE ${PROJECT_SOURCE_DIR}/../../../..) | ||
|
||
add_library(${MODULE} SHARED) | ||
|
||
target_sources(${MODULE} PRIVATE | ||
${CMAKE_CURRENT_LIST_DIR}/../smart_amp_test_ipc4.c | ||
) | ||
|
||
sof_append_relative_path_definitions(${MODULE}) | ||
|
||
target_include_directories(${MODULE} PRIVATE | ||
"${ZEPHYR_BASE}/include" | ||
"${ZEPHYR_BASE}/soc/xtensa/intel_adsp/common/include" | ||
"${ZEPHYR_BASE}/soc/xtensa/intel_adsp/ace/include/intel_ace15_mtpm" | ||
"${ZEPHYR_BASE}/../modules/hal/xtensa/include" | ||
"${ZEPHYR_BASE}/../modules/hal/xtensa/zephyr/soc/intel_ace15_mtpm" | ||
"${SOF_BASE}/src/include" | ||
"${SOF_BASE}/src/arch/xtensa/include" | ||
"${SOF_BASE}/src/platform/meteorlake/include" | ||
"${SOF_BASE}/src/platform/intel/ace/include" | ||
"${SOF_BASE}/src/include/sof/audio/module_adapter/iadk" | ||
"${SOF_BASE}/zephyr/include" | ||
"${SOF_BASE}/xtos/include" | ||
"${SOF_BASE}/rimage/src/include" | ||
"${PROJECT_BINARY_DIR}/../include/generated" | ||
) | ||
|
||
set(MODULE_PROPERTIES HPSRAM_ADDR "0xa06c1000") | ||
set_target_properties(${MODULE} PROPERTIES ${MODULE_PROPERTIES}) | ||
|
||
set(MODULE_COMPILE_DEF | ||
__ZEPHYR__=1 | ||
__XTENSA__ | ||
KERNEL | ||
MAJOR_IADSP_API_VERSION=5 | ||
MIDDLE_IADSP_API_VERSION=0 | ||
MINOR_IADSP_API_VERSION=0 | ||
) | ||
target_compile_definitions(${MODULE} PRIVATE ${MODULE_COMPILE_DEF}) | ||
|
||
target_compile_options(${MODULE} PRIVATE | ||
-imacros${PROJECT_BINARY_DIR}/../include/generated/autoconf.h | ||
-save-temps -O2 | ||
) | ||
|
||
set(MODULE_LINKER_PARAMS -nostdlib -nodefaultlibs) | ||
target_link_options(${MODULE} PRIVATE | ||
${MODULE_LINKER_PARAMS} | ||
) | ||
|
||
add_custom_target(${MODULE}_llext ${CMAKE_C_COMPILER} | ||
${MODULE_LINKER_PARAMS} | ||
"$$(${SOF_BASE}/scripts/calc_elf_addresses.sh" lib${MODULE}.so "A06CA000)" | ||
-shared -fPIC | ||
-o lib${MODULE}_llext.so $<TARGET_OBJECTS:${MODULE}> | ||
COMMAND ${CMAKE_STRIP} -R .xt.* -o lib${MODULE}_out.so lib${MODULE}_llext.so | ||
DEPENDS ${MODULE} | ||
COMMAND_EXPAND_LISTS | ||
) | ||
|
||
add_dependencies(${MODULE} zephyr_interface) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
version = [3, 0] | ||
|
||
[adsp] | ||
name = "mtl" | ||
image_size = "0x2C0000" # (22) bank * 128KB | ||
alias_mask = "0xE0000000" | ||
|
||
[[adsp.mem_zone]] | ||
type = "ROM" | ||
base = "0x1FF80000" | ||
size = "0x400" | ||
[[adsp.mem_zone]] | ||
type = "IMR" | ||
base = "0xA104A000" | ||
size = "0x2000" | ||
[[adsp.mem_zone]] | ||
type = "SRAM" | ||
base = "0xa00f0000" | ||
size = "0x100000" | ||
|
||
[[adsp.mem_alias]] | ||
type = "uncached" | ||
base = "0x40000000" | ||
[[adsp.mem_alias]] | ||
type = "cached" | ||
base = "0xA0000000" | ||
|
||
[cse] | ||
partition_name = "ADSP" | ||
[[cse.entry]] | ||
name = "ADSP.man" | ||
offset = "0x5c" | ||
length = "0x464" | ||
[[cse.entry]] | ||
name = "ADSP.met" | ||
offset = "0x4c0" | ||
length = "0x70" | ||
[[cse.entry]] | ||
name = "ADSP" | ||
offset = "0x540" | ||
length = "0x0" # calculated by rimage | ||
|
||
[css] | ||
|
||
[signed_pkg] | ||
name = "ADSP" | ||
partition_usage = "0x23" | ||
[[signed_pkg.module]] | ||
name = "ADSP.met" | ||
|
||
[adsp_file] | ||
[[adsp_file.comp]] | ||
base_offset = "0x2000" | ||
|
||
[fw_desc.header] | ||
name = "ADSPFW" | ||
load_offset = "0x40000" | ||
|
||
[module] | ||
count = 1 | ||
|
||
[[module.entry]] | ||
name = "SMATEST" | ||
uuid = "167A961E-8AE4-11EA-89F1-000C29CE1635" | ||
affinity_mask = "0x1" | ||
instance_count = "1" | ||
domain_types = "0" | ||
load_type = "0" | ||
init_config = "1" | ||
module_type = "0xD" | ||
auto_start = "0" | ||
sched_caps = [1, 0x00008000] | ||
|
||
# pin = [dir, type, sample rate, size, container, channel-cfg] | ||
pin = [0, 0, 0xfeef, 0xf, 0xa, 0x45ff, | ||
0, 0, 0xfeef, 0xf, 0xa, 0x45ff, | ||
1, 0, 0xfeef, 0xf, 0xa, 0x45ff] | ||
|
||
# mod_cfg [PAR_0 PAR_1 PAR_2 PAR_3 IS_BYTES CPS IBS OBS MOD_FLAGS CPC OBLS] | ||
mod_cfg = [0, 0, 0, 0, 4096, 1000000, 128, 128, 0, 0, 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters