Pass input directories to dtoc
cover Pass input directories to dtoc
The changes make it possible to pass binman input directories to dtoc. This is useful when not running binman from the directory where the device trees are located.
Paul HENRYS (2):
tools: dtoc: Allow passing optional input directories
tools: binman: Pass a list of input directory to EnsureCompiled()
tools/binman/control.py | 9 ++++++--- tools/dtoc/fdt_util.py | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 tools: dtoc: Allow passing optional input directories
An optional list of input directories can be passed to EnsureCompiled() which allows to pass a list of directories where input files can be searched.
--- tools/dtoc/fdt_util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/dtoc/fdt_util.py +3 -1
@@ -55,7 +55,7 @@ def fdt_cells_to_cpu(val, cells): out = out << 32 | fdt32_to_cpu(val[1]) return out -def EnsureCompiled(fname, tmpdir=None, capture_stderr=False): +def EnsureCompiled(fname, tmpdir=None, capture_stderr=False, indir=[]): """Compile an fdt .dts source file into a .dtb binary blob if needed. Args:
@@ -63,6 +63,7 @@ def EnsureCompiled(fname, tmpdir=None, capture_stderr=False): left alone tmpdir: Temporary directory for output files, or None to use the tools-module output directory + indir: List of directories where input files can be found Returns: Filename of resulting .dtb file
@@ -79,6 +80,7 @@ def EnsureCompiled(fname, tmpdir=None, capture_stderr=False): dtb_output = tools.get_output_filename('source.dtb') search_paths = [os.path.join(os.getcwd(), 'include')] + search_paths += indir root, _ = os.path.splitext(fname) cc, args = tools.get_target_compile_tool('cc') args += ['-E', '-P', '-x', 'assembler-with-cpp', '-D__ASSEMBLY__']
Signature · 1 line
2.43.0
Re: [PATCH 1/2] tools: dtoc: Allow passing optional input directories
Hi Paul,
Quoted 8 lines · Paul HENRYS
An optional list of input directories can be passed to
EnsureCompiled()which allows to pass a list of directories where input files can be searched.Signed-off-by Paul HENRYS <[email protected]>--- tools/dtoc/fdt_util.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/dtoc/fdt_util.py def fdt_cells_to_cpu(val, cells): · line 58
Quoted 11 lines
tools/dtoc/fdt_util.py +1
-1@@ -55,7 +55,7 @@ def fdt_cells_to_cpu(val, cells): out = out << 32 | fdt32_to_cpu(val[1]) return out -def EnsureCompiled(fname, tmpdir=None, capture_stderr=False): +def EnsureCompiled(fname, tmpdir=None, capture_stderr=False, indir=[]):
Just a note that I tend to avoid a default argument of a list, since I understood that changing indir within this function will apparently change the default from then on. I've never tried it though, so could be wrong. So I tend to use None as a default rather than a list or dict.
Quoted 20 lines
tools/dtoc/fdt_util.py +2
-1"""Compile an fdt .dts source file into a .dtb binary blob if needed. Args:@@ -63,6 +63,7 @@ def EnsureCompiled(fname, tmpdir=None, capture_stderr=False): left alone tmpdir: Temporary directory for output files, or None to use the tools-module output directory + indir: List of directories where input files can be found Returns: Filename of resulting .dtb file@@ -79,6 +80,7 @@ def EnsureCompiled(fname, tmpdir=None, capture_stderr=False): dtb_output = tools.get_output_filename('source.dtb') search_paths = [os.path.join(os.getcwd(), 'include')] + search_paths += indir root, _ = os.path.splitext(fname) cc, args = tools.get_target_compile_tool('cc') args += ['-E', '-P', '-x', 'assembler-with-cpp', '-D__ASSEMBLY__'] --
Quoted 2 lines
2.43.0
[..]
Regards,
Simon
PATCH 2/2 tools: binman: Pass a list of input directory to EnsureCompiled()
In reply to Paul HENRYSInput directories can be passed to binman using the '-I' option and those input directories are now also passed to 'dtc' when run by binman.
--- tools/binman/control.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tools/binman/control.py +6 -3
@@ -526,7 +526,7 @@ def _RemoveTemplates(parent): if node.name.startswith('template'): node.Delete() -def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded): +def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded, indir): """Prepare the images to be processed and select the device tree This function:
@@ -543,6 +543,7 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded): use_expanded: True to use expanded versions of entries, if available. So if 'u-boot' is called for, we use 'u-boot-expanded' instead. This is needed if update_fdt is True (although tests may disable it) + indir: List of directories where input files can be found Returns: OrderedDict of images:
@@ -558,7 +559,9 @@ def PrepareImagesAndDtbs(dtb_fname, select_images, update_fdt, use_expanded): # Get the device tree ready by compiling it and copying the compiled # output into a file in our output directly. Then scan it for use # in binman. - dtb_fname = fdt_util.EnsureCompiled(dtb_fname) + if indir is None: + indir = [] + dtb_fname = fdt_util.EnsureCompiled(dtb_fname, indir=indir) fname = tools.get_output_filename('u-boot.dtb.out') tools.write_file(fname, tools.read_file(dtb_fname)) dtb = fdt.FdtScan(fname)
@@ -846,7 +849,7 @@ def Binman(args): state.SetThreads(args.threads) images = PrepareImagesAndDtbs(dtb_fname, args.image, - args.update_fdt, use_expanded) + args.update_fdt, use_expanded, args.indir) if args.test_section_timeout: # Set the first image to timeout, used in testThreadTimeout()
Signature · 1 line
2.43.0
Re: [PATCH 2/2] tools: binman: Pass a list of input directory to EnsureCompiled()
Quoted 9 lines · Paul HENRYS
Input directories can be passed to binman using the '-I' option and those input directories are now also passed to 'dtc' when run by binman.
Signed-off-by Paul HENRYS <[email protected]>--- tools/binman/control.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)