diff options
author | Simon Glass <sjg@chromium.org> | 2021-03-21 08:24:38 +0300 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2021-03-27 06:26:48 +0300 |
commit | f6176651bc1bad080d0512aeeed438e8763b951b (patch) | |
tree | 819268d4ffefbc31e14f0a771088b2cc003e3ffc /tools/dtoc/test_fdt.py | |
parent | 76677dd2b230ffb6d83e4acb85d2e7473ab74a4f (diff) | |
download | u-boot-f6176651bc1bad080d0512aeeed438e8763b951b.tar.xz |
dtoc: Support adding subnodes alongside existing ones
So far we have only needed to add subnodes to empty notds, so have not
had to deal with ordering. However this feature is needed for binman's
expanded nodes, since there may be another node in the same section.
While libfdt adds new properties after existing properties, it adds new
subnodes before existing subnodes. This means that we must reorder the
nodes in the cached version, so that the ordering remains consistent.
Update the sync implementation to sync existing subnodes first, then
add new ones, then tidy up the ordering in the cached version. Update the
test to cover this behaviour.
Also improve the comment about property syncing while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/test_fdt.py')
-rwxr-xr-x | tools/dtoc/test_fdt.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/dtoc/test_fdt.py b/tools/dtoc/test_fdt.py index 1e66e1bc35..49a2853f07 100755 --- a/tools/dtoc/test_fdt.py +++ b/tools/dtoc/test_fdt.py @@ -237,6 +237,22 @@ class TestNode(unittest.TestCase): """Test adding various subnode and properies""" node = self.dtb.GetNode('/i2c@0') + # Add one more node next to the pmic one + sn1 = node.AddSubnode('node-one') + sn1.AddInt('integer-a', 12) + sn1.AddInt('integer-b', 23) + + # Sync so that everything is clean + self.dtb.Sync(auto_resize=True) + + # Add two subnodes next to pmic and node-one + sn2 = node.AddSubnode('node-two') + sn2.AddInt('integer-2a', 34) + sn2.AddInt('integer-2b', 45) + + sn3 = node.AddSubnode('node-three') + sn3.AddInt('integer-3', 123) + # Add a property to the node after i2c@0 to check that this is not # disturbed by adding a subnode to i2c@0 orig_node = self.dtb.GetNode('/orig-node') |