Skip to content

Commit 55b2645

Browse files
lrgirdwolgirdwood
authored andcommitted
scripts: delete module_size accumulator before each west build
llext_offset_calc.py uses module_size as a persistent counter across cmake custom-command invocations. Running ninja more than once without a pristine build causes the counter to accumulate, placing all pre-linked LLEXT ELF VMAs outside the valid 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. Delete module_size before every west build invocation so VMA assignment always starts from CONFIG_LIBRARY_BASE_ADDRESS. llext_offset_calc.py already handles a missing file as size=0 (OSError except clause), so deletion is the simplest reset. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
1 parent 9638823 commit 55b2645

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

scripts/xtensa-build-zephyr.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,22 @@ def build_platforms():
986986
env=platf_build_environ, sof_log_env=True)
987987
print()
988988

989+
# Delete the LLEXT VMA accumulator file before every build.
990+
# llext_offset_calc.py uses module_size as a persistent counter
991+
# across cmake custom-command invocations. If ninja is invoked
992+
# more than once without a pristine rebuild this counter keeps
993+
# accumulating, pushing pre-linked VMAs beyond the valid LLEXT
994+
# virtual region and causing sys_mm_drv_map_region() to fail
995+
# silently at runtime (IPC4_MOD_NOT_INITIALIZED error 104).
996+
# llext_offset_calc.py already handles a missing file as size=0,
997+
# so deletion is the simplest and most reliable reset.
998+
zephyr_build_dir = pathlib.Path(abs_build_dir) / "zephyr"
999+
if zephyr_build_dir.is_dir():
1000+
acc_path = zephyr_build_dir / "module_size"
1001+
if acc_path.is_file():
1002+
acc_path.unlink()
1003+
print(f"Deleted LLEXT VMA accumulator: {acc_path}")
1004+
9891005
# Build
9901006
try:
9911007
execute_command(build_cmd, cwd=west_top, env=platf_build_environ, sof_log_env=True)

0 commit comments

Comments
 (0)