Skip to contentSkip to conversation

tools: binman: fix changes not being written to source.dtb

PATCH In review Anshul Dalal 3 participants 7 messages Jul 7 – Jul 15

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: binman: fix changes not being written to source.dtb

In the current setup the changes done to the dtb by binman such as bootph propagation are only made to the intermediary *.dtb.out but not the final dtb.

This means the final dtb that's in *-binman.dtsi never gets the required changes applied. Therefore this patch fixes the behaviour by writing to the supplied dtb before exiting with a modified test to catch any future regressions.

---
 tools/binman/control.py |  3 +++
 tools/binman/ftest.py   | 41 ++++++++++++++++++++++-------------------
 2 files changed, 25 insertions(+), 19 deletions(-)
tools/binman/control.py +3 -0
index 816f7c1eba26..a500e735f6ce 100644
@@ -677,6 +677,9 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind
         dtb_item.Sync(auto_resize=True)
         dtb_item.Pack()
         dtb_item.Flush()
+
+    # Copy the intermediary dtb ('u-boot.dtb.out') to the dtb supplied to binman
+    tools.write_file(dtb_fname, dtb.GetContents())
     return images
 
 def CheckForProblems(image):
tools/binman/ftest.py +22 -19

47 lines not on this page · raw message

---
base-commit: a18265f1ccb7a272721ed4286ed3b5a6182ff424
change-id: 20260707-binman_bootph_fix-16a618090934

Best regards,

Signature · 1 line
Anshul Dalal <[email protected]>
#1 lore raw

Hey Anshul,
Thanks for the patch

Quoted 20 lines · Anshul Dalal

In the current setup the changes done to the dtb by binman such as bootph propagation are only made to the intermediary *.dtb.out but not the final dtb.

This means the final dtb that's in *-binman.dtsi never gets the required changes applied. Therefore this patch fixes the behaviour by writing to the supplied dtb before exiting with a modified test to catch any future regressions.

---
  tools/binman/control.py |  3 +++
  tools/binman/ftest.py   | 41 ++++++++++++++++++++++-------------------
  2 files changed, 25 insertions(+), 19 deletions(-)
tools/binman/control.py +0 -0
index 816f7c1eba26..a500e735f6ce 100644

tools/binman/control.py def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind · line 682

Quoted 6 lines
tools/binman/control.py +3 -0
@@ -677,6 +677,9 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind
          dtb_item.Sync(auto_resize=True)
          dtb_item.Pack()
          dtb_item.Flush()
+
+    # Copy the intermediary dtb ('u-boot.dtb.out') to the dtb supplied to binman
+    tools.write_file(dtb_fname, dtb.GetContents())

The write happens after AddMissingProperties() has run, so source.dtb /u-boot.dtb ends up with zero-valued offset/size/image-pos placeholders for every binman entry node - properties that only get their real values later in SetCalculatedProperties(), which only ever writes to u-boot.dtb.out.

For the bootph use case this is harmless since nothing reads those layout properties from u-boot.dtb. I think a cleaner placement is right after the scan_and_prop_bootph block, before AddMissingProperties() is called:

      if scan_and_prop_bootph(dtb.GetRoot()):
          dtb.Sync(True)

  +   dtb.Sync(True)
  +   dtb.Pack()
  +   tools.write_file(dtb_fname, dtb.GetContents())

      images = _ReadImageDesc(node, use_expanded)

Quoted 29 lines
tools/binman/control.py +0 -0
      return images
 
  def CheckForProblems(image):
tools/binman/ftest.py +0 -18
index bf98b268ac15..d02ab3a87a5f 100644
@@ -8532,25 +8532,28 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
          """Test that bootph-* properties are propagated correctly to supernodes"""
          _, _, _, out_dtb_fname = self._DoReadFileDtb(
                  'fdt/bootph_prop.dts', use_real_dtb=True, update_dtb=True)
-        dtb = fdt.Fdt(out_dtb_fname)
-        dtb.Scan()
-        root = dtb.GetRoot()
-        parent_node = root.FindNode('dummy-parent')
-        subnode1 = parent_node.FindNode('subnode-1')
-        subnode2 = subnode1.FindNode('subnode-2')
-        subnode3 = subnode1.FindNode('subnode-3')
-        subnode4 = subnode3.FindNode('subnode-4')
-
-        self.assertIn('bootph-some-ram', subnode1.props,
-                      "Child node is missing 'bootph-some-ram' property")
-        self.assertIn('bootph-all', subnode1.props,
-                      "Child node is missing 'bootph-all' property")
-        self.assertIn('bootph-some-ram', parent_node.props,
-                      "Parent node is missing 'bootph-some-ram' property")
-        self.assertIn('bootph-all', parent_node.props,
-                      "Parent node is missing 'bootph-all' property")
-        self.assertEqual(len(subnode4.props), 0,

tools/binman/ftest.py fdt fdtmap Extract the devicetree blob from the fdtmap · line 8543

Quoted 10 lines
tools/binman/ftest.py +9 -1
-                        "subnode shouldn't have any properties")
+        def assert_eq(fname: str):
+            dtb = fdt.Fdt(fname)
+            dtb.Scan()
+            root = dtb.GetRoot()
+            parent_node = root.FindNode('dummy-parent')
+            subnode1 = parent_node.FindNode('subnode-1')
+            subnode2 = subnode1.FindNode('subnode-2')
+            subnode3 = subnode1.FindNode('subnode-3')
+            subnode4 = subnode3.FindNode('subnode-4')

Nit: I think subnode 2 is not being used anywhere.

Regards,
Moteen

Quoted 25 lines
tools/binman/ftest.py +13 -1
+
+            self.assertIn('bootph-some-ram', subnode1.props,
+                          "Child node is missing 'bootph-some-ram' property")
+            self.assertIn('bootph-all', subnode1.props,
+                          "Child node is missing 'bootph-all' property")
+            self.assertIn('bootph-some-ram', parent_node.props,
+                          "Parent node is missing 'bootph-some-ram' property")
+            self.assertIn('bootph-all', parent_node.props,
+                          "Parent node is missing 'bootph-all' property")
+            self.assertEqual(len(subnode4.props), 0,
+                            "subnode shouldn't have any properties")
+        assert_eq(out_dtb_fname)
+        assert_eq(tools.get_output_filename('source.dtb'))
 
  if __name__ == "__main__":
      unittest.main()
 
---

base-commit: a18265f1ccb7a272721ed4286ed3b5a6182ff424
change-id: 20260707-binman_bootph_fix-16a618090934

Best regards,
--
Anshul Dalal <[email protected]>

#2 lore raw
In reply to Anshul Dalal

Hi Anshul,

Quoted 11 lines · Anshul Dalal

tools: binman: fix changes not being written to source.dtb

In the current setup the changes done to the dtb by binman such as bootph propagation are only made to the intermediary *.dtb.out but not the final dtb.

This means the final dtb that's in *-binman.dtsi never gets the required changes applied. Therefore this patch fixes the behaviour by writing to the supplied dtb before exiting with a modified test to catch any future regressions.

Quoted 5 lines

tools/binman/control.py | 3 +++

 tools/binman/ftest.py   | 41 ++++++++++++++++++++++-------------------
 2 files changed, 25 insertions(+), 19 deletions(-)

Please can you spell out the concrete symptom? What breaks in a real build when u-boot.dtb doesn't carry the bootph propagation - which stage reads it, what does it expect to find, and what goes wrong when it isn't there? The *-binman.dtsi reference is confusing since a .dtsi is a source file, not something written to.

Also please rewrite in imperative present tense: 'Write the modified dtb back to dtb_fname so that ...' rather than 'this patch fixes the behaviour by ...'

tools/binman/control.py def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind · line 682

Quoted 8 lines
tools/binman/control.py +3 -0
@@ -677,6 +677,9 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind
         dtb_item.Sync(auto_resize=True)
         dtb_item.Pack()
         dtb_item.Flush()
+
+    # Copy the intermediary dtb ('u-boot.dtb.out') to the dtb supplied to binman
+    tools.write_file(dtb_fname, dtb.GetContents())

This is updating an input file...really not keen on that! The updated dtb should already be written into the final image created by Binman.

Regards,
Simon

#3 lore raw
Quoted 20 lines · Simon Glass

Hi Anshul,

Quoted 11 lines · Anshul Dalal

tools: binman: fix changes not being written to source.dtb

In the current setup the changes done to the dtb by binman such as bootph propagation are only made to the intermediary *.dtb.out but not the final dtb.

This means the final dtb that's in *-binman.dtsi never gets the required changes applied. Therefore this patch fixes the behaviour by writing to the supplied dtb before exiting with a modified test to catch any future regressions.

Quoted 5 lines

tools/binman/control.py | 3 +++

 tools/binman/ftest.py   | 41 ++++++++++++++++++++++-------------------
 2 files changed, 25 insertions(+), 19 deletions(-)
Quoted 5 lines

Please can you spell out the concrete symptom? What breaks in a real build when u-boot.dtb doesn't carry the bootph propagation - which stage reads it, what does it expect to find, and what goes wrong when it isn't there? The *-binman.dtsi reference is confusing since a .dtsi is a source file, not something written to.

The actual issue was observed while we were adding support for our a new platform 'AM62l EVM' to U-Boot where the missing bootph properties meant that the parent drivers were not being probed leading to boot failure.

Quoted 4 lines

Also please rewrite in imperative present tense: 'Write the modified dtb back to dtb_fname so that ...' rather than 'this patch fixes the behaviour by ...'

Yeah, the former is more clear. Will fix in the next revision.

Quoted 12 lines

tools/binman/control.py def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind · line 682

Quoted 9 lines
tools/binman/control.py +3 -0
@@ -677,6 +677,9 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind
         dtb_item.Sync(auto_resize=True)
         dtb_item.Pack()
         dtb_item.Flush()
+
+    # Copy the intermediary dtb ('u-boot.dtb.out') to the dtb supplied to binman
+    tools.write_file(dtb_fname, dtb.GetContents())

This is updating an input file...really not keen on that! The updated dtb should already be written into the final image created by Binman.

Perhaps it's an issue with how we're using 'u-boot.dtb'. As I see now, a lot of platforms (including TI's) are using 'u-boot.dtb' as the fdt for U-Boot FIT. Do we not expect the final U-Boot FIT produced in those builds to have this propagation logic applied?

To test things out, I built the am62x_evm_a53 platform and the fdt extracted out of the built u-boot.img lacks proper bootph propagation without this patch applied:

fdtget -t r build/u-boot.img_unsigned /images/fdt-0/ data > extracted.dtb

It makes sense to not modify the input files so then should we change the DTB we use in the u-boot's FIT to 'u-boot.dtb.out' instead of 'u-boot.dtb'?

Quoted 3 lines

Regards,
Simon

#4 lore raw

Hi Anshul,

Quoted 61 lines · Anshul Dalal
Quoted 20 lines · Simon Glass

Hi Anshul,

Quoted 11 lines · Anshul Dalal

tools: binman: fix changes not being written to source.dtb

In the current setup the changes done to the dtb by binman such as bootph propagation are only made to the intermediary *.dtb.out but not the final dtb.

This means the final dtb that's in *-binman.dtsi never gets the required changes applied. Therefore this patch fixes the behaviour by writing to the supplied dtb before exiting with a modified test to catch any future regressions.

Quoted 5 lines

tools/binman/control.py | 3 +++

 tools/binman/ftest.py   | 41 ++++++++++++++++++++++-------------------
 2 files changed, 25 insertions(+), 19 deletions(-)
Quoted 5 lines

Please can you spell out the concrete symptom? What breaks in a real build when u-boot.dtb doesn't carry the bootph propagation - which stage reads it, what does it expect to find, and what goes wrong when it isn't there? The *-binman.dtsi reference is confusing since a .dtsi is a source file, not something written to.

The actual issue was observed while we were adding support for our a new platform 'AM62l EVM' to U-Boot where the missing bootph properties meant that the parent drivers were not being probed leading to boot failure.

Quoted 4 lines

Also please rewrite in imperative present tense: 'Write the modified dtb back to dtb_fname so that ...' rather than 'this patch fixes the behaviour by ...'

Yeah, the former is more clear. Will fix in the next revision.

Quoted 12 lines

tools/binman/control.py def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind · line 682

Quoted 9 lines
tools/binman/control.py +3 -0
@@ -677,6 +677,9 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind
         dtb_item.Sync(auto_resize=True)
         dtb_item.Pack()
         dtb_item.Flush()
+
+    # Copy the intermediary dtb ('u-boot.dtb.out') to the dtb supplied to binman
+    tools.write_file(dtb_fname, dtb.GetContents())

This is updating an input file...really not keen on that! The updated dtb should already be written into the final image created by Binman.

Perhaps it's an issue with how we're using 'u-boot.dtb'. As I see now, a lot of platforms (including TI's) are using 'u-boot.dtb' as the fdt for U-Boot FIT. Do we not expect the final U-Boot FIT produced in those builds to have this propagation logic applied?

To test things out, I built the am62x_evm_a53 platform and the fdt extracted out of the built u-boot.img lacks proper bootph propagation without this patch applied:

Quoted 5 lines

fdtget -t r build/u-boot.img_unsigned /images/fdt-0/ data > extracted.dtb

It makes sense to not modify the input files so then should we change the DTB we use in the u-boot's FIT to 'u-boot.dtb.out' instead of 'u-boot.dtb'?

Possibly, but are you using Binman to create the FIT? If so it should use the updated FDT. This might be a hole in how Binman works?

Regards,
Simon

#5 lore raw

Hi Simon,

Quoted 62 lines · Simon Glass
Quoted 61 lines · Anshul Dalal
Quoted 20 lines · Simon Glass

Hi Anshul,

Quoted 11 lines · Anshul Dalal

tools: binman: fix changes not being written to source.dtb

In the current setup the changes done to the dtb by binman such as bootph propagation are only made to the intermediary *.dtb.out but not the final dtb.

This means the final dtb that's in *-binman.dtsi never gets the required changes applied. Therefore this patch fixes the behaviour by writing to the supplied dtb before exiting with a modified test to catch any future regressions.

Quoted 5 lines

tools/binman/control.py | 3 +++

 tools/binman/ftest.py   | 41 ++++++++++++++++++++++-------------------
 2 files changed, 25 insertions(+), 19 deletions(-)
Quoted 5 lines

Please can you spell out the concrete symptom? What breaks in a real build when u-boot.dtb doesn't carry the bootph propagation - which stage reads it, what does it expect to find, and what goes wrong when it isn't there? The *-binman.dtsi reference is confusing since a .dtsi is a source file, not something written to.

The actual issue was observed while we were adding support for our a new platform 'AM62l EVM' to U-Boot where the missing bootph properties meant that the parent drivers were not being probed leading to boot failure.

Quoted 4 lines

Also please rewrite in imperative present tense: 'Write the modified dtb back to dtb_fname so that ...' rather than 'this patch fixes the behaviour by ...'

Yeah, the former is more clear. Will fix in the next revision.

Quoted 12 lines

tools/binman/control.py def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind · line 682

Quoted 9 lines
tools/binman/control.py +3 -0
@@ -677,6 +677,9 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind
         dtb_item.Sync(auto_resize=True)
         dtb_item.Pack()
         dtb_item.Flush()
+
+    # Copy the intermediary dtb ('u-boot.dtb.out') to the dtb supplied to binman
+    tools.write_file(dtb_fname, dtb.GetContents())

This is updating an input file...really not keen on that! The updated dtb should already be written into the final image created by Binman.

Perhaps it's an issue with how we're using 'u-boot.dtb'. As I see now, a lot of platforms (including TI's) are using 'u-boot.dtb' as the fdt for U-Boot FIT. Do we not expect the final U-Boot FIT produced in those builds to have this propagation logic applied?

To test things out, I built the am62x_evm_a53 platform and the fdt extracted out of the built u-boot.img lacks proper bootph propagation without this patch applied:

Quoted 9 lines
Quoted 5 lines

fdtget -t r build/u-boot.img_unsigned /images/fdt-0/ data > extracted.dtb

It makes sense to not modify the input files so then should we change the DTB we use in the u-boot's FIT to 'u-boot.dtb.out' instead of 'u-boot.dtb'?

Possibly, but are you using Binman to create the FIT? If so it should use the updated FDT. This might be a hole in how Binman works?

Yes, we are using binman for FIT creation here.

I'm not sure what's the correct behaviour here either, in our binman DTSI for the platform (k3-am625-sk-binman.dtsi) we explicitly set the fdt-0 for the u-boot node as a blob-ext with "u-boot.dtb" as the filename.

Since the same file is given as an input to binman and we don't want to modify the input files we have two options here:

1. If 'u-boot.dtb.out' is known to be the fdt outputted by binman with all the fixes applied, we could just use that instead as the external blob in fdt-0.

2. We could have binman detect a node as 'fdt' and apply the required fixes in-place before spitting out the final 'u-boot.img' FIT.

Regards,
Anshul

#6 lore raw

Hi,

Quoted 83 lines · On Mon, 13 Jul 2026, 23:24 Anshul Dalal, <[email protected]> wrote:

Hi Simon,

Quoted 62 lines · Simon Glass
Quoted 61 lines · Anshul Dalal
Quoted 20 lines · Simon Glass

Hi Anshul,

Quoted 11 lines · Anshul Dalal

tools: binman: fix changes not being written to source.dtb

In the current setup the changes done to the dtb by binman such as bootph propagation are only made to the intermediary *.dtb.out but not the final dtb.

This means the final dtb that's in *-binman.dtsi never gets the required changes applied. Therefore this patch fixes the behaviour by writing to the supplied dtb before exiting with a modified test to catch any future regressions.

Quoted 5 lines

tools/binman/control.py | 3 +++

 tools/binman/ftest.py   | 41 ++++++++++++++++++++++-------------------
 2 files changed, 25 insertions(+), 19 deletions(-)
Quoted 5 lines

Please can you spell out the concrete symptom? What breaks in a real build when u-boot.dtb doesn't carry the bootph propagation - which stage reads it, what does it expect to find, and what goes wrong when it isn't there? The *-binman.dtsi reference is confusing since a .dtsi is a source file, not something written to.

The actual issue was observed while we were adding support for our a new platform 'AM62l EVM' to U-Boot where the missing bootph properties meant that the parent drivers were not being probed leading to boot failure.

Quoted 4 lines

Also please rewrite in imperative present tense: 'Write the modified dtb back to dtb_fname so that ...' rather than 'this patch fixes the behaviour by ...'

Yeah, the former is more clear. Will fix in the next revision.

Quoted 12 lines

tools/binman/control.py def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind · line 682

Quoted 9 lines
tools/binman/control.py +3 -0
@@ -677,6 +677,9 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, ind
         dtb_item.Sync(auto_resize=True)
         dtb_item.Pack()
         dtb_item.Flush()
+
+    # Copy the intermediary dtb ('u-boot.dtb.out') to the dtb supplied to binman
+    tools.write_file(dtb_fname, dtb.GetContents())

This is updating an input file...really not keen on that! The updated dtb should already be written into the final image created by Binman.

Perhaps it's an issue with how we're using 'u-boot.dtb'. As I see now, a lot of platforms (including TI's) are using 'u-boot.dtb' as the fdt for U-Boot FIT. Do we not expect the final U-Boot FIT produced in those builds to have this propagation logic applied?

To test things out, I built the am62x_evm_a53 platform and the fdt extracted out of the built u-boot.img lacks proper bootph propagation without this patch applied:

Quoted 9 lines
Quoted 5 lines

fdtget -t r build/u-boot.img_unsigned /images/fdt-0/ data > extracted.dtb

It makes sense to not modify the input files so then should we change the DTB we use in the u-boot's FIT to 'u-boot.dtb.out' instead of 'u-boot.dtb'?

Possibly, but are you using Binman to create the FIT? If so it should use the updated FDT. This might be a hole in how Binman works?

Yes, we are using binman for FIT creation here.

I'm not sure what's the correct behaviour here either, in our binman DTSI for the platform (k3-am625-sk-binman.dtsi) we explicitly set the fdt-0 for the u-boot node as a blob-ext with "u-boot.dtb" as the filename.

Quoted 6 lines

Since the same file is given as an input to binman and we don't want to modify the input files we have two options here:

1. If 'u-boot.dtb.out' is known to be the fdt outputted by binman with all the fixes applied, we could just use that instead as the external blob in fdt-0.

You should really be using the built-in u-boot-fdt entry type. External blobs are just for blobs built by other projects.

Quoted 3 lines

2. We could have binman detect a node as 'fdt' and apply the required fixes in-place before spitting out the final 'u-boot.img' FIT.

If you use u-boot-fdt then you should not need to do this.

Regards,
Simon