rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | #!/usr/bin/perl -w |
| 2 | |
| 3 | #use strict; |
| 4 | use lib "tools/perl"; |
| 5 | use Spreadsheet::ParseExcel; |
| 6 | |
| 7 | my $CUSTOMDIR; |
| 8 | if ($#ARGV == 0) { |
| 9 | $CUSTOMDIR = $ARGV[0]; |
| 10 | } else { |
| 11 | $CUSTOMDIR = "$ENV{'WORKDIR'}/custom/build"; |
| 12 | } |
| 13 | |
| 14 | my $FileName = "$CUSTOMDIR/flash_partition.xls"; |
| 15 | my $parser = Spreadsheet::ParseExcel->new(); |
| 16 | my $workbook = $parser->parse($FileName); |
| 17 | |
| 18 | die $parser->error(), ".\n" if ( !defined $workbook ); |
| 19 | |
| 20 | # Iterate through all worksheets |
| 21 | |
| 22 | system("rm -rf $CUSTOMDIR/*.txt"); |
| 23 | |
| 24 | for my $worksheet ( $workbook->worksheets() ) { |
| 25 | |
| 26 | # Find out the worksheet ranges |
| 27 | my ( $row_min, $row_max ) = $worksheet->row_range(); |
| 28 | my ( $col_min, $col_max ) = $worksheet->col_range(); |
| 29 | |
| 30 | my $FILE = "$CUSTOMDIR/$worksheet->{Name}.txt"; |
| 31 | open (MYFILE, ">$FILE"); |
| 32 | print MYFILE "############################################################################################################\n"; |
| 33 | print MYFILE "#\n"; |
| 34 | print MYFILE "# Layout Setting\n"; |
| 35 | print MYFILE "#\n"; |
| 36 | print MYFILE "############################################################################################################\n"; |
| 37 | |
| 38 | for my $row ( $row_min .. $row_max ) { |
| 39 | next if ($row == 0); |
| 40 | $tmp = $row; |
| 41 | print MYFILE "- partition_index: SYS", $tmp - 1, "\n"; |
| 42 | for my $col ( $col_min .. $col_max ) { |
| 43 | |
| 44 | # Return the cell object at $row and $col |
| 45 | my $cell = $worksheet->get_cell( $row, $col ); |
| 46 | next unless $cell; |
| 47 | |
| 48 | if ($col == 0 ) { print MYFILE " partition_name: ", $cell->value(), "\n"} |
| 49 | if ($col == 1 ) { |
| 50 | |
| 51 | =head |
| 52 | if($cell->value() eq "modem.img") |
| 53 | { |
| 54 | if($ENV{'MODEM_NAME'} eq "modem.img") |
| 55 | { |
| 56 | #Default Value |
| 57 | print MYFILE " file_name: ", $cell->value(), "\n" |
| 58 | }else{ |
| 59 | print MYFILE " file_name: ", $ENV{'MODEM_NAME'}, "\n" |
| 60 | } |
| 61 | }elsif($cell->value() eq "modemc2k.img"){ |
| 62 | if($ENV{'MODEMC2K_NAME'} eq "modemc2k.img") |
| 63 | { |
| 64 | #Default Value |
| 65 | print MYFILE " file_name: ", $cell->value(), "\n" |
| 66 | }else{ |
| 67 | print MYFILE " file_name: ", $ENV{'MODEMC2K_NAME'}, "\n" |
| 68 | } |
| 69 | }elsif($cell->value() eq "dsp.bin"){ |
| 70 | if($ENV{'DSP_NAME'} eq "dsp.bin") |
| 71 | { |
| 72 | #Default Value |
| 73 | print MYFILE " file_name: ", $cell->value(), "\n" |
| 74 | }else{ |
| 75 | print MYFILE " file_name: ", $ENV{'DSP_NAME'}, "\n" |
| 76 | } |
| 77 | }else{ |
| 78 | print MYFILE " file_name: ", $cell->value(), "\n" |
| 79 | } |
| 80 | =cut |
| 81 | print MYFILE " file_name: ", $cell->value(), "\n" |
| 82 | |
| 83 | } |
| 84 | if ($col == 2 ) { print MYFILE " is_download: ", $cell->value(), "\n"} |
| 85 | if ($col == 3 ) { print MYFILE " type: ", $cell->value(), "\n"} |
| 86 | if ($col == 4 ) { print MYFILE " linear_start_addr: ", $cell->value(), "\n"} |
| 87 | if ($col == 5 ) { print MYFILE " physical_start_addr: ", $cell->value(), "\n"} |
| 88 | if ($col == 6 ) { print MYFILE " partition_size: ", $cell->value(), "\n"} |
| 89 | if ($col == 7 ) { print MYFILE " region: ", $cell->value(), "\n"} |
| 90 | if ($col == 8 ) { print MYFILE " storage: ", $cell->value(), "\n"} |
| 91 | if ($col == 9 ) { print MYFILE " boundary_check: ", $cell->value(), "\n"} |
| 92 | if ($col == 10) { print MYFILE " is_reserved: ", $cell->value(), "\n"} |
| 93 | if ($col == 11) { print MYFILE " operation_type: ", $cell->value(), "\n"} |
| 94 | if ($col == 12) { print MYFILE " reserve: ", $cell->value(), "\n"} |
| 95 | } |
| 96 | print MYFILE "\n"; |
| 97 | } |
| 98 | print MYFILE "\n"; |
| 99 | close (MYFILE); |
| 100 | } |