blob: 43820fc7f571a10b26c8c332d96d0489e91cf27f [file] [log] [blame]
rjw6c1fd8f2022-11-30 14:33:01 +08001#!/usr/bin/perl
2#
3# Copyright Statement:
4# --------------------
5# This software is protected by Copyright and the information contained
6# herein is confidential. The software may not be copied and the information
7# contained herein may not be used or disclosed except with the written
8# permission of MediaTek Inc. (C) 2007
9#
10# BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
11# THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
12# RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
13# AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
14# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
15# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
16# NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
17# SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
18# SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
19# THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
20# NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
21# SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
22#
23# BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
24# LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
25# AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
26# OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
27# MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
28#
29# THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
30# WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
31# LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
32# RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
33# THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
34#
35#*****************************************************************************
36#*
37#* Filename:
38#* ---------
39#* scatGen.pl
40#*
41#* Project:
42#* --------
43#*
44#*
45#* Description:
46#* ------------
47#* This script aim to generate scatter file base on Makefile and custom_EMI.h
48#* 1. generate scatter file if not exists
49#*
50#* Author:
51#* -------
52#* JI Huang (mtk01077)
53#*
54#****************************************************************************/
55
56#****************************************************************************
57# Included Modules
58#****************************************************************************
59use strict;
60BEGIN { push @INC , './tools/' } # add additional library path
61use sysGenUtility; # pm file name without case sensitivity
62use FileInfoParser;
63use CommonUtility;
64use scatInfo;
65use config_MemSegment;
66use tools::pack_dep_gen;
67use File::Copy;
68PrintDependModule();
69
70#****************************************************************************
71# Global Variables
72#****************************************************************************
73my $g_strCOMPILER = undef;
74my $g_bb = undef;
75my $g_bUSE_DUMMY_SCATTER = 0;
76my $DebugPrint = 1; # 1 for debug; 0 for non-debug
77
78#****************************************************************************
79# File Names
80#****************************************************************************
81my $SCATTERFILE = $ARGV[0];
82my $BL_SCATTERFILE = $ARGV[1];
83my $themf = $ARGV[2];
84my $BB_PATH = $ARGV[3];
85my $CUSTOM_EMI_RELEASE_H = $ARGV[3] . '/' . "custom_EMI_release.h";
86my $CUSTOM_MEM_DEV_H = $ARGV[3] . '/' . "custom_MemoryDevice.h";
87my $CUSTOM_FEATURECONFIG_H = $ARGV[3] . '/' . "custom_FeatureConfig.h";
88my $CUSTOM_FLASH_H = $ARGV[3] . '/' . "custom_flash.h";
89my $CUSTOM_IMG_CONFIG_H = $ARGV[3] . '/' . "custom_img_config.h";
90my $NEED_BUILD_BOOTLOADER = $ARGV[4];
91my $INSIDE_MTK = $ARGV[5]; # INSIDE_MTK (need to check dummy_scatter_enable)
92my $DUMMY_SCATTER_FORCE = $ARGV[6]; # DUMMY_LIS (from gendummylis)
93my $INFOMAKELOG = $ARGV[7];
94my $CC_CMD = $ARGV[9];
95
96# to align error message file name format
97$SCATTERFILE =~ s/^.\/|^\///;
98$themf =~ s/^.\/|^\///;
99$BB_PATH =~ s/^.\/|^\///;
100
101# DL scat: scatter file for flash tool to download images
102my $DL_SCATTERFILE = $SCATTERFILE;
103$DL_SCATTERFILE =~ s/\.txt//;
104$DL_SCATTERFILE .= "_flashtool.txt";
105my $DL_Wateramrk = ';AutoGen Copyed from';
106
107# ext_BL scatter file
108my $EXT_BL_SCATTERFILE = $BL_SCATTERFILE;
109$EXT_BL_SCATTERFILE =~ s/.txt//;
110$EXT_BL_SCATTERFILE .= "_ext.txt";
111#****************************************************************************
112# 1 >>> main judges : scatter file exists or not
113#****************************************************************************
114&sysUtil::del_noCheckinHistory_file($BL_SCATTERFILE);
115&sysUtil::del_noCheckinHistory_file($EXT_BL_SCATTERFILE);
116&sysUtil::del_noCheckinHistory_file($SCATTERFILE);
117&sysUtil::del_noCheckinHistory_file($DL_SCATTERFILE);
118# DL_scatter with watermark($DL_Wateramrk) and Check-in history will be deleted.
119# -> Always regen copyed file.
120&DelFileWithKeyword($DL_SCATTERFILE, $DL_Wateramrk);
121#****************************************************************************
122# 2 >>> parse infomake.log and Project MakeFile+corpo_info_gen.log
123#****************************************************************************
124my %MAKEFILE_OPTIONS;
125my %CmplOption;
126my %RelOption;
127FileInfo::PreProcess($themf, \%MAKEFILE_OPTIONS, $INFOMAKELOG, \%CmplOption, \%RelOption,1);
128$g_strCOMPILER = &FileInfo::GetCompiler();
129$g_bb = &sysUtil::SwitchToClonedChip(&FileInfo::GetChip()); #use infomake.log
130
131#****************************************************************************
132# 4 >>> Check user settings validity - DUMMY SCATTER
133#****************************************************************************
134$g_bUSE_DUMMY_SCATTER = &sysUtil::isDummyScatter($INSIDE_MTK, $DUMMY_SCATTER_FORCE);
135&CheckDummyScatter($SCATTERFILE, $g_bUSE_DUMMY_SCATTER);
136#****************************************************************************
137# 5 >>> Parse Input files
138#****************************************************************************
139&memConfig::Parse($CUSTOM_MEM_DEV_H, memConfig::MEMORY_DEVICE, $INSIDE_MTK, $g_bUSE_DUMMY_SCATTER);
140&memConfig::Parse($CUSTOM_FEATURECONFIG_H, memConfig::FEATURE_CONFIG, $INSIDE_MTK, $g_bUSE_DUMMY_SCATTER);
141&memConfig::Parse($CUSTOM_EMI_RELEASE_H, memConfig::CUSTOM_EMI, $INSIDE_MTK, $g_bUSE_DUMMY_SCATTER);
142&memConfig::Parse($CUSTOM_FLASH_H, memConfig::CUSTOM_FLASH, $INSIDE_MTK, $g_bUSE_DUMMY_SCATTER);
143&memConfig::Parse($CUSTOM_IMG_CONFIG_H, memConfig::CUSTOM_IMG_CONFIG, $INSIDE_MTK, $g_bUSE_DUMMY_SCATTER) if($g_strCOMPILER =~ /RVCT/i);
144#****************************************************************************
145# 12 >>> Verify parsed value
146#****************************************************************************
147&PrintDebugInfo();
148&memConfig::VerifyRAMInfo($g_bUSE_DUMMY_SCATTER);
149&memConfig::VerifyFSInfo($g_bUSE_DUMMY_SCATTER);
150#****************************************************************************
151# 16 >>> Generate MAUI Scatter File
152#****************************************************************************
153if (!-e $SCATTERFILE)
154{
155 &GenMAUIScatter($SCATTERFILE, 0) if($g_strCOMPILER eq "RVCT");
156 &GenMAUI_LDS($SCATTERFILE, 0) if($g_strCOMPILER eq "GCC");
157} else {
158 #this is used to enable the write permission of LDS for TCM_ONLY_LOAD!
159 system("chmod 777 $SCATTERFILE");
160}
161#****************************************************************************
162# 17 >>> Generate DL Scatter File for flash tool
163#****************************************************************************
164if (!-e $DL_SCATTERFILE)
165{
166 if(-e $SCATTERFILE)
167 {
168 &CopyandMarkFile($SCATTERFILE, $DL_SCATTERFILE, $DL_Wateramrk) if($g_strCOMPILER eq "RVCT");
169 &GenScatSkeleton($SCATTERFILE, $DL_SCATTERFILE) if($g_strCOMPILER eq "GCC");
170 }
171}
172#****************************************************************************
173# 18 >>> Generate Bootloader Scatter File
174#****************************************************************************
175if (!-e $BL_SCATTERFILE and $NEED_BUILD_BOOTLOADER eq "TRUE")
176{
177 &GenBLScatter() if($g_strCOMPILER eq "RVCT");
178 if($g_strCOMPILER eq "GCC")
179 {
180 &GenBL_LDS($BL_SCATTERFILE, "BL");
181 &GenBL_LDS($EXT_BL_SCATTERFILE, "EXT_BL");
182 }
183}
184
185#****************************************************************************
186# 19 >>> Preprocess scatter file
187#****************************************************************************
188PreprocessLDS($SCATTERFILE);
189
190#****************************************************************************
191# 20 >>> sysgen2
192#****************************************************************************
193require "sysGen2.pl";
194print "========Run sysGen2.pl==========\n";
195&sysgen2_main($BB_PATH, $SCATTERFILE, $BL_SCATTERFILE, $EXT_BL_SCATTERFILE, $CC_CMD, $INFOMAKELOG);
196#****************************************************************************
197# oo >>> Finished
198#****************************************************************************
199exit 0;
200#****************************************************************************
201# subroutine: PreprocessLDS run scatterfile throught preprocessor
202# input: 1. LDS file
203# return: N/A
204#****************************************************************************
205sub PreprocessLDS
206{
207 my ($LDSFileName) = @_;
208 my $cmpOpt = undef;
209 my ($tempdir) = ($LDSFileName =~ /(.*)custom/);
210 $tempdir .= "tmp/";
211 my $OptFile = $tempdir."PreProcessOpt.txt";
212 my ($scatterfile) = ($LDSFileName =~ /\/(\w*.\w*)$/);
213
214 #Gather copiler options
215 foreach my $key ( keys %CmplOption )
216 {
217 next if($key eq lc $key);
218 if (defined $CmplOption{$key})
219 {
220 $cmpOpt .= " -D$key=$CmplOption{$key}";
221 } else {
222 $cmpOpt .= " -D$key";
223 }
224 }
225 open (FILE, ">$OptFile") or &sysUtil::sysgen_die("$OptFile: open file error!", __FILE__, __LINE__);
226 print FILE $cmpOpt;
227 close FILE;
228
229 #Preprocess scatterfile
230 my $cmd = "$CC_CMD -x c -E -undef \@$OptFile $LDSFileName";
231 my $output = qx($cmd);
232 $? == 0 or die "LDS preprosseing failed $?\n$output";
233 unlink $OptFile;
234
235 #Tidy preprocessor output
236 my $output2;
237 foreach (split /\n/,$output)
238 {
239 $output2 .= $_."\n" if (!($_ =~ /^#/));
240 }
241
242 #Backup old scatterfile for debug
243 copy($LDSFileName, $tempdir.$scatterfile) or die "File copy from $LDSFileName to $tempdir$scatterfile failed \n";
244
245 #Write new scatterfile
246 Output($LDSFileName, "defines the memory map for the validation board",
247 0, &get_board_parameters(), 1, $output2);
248
249}
250
251#****************************************************************************
252# subroutine: GenScatSkeleton: Generate flashtool.txt from linker script
253# input: 1. Linker script path
254# 2. flashtool.txt path
255# return: N/A
256#****************************************************************************
257sub GenScatSkeleton
258{
259 my ($LDS_FILEPATH, $DL_ScatSkeleton) = @_;
260 my $strLayout;
261 my $LinkInfo = lds_new scatInfo($LDS_FILEPATH, "ROM");
262 my $LR_aref = $LinkInfo->GetAllLoadRegion();
263 my $RegionMap_href = $LinkInfo->GetRegionMap();
264 push (@$LR_aref, "DSP_ROM") if($g_bb eq "MT6290");
265 foreach my $strLRName (@$LR_aref)
266 {
267 my $LR = $RegionMap_href->{$strLRName};
268 $strLayout .= $strLRName . "\n{\n";
269 map{ $strLayout .= ' 'x4 ."$_\n";} @$LR;
270 $strLayout .= "}\n";
271 }
272 &Output($DL_ScatSkeleton, "defines the memory map for the validation board",
273 &scatInfo::GetldsInfoWrap_VERNO(), &get_board_parameters(), 1, $strLayout);
274}
275
276#****************************************************************************
277# subroutine: GenMAUI_LDS: Generate MAUI main linker script
278# input:
279# return: x
280# require: tools/ldsGenLib.pl -> ldsGen_main();
281#****************************************************************************
282sub GenMAUI_LDS
283{
284 my ($filepath, $bIs_Flashtool_Layout) = @_;
285 require "ldsGenLib.pl";
286 my $strLayout = &ldsGen_main( $g_bb,
287 &memConfig::GetExtRamSize(),
288 $NEED_BUILD_BOOTLOADER,
289 $BB_PATH,
290 $themf);
291 &Output($filepath, "defines the memory map for the validation board",
292 &ldsGen_verno(), &get_board_parameters(), 1, $strLayout);
293}
294#****************************************************************************
295# subroutine: GenMAUIScatter: Generate MAUI main scatter file
296# input: $filepath : the file path to save a scatter layout
297# $Is_Flashtool_Layout : 0=normal layout, 1=flashtool required layout
298# return: x
299# require: tools/scatGenLib.pl -> scatGen_main();
300#****************************************************************************
301sub GenMAUIScatter
302{
303 #$Is_Flashtool_Layout : 0=normal layout, 1=flashtool required layout
304 my ($filepath, $Is_Flashtool_Layout) = @_;
305 require "scatGenLib.pl";
306 my $scat_content = &scatGen_main(sub { my ($key) = @_;
307 return &FileInfo::get($key);
308 },
309 $g_bb,
310 &memConfig::GetROMSize(),,
311 &memConfig::GetBlockTable(),
312 &memConfig::GetExtRamSize(),
313 (!&FileInfo::is_NOR()) ? "TRUE" : "FALSE",
314 &memConfig::GetSource(memConfig::CUSTOM_IMG_CONFIG),
315 $BB_PATH,
316 $themf,
317 $NEED_BUILD_BOOTLOADER,
318 &memConfig::GetSource(memConfig::MEMORY_DEVICE),
319 $Is_Flashtool_Layout,
320 $g_bUSE_DUMMY_SCATTER,
321 &memConfig::GetSource(memConfig::FEATURE_CONFIG),
322 0
323 );
324
325 &sysUtil::sysgen_die("Unsupported Feature Combination. Please create $filepath manually!", __FILE__, __LINE__)
326 unless defined $scat_content;
327 &OutputScatter($filepath, "defines the memory map for the validation board",
328 &get_board_parameters(),$scat_content);
329}
330#****************************************************************************
331# subroutine: GenBLScatter: Generate BL scatter file
332# input: $filepath : the file path to save a scatter layout
333# return: x
334# require: tools/BLscatGen.pl -> scatGenBL_main()
335#****************************************************************************
336sub GenBLScatter
337{
338 require "tools/scatGenBL.pl";
339 my ($strBL, $strEXTBL) = &scatGenBL_main(sub { my ($key) = @_;
340 return &FileInfo::get($key);
341 },
342 $g_bb,
343 &memConfig::GetExtRamSize(),
344 $BB_PATH,
345 $SCATTERFILE
346 );
347 &OutputScatter($BL_SCATTERFILE, "defines the memory map for boot-loader", undef, $strBL);
348 &OutputScatter($EXT_BL_SCATTERFILE, "defines the memory map for ext-bootloader", undef, $strEXTBL);
349}
350
351sub OutputScatter
352{
353 my ($strFilePath, $description, $Comments, $strFileContent) = @_;
354 open (FILE, ">$strFilePath") or &sysUtil::sysgen_die("$strFilePath: open file error!", __FILE__, __LINE__);
355 print FILE &copyright_file_header_for_scatter($g_bb);
356 require "tools/scatGenLib.pl";
357 print FILE &description_file_header_for_scatter( $strFilePath,
358 $description."\n",
359 "system auto generator ". &scatGen_verno().
360 " + scatGen" . &GetSCATGEN_VERNO().
361 " + sysGenUtility" . &sysUtil::sysgenUtility_verno(),
362 , $Comments);
363 print FILE $strFileContent;
364 close FILE;
365 print "$strFilePath is generated\n";
366}
367sub Output
368{
369 my ($strFilePath, $description, $verno, $Comments, $bAutoGen, $strFileContent) = @_;
370 open (FILE, ">$strFilePath") or &sysUtil::sysgen_die("$strFilePath: open file error!", __FILE__, __LINE__);
371 print FILE &sysUtil::copyright_file_header();
372 print FILE &sysUtil::description_file_header($strFilePath,
373 $description."\n",
374 "system auto generator ". $verno .
375 " + scatGen" . &GetSCATGEN_VERNO().
376 " + sysGenUtility" . &sysUtil::sysgenUtility_verno(),
377 $Comments, $bAutoGen);
378 print FILE $strFileContent;
379 close FILE;
380 print "$strFilePath is generated\n";
381}
382#****************************************************************************
383# subroutine: GenBL_LDS: Generate bootloader linker script
384# input:
385# return: x
386# require: tools/ldsGenBL.pl -> BLldsGen_main();
387#****************************************************************************
388sub GenBL_LDS
389{
390 my ($filepath, $strBLType) = @_;
391 require "tools/ldsGenBL.pl";
392 my $strLDS = &ldsGenBL_main( $g_bb,
393 &memConfig::GetExtRamSize(),
394 $BB_PATH,
395 $themf,
396 $SCATTERFILE,
397 $strBLType);
398
399 &Output($filepath, "defines the memory map for bootloader",
400 &ldsGenBL_verno(), &get_board_parameters(), 1, $strLDS);
401}
402
403#****************************************************************************
404# subroutine: CopyandMarkFile: Copy a file from source to destination
405# with adding $Watermark in the line containing 'Filename:',
406# and replace .txt to _flashtool.txt once.
407# input: $SrcPath : Source file path
408# $DestPath : Destined file path
409# $Watermark : the keyword to identify if the destined file is copied or manually added.
410# return: x
411#****************************************************************************
412sub CopyandMarkFile
413{
414 my($SrcPath, $DestPath, $Watermark)= @_;
415 my $KeyWordtoMark = "$Watermark: $SrcPath";
416 my $content;
417 open FILE, "<$SrcPath" or &sysUtil::sysgen_die("$SrcPath: open file error!", __FILE__, __LINE__);
418 {
419 local $/;
420 $content = <FILE>;
421 }
422 close FILE;
423
424 #Change File Name
425 $content =~ s/\.txt/_flashtool.txt/;
426 #Write Copy Mark
427 $content =~ s/Filename:/Filename: $KeyWordtoMark/;
428
429 open FILE, ">$DestPath" or &sysUtil::sysgen_die("$DestPath: open file error!", __FILE__, __LINE__);
430 print FILE $content;
431 close FILE;
432}
433#****************************************************************************
434# subroutine: DelFileWithKeyword: Delete the existent file which contains $Watermark
435# input: $FilePath : the file path you want to delete
436# $Keyword : the keyword you want to search in the file
437# return: x
438#****************************************************************************
439sub DelFileWithKeyword
440{
441 my ($FilePath, $Keyword) = @_;
442
443 if(-e $FilePath)
444 {
445 my $NeedDelete = 0;
446
447 open FILE, "<$FilePath" or &sysUtil::sysgen_die("$FilePath: open file error!", __FILE__, __LINE__);
448 {
449 local $/;
450 my $content = <FILE>;
451 $NeedDelete = 1 if($content =~ /$Keyword/);
452 }
453 close FILE;
454 if($NeedDelete eq 1)
455 {
456 unlink $FilePath;
457 }
458 }
459}
460#****************************************************************************
461# subroutine: get the board parameters
462# return: the summary string
463#****************************************************************************
464sub get_board_parameters
465{
466 my ($loadsize, $ramsize) = ( &memConfig::GetROMSize() / (1024 * 1024),
467 &memConfig::GetExtRamSize() / (1024 * 1024)
468 );
469 $loadsize = $loadsize . "MB";
470 $ramsize = $ramsize . "MB";
471 my $sw_features = &CollectMemoryTypeForComments();
472 my $strDummy = $g_bUSE_DUMMY_SCATTER ? "Yes" : "No";
473 my $template1 = <<"__TEMPLATE";
474;--------------------
475; SCHEME : external $loadsize flash memory and $ramsize SRAM
476; DUMMY SETTING : $strDummy
477; PLATFORM : $g_bb
478; FEATURES : $sw_features
479;--------------------
480__TEMPLATE
481
482 my $template2 = <<"__TEMPLATE";
483;--------------------
484; SCHEME : external NAND flash and $ramsize LPSDRAM
485; DUMMY SETTING : $strDummy
486; PLATFORM : $g_bb
487; FEATURES : $sw_features
488;--------------------
489__TEMPLATE
490
491 if($g_strCOMPILER eq "GCC")
492 {
493 $template1 =~ s/\;/ \*/g;
494 $template2 =~ s/\;/ \*/g;
495 }
496 if (!FileInfo::is_NonSPNOR()) { return $template2; }
497 else { return $template1; }
498}
499
500sub CollectMemoryTypeForComments
501{
502 my $strSWCFG;
503 if(&FileInfo::isnot('nand_flash_booting', 'NONE'))
504 {
505 $strSWCFG .= "NFB ";
506 }
507 if(&FileInfo::isnot('emmc_booting', 'NONE'))
508 {
509 $strSWCFG .= "EMB ";
510 }
511 if(&FileInfo::is_SmartPhone())
512 {
513 $strSWCFG .= "[SmartPhone]". &FileInfo::get("SMART_PHONE_CORE"). " ";
514 }
515 if(&FileInfo::isnot('usb_download_in_bl', 'NONE'))
516 {
517 $strSWCFG .= "USBDOWNLOAD ";
518 }
519 if(&FileInfo::is('multiple_binary_files', 'TRUE'))
520 {
521 $strSWCFG .= "MULTIBIN ";
522 }
523 if(&FileInfo::is('secure_support', 'TRUE'))
524 {
525 $strSWCFG .= "SECURE ";
526 }
527 if(&FileInfo::is('enhanced_single_bank_nor_flash_support', 'TRUE'))
528 {
529 $strSWCFG .= "ESBNOR ";
530 }
531 return $strSWCFG;
532}
533#****************************************************************************
534# subroutine: description_file_header
535# return: file header -- description
536# input: $filename: filename
537# input: $description: one line description
538# input: $author: optional
539#****************************************************************************
540sub description_file_header_for_scatter
541{
542 my ($filename, $description, $author, $board_description) = @_;
543 my @lines = split(/\n/, &sysUtil::description_file_header($filename, $description, $author, $board_description, 1));
544 my $template;
545 map{ $template .= ";".$_."\n" }@lines;
546 return $template;
547}
548#****************************************************************************
549# subroutine: copyright_file_header
550# return: file header -- copyright
551#****************************************************************************
552sub copyright_file_header_for_scatter
553{
554 my ($bb) = @_;
555 my $pre_compile_str;
556 if(&FileInfo::is("dsp_solution", "DUALMACDSP") or $bb eq "MT6251")
557 {
558 $pre_compile_str = "#! armcc -E";
559 }
560 my @lines = split(/\n/, &sysUtil::copyright_file_header());
561 my $template;
562 map{ $template .= ";".$_."\n" }@lines;
563 return $pre_compile_str.$template;
564}
565
566
567#****************************************************************************
568# Subroutine: PrintDebugInfo
569# Purpose: Print Memory related information for debug usage
570#****************************************************************************
571sub PrintDebugInfo
572{
573 if ($DebugPrint == 1)
574 {
575 print "Chip=$g_bb\n";
576
577 print "custom_MemoryDevice.h:\n";
578 print "NOR_BOOTING_NOR_FS_BASE_ADDRESS = ".&memConfig::GetMemDev('NOR_BOOTING_NOR_FS_BASE_ADDRESS')."\n";
579 print "NOR_BOOTING_NOR_FS_SIZE = ".&memConfig::GetMemDev('NOR_BOOTING_NOR_FS_SIZE')."\n";
580 print "NAND_BOOTING_NAND_FS_BASE_ADDRESS = ".&memConfig::GetMemDev('NAND_BOOTING_NAND_FS_BASE_ADDRESS')."\n";
581 print "NAND_BOOTING_NAND_FS_SIZE = ".&memConfig::GetMemDev('NAND_BOOTING_NAND_FS_SIZE')."\n";
582
583 print "PROJECT_EXPECTED_RAM_LIMIT = ".&memConfig::GetFtCfg('PROJECT_EXPECTED_RAM_LIMIT')."\n";
584 print "PROJECT_EXPECTED_CODE_LIMIT = ".&memConfig::GetFtCfg('PROJECT_EXPECTED_CODE_LIMIT')."\n";
585 print "PROJECT_EXPECTED_RAM_LIMIT_NFB = ".&memConfig::GetFtCfg('PROJECT_EXPECTED_RAM_LIMIT_NFB')."\n";
586 print "\n";
587
588 if(!&FileInfo::is_SmartPhone())
589 {
590 print "custom_flash.h:\n";
591 print "[original input]\n";
592 my ($Blk, $Region, $Bank, $density, $size) = &memConfig::GetFlashInfoLog();
593 print "BlockTBLTxt = ". $Blk ."\n";
594 print "RegionInfoTxt = ". $Region,."\n";
595 print "BankInfoTxt = ". $Bank."\n";
596 print "NOR_FLASH_DENSITY = ". $density."\n";
597 print "NOR_FLASH_SIZE = ". $size."\n";
598 print "\n";
599
600 print "custom_emi_release.h:\n";
601 print "[original input]\n";
602 print "Original RamSize = ". &memConfig::GetPhysicalExtRAMSize(1)."\n";
603 print "\n";
604 }
605
606 print "BOARD_PARAMTERS(Processed information):\n";
607 print "Processed RamSize = ". &memConfig::GetExtRamSize().
608 "(".&CommonUtil::Dec2Hex(&memConfig::GetExtRamSize()).")\n";
609 print "Processed ROMSize = ". &memConfig::GetROMSize().
610 "(".&CommonUtil::Dec2Hex(&memConfig::GetROMSize()).")\n";
611 print "\n";
612 }
613}
614sub CheckDummyScatter
615{
616 my ($strScatterPath, $bIsDummy) = @_;
617 if(&sysUtil::HasCheckinHistory($strScatterPath) && $bIsDummy)
618 {
619 &sysUtil::sysgen_die("Generating DUMMY SCATTER FILE can't work when a manual checked-in scatter file exists.\nRecommand: Please remove your own modifications first, \nrebuild and make sure the load is successfully built, \nthen add your own modifications back.\n", __FILE__, __LINE__);
620 }
621}
622
623sub GetSCATGEN_VERNO
624{
625 my $SCATGEN_VERNO = " m0.05";
626 # m0.05 by mei , 20130625, support copro_info.log input
627 # m0.04 by mei , 20130528, support infomake.log input
628 # m0.03 by mei , 20130212, Add DSP into fake scatter for MT6290's cfggen
629 # m0.02 by mei , 20121019, Remove FOTA
630 # m0.01 by mei , 20120920, Support MultiBin on MOLY
631
632 return $SCATGEN_VERNO;
633}
634