Chinaunix首页 | 论坛 | 博客
  • 博客访问: 57152
  • 博文数量: 35
  • 博客积分: 735
  • 博客等级: 军士长
  • 技术积分: 290
  • 用 户 组: 普通用户
  • 注册时间: 2011-06-28 16:23
文章分类
文章存档

2014年(2)

2013年(2)

2012年(31)

我的朋友

分类: WINDOWS

2012-10-22 13:06:39

auto_set_dir.pl
==========================
 #!/usr/bin/perl
#use strict;
use Cwd;
###################################################################################
# author:
#note:自动加载下载文件路径
#ver   auto_set_dir  (V1.0)
#date  2012-10-22
###################################################################################
my $ResearchDownload="E:\\Spreadtrum\\TOOLS\\6820a_down\\ResearchDownload_R2.9.6011\\Bin";
my $ResearchDownload_file =$ResearchDownload."";
my $ResearchDownload_exe =$ResearchDownload."";
my $test_temp="test.ini";
                    
###################################################################################
# author:  
# note: gen_ini_file_6820
###################################################################################
sub gen_ini_file_6820
{
 my $cur_dir = getcwd;
 #printf $cur_dir;
  
 open FILE_HANDLE, ">".$test_temp;
 my $curline;
 printf FILE_HANDLE "[SC6820]\n";  
     
 $curline = "FDL=1\@$cur_dir\\fdl1.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "FDL2=1\@$cur_dir\\fdl2.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "NV=1\@$cur_dir\\nvitem_sp6820b.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "SPLLoader=1\@$cur_dir\\u-boot-spl-16k.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "UBOOTLoader=1\@$cur_dir\\u-boot-hvga-256M.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "Vmjaluna=1\@$cur_dir\\20120428080001_vmjaluna.imagenkcbsp-sc8810-sp6820a_nodebug\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "Modem=1\@$cur_dir\\SC8800G_sc6820_modem_vlx.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "DSP=1\@$cur_dir\\SC6820_SR1018_GSM_DSP_DCXO_12.09.11_12.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "BootImg=1\@$cur_dir\\boot.img\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "Recovery=1\@$cur_dir\\recovery.img\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "System=1\@$cur_dir\\system.img\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "UserData=1\@$cur_dir\\userdata.img\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "Boot_Logo=1\@$cur_dir\\PowerON_LOGO.bmp\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "Fastboot_Logo=1\@$cur_dir\\Fast_LOGO.bmp\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 printf FILE_HANDLE "FLASH=1\@\n";
 printf FILE_HANDLE "PhaseCheck=1\@\n";
 printf FILE_HANDLE "EraseCache=1\@\n";
 printf FILE_HANDLE "EraseMisc=1\@";
 
 close FILE_HANDLE;
}
###################################################################################
# author:  
# note: gen_ini_file_8810
###################################################################################
sub gen_ini_file_8810
{
 my $cur_dir = getcwd;
 #printf $cur_dir;
  
 open FILE_HANDLE, ">".$test_temp;
 my $curline;
 printf FILE_HANDLE "[SC8810]\n";  
     
 $curline = "FDL=1\@$cur_dir\\fdl1.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "FDL2=1\@$cur_dir\\fdl2.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "NV=1\@$cur_dir\\nvitem.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "SPLLoader=1\@$cur_dir\\u-boot-spl-16k.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "UBOOTLoader=1\@$cur_dir\\u-boot-256M.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "Vmjaluna=1\@$cur_dir\\20120607080001_vmjaluna.imagenkcbsp-sc8810_nodebug\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "Modem=1\@$cur_dir\\SC8800G_sc8810_modem_vlx.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "DSP=1\@$cur_dir\\SC6820_DSP.bin\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "BootImg=1\@$cur_dir\\boot.img\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "Recovery=1\@$cur_dir\\recovery.img\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "System=1\@$cur_dir\\system.img\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "UserData=1\@$cur_dir\\userdata.img\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "Boot_Logo=1\@$cur_dir\\PowerON_LOGO.bmp\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 $curline = "Fastboot_Logo=1\@$cur_dir\\PowerON_LOGO.bmp\n";
 $curline =~tr/\//\\/;
 printf FILE_HANDLE $curline;
 
 printf FILE_HANDLE "FLASH=1\@\n";
 printf FILE_HANDLE "PhaseCheck=1\@\n";
 printf FILE_HANDLE "EraseCache=1\@\n";
 printf FILE_HANDLE "EraseMisc=1\@";
 
 close FILE_HANDLE;
}

my @entire_lines;
###################################################################################
# author:  
# note: inset_inifile_code
###################################################################################
sub file_to_arry
{
    open FILE_HANDLE, "<".$ResearchDownload_file;
    @entire_lines =
        
    for my $file_line (@entire_lines)
    {
     #printf $file_line;       
    }
    close FILE_HANDLE;
}
###################################################################################
# author:  
# note: inset_inifile_code
###################################################################################
sub inset_inifile_code
{
    my ($fh) = @_;      
    open FILE_UP_SUPPORT, "<".$test_temp;
    my @port_code_lines = ;
    close FILE_UP_SUPPORT;   
    print $fh @port_code_lines;
}
###################################################################################
# author:  
# note: set_select_project
###################################################################################
sub set_select_project
{
 my @file_lines1;
 my @file_lines2; 
 my $flag_key_isfind=0;
 my ($project) = @_;   
 for my $file_line (@entire_lines)
 {                       
     if ($file_line=~/SelectProduct/)
     {
         $flag_key_isfind = 1;
         next;
     }
 
     if($flag_key_isfind)
     {
        push(@file_lines2,$file_line);               
     }
     else
     {
         push(@file_lines1,$file_line);
     }                      
 }
 open FILE_HANDLE, ">".$ResearchDownload_file;;       
 print FILE_HANDLE @file_lines1;
 printf FILE_HANDLE "SelectProduct=SC$project\n";   
 print FILE_HANDLE @file_lines2;            
 close FILE_HANDLE;
}
###################################################################################
# author:  
# note: set_ini_file
###################################################################################
sub set_ini_file
{
 my @file_lines1;
 my @file_lines2;
 my $skip_lines=0; 
 my $SUM_LINES=18; 
 
 my $flag_key_isfind=0;
 my ($project) = @_;   
 for my $file_line (@entire_lines)
 {                       
     if ($file_line=~/\[SC$project\]/)
     {
         $flag_key_isfind = 1;
     }
 
     if($flag_key_isfind)
     {
        
         if ($skip_lines >$SUM_LINES)
         {
          push(@file_lines2,$file_line);               
         }
        $skip_lines++;
     }
     else
     {
         push(@file_lines1,$file_line);
     }                       
 }          
    
 open FILE_HANDLE, ">".$ResearchDownload_file;;       
 print FILE_HANDLE @file_lines1;
 
 inset_inifile_code(\*FILE_HANDLE);
 printf FILE_HANDLE "\n";   
 print FILE_HANDLE @file_lines2;            
 close FILE_HANDLE;
}
###################################################################################
# author:   main entry支持6820 8810----$input_param-------------->
###################################################################################
my $input_param=$ARGV[0];
printf   $input_param."\n";
if ($input_param eq "6820")
{
 printf   "is eq 6820\n";
 gen_ini_file_6820();
}
elsif ($input_param eq "8810")
{
 printf   "is eq 8810\n";
 gen_ini_file_8810();
}
else
{
 printf   "is not eq 6820,8810,please retry\n";
 exit 0;
}

file_to_arry();
set_select_project($input_param);
file_to_arry();
set_ini_file($input_param);
printf "auto set dir complete!,you can download please--->   ok\n";         
exec($ResearchDownload_exe);
====================================================================

使用说明:
1.把文件夹下三个文件拷贝在image文件夹下。
2.如果使用的是8810的项目(如f600),双击go_8810.bat,
  如果使用的是6820的项目(如f300),双击go_6820.bat
说明:1)image文件夹,就是放置各种下载文件的总文件夹
      2)ResearchDownload每个人放置位置不一样,所以必须配置.
      配置方法:
     打开auto_set_dir.pl.修改如下路径。
     my $ResearchDownload="E:\\Spreadtrum\\TOOLS\\6820a_down\\ResearchDownload_R2.9.6011\\Bin";
      3)需要安装perl(如果没有可以向我索要)
      4)暂时支持6820(E300等),和8810(F600等)项目。
      5)code说明,配置文件在gen_ini_file_XXXX生成,根据不同项目可以后期扩展。
阅读(4039) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~