diff options
author | Tero Kristo <t-kristo@ti.com> | 2021-02-11 15:17:55 -0600 |
---|---|---|
committer | Suman Anna <s-anna@ti.com> | 2021-02-26 11:19:36 -0600 |
commit | b10c5ae998c5eea1328f095af5f0130f77862202 (patch) | |
tree | 9383fca5ef9d9470819afa0f2b675576cdbb0956 /scripts/dtb-merge | |
parent | 09d4597614453296665035dd3791f11fcd888b38 (diff) |
scripts/dtb-merge: Add tool for merging DTB overlays
Add tool for merging DT overlays into single DTB file. This parses
the TI specific dtb-merge.cfg file to find out the configuration
needed for the DTBs. Once matching config is found, passes the data
to fdtoverlay tool to merge everything into a single .dtb.
Signed-off-by: Tero Kristo <t-kristo@ti.com>
[s-anna@ti.com: add license header]
Signed-off-by: Suman Anna <s-anna@ti.com>
Diffstat (limited to 'scripts/dtb-merge')
-rwxr-xr-x | scripts/dtb-merge | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/dtb-merge b/scripts/dtb-merge new file mode 100755 index 000000000000..3689fabd1cb1 --- /dev/null +++ b/scripts/dtb-merge @@ -0,0 +1,55 @@ +#!/usr/bin/perl +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2018-2021 Texas Instruments Incorporated - https://www.ti.com/ +# +# Author: Tero Kristo <t-kristo@ti.com> +# + +use strict; + +my $debug = 0; + +die "Usage: $ARGV[0] <srctree> <objtree> <dtb-file> <overlay-tool> <config-dir>\n" + if @ARGV != 5; + +my $srctree = shift @ARGV; +my $objtree = shift @ARGV; +my $dtb_tgt = shift @ARGV; +my $fdtoverlay = shift @ARGV; +my $dir = shift @ARGV; + +print " DTC-M $dtb_tgt\n"; + +open my $in, "<$srctree/$dir/dtb-merge.cfg" or die "Unable to open $srctree/$dir/dtb-merge.cfg"; + +my $tgt; +my @dtbs; + +# Generate target config string +if ($dtb_tgt =~ /\/([^\/]+)\.dtb$/) { + $tgt = $1; +} + +foreach (<$in>) { + if (/$tgt: (.*)$/) { + @dtbs = split " ", $1; + } +} + +close $in; + +die "No config found for $tgt\n" if !@dtbs; + +print "Found config for $tgt:\n" if $debug; + +# Generate the merged dtb file +my $cmd = "$fdtoverlay"; +$cmd .= " -v" if $debug; +$cmd .= " -o $dtb_tgt -i"; + +foreach my $dtb (@dtbs) { + $cmd .= " $objtree/$dir/$dtb"; +} + +exit system($cmd); |