Re: patching of device tree from layer

Rudolf J Streif


On 10/26/22 17:59, ron.eggler@... wrote:


I'm new here and relatively new to working with Yocto (creating my own layers anyways). I'm working on developing a SOM platform based on Renesas RZ series of MPUs.
Welcome. When asking a question on a mailing list it is always advisable to put all relevant information pertaining to the question into the email and be specific about what you think the problem is. It alleviates people from having to collect additional data to understand the problem.

I've followed the guide on Digikey by Shawn Hymel to learn about device tree patching ( I assume many of you know about it as well.
Not necessarily. There are so many different devices and there's probably nobody who knows them all. :)

It does a good job in describing how to add changes in a dts file. In the example, a i2c5 node is added in the dts, overwriting what had been defined in the original dtsi file and I'm doubting the cleanliness of it.
It is good practice to override definitions from a dtsi in a dts. That is the entire idea of the device tree include file which is what the 'i' suggests. The idea is to use dtsi to define device nodes that are shared between different platforms. Some of them are always enabled since all platforms use them. Others, like the i2c bus in question, may only be used on some devices and hence they are disabled. Some nodes might only be templates and the platform's dts needs to complete them if they are used.

In this particular case it would have been better to simply add

&i2c5 {
   status = "ok";

to the dts as the other definitions were already present as such in the dtsi stm32mp15xx-dkx.dtsi

Would it not be better, to patch the node in the dtsi file and add the required changes there instead of adding them to the dts file essentially overwriting what was set previously? I imagine this will essentially lead to two nodes being defined with the same name, the latter just overwriting the former, is that so?
Nope, that is the idea of using the & before the device node name. All of the &'s and the node's root definition will be merged by the device tree compiler into the resulting device node definition. In this case the i2c5 node's root definition is in stm32mp151.dtsi which is included by stm32mp153.dts which is in turn included by stm32mp157.dtsi which is included by stm32157d-dk1.dts. (I might be wrong with the details of the chain as just browsed through it quickly but you get the idea.)

How would one go about patching the dtsi and making sure that the patch is applied before ther file is included?
I don't recommend doing this but the example explains how to patch the dts file. It works the same way for the dtsi.

Thank you all,


Rudolf J Streif

Join to automatically receive all group messages.