mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-05 04:36:13 +02:00
binman: fit: Allow providing FDT filenames in a directory
In some cases the list of available FDT files is not available in an entryarg. Provide an option to point to a directory containing them instead. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
7081a94ea4
commit
9db7a3a432
@ -857,6 +857,13 @@ The top-level 'fit' node supports the following special properties:
|
||||
|
||||
fit,fdt-list-val = "dtb1", "dtb2";
|
||||
|
||||
fit,fdt-list-dir
|
||||
As an alternative to fit,fdt-list the list of device tree files
|
||||
can be provided as a directory. Each .dtb file in the directory is
|
||||
processed, , e.g.::
|
||||
|
||||
fit,fdt-list-dir = "arch/arm/dts
|
||||
|
||||
Substitutions
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
|
||||
@ -5,7 +5,9 @@
|
||||
|
||||
"""Entry-type module for producing a FIT"""
|
||||
|
||||
import glob
|
||||
import libfdt
|
||||
import os
|
||||
|
||||
from binman.entry import Entry, EntryArg
|
||||
from binman.etype.section import Entry_section
|
||||
@ -87,6 +89,13 @@ class Entry_fit(Entry_section):
|
||||
|
||||
fit,fdt-list-val = "dtb1", "dtb2";
|
||||
|
||||
fit,fdt-list-dir
|
||||
As an alternative to fit,fdt-list the list of device tree files
|
||||
can be provided as a directory. Each .dtb file in the directory is
|
||||
processed, , e.g.::
|
||||
|
||||
fit,fdt-list-dir = "arch/arm/dts
|
||||
|
||||
Substitutions
|
||||
~~~~~~~~~~~~~
|
||||
|
||||
@ -352,6 +361,7 @@ class Entry_fit(Entry_section):
|
||||
self._fit = None
|
||||
self._fit_props = {}
|
||||
self._fdts = None
|
||||
self._fdt_dir = None
|
||||
self.mkimage = None
|
||||
self._priv_entries = {}
|
||||
self._loadables = []
|
||||
@ -368,7 +378,14 @@ class Entry_fit(Entry_section):
|
||||
if fdts is not None:
|
||||
self._fdts = fdts.split()
|
||||
else:
|
||||
self._fdts = fdt_util.GetStringList(self._node, 'fit,fdt-list-val')
|
||||
self._fdt_dir = fdt_util.GetString(self._node, 'fit,fdt-list-dir')
|
||||
if self._fdt_dir:
|
||||
indir = tools.get_input_filename(self._fdt_dir)
|
||||
fdts = glob.glob('*.dtb', root_dir=indir)
|
||||
self._fdts = [os.path.splitext(f)[0] for f in sorted(fdts)]
|
||||
else:
|
||||
self._fdts = fdt_util.GetStringList(self._node,
|
||||
'fit,fdt-list-val')
|
||||
|
||||
self._fit_default_dt = self.GetEntryArgsOrProps([EntryArg('default-dt',
|
||||
str)])[0]
|
||||
|
||||
@ -4181,8 +4181,8 @@ class TestFunctional(unittest.TestCase):
|
||||
data = self._DoReadFile('172_scp.dts')
|
||||
self.assertEqual(SCP_DATA, data[:len(SCP_DATA)])
|
||||
|
||||
def testFitFdt(self):
|
||||
"""Test an image with an FIT with multiple FDT images"""
|
||||
def CheckFitFdt(self, dts='170_fit_fdt.dts', use_fdt_list=True):
|
||||
"""Check an image with an FIT with multiple FDT images"""
|
||||
def _CheckFdt(seq, expected_data):
|
||||
"""Check the FDT nodes
|
||||
|
||||
@ -4221,11 +4221,12 @@ class TestFunctional(unittest.TestCase):
|
||||
self.assertEqual('fdt-%d' % seq, fnode.props['fdt'].value)
|
||||
|
||||
entry_args = {
|
||||
'of-list': 'test-fdt1 test-fdt2',
|
||||
'default-dt': 'test-fdt2',
|
||||
}
|
||||
if use_fdt_list:
|
||||
entry_args['of-list'] = 'test-fdt1 test-fdt2'
|
||||
data = self._DoReadFileDtb(
|
||||
'170_fit_fdt.dts',
|
||||
dts,
|
||||
entry_args=entry_args,
|
||||
extra_indirs=[os.path.join(self._indir, TEST_FDT_SUBDIR)])[0]
|
||||
self.assertEqual(U_BOOT_NODTB_DATA, data[-len(U_BOOT_NODTB_DATA):])
|
||||
@ -4244,6 +4245,10 @@ class TestFunctional(unittest.TestCase):
|
||||
_CheckConfig(1, TEST_FDT1_DATA)
|
||||
_CheckConfig(2, TEST_FDT2_DATA)
|
||||
|
||||
def testFitFdt(self):
|
||||
"""Test an image with an FIT with multiple FDT images"""
|
||||
self.CheckFitFdt()
|
||||
|
||||
def testFitFdtMissingList(self):
|
||||
"""Test handling of a missing 'of-list' entry arg"""
|
||||
with self.assertRaises(ValueError) as e:
|
||||
@ -7605,6 +7610,10 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
|
||||
self.assertIn("Invalid U-Boot phase 'bad-phase': Use tpl/vpl/spl",
|
||||
str(e.exception))
|
||||
|
||||
def testFitFdtListDir(self):
|
||||
"""Test an image with an FIT with FDT images using fit,fdt-list-dir"""
|
||||
self.CheckFitFdt('333_fit_fdt_dir.dts', False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
58
tools/binman/test/333_fit_fdt_dir.dts
Normal file
58
tools/binman/test/333_fit_fdt_dir.dts
Normal file
@ -0,0 +1,58 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
/ {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
binman {
|
||||
u-boot {
|
||||
};
|
||||
fit {
|
||||
description = "test-desc";
|
||||
#address-cells = <1>;
|
||||
fit,fdt-list-dir = "fdts";
|
||||
|
||||
images {
|
||||
kernel {
|
||||
description = "Vanilla Linux kernel";
|
||||
type = "kernel";
|
||||
arch = "ppc";
|
||||
os = "linux";
|
||||
compression = "gzip";
|
||||
load = <00000000>;
|
||||
entry = <00000000>;
|
||||
hash-1 {
|
||||
algo = "crc32";
|
||||
};
|
||||
hash-2 {
|
||||
algo = "sha1";
|
||||
};
|
||||
u-boot {
|
||||
};
|
||||
};
|
||||
@fdt-SEQ {
|
||||
description = "fdt-NAME.dtb";
|
||||
type = "flat_dt";
|
||||
compression = "none";
|
||||
hash {
|
||||
algo = "sha256";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
configurations {
|
||||
default = "@config-DEFAULT-SEQ";
|
||||
@config-SEQ {
|
||||
description = "conf-NAME.dtb";
|
||||
firmware = "uboot";
|
||||
loadables = "atf";
|
||||
fdt = "fdt-SEQ";
|
||||
};
|
||||
};
|
||||
};
|
||||
u-boot-nodtb {
|
||||
};
|
||||
};
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user