lopper: assists: fix Zephyr combined-DTS overlay phandle merge - #800
lopper: assists: fix Zephyr combined-DTS overlay phandle merge#800dbingi-amd wants to merge 1 commit into
Conversation
Lopper core overlay APIs resolve global fixups but not plugin __local_fixups__, so in-fragment phandles (e.g. phy-handle) could point at the wrong node after merging board overlay into the domain tree. Handle this in zephyr_board_dt only: remap nested unwrapped fragment paths, defer prop resolve until children are merged, and apply __symbols__/__local_fixups__ post-merge fixup. Signed-off-by: Bingi Dinesh kumar <dineshkumar.bingi@amd.com>
|
@kedareswararao, please review the changes |
|
Thanks @dbingi-amd — your diagnosis was right: after #790 merges the board
So on this PR you can drop the parallel path entirely — Thanks again — these keep surfacing gaps worth fixing at the root. |
PR #790 merges the board .dtsi from the SDT folder directly into the domain tree inside Lopper, instead of emitting a separate board.overlay for Zephyr to apply later. That combined-DTS approach is correct, but it exposed a gap in what the existing lopper overlay APIs actually resolve.
When dtc compiles a plugin overlay, it records two kinds of phandle fixups. Global fixups under fixups (often 0xffffffff pointing at a fragment target like &gem0) are handled by _unwrap_overlay_tree() and _resolve_overlay_fixups(). Local fixups
under local_fixups (references to labels defined inside the same fragment, like phy-handle = <&phy0>) are not handled by those APIs at all.
That did not matter in the old flow, because Zephyr applied the overlay at build time and dtc fixed both kinds in one pass. After #790, the merge happens inside Lopper on an in-memory domain tree, so local fixups never get applied unless we do it explicitly. On top of that, _merge_node_into_tree() resolves properties immediately after copy, which can bind wrong phandle values before the tree is ready, and _unwrap_overlay_tree() leaves nested overlay children on /fragment@N/overlay/... paths instead of real domain paths.
This commit adds three helpers in zephyr_board_dt.py and reorders _merge_plugin_overlay() so local phandles are fixed after merge, without changing Lopper core.
overlay phandle numbers with the correct domain phandles — only for properties dtc flagged in local_fixups, so unrelated integer properties are left alone.