blob: 0ba2554d59dba96ced0bb92edd7abd69b1ada2c6 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001#!/usr/bin/perl -w
2
3#use strict;
4use lib "tools/perl";
5use Spreadsheet::ParseExcel;
6
7my $CUSTOMDIR;
8if ($#ARGV == 0) {
9 $CUSTOMDIR = $ARGV[0];
10} else {
11 $CUSTOMDIR = "$ENV{'WORKDIR'}/custom/build";
12}
13
14my $FileName = "$CUSTOMDIR/flash_partition.xls";
15my $parser = Spreadsheet::ParseExcel->new();
16my $workbook = $parser->parse($FileName);
17
18die $parser->error(), ".\n" if ( !defined $workbook );
19
20# Iterate through all worksheets
21
22system("rm -rf $CUSTOMDIR/*.txt");
23
24for 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}