summaryrefslogtreecommitdiff
path: root/tools/binman/ftest.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2024-07-20 11:49:47 +0100
committerSimon Glass <sjg@chromium.org>2024-07-29 08:42:18 -0600
commit57902e6941a0e914313afe50104fd0660ab47839 (patch)
tree560ff0f1dd43f5c1bbfe80bd9661867630c64f93 /tools/binman/ftest.py
parent9db7a3a4325d1b67287cdc2db2d80c5fc1e7cb76 (diff)
binman: fit: Write the compatible string to configuration
FIT allows the FDT's root-node compatible string to be placed in a configuration node to simplify and speed up finding the best match for booting. Add a new property to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/ftest.py')
-rw-r--r--tools/binman/ftest.py55
1 files changed, 48 insertions, 7 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 6e1e1e9b50b..d930e353faf 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -7490,6 +7490,24 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
err,
"Image '.*' is missing external blobs and is non-functional: .*")
+ def SetupAlternateDts(self):
+ """Compile the .dts test files for alternative-fdt
+
+ Returns:
+ tuple:
+ str: Test directory created
+ list of str: '.bin' files which we expect Binman to create
+ """
+ testdir = TestFunctional._MakeInputDir('dtb')
+ dtb_list = []
+ for fname in glob.glob(f'{self.TestFile("alt_dts")}/*.dts'):
+ tmp_fname = fdt_util.EnsureCompiled(fname, testdir)
+ base = os.path.splitext(os.path.basename(fname))[0]
+ dtb_list.append(base + '.bin')
+ shutil.move(tmp_fname, os.path.join(testdir, base + '.dtb'))
+
+ return testdir, dtb_list
+
def CheckAlternates(self, dts, phase, xpl_data):
"""Run the test for the alterative-fdt etype
@@ -7503,13 +7521,7 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
key: str filename
value: Fdt object
"""
- testdir = TestFunctional._MakeInputDir('dtb')
- dtb_list = []
- for fname in glob.glob(f'{self.TestFile("alt_dts")}/*.dts'):
- tmp_fname = fdt_util.EnsureCompiled(fname, testdir)
- base = os.path.splitext(os.path.basename(fname))[0]
- dtb_list.append(base + '.bin')
- shutil.move(tmp_fname, os.path.join(testdir, base + '.dtb'))
+ dtb_list = self.SetupAlternateDts()[1]
entry_args = {
f'{phase}-dtb': '1',
@@ -7614,6 +7626,35 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
"""Test an image with an FIT with FDT images using fit,fdt-list-dir"""
self.CheckFitFdt('333_fit_fdt_dir.dts', False)
+ def testFitFdtCompat(self):
+ """Test an image with an FIT with compatible in the config nodes"""
+ entry_args = {
+ 'of-list': 'model1 model2',
+ 'default-dt': 'model2',
+ }
+ testdir, dtb_list = self.SetupAlternateDts()
+ data = self._DoReadFileDtb(
+ '334_fit_fdt_compat.dts', use_real_dtb=True, update_dtb=True,
+ entry_args=entry_args, extra_indirs=[testdir])[0]
+
+ fit_data = data[len(U_BOOT_DATA):-len(U_BOOT_NODTB_DATA)]
+
+ fit = fdt.Fdt.FromData(fit_data)
+ fit.Scan()
+
+ cnode = fit.GetNode('/configurations')
+ self.assertIn('default', cnode.props)
+ self.assertEqual('config-2', cnode.props['default'].value)
+
+ for seq in range(1, 2):
+ name = f'config-{seq}'
+ fnode = fit.GetNode('/configurations/%s' % name)
+ self.assertIsNotNone(fnode)
+ self.assertIn('compatible', fnode.props.keys())
+ expected = 'one' if seq == 1 else 'two'
+ self.assertEqual(f'u-boot,model-{expected}',
+ fnode.props['compatible'].value)
+
if __name__ == "__main__":
unittest.main()