scripts: reset LLEXT VMA accumulators before each west build#10793
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR prevents incorrect pre-linked LLEXT VMAs on incremental rebuilds by resetting the on-disk accumulator counters before each west build, ensuring VMA assignment restarts from CONFIG_LIBRARY_BASE_ADDRESS.
Changes:
- Reset
openmod_module_sizeandmodule_sizeaccumulator files to0before invoking the build command. - Add inline documentation explaining the runtime failure mode prevented by the reset.
| for acc_file in ("openmod_module_size", "module_size"): | ||
| acc_path = zephyr_build_dir / acc_file | ||
| if acc_path.is_file(): |
| for acc_file in ("openmod_module_size", "module_size"): | ||
| acc_path = zephyr_build_dir / acc_file | ||
| if acc_path.is_file(): | ||
| acc_path.write_text("0\n") |
| # valid LLEXT virtual region and causing sys_mm_drv_map_region() to | ||
| # fail silently at runtime (IPC4_MOD_NOT_INITIALIZED error 104). | ||
| zephyr_build_dir = pathlib.Path(abs_build_dir) / "zephyr" | ||
| for acc_file in ("openmod_module_size", "module_size"): |
There was a problem hiding this comment.
I don't see "openmod_module_size" anywhere, where does it come from?
lyakh
left a comment
There was a problem hiding this comment.
need to check where openmod_module_size comes from
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>
looks like an intermediate step during solution search - lets see what copilot thinks of copilot again. |
|
Infra/network error in Intel internal test, needs a rerun. |
ok, passed now. |
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.