-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Description
Describe the bug
There seems to be something wrong with edtlib in that it does not respect default values for the #address-cells and #size-cells properties in binding files, given this part of a binding:
properties:
"#address-cells":
type: int
default: 1
"#size-cells":
type: int
default: 1
and the following piece of dts:
flash0: memory@0 {
compatible = "soc-nv-flash";
reg = <0x00000000 DT_SIZE_K(1024)>;
ranges = <0x0 0x00000000 DT_SIZE_K(1024)>;
status = "okay";
#address-cells = <1>;
#size-cells = <1>;
storage_partition: partition@f8000 {
compatible = "zephyr,xip-partition";
label = "storage";
reg = <0x000f8000 0x00008000>;
ranges = <0x0 0x000f8000 0x00008000>;
#address-cells = <1>;
#size-cells = <1>;
blah_partition: subpartition@0 {
compatible = "zephyr,xip-partition";
reg = <0x00000000 0x00003000>;
#if 0
#address-cells = <1>;
#size-cells = <1>;
#endif
};
the above will emit the following error:
devicetree error: 'ranges' property in <Node /memory@0/partition@f8000 in /tmp/aa/zephyr/dts/vendor/nordic/nrf52840_partition.dtsi:43> has length 12, which is not evenly divisible by 16 (= 4*(<#address-cells> (= 2) + <#address-cells for parent> (= 1) + <#size-cells> (= 1))). Note that #*-cells properties come either from the parent node or from the controller (in the case of 'interrupts').
which doesn't make sense, the default values for address and size fields should be getting applied from the binding, if the #if 0 part is changed to #if 1 then it seems to work. Inside of edtlib seems to be this code https://github.com/zephyrproject-rtos/zephyr/blob/main/scripts/dts/python-devicetree/src/devicetree/edtlib.py#L1878 which seems to skip the default value and either loads an explicit value or uses the default value of 2. If that is changed to use something like
if self._binding is not None and '#address-cells' in self._binding.prop2specs and self._binding.prop2specs['#address-cells'].default:
child_address_cells = self._binding.prop2specs['#address-cells'].default
then that error vanishes, but a new one appears:
devicetree error: 'reg' property in <Node /memory@0/partition@f8000/subpartition@0 in /tmp/aa/zephyr/dts/vendor/nordic/nrf52840_partition.dtsi:53> has length 8, which is not evenly divisible by 12 (= 4*(<#address-cells> (= 2) + <#size-cells> (= 1))). Note that #*-cells properties come either from the parent node or from the controller (in the case of 'interrupts').
which, again, does not make sense, because it should be using the values from the binding which is 1 and 1, not 2 and 1
Regression
- This is a regression.
Steps to reproduce
No response
Relevant log output
Impact
Annoyance – Minor irritation; no significant impact on usability or functionality.
Environment
No response
Additional Context
No response