scripts: reset LLEXT VMA accumulators before each west build#10793
Open
lgirdwood wants to merge 1 commit into
Open
scripts: reset LLEXT VMA accumulators before each west build#10793lgirdwood wants to merge 1 commit into
lgirdwood wants to merge 1 commit into
Conversation
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>
Contributor
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.
Comment on lines
+990
to
+992
| 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") |
kv2019i
approved these changes
May 20, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.