[PATCH] tools: binman: fix changes not being written to source.dtb
Moteen Shah
m-shah at ti.com
Wed Jul 8 08:16:56 CEST 2026
Hey Anshul,
Thanks for the patch
On 07/07/26 16:14, Anshul Dalal wrote:
> 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.
>
> Signed-off-by: Anshul Dalal <anshuld at ti.com>
> ---
> tools/binman/control.py | 3 +++
> tools/binman/ftest.py | 41 ++++++++++++++++++++++-------------------
> 2 files changed, 25 insertions(+), 19 deletions(-)
>
> diff --git a/tools/binman/control.py b/tools/binman/control.py
> index 816f7c1eba26..a500e735f6ce 100644
> --- a/tools/binman/control.py
> +++ b/tools/binman/control.py
> @@ -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)
> return images
>
> def CheckForProblems(image):
> diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
> index bf98b268ac15..d02ab3a87a5f 100644
> --- a/tools/binman/ftest.py
> +++ b/tools/binman/ftest.py
> @@ -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,
> - "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
> +
> + 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 <anshuld at ti.com>
>
More information about the U-Boot
mailing list