Skip to content
Draft
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
3 changes: 3 additions & 0 deletions app/boards/intel_adsp/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ config L3_HEAP
config ZEPHYR_DP_SCHEDULER
default y

config DP_TO_DP_BIND
default y

config ZEPHYR_NATIVE_DRIVERS
default y

Expand Down
32 changes: 30 additions & 2 deletions app/boards/intel_adsp_ace30_ptl.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ CONFIG_FORMAT_CONVERT_HIFI3=n
CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING=m
CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MOCK=y
CONFIG_COMP_STFT_PROCESS=y
CONFIG_SOF_STAGING=y
CONFIG_COMP_KPB=y
CONFIG_CPP=y
CONFIG_STD_CPP17=y
# tflmcly (stock keyword model) is not yet GNU-toolchain-clean on aphid
# (undefined sof_ut_log/__assert_no_args/abs); not required by mww, which
# builds its own independent TFLM lib copy. Disabled here to unblock the
# aphid mww LLEXT build.
CONFIG_COMP_TENSORFLOW=n
CONFIG_COMP_MFCC=y
CONFIG_COMP_MWW=m
CONFIG_AMS=y
CONFIG_STACK_SIZE_EDF=32768
CONFIG_COMP_VOLUME=y
CONFIG_COMP_GAIN=y

# SOF / infrastructure
CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL=n
Expand All @@ -29,7 +44,7 @@ CONFIG_COLD_STORE_EXECUTE_DRAM=y
CONFIG_INTEL_MODULES=y
CONFIG_LIBRARY_AUTH_SUPPORT=y
CONFIG_LIBRARY_MANAGER=y
CONFIG_LIBRARY_BASE_ADDRESS=0xa0688000
CONFIG_LIBRARY_BASE_ADDRESS=0xa0700000
CONFIG_LIBRARY_BUILD_LIB=y
CONFIG_LIBRARY_DEFAULT_MODULAR=y

Expand All @@ -43,11 +58,19 @@ CONFIG_SOF_LOG_LEVEL_INF=y
CONFIG_DEBUG_COREDUMP_BACKEND_INTEL_ADSP_MEM_WINDOW=y
CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN=y
CONFIG_COUNTER=y
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=32768
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=32768
CONFIG_LLEXT=y
CONFIG_LLEXT_STORAGE_WRITABLE=y
CONFIG_LLEXT_EXPERIMENTAL=y
CONFIG_LLEXT_EDK=n

# Default LLEXT metadata heap (CONFIG_LLEXT_HEAP_SIZE, 8 KB) is sized for
# small extensions with few STB_GLOBAL-only exported symbols. mww.llext
# links in TFLM, whose template-instantiated vtables/typeinfo are emitted
# STB_WEAK -- now included in ext->sym_tab after the llext_load.c fix -- and
# blows past 8 KB (Failed to allocate extension symbol table, ret -12).
CONFIG_LLEXT_HEAP_SIZE=256
CONFIG_MODULES=y

# Zephyr / device drivers
Expand Down Expand Up @@ -83,3 +106,8 @@ CONFIG_SOF_USERSPACE_PROXY=y
CONFIG_MAX_THREAD_BYTES=3

CONFIG_MAX_DOMAIN_PARTITIONS=32

# Debug: get faulting virtual address for openmodules-load panic
# CONFIG_XTENSA_ADSP_FATAL_BREADCRUMB_DATA_VADDR=y
CONFIG_SYS_HEAP_RUNTIME_STATS=y
CONFIG_SOF_ZEPHYR_HEAP_SIZE=0x80000
14 changes: 13 additions & 1 deletion app/boards/intel_adsp_cavs25.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@ CONFIG_COMP_MFCC=y
CONFIG_COMP_MULTIBAND_DRC=y
CONFIG_COMP_VOLUME_WINDOWS_FADE=y
CONFIG_FORMAT_CONVERT_HIFI3=n
CONFIG_SOF_STAGING=y
CONFIG_CPP=y
CONFIG_STD_CPP17=y
# cavs2.5 has no LLEXT/module-manager support (see CONFIG_LIBRARY_MANAGER=n
# below), so build mww in statically rather than as an LLEXT module.
CONFIG_COMP_MWW=y
CONFIG_COMP_MWW_DEBUG_TRACE=y
CONFIG_COMP_MWW_MODEL_FROM_CONTROL=y
CONFIG_STACK_SIZE_EDF=32768
CONFIG_PCM_CONVERTER_FORMAT_S16LE=y
CONFIG_PCM_CONVERTER_FORMAT_S24LE=y
CONFIG_PCM_CONVERTER_FORMAT_S32LE=y
CONFIG_PCM_CONVERTER_FORMAT_S24_3LE=y

# SOF / infrastructure
CONFIG_AMS=y
CONFIG_IDC_TIMEOUT_US=100000
CONFIG_P4WQ_INIT_STAGE_EARLY=y
CONFIG_LP_MEMORY_BANKS=1
CONFIG_HP_MEMORY_BANKS=30

Expand All @@ -35,7 +46,8 @@ CONFIG_SOF_LOG_LEVEL_INF=y
# choices have to be selected per board.
CONFIG_DEBUG_COREDUMP_BACKEND_INTEL_ADSP_MEM_WINDOW=y
CONFIG_DEBUG_COREDUMP_MEMORY_DUMP_MIN=y
CONFIG_HEAP_MEM_POOL_SIZE=8192
CONFIG_HEAP_MEM_POOL_SIZE=32768
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=32768

# Zephyr / device drivers
CONFIG_DAI_INIT_PRIORITY=70
Expand Down
1 change: 1 addition & 0 deletions app/llext_relocatable.conf
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
CONFIG_LLEXT_TYPE_ELF_RELOCATABLE=y
CONFIG_LLEXT_EXPORT_BUILTINS_BY_SLID=y
3 changes: 3 additions & 0 deletions scripts/llext_offset_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def get_elf_size(elf_name):
if section.header['sh_addr'] + section.header['sh_size'] > end:
end = section.header['sh_addr'] + section.header['sh_size']

if start == 0xffffffff:
return 0

size = end - start

return size
Expand Down
67 changes: 47 additions & 20 deletions scripts/tensorflow-clone.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2025 Intel Corporation. All rights reserved.
# Copyright(c) 2025-2026 Intel Corporation. All rights reserved.

# fail immediately on any errors
set -e
Expand All @@ -14,8 +14,7 @@ declare -a REPOS=(
"https://github.com/google/ruy"
)

# Commit ID to check for (optional). If specified, the script will update
# the repository if this commit ID is not found. Leave empty to skip.
# Commit ID to check out. If specified, the script will checkout this commit.
declare -a COMMIT_ID=(
"cdedfb1a1044eb774915de21b63a1b6aa93276f6"
"e86d97b6237f88ab5925c0b41e3e3589a1560d86"
Expand All @@ -25,7 +24,10 @@ declare -a COMMIT_ID=(
)

# Directory where repositories will be cloned/updated.
BASE_DIR="$HOME/work/sof" # Or any other desired location
# Default to the parent directory containing the SOF workspace.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SOF_PARENT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
BASE_DIR="${1:-"$SOF_PARENT_DIR"}"

# Function to check if a commit ID exists in a repository
check_commit() {
Expand All @@ -36,40 +38,65 @@ check_commit() {
return 0 # Skip check if no commit ID is provided
fi

if ! git -C "$repo_dir" rev-parse --quiet --verify "$commit_id" >/dev/null 2>&1; then
return 1 # Commit ID not found
if ! git -C "$repo_dir" rev-parse --quiet --verify "$commit_id^{commit}" >/dev/null 2>&1; then
return 1 # Commit ID not found locally
else
return 0 # Commit ID found
return 0 # Commit ID found locally
fi
}


# Function to update the repository
update_repo() {
local repo_dir="$1"
echo "Updating repository: $repo_dir"
git -C "$repo_dir" fetch --all
git -C "$repo_dir" pull
git -C "$repo_dir" fetch --all --tags --prune
}

# Function to checkout the required commit ID
checkout_commit() {
local repo_dir="$1"
local commit_id="$2"
local repo_name="$3"

if [ -z "$commit_id" ]; then
return 0
fi

local current_commit
current_commit=$(git -C "$repo_dir" rev-parse HEAD)

local target_commit
target_commit=$(git -C "$repo_dir" rev-parse "$commit_id^{commit}")

if [ "$current_commit" != "$target_commit" ]; then
echo "Checking out $commit_id in $repo_name..."
git -C "$repo_dir" checkout -q "$commit_id"
else
echo "Repository $repo_name is already at commit $commit_id."
fi
}

# Main script logic
mkdir -p "$BASE_DIR"

for ((i = 0; i < ${#REPOS[@]}; i++)); do
echo "Counter: $i, Value: ${REPOS[i]}"
repo_url=${REPOS[i]}

repo_name=$(basename "$repo_url" .git) # Extract repo name
repo_url="${REPOS[i]}"
commit_id="${COMMIT_ID[i]}"
repo_name=$(basename "$repo_url" .git)
repo_dir="$BASE_DIR/$repo_name"

if [ ! -d "$repo_dir" ]; then
echo "Cloning repository: $repo_url"
echo "=== [$((i + 1))/${#REPOS[@]}] $repo_name ==="

if [ ! -d "$repo_dir/.git" ]; then
echo "Cloning repository: $repo_url -> $repo_dir"
git clone "$repo_url" "$repo_dir" || { echo "git clone failed for $repo_url"; exit 1; }
elif ! check_commit "$repo_dir" "${COMMIT_ID[i]}"; then
fi

if ! check_commit "$repo_dir" "$commit_id"; then
update_repo "$repo_dir"
else
echo "Repository $repo_name is up to date."
fi

checkout_commit "$repo_dir" "$commit_id" "$repo_name"
done

echo "All repositories processed."
echo "All repositories processed and checked out to required commits."
4 changes: 4 additions & 0 deletions scripts/xtensa-build-zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,10 @@ def install_lib(platform, sof_output_dir, abs_build_dir, platform_wconfig):
symlink_or_copy(lib_install_dir, lib_name,
lib_dir, alias_libname)

for uuid in lib_uuids.get(key, []):
linkname = uuid + '.bin'
symlink_or_copy(lib_install_dir, lib_name, sof_lib_dir, linkname)

def install_platform(platform, sof_output_dir, platf_build_environ, platform_wconfig):

# Keep in sync with caller
Expand Down
3 changes: 3 additions & 0 deletions src/audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD)
if(CONFIG_COMP_MFCC)
add_subdirectory(mfcc)
endif()
if(CONFIG_COMP_MWW)
add_subdirectory(microwakeword)
endif()
if(CONFIG_COMP_MIXER)
add_subdirectory(mixer)
endif()
Expand Down
1 change: 1 addition & 0 deletions src/audio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ rsource "eq_iir/Kconfig"
rsource "google/Kconfig"
rsource "igo_nr/Kconfig"
rsource "mfcc/Kconfig"
rsource "microwakeword/Kconfig"
rsource "mixer/Kconfig"
rsource "mixin_mixout/Kconfig"
rsource "module_adapter/Kconfig"
Expand Down
78 changes: 67 additions & 11 deletions src/audio/buffers/audio_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,16 @@
int audio_buffer_attach_secondary_buffer(struct sof_audio_buffer *buffer, bool at_input,
struct sof_audio_buffer *secondary_buffer)
{
#if CONFIG_DP_TO_DP_BIND
/* check per-side: allow attaching on both sides (needed for DP-to-DP) */
if (at_input && buffer->secondary_buffer_sink)
return -EINVAL;
if (!at_input && buffer->secondary_buffer_source)
return -EINVAL;
#else
if (buffer->secondary_buffer_sink || buffer->secondary_buffer_source)
return -EINVAL;
#endif

/* secondary buffer must share audio params with the primary buffer */
secondary_buffer->audio_stream_params = buffer->audio_stream_params;
Expand All @@ -48,6 +56,56 @@ int audio_buffer_sync_secondary_buffer(struct sof_audio_buffer *buffer, size_t l
struct sof_source *data_src;
struct sof_sink *data_dst;

#if CONFIG_DP_TO_DP_BIND
if (buffer->secondary_buffer_sink && buffer->secondary_buffer_source) {
/*
* DP-to-DP case: both secondary buffers present.
* Data flows: input_ring_buffer -> comp_buffer -> output_ring_buffer
*
* This buffer is visited twice during each LL cycle:
* - In the input loop (sink DP module via comp_dev_for_each_producer) with
* limit == SIZE_MAX. In a DP-to-DP connection, input to sink DP is fed
* via output_ring_buffer; the intermediate comp_buffer transfer is driven
* by the output loop. Hence, this call is a no-op.
* - In the output loop (source DP module via comp_dev_for_each_consumer) with
* limit == source_get_min_available(downstream). This executes the 2-step
* cascade with rate-limiting properly applied on the output transfer.
*/
if (limit == SIZE_MAX)
return 0;

/*
* Step 1: copy from input secondary buffer to primary (comp_buffer).
* No limit on input side - copy all available data.
*/
data_src = audio_buffer_get_source(buffer->secondary_buffer_sink);
data_dst = &buffer->_sink_api;

size_t data_available = source_get_data_available(data_src);
size_t free_size = sink_get_free_size(data_dst);
size_t to_copy = MIN(data_available, free_size);

err = source_to_sink_copy(data_src, data_dst, true, to_copy);
if (err)
return err;

/*
* Step 2: copy from primary (comp_buffer) to output secondary buffer.
* Apply the limit to the output side to control how much data
* is made available to the downstream DP module per LL cycle.
*/
data_src = &buffer->_source_api;
data_dst = audio_buffer_get_sink(buffer->secondary_buffer_source);

data_available = source_get_data_available(data_src);
free_size = sink_get_free_size(data_dst);
to_copy = MIN(MIN(data_available, free_size), limit);

err = source_to_sink_copy(data_src, data_dst, true, to_copy);
return err;
}
#endif

if (buffer->secondary_buffer_sink) {
/*
* audio_buffer sink API is shadowed, that means there's a secondary_buffer
Expand Down Expand Up @@ -203,18 +261,16 @@ uint32_t audio_buffer_sink_get_lft(struct sof_sink *sink)
return us_in_buffer;

/*
* TODO, Currently there's no DP to DP connection
* >>> the code below is never accessible and won't work because of cache incoherence <<<
*
* to make DP to DP connection possible:
* NOTE: DP-to-DP connections are now supported via dual ring_buffers
* attached as secondary buffers on both sides of a comp_buffer.
* Data cascades: ring_buf_src -> comp_buffer -> ring_buf_sink
* with syncing during each LL cycle.
*
* 1) module data must be ALWAYS located in non cached memory alias, allowing
* cross core access to params like period (needed below) and calling
* module_get_deadline for the next module, regardless of cores the modules are
* running on
* 2) comp_buffer must be removed from all pipeline code, replaced with a generic abstract
* class audio_buffer - allowing using comp_buffer and ring_buffer without current
* "hybrid buffer" solution
* Future improvements:
* 1) module data should be in non-cached memory alias for reliable
* cross-core access to params like period and deadlines
* 2) comp_buffer should be replaced with generic audio_buffer
* throughout pipeline code (Pipeline 2.0)
*/
}

Expand Down
13 changes: 12 additions & 1 deletion src/audio/buffers/ring_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ static inline void ring_buffer_writeback_shared(struct ring_buffer *ring_buffer,
dcache_writeback_region(ptr, size);
}


/**
* @brief remove the queue from the list, free memory
*/
Expand All @@ -101,6 +100,18 @@ static void ring_buffer_free(struct sof_audio_buffer *audio_buffer)

sof_ctx_free(alloc, (__sparse_force void *)ring_buffer->_data_buffer);
sof_ctx_free(alloc, ring_buffer);

#if CONFIG_DP_TO_DP_BIND
/*
* For DP-to-DP binding: matches vregion_get() in ipc_comp_connect()
* for each ring_buffer. Releases the DP module's virtual memory region
* and frees the module allocation context when the refcount reaches zero.
*/
if (alloc && alloc->vreg) {
if (!vregion_put(alloc->vreg))
rfree(alloc);
}
#endif
}

static void ring_buffer_reset(struct sof_audio_buffer *audio_buffer)
Expand Down
2 changes: 1 addition & 1 deletion src/audio/mfcc/mfcc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ int mfcc_stft_process(struct processing_module *mod, struct mfcc_comp_data *cd)
/* Use hop counter for frame numbering (independent of VAD enable) */
state->header.frame_number = state->hop_count;

/* Run VAD on the mel log spectrum (available in both modes) */
/* Run VAD on the scaled mel log spectrum (available in both modes) */
if (config->enable_vad) {
mfcc_vad_update(&cd->vad, state->mel_log_32);

Expand Down
Loading
Loading