aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dtb-merge
blob: 29e7f85b6d474f9fac7da20bc5da7941e28e9000 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl
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;

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);