[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/bach/build.bach/tools/cfgGen_module.pl b/src/bach/build.bach/tools/cfgGen_module.pl
new file mode 100644
index 0000000..cc0caf7
--- /dev/null
+++ b/src/bach/build.bach/tools/cfgGen_module.pl
@@ -0,0 +1,171 @@
+#!/usr/bin/perl -w
+
+#use strict;
+use lib "tools/perl";
+use Spreadsheet::ParseExcel;
+my $CUSTOMDIR;
+my $OUTDIR;
+my $OUTSUBDIR;
+my $TYPE;
+
+if ($#ARGV < 2) {
+ print "Usage: \n";
+ print " cfgGen_module.pl CUSTOMDIR TYPE OUTDIR\n";
+ exit -1;
+}
+
+$CUSTOMDIR = $ARGV[0]."/".$ARGV[1];
+$TYPE = $ARGV[1];
+$OUTDIR = $ARGV[2];
+$OUTSUBDIR = $ARGV[2]."/".$ARGV[1];
+
+if (!-e $CUSTOMDIR) {
+ print $CUSTOMDIR," not exist!\n";
+ exit -1;
+}
+
+if ($TYPE eq "nf") {
+ genall();
+}
+if ($TYPE eq "sf") {
+ genall();
+}
+if ($TYPE eq "bf") {
+ genall();
+}
+
+sub genall {
+ my $FileName = "$CUSTOMDIR/flash_partition.xls";
+ my $parser = Spreadsheet::ParseExcel->new();
+ my $workbook = $parser->parse($FileName);
+
+ die $parser->error(), ".\n" if ( !defined $workbook );
+
+ for my $worksheet ( $workbook->worksheets() ) {
+ if ($worksheet->{Name} =~ m/HOST/) {
+ gen_host_file($worksheet);
+ }
+ if ($worksheet->{Name} =~ m/FDA/) {
+ gen_fda_cfg($worksheet);
+ }
+ if ($worksheet->{Name} =~ m/SPI/) {
+ gen_spi_cfg();
+ }
+ }
+}
+
+sub gen_host_file {
+ my ($worksheet) = @_;
+ my ( $row_min, $row_max ) = $worksheet->row_range();
+ my ( $col_min, $col_max ) = $worksheet->col_range();
+
+ my $FILE = "$OUTSUBDIR/HOST.cfg";
+
+ open (MYFILE, ">$FILE");
+
+ for my $row ( $row_min .. $row_max ) {
+ next if ($row == 0);
+ my ($name, $file, $size, $type);
+ for my $col ( $col_min .. $col_max ) {
+ # Return the cell object at $row and $col
+ my $cell = $worksheet->get_cell( $row, $col );
+ next unless $cell;
+ if ($col == 0) {
+ $name = $cell->value();
+ }
+ if ($col == 1) {
+ $file = $cell->value();
+ }
+ if ($col == 2) {
+ $size = $cell->value();
+ }
+ if ($col == 3) {
+ $type = $cell->value();
+ }
+ }
+
+ my $new_file;
+ my $new_size;
+ if ($type =~ m/yaffs/) {
+ #$new_file = $file;
+ #$new_file =~ s/\..*$/\.oob/;
+ $new_file = lc($name).".oob";
+ $new_size = $size*(1024+32)*(1024+32);
+ system("dd if=/dev/zero bs=$new_size count=1 2>/dev/null | tr '\\000' '\\377' > $OUTSUBDIR/$new_file");
+ if ("$file" ne "__NODL") {
+ system("dd if=$OUTDIR/$file of=$OUTSUBDIR/$new_file conv=notrunc 2>/dev/null");
+ }
+ print MYFILE "name: ", $name, "\n";
+ print MYFILE "file: ", $new_file, "\n";
+ }
+ if ($type =~ m/raw/) {
+ $new_file = lc($name).".raw";
+ $new_size = $size*1024*1024;
+ system("dd if=/dev/zero bs=$new_size count=1 2>/dev/null | tr '\\000' '\\377' > $OUTSUBDIR/$new_file");
+ if ("$file" ne "__NODL") {
+ system("dd if=$OUTDIR/$file of=$OUTSUBDIR/$new_file conv=notrunc 2>/dev/null");
+ }
+ print MYFILE "name: ", $name, "\n";
+ print MYFILE "file: ", $new_file, "\n";
+ }
+ if ($type =~ m/reserved/) {
+ $new_file = lc($name).".raw";
+ $new_size = $size*1024*1024;
+ system("dd if=/dev/zero bs=$new_size count=1 2>/dev/null | tr '\\000' '\\377' > $OUTSUBDIR/$new_file");
+ print MYFILE "name: ", $name, "\n";
+ print MYFILE "file: ", $new_file, "\n";
+ }
+
+ }
+
+ print MYFILE "\n";
+ close (MYFILE);
+}
+
+sub gen_fda_cfg {
+ my ($worksheet) = @_;
+ my ( $row_min, $row_max ) = $worksheet->row_range();
+ my ( $col_min, $col_max ) = $worksheet->col_range();
+
+ my $FILE = "$OUTSUBDIR/FDA.cfg";
+
+ open (MYFILE, ">$FILE");
+ print MYFILE "############################################################################################################\n";
+ print MYFILE "#\n";
+ print MYFILE "# Android Region Setting\n";
+ print MYFILE "#\n";
+ print MYFILE "############################################################################################################\n";
+ print MYFILE "linux_region:\n";
+ print MYFILE " partitions:\n";
+
+ for my $row ( $row_min .. $row_max ) {
+ next if ($row == 0);
+ print MYFILE " - partition:\n";
+ for my $col ( $col_min .. $col_max ) {
+
+ # Return the cell object at $row and $col
+ my $cell = $worksheet->get_cell( $row, $col );
+ next unless $cell;
+
+ if ($col == 0) {
+ print MYFILE " name: ", $cell->value(), "\n";
+ }
+ if ($col == 1) {
+ print MYFILE " file: ", $cell->value(), "\n";
+ my $file = $cell->value();
+ if ( -e "$OUTDIR/$file" ) {
+ system("cp -f $OUTDIR/$file $OUTSUBDIR/");
+ }
+ }
+ if ($col == 2) {
+ print MYFILE " address: ", $cell->value(), "\n";
+ }
+ if ($col == 3) {
+ print MYFILE " type: ", $cell->value(), "\t\t#raw, yaffs, yaffs2\n";
+ }
+ }
+ }
+ print MYFILE "\n";
+ close (MYFILE);
+}
+