raspberrypi / utils

A collection of scripts and simple applications
BSD 3-Clause "New" or "Revised" License
134 stars 41 forks source link

Fix the fixups #54

Closed pelwell closed 8 months ago

pelwell commented 8 months ago

Some more recent features in the overlay handling cause problems when applying overlays at runtime. Fragments that target other fragments, and the ability to embed label references into parameters/overrides, both add the ability to copy phandles around. Phandles that represent unresolved symbols require fixups (literally __fixups__), so when one of these phandles is copied or overwritten then the fixups also have to be updated. Failure to do so results in kernel complaints about invalid phandles, or parameters appearing not to do anything.

This PR adds logic to track the movement of phandles. It is not completely foolproof - writing a string over a phandle won't be spotted, for example - but it should work in sensible use cases.

See: https://github.com/raspberrypi/linux/issues/5652

pelwell commented 8 months ago

See also https://forums.raspberrypi.com/posting.php?mode=reply&t=358339.

pelwell commented 8 months ago

To test this PR:

sudo apt install cmake device-tree-compiler libfdt-dev
git clone https://github.com/raspberrypi/utils.git
cd utils
git fetch origin pull/54/head
git checkout -b pr54 FETCH_HEAD
cmake .
cd dtmerge
make
sudo make install

(You can skip the last line if you don't mind specifying the path to the executable, e.g. sudo ./dtoverlay -l.

pelwell commented 8 months ago

Merging, given that the existing dtoverlay code fails easily and this updated version has passed all the tests thrown at it.