Skip to content

Commit 00621a5

Browse files
committed
scripts: reset LLEXT VMA accumulators before each west build
llext_link_helper.py uses openmod_module_size and module_size as persistent counters to assign pre-linked VMAs to LLEXT ELFs. Running ninja more than once without a pristine build causes these files to accumulate across invocations. The second run doubles the counter values, placing all ELF VMAs outside the valid LLEXT virtual region [CONFIG_LIBRARY_BASE_ADDRESS, +CONFIG_LIBRARY_REGION_SIZE). When pre_located=true the LLEXT loader uses the ELF sh_addr VMAs directly as physical load addresses. sys_mm_drv_map_region() silently fails for out-of-range addresses, so the module is never registered. The kernel then receives IPC4_MOD_NOT_INITIALIZED (error 104) for every module init IPC. Reset both accumulator files to 0 before every west build invocation so VMA assignment always starts from CONFIG_LIBRARY_BASE_ADDRESS. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 2896e23 commit 00621a5

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

scripts/xtensa-build-zephyr.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,20 @@ def build_platforms():
979979
env=platf_build_environ, sof_log_env=True)
980980
print()
981981

982+
# Reset the LLEXT VMA accumulator files before every build.
983+
# llext_link_helper.py uses openmod_module_size and module_size as
984+
# persistent counters across cmake custom-command invocations. If
985+
# ninja is invoked more than once without a pristine rebuild these
986+
# counters keep accumulating, pushing pre-linked VMAs beyond the
987+
# valid LLEXT virtual region and causing sys_mm_drv_map_region() to
988+
# fail silently at runtime (IPC4_MOD_NOT_INITIALIZED error 104).
989+
zephyr_build_dir = pathlib.Path(abs_build_dir) / "zephyr"
990+
for acc_file in ("openmod_module_size", "module_size"):
991+
acc_path = zephyr_build_dir / acc_file
992+
if acc_path.is_file():
993+
acc_path.write_text("0\n")
994+
print(f"Reset LLEXT VMA accumulator: {acc_path}")
995+
982996
# Build
983997
try:
984998
execute_command(build_cmd, cwd=west_top, env=platf_build_environ, sof_log_env=True)

0 commit comments

Comments
 (0)