]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
binman: fit: Refine handling of devicetrees for OF_UPSTREAM
authorSimon Glass <sjg@chromium.org>
Mon, 26 Aug 2024 19:11:37 +0000 (13:11 -0600)
committerSimon Glass <sjg@chromium.org>
Thu, 26 Sep 2024 10:40:30 +0000 (12:40 +0200)
With OF_UPSTREAM the dts files are in an SoC-specific subdirectory,
meaning that the resulting dtb files all end up in a similar
subdirectory.

We don't want the subdirectory name to appear as a node name in the FIT,
so handle this as a special case.

Also the default devicetree may have a directory-name prefix, so handle
that when searching through the available devicetree files.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/etype/fit.py
tools/binman/ftest.py

index 96f4fdf33339feb1b5bc796658a44df6a15f098c..0abe1c78c432a6ea00a45b883c8a648defd3a049 100644 (file)
@@ -600,13 +600,17 @@ class Entry_fit(Entry_section):
                 if val.startswith('@'):
                     if not self._fdts:
                         return
-                    if not self._fit_default_dt:
+                    default_dt = self._fit_default_dt
+                    if not default_dt:
                         self.Raise("Generated 'default' node requires default-dt entry argument")
-                    if self._fit_default_dt not in self._fdts:
-                        self.Raise(
-                            f"default-dt entry argument '{self._fit_default_dt}' "
-                            f"not found in fdt list: {', '.join(self._fdts)}")
-                    seq = self._fdts.index(self._fit_default_dt)
+                    if default_dt not in self._fdts:
+                        if self._fdt_dir:
+                            default_dt = os.path.basename(default_dt)
+                        if default_dt not in self._fdts:
+                            self.Raise(
+                                f"default-dt entry argument '{self._fit_default_dt}' "
+                                f"not found in fdt list: {', '.join(self._fdts)}")
+                    seq = self._fdts.index(default_dt)
                     val = val[1:].replace('DEFAULT-SEQ', str(seq + 1))
                     fsw.property_string(pname, val)
                     return
@@ -711,8 +715,9 @@ class Entry_fit(Entry_section):
                         # Add data for 'images' nodes (but not 'config')
                         if depth == 1 and in_images:
                             if fdt_phase:
+                                leaf = os.path.basename(fdt_fname)
                                 phase_fname = tools.get_output_filename(
-                                    f'{fdt_fname}-{fdt_phase}.dtb')
+                                    f'{leaf}-{fdt_phase}.dtb')
                                 self._run_fdtgrep(fname, fdt_phase, phase_fname)
                                 data = tools.read_file(phase_fname)
                             else:
index 3f05559501dd4fdbf8d83a974d0175297452c7a5..b133c76188cfa781a5aa65409fa0593421c36da6 100644 (file)
@@ -4183,7 +4183,8 @@ class TestFunctional(unittest.TestCase):
         data = self._DoReadFile('172_scp.dts')
         self.assertEqual(SCP_DATA, data[:len(SCP_DATA)])
 
-    def CheckFitFdt(self, dts='170_fit_fdt.dts', use_fdt_list=True):
+    def CheckFitFdt(self, dts='170_fit_fdt.dts', use_fdt_list=True,
+                    default_dt=None):
         """Check an image with an FIT with multiple FDT images"""
         def _CheckFdt(seq, expected_data):
             """Check the FDT nodes
@@ -4227,6 +4228,8 @@ class TestFunctional(unittest.TestCase):
         }
         if use_fdt_list:
             entry_args['of-list'] = 'test-fdt1 test-fdt2'
+        if default_dt:
+            entry_args['default-dt'] = default_dt
         data = self._DoReadFileDtb(
             dts,
             entry_args=entry_args,
@@ -7633,6 +7636,16 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         finally:
             os.chdir(old_dir)
 
+    def testFitFdtListDirDefault(self):
+        """Test an FIT fit,fdt-list-dir where the default DT in is a subdir"""
+        old_dir = os.getcwd()
+        try:
+            os.chdir(self._indir)
+            self.CheckFitFdt('333_fit_fdt_dir.dts', False,
+                             default_dt='rockchip/test-fdt2')
+        finally:
+            os.chdir(old_dir)
+
     def testFitFdtCompat(self):
         """Test an image with an FIT with compatible in the config nodes"""
         entry_args = {