blob: f26b469244f446f259d846176ca5e776b37b38af [file] [log] [blame]
yu.dongc33b3072024-08-21 23:14:49 -07001#!/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) 2006
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#* emigenMD.pl
40#*
41#* Project:
42#* --------
43#*
44#*
45#* Description:
46#* ------------
47#* This script will
48#* 1. parse custom_MemoryDevice.h to get memory device type and part number
49#* 2. read a excel file to get appropriate emi setting based on the part number
50#* 3. based on the emi settings, generate custom_EMI.h if not exist
51#* 4. based on the emi settings, generate custom_EMI_INFO.h if not exist
52#* 5. based on the emi settings, generate custom_EMI_release.h if not exist
53#* 6. based on the emi settings, generate custom_flash_norfdm5.h if not exist
54#* 7. based on the emi settings, generate custom_sfi_defs.h if not exist
55#* 8. based on the emi settings, generate custom_flash.h if not exist
56#* 9. based on the emi settings, generate combo_flash_config.h if not exist
57#* 10. based on the emi settings, generate combo_flash_id.h if not exist
58#* 11. based on the emi settings, generate flash_opt_gen.h if not exist
59#*
60#* Author:
61#* -------
62#* Guo-Huei Chang (mtk04123)
63#* Way Chen (mtk54483)
64#*
65#*============================================================================
66#* HISTORY
67#* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
68#*------------------------------------------------------------------------------
69#* $Revision$
70#* $Modtime$
71#* $Log$
72#*
73#* 06 16 2016 wcpadmin
74#* smart new env.
75#*
76#* 06 04 2015 guo-huei.chang
77#* [MOLY00118588] update emigen for SP projrect
78#* update emigen for SP project with common MDL
79#*
80#* 04 23 2014 guo-huei.chang
81#* [MOLY00062623] [UMOLY] update TK6291 emi
82#* updat emigen flow for generating external emi size when EMI is not in MD own.
83#*
84#* 04 21 2014 guo-huei.chang
85#* [MOLY00063203] [EMIGEN] Update EMIGEN for Smart Phone Project
86#* Update emigen to generate EMI size for none EMI support
87#*
88#* 03 31 2014 way.chen
89#* [MOLY00061385] [TK6291][UMOLY] Update EMIGEN Flash Part Code
90#* Update EMIGEN code for TK6291 chips
91#*
92#* 01 08 2014 guo-huei.chang
93#* [MOLY00052841] [EMIGEN] Update EMIGEN for SmartPhone project
94#* 1. update emigen for smart phone to generate custom emi header
95#* 2. update custom_EMI_SP.c for smart phone
96#*
97#* 12 09 2013 guo-huei.chang
98#* [MOLY00048000] [MT6595] Update custom_EMI for MT6595
99#* Merge MT6595_E1_DEV to MOLY TRUNK
100#*
101#* 11 15 2013 way.chen
102#* [MOLY00046608] [ROME][EMIGEN] Optimal EMIGEN Flash Code
103#* Optimal EMIGEN Flash Part Code for ROME.
104#*
105#* 11 06 2013 guo-huei.chang
106#* [MOLY00045425] [MT6595][EMIGEN] Update EMIGEN
107#* update emigen for MT6595 build pass
108#*
109#* 10 30 2013 way.chen
110#* [MOLY00044297] [MT6290][EMIGEN] Upload New MDL for MP
111#* Add New MDL File for MP.
112#*
113#* 08 23 2013 guo-huei.chang
114#* [MOLY00034592] [MT6290][Combo Memory Support] Enable Combo Memory Feature
115#* 1. Update Memory Device List for MT6290(m)
116#* 2. Update/re-arch cfggen
117#* 3. Update/re-arch emigen
118#* 4. remove emigen/cfggen legacy
119#* 5. Add combo memory supporting
120#* 6. auto-generate all header files that emigen related
121#*
122#* 05 29 2013 way.chen
123#* [MOLY00024037] [MakeFile] [Config project makefile] MT6290M_LTE(MULTI_MODE_EXT_SP).mak
124#* Fix EMIGEN Can not gen EMI releated files.
125#*
126#* 05 23 2013 way.chen
127#* [MOLY00023060] [MT6290 Bring-up] Update EMIGEN Related Code
128#* Modify correct NAND flash size and change emigen not care SMART_PHONE_CORE.
129#*
130#* 05 22 2013 guo-huei.chang
131#* [MOLY00011607] update custom_EMI function and cfggen EMI part
132#* change checking smart phone method without emi
133#*
134#* 05 02 2013 guo-huei.chang
135#* [MOLY00013409] [MT6290 Bring-up] DRAMC/EMI related Code Update
136#* add emigen to support combo memory
137#*
138#* 04 16 2013 guo-huei.chang
139#* [MOLY00013409] [MT6290 Bring-up] DRAMC/EMI related Code Update
140#* 1. update emigen to auto-gen all header files
141#* 2. update init mempll
142#* 3. update cfggen
143#*
144#* 03 27 2013 yaohua.liu
145#* [MOLY00012498] MT6290 MOLY_NAND Integrate to Trunk
146#* Merging //MOLY_CBr/yaohua.liu/MOLY_NAND/mcu/... to TRUNK
147#*
148#* 03 22 2013 guo-huei.chang
149#* [MOLY00012511] Update Auto-k for E1
150#* fix MoDIS compile error
151#*
152#* 03 22 2013 guo-huei.chang
153#* [MOLY00012511] update auto-k for MT6290 FPGA, MT6290 EVB, and MT6290M EVB
154#* 1. add custom folder for MT6290M
155#* 2. update custom_EMI.h and custom_EMI_release.h with emigen
156#* 3. update custom_EMI_INFO.h with manual check in
157#* 4. update cfggen
158#*
159#* 03 19 2013 guo-huei.chang
160#* [MOLY00011607] update custom_EMI function and cfggen EMI part
161#* integrate CBr that update emigen and cfggen
162#*
163#* 02 05 2013 guo-huei.chang
164#* [MOLY00009961] rename emigen from 7208 to 6290
165#*
166#* 11 01 2012 marvin.lin
167#* [MOLY00005622] [MemoryStorage][Auto-Gen][EMI Gen/CFG Gen][Request For Design Change] EMIGEN support MT6290 on MOLY
168#* .
169#*
170#* 07 24 2012 marvin.lin
171#* [MOLY00001098] [MemoryStorage][Auto-Gen][EMI Gen/CFG Gen][Request For Design Change] autogen support nand flash 8-bit ecc on MT6280
172#* .
173#*
174#*
175#*------------------------------------------------------------------------------
176#* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
177#*============================================================================
178#****************************************************************************/
179#****************************************************************************
180# Included Modules
181#****************************************************************************
182use strict;
183use warnings;
184no warnings 'redefine';
185BEGIN { push @INC , './tools/' }
186use tools::pack_dep_gen;
187use Scalar::Util qw/reftype/;
188use Storable 'dclone';
189#auto flush 'print' function
190local $| = 1;
191
192push @INC, "tools/perl";
193require Spreadsheet::ParseExcel;
194# use Spreadsheet::ParseExcel;
195# die on errors...
196
197my $EMIGEN_VERNO = " V9.008";
198 # V9.008 , by Guo-Huei at 2014/04/15, Update EMIGEN to generate SmartPhone's DRAM Size by MDL
199 # V9.007 , by Guo-Huei at 2014/01/08, Update EMIGEN for SmartPhone project
200 # V9.006 , by Guo-Huei at 2013/12/09, Update custom_EMI for MT6595
201 # V9.005 , by Way at 2013/11/15, Optimal EMIGEN Flash Part Code for ROME.
202 # V9.004 , by Guo-Huei at 2013/11/06, update emigen for MT6595 build pass
203 # V9.003 , by Way at 2013/10/24, Support MP Level MDL
204 # V9.002 , by Guo-Huei at 2013/08/07, 1. remove lagacy code. 2. auto-generate header file according MDL content 3. Add combo memory support 4. error check for combo memory configuration.
205 # V9.001 , by Guo-Huei at 2013/08/05, 1. remove lagacy code. 2. re-arch emigen flow. 3. remove WIN32 OLE related code. 4. use warnings
206 # V8.276 , by Way at 2013/06/24, 1. remove lagacy code; 2. Re-arch EMIGEN flow; 3. Implement combo flash part auto gen flow; 4. Add combo_nfi_config.h for enhance NAND flash flow of mT6290.
207 # V8.275 , by Way at 2013/06/7, enable auto emigen flash part.
208 # V8.274 , by Way at 2013/05/23, change checking smart phone method without flash.
209 # V8.273 , by Guo-Huei at 2013/05/15, change checking smart phone method without emi.
210 # V8.272 , by Guo-Huei at 2013/05/02, add emigen to support combo memory.
211 # V8.271 , by Guo-Huei at 2013/04/12, update emigen to auto-gen custom_EMI_INFO.h
212 # V8.270 , by Guo-Huei at 2013/03/27, update emigen to support parsing flash.
213 # V8.269 , by Guo-Huei at 2013/03/22, update emigen to auto-generate emi related output files.
214 # V8.268 , by Guo-Huei at 2013/03/19, update custom_EMI function and cfggen EMI part
215 # V8.267 , by Guo-Huei at 2013/02/05, rename emigen from MT7208 to MT6290
216 # V8.266 , by Marvin at 2012/11/01 , autogen support MT6290
217 # V8.259 , by Marvin at 2012/07/24 , autogen support nand flash 8-bit ecc
218 # V8.258 , by Marvin at 2012/07/05 , Autogen support MT6280
219 # V8.254 , by Marvin at 2012/06/08 , modify open MDL method for autogen on linux
220 # V8.249 , by Marvin at 2012/04/30 , modify combo memory hw list data structure name
221 # V8.234 , by Marvin at 2012/01/09 , check in MT6280 DVT
222 # V8.231 , by Marvin at 2011/12/26 , EMIGEN support MT6255 combo memory
223 # V8.229 , by Marvin at 2011/12/06 , modify emigen bug in emigensf.pl variable makefile_options define error
224 # V8.228 , by Marvin at 2011/12/02 , EMIGEN support MT6255 on MAUI, 11B, 11AW1112SP2, 11BW1144SP
225 # V8.226 , by Marvin at 2011/11/17 , add emi 156Mhz setting to work around for 6256 ORFS 600KHz fail
226 # V8.227 , by Marvin at 2011/11/24 , to fix the sanity fail that init_eco_version corrupt the EMI region code for 6921 on 11B
227 # V8.225 , by Marvin at 2011/11/16 , to fix the emigen error for 6252D sip serialflash
228 # V8.224 , by Marvin at 2011/11/10 , supprot MT6276 L1 downgrade for memory device 32 or 16 bit
229 # V8.223 , by Marvin at 2011/11/04 , remove the card DL + combo memory flash layout
230 # V8.222 , by Marvin at 2011/11/02 , support new version perl rule
231 # V8.221 , by Marvin at 2011/11/01 , modify custom_emi.c to fix the build error for 6921 on 11B
232 # V8.220 , by Marvin at 2011/10/31 , remove check demo project policy to avoid production release load build error
233 # V8.219 , by Marvin at 2011/10/24 , modify custom_emi.c and custom_emi.h to support combo memory for 6921 on 11B & maui
234 # V8.218 , by Marvin at 2011/10/13, modify custom_emi.c to match 11B hal rule
235 # V8.217 , by Marvin at 2011/10/10 , to fix emigen re-sructure error
236 # V8.216 , by Marvin at 2011/10/07 , emi sw work-around for 6236 BT issue.
237 # V8.215 , by Marvin at 2011/10/05 , emigen support 6256 combo memory
238 # V8.214 , by Marvin at 2011/09/22 , support 6252E sip serial flash size 32Mbit
239 # V8.213 , by Marvin at 2011/09/20 , modify emi dynamicclockswitch return value
240 # V8.210 , by Marvin at 2011/09/05 , add the dependency of the custom_featureconfig.h
241 # V8.209 , by Marvin at 2011/09/02 , support to parse custom_featureconfig.h
242 # V8.208 , by Marvin at 2011/08/31 , EMI GEN Re-structure and EMI GEN version update
243 # V7.207 , by Marvin at 2011/08/29 , to support the feature of psuedo sized block.
244 # V7.206 , by Claudia at 2011/08/15 , Modify SP custom_EMI_release.h EMI_EXTSRAM_SIZE template to sync with feature phones
245 # V7.205 , by Marvin at 2011/08/08 , modify custom_emi.c for supporting WQVGA of 6252
246 # V7.204 , by Marvin at 2011/08/01 , modify the custom_flash.c for FOTA + Card DL + combo memory feature support
247 # V7.203 , by Marvin at 2011/07/15 , modify the custom_flash.c for NOR FDM slim
248 # V7.202 , by Marvin at 2011/07/13 , modify the custom_sfi.c to fix build error for compile option UBL
249 # V7.201 , by Claudia at 2011/07/11 , Fix Combo Memory error for error-detecting EMMC_BOOTING
250 # V7.200 , by Marvin at 2011/07/11 , modify the FS address for FOTA backup storage
251 # V7.199 , by Marvin at 2011/07/11 , Modify custom_EMI.c to fix build error for compile option EMMC_BOOTING
252 # V7.198 , by Claudia at 2011/07/08 , Modify custom_EMI.c to fix build error when _EMI_NOR_CMD_NUM is 0
253 # V7.197 , by Claudia at 2011/07/08 , Remove __NOR_FULL_DRIVER__ option for BL re-structure
254 # V7.196 , by Claudia at 2011/07/07 , Support Combo Memory on all platforms
255 # V7.184 , by Claudia at 2011/05/17 , Support MT6921 Auto-Gen
256 # V7.183 , by Claudia at 2011/05/16 , Correct MT6236 DRAM init flow
257 # V7.150 , by Claudia at 2011/03/04 , To support Card DL
258 # V7.159 , by Claudia at 2011/02/21 , Modify custom_EMI.c template to fix MT6235E5 DCM conflict with sw-workaround issue
259 # V7.149 , by Claudia at 2011/01/21 , To generate the entire NOR flash geometry for SDS (Secure Data Storage) feature
260 # V7.195 , by Marvin at 2011/07/06 , modify custom_flash.c template for bootloader re-organize
261 # V7.194 , by Marvin at 2011/06/15 , modify custom_flash.c
262 # V7.193 , by Marvin at 2011/06/15 , add pid to copy MDL file name, flash_opt.h template
263 # V7.192 , by Marvin at 2011/06/14 , add output file owner name for BM to find correct file owner quickly
264 # V7.191 , by Marvin at 2011/06/13 , Modify custom_SFI.c to remove include pwic.h to fix build error
265 # V7.190 , by Claudia at 2011/05/30 , Modify custom_EMI_release.h to include kal_general_types.h to fix build error
266 # V7.189 , by Claudia at 2011/05/30 , Support MT6252D SIP_SERIAL_FLASH_SIZE selection
267 # V7.188 , by Claudia at 2011/05/29 , Modify MT6276 custom_EMI.c for data training result and fix auto-tracking coding error
268 # V7.187 , by Claudia at 2011/05/29 , Remove 64Mb serial flash upper limit for MT6252 and MT6251
269 # V7.186 , by Claudia at 2011/05/26 , Modify custom_EMI.c to fix build error for EMMC_BOOTING
270 # V7.185 , by Claudia at 2011/05/26 , Modify custom_flash.c to fix build warnings
271 # V7.182 , by Claudia at 2011/05/13 , Modify custom_flash.c and flash_opt.h templates and add EMMC_BOOTING options to support eMMC Booting
272 # V7.181 , by Claudia at 2011/05/11 , Modify custom_EMI.c, custom_SFI.c, combo_sfi_config.h, and combo_sfi_defs.h templates to support MT6252 porting IC; Modify MDL version from 10AW1108MP to 10AW1124MP
273 # V7.180 , by Claudia at 2011/05/10 , Modify MT6252 custom_EMI.c to correct pragma wrapping
274 # V7.179 , by Claudia at 2011/05/05 , Retrieve MTKSIP information from internal MDL as well, and skip internal MDL operation for customer release
275 # V7.178 , by Claudia at 2011/04/22 , Support EMI Gen for MT6573 (and future smart phone projects)
276 # V7.177 , by Claudia at 2011/04/18 , Support MT6276M MDL split with MT6276
277 # V7.176 , by Claudia at 2011/04/16 , Support MT6252 SIP PSRAM selection by makefile option SIP_RAM_SIZE
278 # V7.175 , by Claudia at 2011/04/11 , Auto-select highest EMI clock by available EMI settings in MDL on MT6276 when EMI_CLK is set as DEFAULT
279 # V7.173 , by Claudia at 2011/04/01 , Fix the issue that MDL copy will fail when load path contains '+'
280 # V7.172 , by Claudia at 2011/03/24 , Modify flash_opt.h template to tune FS size for SDS
281 # V7.171 , by Claudia at 2011/03/18 , Modify Lookup_SFI_setting_by_IDX_CLK_BB_REG to retrieve MT6252 SFI setting with old MDL format (with chip information in the field)
282 # V7.170 , by Claudia at 2011/03/18 , Remove dependency check for SFI files on platforms which do not support SFI
283 # V7.169 , by Claudia at 2011/03/15 , Refine MT6251 MDL to remove chip information and to move MT6251 from common internal MDL to a separate internal MDL for MT6251
284 # V7.168 , by Claudia at 2011/03/12 , Modify custom_EMI.c and custom_EMI.h template to fix MT6252 build error
285 # V7.167 , by Claudia at 2011/03/11 , Fix custom_MemoryDevice.h unable to recognize "#define option" format issue
286 # V7.166 , by Claudia at 2011/03/10 , Modify custom_EMI.c template to set EPLL by or operation to prevent DSS configurations set by BL from being overwritten
287 # V7.165 , by Claudia at 2011/03/08 , Modify custom_EMI.c and custom_EMI.h templates to rename MT6270 as MT6276M
288 # V7.164 , by Claudia at 2011/03/07 , Modify custom_SFI.c to support MT6251 Meta, and modify custom_EMI.h to fix MT6251 build error when no COMBO_MEMORY_ENTRY_COUNT is defined
289 # V7.163 , by Claudia at 2011/03/04 , Support EMI Gen for MT6276 (including Combo Memory)
290 # V7.162 , by Claudia at 2011/03/01 , Forbid MT6251 with serial flash larger than 64Mb
291 # V7.161 , by Claudia at 2011/02/25 , Change MDL to 10AW1108 and report error directly when MDL does not exist
292 # V7.160 , by Claudia at 2011/02/21 , Fix custom_SFI.c GFH declaration invalid format error
293 # V7.158 , by Claudia at 2011/02/18 , Fix incorrect EXTSRAM_SIZE issue when RAM size is larger than 128Mb in MDL
294 # V7.157 , by Claudia at 2011/02/18 , Support EMI Gen for MT6251 (including Combo Memory)
295 # V7.156 , by Claudia at 2011/02/17 , Correct MT6252 compile option and fix SFI DCM issue; correct custom_flash.c Card DL template
296 # V7.155 , by Claudia at 2011/02/15 , Change MDL to 10AW1108 version; generate entire flash to support Card DL; generate 0 instead of x to fix SFI build error; remove redundant codes; add extra checking and bug fix to support MT6252 MP
297 # V7.152 , by Claudia at 2011/02/07 , Generate flash ID under all cases to support Card DL ini gen
298 # V7.151 , by Claudia at 2011/01/27 , Allow RegionInfo to be compiled for COMBO_MEMORY_SUPPORT and SERIAL_FLASH to prevent cksydrv error
299 # V7.148 , by Claudia at 2011/01/20 , To support NOR Idle Sweep
300 # V7.147 , by Claudia at 2011/01/20 , Support Combo Memory and refine emiclean and emigen behavior in Gsm2.mak
301 # V6.146 , by Claudia at 2011/01/14 , Put emiclean control in EMI Gen script instead of Gsm2.mak and to support MANUAL-CHECKIN for custom release
302 # V6.145 , by Claudia at 2011/01/04 , Modify custom_EMI.c template to skip Enhanced SW DCM
303 # V6.144 , by Claudia at 2010/12/23 , Modify custom_EMI.c template to remove the include of pwic.h to prevent build error caused by HAL
304 # V6.143 , by Claudia at 2010/12/17 , Modfiy MT6236/MT6268 custom_EMI.c to extend delay after CAL_EN (1/5T DLL Enable)
305 # V6.142 , by Claudia at 2010/12/17 , Support RHR (Merge MAUIW1043OF_RHR to MAUI)
306 # V6.141 , by Claudia at 2010/12/10 , Support PROJECT_EXPECTED_RAM_LIMIT_NFB for NAND+DRAM projects to set RAM boundary
307 # V6.140 , by Claudia at 2010/12/10 , Remove MT6253D, and rename for chip ID
308 # V6.132 , by Claudia at 2010/12/02 , Modify custom_flash.c and flash_opt.h to add new compile options for Spansion VSR
309 # V6.129 , by Claudia at 2010/12/02 , Enhance NOR FDM 4.0 to support Spansion VSR flipping problem.
310 # V6.138 , by Claudia at 2010/11/26 , Modify custom_flash.c template to replace DWORD with kal_uint32 to prevent build error
311 # V6.137 , by Claudia at 2010/11/19 , Modify flash_opt.h template to force build error if the public drive size is not enough
312 # V6.136 , by Claudia at 2010/11/14 , Rename MT6253E/L as MT6252H/MT6252
313 # V6.135 , by Claudia at 2010/11/11 , Support EMI Gen for MT6516
314 # V6.134 , by Claudia at 2010/11/05 , Support EMI clock configurable to enable force MCP at 52MHz
315 # V6.133 , by Claudia at 2010/10/27 , Modify MT6253(D) ASYNC setting retrieval to support 52MHz-only MCP on MT6253(DV)
316 # V6.131 , by Claudia at 2010/10/18 , Modify MT6253E/L custom_EMI.c template to enable DMA soft mode grant count
317 # V6.130 , by Claudia at 2010/10/18 , Support RHR Add and add header files include on custom_EMI.c, custom_EMI.h, and custom_flash.c
318 # V6.128 , by Claudia at 2010/10/01 , Modify custom_flash.c template to add NAND init check to support X-DL for TotalBBM
319 # V6.127 , by Claudia at 2010/09/13 , Support MT6253E/L
320 # V6.126 , by Claudia at 2010/09/05 , Support Spansion VSR flash
321 # V6.125 , by Claudia at 2010/08/16 , Support MT6253DV MCP clock rate selection
322 # V6.124 , by Claudia at 2010/08/06 , Correct compile option ARM9_MMU to __ARM9_MMU__
323 # V6.122 , by Claudia at 2010/07/29 , Support MT6236(ADMUX)
324 # V6.121 , by Claudia at 2010/07/12 , Modify custom_flash.c and flash_opt.h templates to support Intel SIBLEY M18 ESB
325 # V6.120 , by Claudia at 2010/07/11 , Rename the MDL before opening it to prevent WIN32 error due to opening MDL with the same name at the same time
326 # V6.119 , by Claudia at 2010/07/09 , Modify custom_EMI_release.h template to remove #define on platforms other than MT6236(B) to prevent compile error in ADS
327 # V6.118 , by Claudia at 2010/07/07 , Modify custom_EMI.c template to include custom_EMI_release.h to prevent custom release EMI Gen error due to the opening of excel files
328 # V6.117 , by Claudia at 2010/06/18 , Modify custom_EMI.c template to include pll.h instead of init.h for init.h file split
329 # V6.116 , by Claudia at 2010/06/17 , Create dummy custom_flash_norfdm5.c and custom_EMI_release.h when NOR_FDM5 not defined and when platform is not MT6236
330 # V6.115 , by Claudia at 2010/06/17 , Modify flash_opt.h template to add __FS_PHOE_DRIVE_AVAILABLE__ options
331 # V6.114 , by Claudia at 2010/06/11 , Create custom_EMI_release.h to define memory device type compile option
332 # V6.113 , by Claudia at 2010/05/23 , Modify MT6236 DCM flow to improve power-saving
333 # V6.111 , by Claudia at 2010/04/14 , Modify flash_opt.h template to support Spansion NS_P series flash
334 # V6.110 , by Claudia at 2010/04/09 , Search for missing part numbers in the internal MDL for unsupported MCPs
335 # V6.109 , by Claudia at 2010/03/20 , Modify custom_EMI.h template for MT6253(D) RF Desense
336 # V6.108 , by Claudia at 2010/03/19 , Modify custom_flash.c template to support NOR raw disk
337 # V6.107 , by Claudia at 2010/03/17 , Modify custom_flash.c template to support totalBBM
338 # V6.106 , by Claudia at 2010/03/16 , Modify custom_flash.c and flash_opt.h template to support customized reserve block
339 # V6.105 , by Claudia at 2010/03/07 , Modify MEM Info EMI setting retrieval to get the setting by the EMI fast clock of each chip
340 # V6.104 , by Claudia at 2010/03/06 , Modify EMI Gen part number comparison rule to be exactly match as one single line of the Part Number field of MDL
341 # V6.103 , by Claudia at 2010/03/06 , Fix side effect of EMI Init flow change
342 # V6.102 , by Claudia at 2010/03/06 , Modify EMI Init flow to support different MCPs
343 # V6.101 , by Claudia at 2010/02/09 , Work around to tune FAT size for Toshiba MCP bad small blocks issue
344 # V6.100 , by Claudia at 2010/01/25 , Add MEM_Info for MT6253
345 # V6.99 , by Claudia at 2010/01/23 , Support MT6236 and MT6253D Auto-Gen
346 # V6.98 , by Claudia at 2010/01/21 , Re-calculate NOR flash size and FAT base address for Toshiba MCP bad small blocks issue
347 # V6.97 , by Claudia at 2010/01/19 , Modify custom_flash.c template to allow FDM in BL
348 # V6.96 , by Claudia at 2010/01/05 , Support ARM11 Phase-in
349 # V6.95 , by Claudia at 2009/12/27 , EMI Initialization flow change on platfoms later than MT6253
350 # V6.94 , by Claudia at 2009/12/24 , Support MMAA
351 # V6.93 , by Claudia at 2009/12/20 , Add MT6253D
352 # V6.92 , by Claudia at 2009/12/01 , Modify custom_flash.c template to support NAND FDM5.0 Replace Block Count
353 # V6.91 , by Claudia at 2009/11/23 , Add NFB=BASIC case when calculating FAT offset for FOTA
354 # V6.90 , by Claudia at 2009/11/05 , Modify custom_flash.c template to avoid multi-instance compile error
355 # V6.89 , by JI at 2009/11/04 , MT6268 disable dqs enlarge feature
356 # V6.88 , by JI at 2009/10/20 , Support MT6253 SYNC_ACCESS Pseudo RAM CRE
357 # V6.87 , by Claudia at 2009/10/14 , Support NAND multi-instance
358 # V6.86 , by JI at 2009/08/05 , MT6235 BURST MODE Device Definition Missed Bug Fix
359 # V6.85 , by JI at 2009/08/04 , MT6253 add SAMSUNG SERIES SYNC type NOR_RAM_MCP support
360 # V6.84 , by JI at 2009/07/08 , MT6253 and INTEL_SIBLEY custom_EMI.c template
361 # V6.83 , by Claudia at 2009/06/16 , Modify MT6268 custom_EMI.c template
362 # V6.82 , by Claudia at 2009/06/05 , Retrieve MT6229/MT6230 information with platform as "MT6229 MT6230".
363 # V6.81 , by Claudia at 2009/06/05 , Modify flash_opt.h to remove NOR_BOOTING_NAND_BLOCK_SIZE and to set NAND_PARTITION_SECTORS as 0 when FOTA UPDATE_PACKAGE_ON_NAND
364 # V6.80 , by Claudia at 2009/05/27 , Modify custom_setEMI() in custom_EMI.c to forbid ultra-high requests
365 # V6.79 , by Claudia at 2009/05/22 , Modify custom_flash.c and flash_opt.h templates for FOTA Update Package on NAND
366 # V6.78 , by Claudia at 2009/05/20 , Modify DRAM initialization flow on MT6235/MT6238 to set PDN bit according to database
367 # V6.77 , by Claudia at 2009/05/19 , Modify custom_MemoryDevice.h, custom_flash.c, custom_flash_norfdm5.c, flash_opt.h, custom_fota.c to re-organize flash-related configurations
368 # V6.76 , by Claudia at 2009/05/07 , Modify DRAM initialization flow to remove power-down and auto-refresh
369 # V6.75 , by Claudia at 2009/04/08 , Remove FAT tuning for FOTA when FAT is already valid
370 # V6.74 , by Claudia at 2009/04/07 , Roll back temp solution to turn on FOTA for CMCC projects
371 # V6.73 , by Claudia at 2009/04/03 , Remove MCU Data prefetch buffer related codes on MT6268
372 # V6.72 , by Claudia at 2009/04/02 , Turn on FOTA when OPTR_SPEC is set to CMCC_0202_SEGA(_TECH) or CMCC_0202_SEGC(_TECH)
373 # V6.71 , by Claudia at 2009/03/25 , Tune FAT and Partition Sector settings automatically when FOTA is turned on
374 # V6.70 , by Claudia at 2009/03/25 , Modify EMI Gen V5 to support MT6230 for part number change
375 # V6.69 , by Claudia at 2009/03/19 , Use split_addr instead of split_emi for EMI Address and add MT6268 check for MT6268-specific registers
376 # V6.68 , by Claudia at 2009/03/16 , Support MT6223+INTEL_SIBLEY device templates
377 # V6.67 , by Claudia at 2009/03/13 , EMI Gen script Enhancement due to Device Excel data base extended for MT6253/MT6268
378 # V5.66 , by Claudia at 2009/03/06 , Add a new API custom_get_NORFLASH_Size in custom_flash.c for boot-loader
379 # V5.65 , by Claudia at 2009/01/14 , Modify FAT offset calculation when FOTA is turned on
380 # V5.64 , by Claudia at 2008/12/31 , Remove MT6205B
381 # V5.63 , by Claudia at 2008/12/30 , Remove LCSB
382 # V5.62 , by Claudia at 2008/12/25 , Remove FOTA_PROPRIETARY
383 # V5.61 , by Claudia at 2008/12/10 , Refine compile error messages.
384 # V5.60 , by Claudia at 2008/12/10 , Modify flash_opt.h template for new NOR flash devices
385 # V5.59 , by Claudia at 2008/12/02 , Modify flash_opt.h template to fix Spansion tESL and tERS issue
386 # V5.58 , by Claudia at 2008/11/14 , Add a new category in flash_opt.h for Spansion WSP
387 # V5.57 , by Claudia at 2008/10/28 , Fix NOR RDM5.0 FAT and small block judgement error
388 # V5.56 , by Claudia at 2008/10/22 , Revise MEMORY_DEVICE_TYPE and NAND_FLASH_BOOTING consistency check notification
389 # V5.55 , by Claudia at 2008/10/15 , Support FOTA+NFB Auto-Gen
390 # V5.54 , by Claudia at 2008/10/09 , Check MEMORY_DEVICE_TYPE and NAND_FLASH_BOOTING consistency in EMI Gen
391 # V5.53 , by Claudia at 2008/09/12 , Add file name and fline number information and unify all auto-gen error messages
392 # V5.52 , by Claudia at 2008/09/11 , To support ESB on MT6235
393 # V5.51 , by Claudia at 2008/08/28 , Modify custom_flash.c temlate to support FOTA on ARM9
394 # V5.50 , by Claudia at 2008/08/22 , To support FOTA on ARM9
395 # V5.49 , by Claudia at 2008/08/22 , Modify custom_EMI.c template for MT6235 NOR+PSRAM BURST MODE to remove EMI_CONE/EMI_CONF
396 # V5.48 , by Claudia at 2008/08/21 , Unify Auto-Gen error messages and modify EMI Gen part number parsing rules
397 # V5.47 , by Claudia at 2008/08/14 , Support FOTA Auto-Gen
398 # V5.46 , by Claudia at 2008/07/30 , Modify custom_EMI.c template to fix EMI_GENA and EMI_GEND issue on MT6235/MT6238 NFB
399 # V5.45 , by Claudia at 2008/07/24 , Align MT6238 info retrieval behavior with memory device database excel columns
400 # V5.44 , by Claudia at 2008/07/16 , Modify MT6235 DCM flow to fix UART data error issue
401 # V5.43 , by Claudia at 2008/07/16 , Modify custom_flash.c template for FOTA bug fix
402 # V5.42 , by Claudia at 2008/07/16 , Modify custom_flash.c template for FOTA bug fix on boot-loader
403 # V5.41 , by Claudia at 2008/07/15 , Modify custom_flash.c template for FOTA bug fix on boot-loader
404 # V5.40 , by Claudia at 2008/07/11 , Modify custom_flash.c template for FOTA
405 # V5.39 , by Claudia at 2008/07/10 , Modify custom_EMI.c template for EMI_GENA bit-clear issue
406 # V5.38 , by Claudia at 2008/06/13 , Modify custom_flash.c template to support NFB MBA
407 # V5.37 , by Claudia at 2008/06/11 , Set PARTITION_SIZE to 0 when NAND_FLASH_BOOTING and SYSTEM_DRIVE_ON_NAND are not defined
408 # V5.36 , by Claudia at 2008/06/10 , Remove page mode settings when ASYNC_ACCESS is selected
409 # V5.35 , by Claudia at 2008/06/02 , Modify custom_EMI.c template to adjust PMU output voltage by calling pmic_adpt_init() on MT6235/MT6238
410 # V5.34 , by Claudia at 2008/05/29 , Modify EMI Gen to change #if 0 patterns to comments so that they will not be removed from custom release
411 # V5.33 , by Claudia at 2008/05/23 , Modify flash_opt.h template so that when unsupported flash is used for ESB, compile error will occur
412 # V5.32 , by Claudia at 2008/05/22 , Modify DCM templates for MT6235/MT6238
413 # V5.31 , by Claudia at 2008/05/22 , Modify NOR_BLOCK_SIZE to be the largest block size in FAT
414 # V5.30 , by Claudia at 2008/05/22 , Modify MT6235 custom_setEMI template for E4
415 # V5.29 , by Claudia at 2008/05/19 , Modify MT6235/MT6238 DCM templates
416 # V5.28 , by Claudia at 2008/05/14 , Add MT6235B/MT6239 for EMI Info
417 # V5.27 , by Claudia at 2008/05/12 , Modify RegionInfo/BankInfo/BlockInfo patterh to { , } (spaces before and after , allowed)
418 # V5.26 , by Claudia at 2008/05/12 , Modify EMI Gen so that RegionInfo starts from FAT base address.
419 # V5.25 , by Claudia at 2008/04/23 , Generate part number and flash geometry information in custom_EMI.h and flash_opt.h for Scatter Gen
420 # V5.24 , by Claudia at 2008/04/02 , Erase queue size is either 5 (default) or according to user-setting
421 # V5.23 , by Claudia at 2008/03/28 , Add EMI Info for custom_EMI.c and custom_EMI.h
422 # V5.22 , by Claudia at 2008/03/24 , Fix PROJECT_EXPECTED_CODE_LIMIT errors and force erase queue size to be 3 when ALLOCATED_FAT_SPACE is set
423 # V5.21 , by Claudia at 2008/03/19 , Modify custom_flash.c template for ESB RAM shrink
424 # V5.20 , by Claudia at 2008/03/19 , FLASH_BASE_ADDRESS/ALLOCATED_FAT_SIZE should be defined when __FS_SYSDRV_ON_NAND__
425 # V5.19 , by Claudia at 2008/03/18 , region_info should align with FAT size setting by customer
426 # V5.18 , by Claudia at 2008/03/12 , Modify EMI Gen to split EMI/flash
427 # V5.17 , by Claudia at 2008/03/12 , Modify check mechanism when both EXPECTED_CODE_SIZE and EXPECTED_FAT_SIZE are set
428 # V5.16 , by Claudia at 2008/02/22 , Device Excel data base extended for MT6235/MT6238
429my $DebugPrint = 0; # 1 for debug; 0 for non-debug
430
431my $BOOL_EMI_CLEAN = $ARGV[0];
432my $CUSTOM_MEMORY_DEVICE_HDR = $ARGV[1];
433my $THEMF = $ARGV[2];
434my $BOOL_MD_INFO = $ARGV[3];
435my $INSIDE_MTK = $ARGV[4];
436my $LOAD_TMP_PATH = $ARGV[5];
437my $TARGET_DET = $ARGV[6];
438my $CUSTOM_FEATURE_CONFIG_HDR = $CUSTOM_MEMORY_DEVICE_HDR;
439$CUSTOM_FEATURE_CONFIG_HDR =~ s/custom_MemoryDevice/custom_FeatureConfig/;
440
441
442# to align error message file name format
443$CUSTOM_MEMORY_DEVICE_HDR =~ s/^.\\|^\\//;
444$THEMF =~ s/^.\\|^\\//;
445#print "$BOOL_EMI_CLEAN $CUSTOM_MEMORY_DEVICE_HDR $THEMF\n";
446# the following parameters come from $CUSTOM_MEMORY_DEVICE_HDR
447my %PART_NUMBER;
448my $MEMORY_DEVICE_TYPE;
449my $EMI_CLK;
450my $emi_clk_config;
451my $SFI_CLK;
452my $sfi_clk_config;
453my $NOR_FLASH_BASE_ADDRESS_VAL;
454my $NOR_ALLOCATED_FAT_SPACE_VAL;
455my $LPSDRAM_CHIP_SELECT = 0xFF;
456my $PROJECT_EXPECTED_RAM_LIMIT;
457my $PROJECT_EXPECTED_CODE_LIMIT;
458my $PROJECT_EXPECTED_RAM_LIMIT_NFB;
459my $SNOR_ERASE_QUEUE_SIZE;
460my $NOR_SYSTEM_DRIVE_RESERVED_BLOCK;
461my $emi_is_existed = 1;
462my %MEM_DEV_LIST_INDEX;
463my @MCP_LIST; # list of PART_NUMBER hash references
464my @MDL_INFO_LIST; # list of MEM_DEV_LIST_INFO has references
465my %COMM_MDL_INFO; # common MDL info, obtained from MDL_INFO_LIST.
466my @REGION_INFO_LIST; # extracted list of Region Info of all memory devices
467my @BANK_INFO_LIST; # extracted list of Bank Info of all memory devices
468my @BLOCK_INFO_LIST; # extracted list of Block Info of all memory devices
469my %MAKEFILE_OPTIONS; #list of makefile option
470my %CUSTOM_MEM_DEV_OPTIONS; #list of custom_memory_device option
471my $MEMORY_DEVICE_LIST_XLS; #CORRECT MDL FILE
472my $MEMORY_DEVICE_LIST_INT_XLS; #INTERNAL MDL FILE
473my $MEMORY_DEVICE_LIST_XLS_E;
474my $nor_block_size;
475my %CUSTOM_FEATURE_CFG_OPTIONS;
476my $OS_ENV = $^O;
477
478# locations of output EMI settings
479my $CUSTOM_EMI_H = $CUSTOM_MEMORY_DEVICE_HDR;
480my $CUSTOM_EMI_INFO_H = $CUSTOM_MEMORY_DEVICE_HDR;
481my $CUSTOM_EMI_RELEASE_H = $CUSTOM_MEMORY_DEVICE_HDR;
482my $CUSTOM_EMI_C = $CUSTOM_MEMORY_DEVICE_HDR;
483my $CUSTOM_SFI_H = $CUSTOM_MEMORY_DEVICE_HDR;
484my $CUSTOM_FLASH_H = $CUSTOM_MEMORY_DEVICE_HDR;
485my $FLASH_OPT_GEN_H = $CUSTOM_MEMORY_DEVICE_HDR;
486my $CUSTOM_FLASH_NORFDM5_H = $CUSTOM_MEMORY_DEVICE_HDR;
487my $COMBO_FLASH_CONFIG_H = $CUSTOM_MEMORY_DEVICE_HDR;
488my $COMBO_FLASH_ID_H = $CUSTOM_MEMORY_DEVICE_HDR;
489my $COMBO_SFI_CONFIG_H = $CUSTOM_MEMORY_DEVICE_HDR;
490my $COMBO_SFI_DEFS_H = $CUSTOM_MEMORY_DEVICE_HDR;
491my $CUSTOM_SFI_CLOCK_DEFS_H = $CUSTOM_MEMORY_DEVICE_HDR;
492my $COMBO_NFI_CONFIG_H = $CUSTOM_MEMORY_DEVICE_HDR;
493
494print "os environment : $OS_ENV\n";
495
496$CUSTOM_EMI_H =~ s/\/custom_MemoryDevice\.h$/\/custom_EMI\.h/i;
497$CUSTOM_EMI_INFO_H =~ s/\/custom_MemoryDevice\.h$/\/custom_EMI_INFO\.h/i;
498$CUSTOM_EMI_RELEASE_H =~ s/\/custom_MemoryDevice\.h$/\/custom_EMI_release\.h/i;
499$CUSTOM_EMI_C =~ s/\/custom_MemoryDevice\.h$/\/custom_EMI\.c/i;
500$CUSTOM_SFI_H =~ s/\/custom_MemoryDevice\.h$/\/custom_SFI\.h/i;
501$CUSTOM_FLASH_H =~ s/\/custom_MemoryDevice\.h$/\/custom_flash\.h/i;
502$FLASH_OPT_GEN_H =~ s/\/custom_MemoryDevice\.h$/\/flash_opt_gen\.h/i;
503$CUSTOM_FLASH_NORFDM5_H =~ s/\/custom_MemoryDevice\.h$/\/custom_flash_norfdm5\.h/i;
504$COMBO_FLASH_CONFIG_H =~ s/\/custom_MemoryDevice\.h$/\/combo_flash_config\.h/i;
505$COMBO_FLASH_ID_H =~ s/\/custom_MemoryDevice\.h$/\/combo_flash_id\.h/i;
506$COMBO_SFI_CONFIG_H =~ s/\/custom_MemoryDevice\.h$/\/combo_sfi_config\.h/i;
507$COMBO_SFI_DEFS_H =~ s/\/custom_MemoryDevice\.h$/\/combo_sfi_defs\.h/i;
508$CUSTOM_SFI_CLOCK_DEFS_H =~ s/\/custom_MemoryDevice\.h$/\/custom_sfi_clock\.h/i;
509$COMBO_NFI_CONFIG_H =~ s/\/custom_MemoryDevice\.h$/\/combo_nfi_config\.h/i;
510
511print "Load path:$LOAD_TMP_PATH\n";
512print "custom memory device:$CUSTOM_MEMORY_DEVICE_HDR\n";
513print "makefile: $THEMF\n";
514print "inside_mtk : $INSIDE_MTK\n";
515print "OutputFile: $CUSTOM_EMI_H, $CUSTOM_EMI_INFO_H, $CUSTOM_EMI_RELEASE_H, $CUSTOM_EMI_C, $CUSTOM_SFI_H, $CUSTOM_FLASH_H, $FLASH_OPT_GEN_H, $CUSTOM_FLASH_NORFDM5_H, $COMBO_FLASH_CONFIG_H, $COMBO_FLASH_ID_H, $COMBO_SFI_CONFIG_H, $COMBO_SFI_DEFS_H, $COMBO_NFI_CONFIG_H\n";
516
517# output file owner
518my $CUSTOM_EMI_H_OWNER = "Guo-Huei Chang(mtk04123)";
519my $CUSTOM_EMI_INFO_H_OWNER = "Guo-Huei Chang(mtk04123)";
520my $CUSTOM_EMI_RELEASE_H_OWNER = "Guo-Huei Chang(mtk04123)";
521my $CUSTOM_EMI_C_OWNER = "Guo-Huei Chang(mtk04123)";
522my $CUSTOM_SFI_H_OWNER = "Way Chen(mtk54483)";
523my $CUSTOM_FLASH_H_OWNER = "Way Chen(mtk54483)";
524my $FLASH_OPT_GEN_H_OWNER = "Way Chen(mtk54483)";
525my $CUSTOM_FLASH_NORFDM5_H_OWNER = "Way Chen(mtk54483)";
526my $COMBO_FLASH_CONFIG_H_OWNER = "Way Chen(mtk54483)";
527my $COMBO_FLASH_ID_H_OWNER = "Way Chen(mtk54483)";
528my $COMBO_SFI_CONFIG_H_OWNER = "Way Chen(mtk54483)";
529my $COMBO_SFI_DEFS_H_OWNER = "Way Chen(mtk54483)";
530my $COMBO_NFI_CONFIG_H_OWNER = "Way Chen(mtk54483)";
531
532require "tools/emigenemi.pl";
533require "tools/emigenflash.pl";
534require "tools/emigenSF.pl";
535
536#****************************************************************************
537# parse makefile
538#****************************************************************************
539&Parse_Makefile();
540#****************************************************************************
541# find the correct EMI database
542#****************************************************************************
543&Find_MDL();
544
545#****************************************************************************
546# emiclean
547#****************************************************************************
548if ($BOOL_EMI_CLEAN eq 'TRUE')
549{
550 &Check_ManualCheckIn($CUSTOM_EMI_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
551 &Check_ManualCheckIn($CUSTOM_EMI_RELEASE_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
552 &Check_ManualCheckIn($CUSTOM_EMI_INFO_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
553 &Check_ManualCheckIn($CUSTOM_SFI_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigen_flash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
554 &Check_ManualCheckIn($CUSTOM_FLASH_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
555 &Check_ManualCheckIn($FLASH_OPT_GEN_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
556 &Check_ManualCheckIn($CUSTOM_FLASH_NORFDM5_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
557 &Check_ManualCheckIn($COMBO_FLASH_CONFIG_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
558 &Check_ManualCheckIn($COMBO_FLASH_ID_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
559 &Check_ManualCheckIn($COMBO_SFI_CONFIG_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
560 &Check_ManualCheckIn($COMBO_SFI_DEFS_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
561 exit;
562}
563
564#****************************************************************************
565# generate emigen dependency file
566#****************************************************************************
567if ($TARGET_DET)
568{
569 print "TARGET_DET: $TARGET_DET\n";
570 unlink $TARGET_DET if (-e $TARGET_DET);
571 &PrintDependModule();
572 &PrintDependModule($MEMORY_DEVICE_LIST_XLS or $MEMORY_DEVICE_LIST_INT_XLS);
573 &PrintToDep("$TARGET_DET");
574}
575
576#****************************************************************************
577# PLATFORM EMI support matrix
578#****************************************************************************
579my %BBtbl_SFI_FAST_CLK =
580 (
581 'MT6290' => 78,
582 'TK6291' => 78,
583 );
584my %BBtbl_SFI_SLOW_CLK =
585 (
586 'MT6290' => 13,
587 'TK6291' => 13,
588 );
589
590if($BOOL_MD_INFO eq 'TRUE')
591{
592 print "emigen should not enter this routine\n";
593 &Parse_Memory_Device();
594 &Parse_MDL(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST,\$MEMORY_DEVICE_LIST_XLS, \$MEMORY_DEVICE_LIST_INT_XLS);
595 #****************************************************************************
596 # check consistency among FEATURE, MEMORY_DEVICE_TYPE, PLATFORM, MCU_CLOCK and MemoryDeviceList data
597 #****************************************************************************
598 $sfi_clk_config = $BBtbl_SFI_FAST_CLK{$MAKEFILE_OPTIONS{'platform'}};
599 &Decide_MemClockSpeed();
600
601 #****************************************************************************
602 # get common MDL information from a list of MDL information for Combo Memory
603 #****************************************************************************
604 &get_common_MDL_info(\@MDL_INFO_LIST, \%CUSTOM_MEM_DEV_OPTIONS, \%COMM_MDL_INFO,\%MAKEFILE_OPTIONS, $LPSDRAM_CHIP_SELECT, $CUSTOM_MEMORY_DEVICE_HDR, $emi_is_existed);
605 &query_MD_INFO(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\%COMM_MDL_INFO);
606 if ($DebugPrint == 1)
607 {
608 print "COMM_MDL_INFO: Flash Size = $COMM_MDL_INFO{0}->{'Flash Size'}, NAND Block Size(KB) = $COMM_MDL_INFO{0}->{'NAND Block Size(KB)'}, Small Block Start = $COMM_MDL_INFO{0}->{'Small Block Start'}, Default FAT Base = $COMM_MDL_INFO{0}->{'Default FAT Base'}, Default FAT Size = $COMM_MDL_INFO{0}->{'Default FAT Size'}, RAM \"Size (Mb)\" = $COMM_MDL_INFO{1}->{'Size (Mb)'}, \"CS0 ADMUX\" = $COMM_MDL_INFO{0}->{'ADMUX'}, \"CS1 ADMUX\" = $COMM_MDL_INFO{1}->{'ADMUX'}, \"DRAM\" = $COMM_MDL_INFO{1}->{'DRAM'}, \"CS0 Comm. Series\" = $COMM_MDL_INFO{0}->{'Comm. Series'}, \"CS1 Comm. Series\" = $COMM_MDL_INFO{1}->{'Comm. Series'}, \"Bank\" = $COMM_MDL_INFO{0}->{'Bank'}, \"PBP->Y / N\" = $COMM_MDL_INFO{0}->{'PBP'}->{'Y / N'}, \"PBP->Size(W)\" = $COMM_MDL_INFO{0}->{'PBP'}->{'Size(W)'}\n";
609 }
610 exit;
611}
612
613#****************************************************************************
614# dependency check
615#****************************************************************************
616&Check_ManualCheckIn($CUSTOM_EMI_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
617&Check_ManualCheckIn($CUSTOM_EMI_RELEASE_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
618&Check_ManualCheckIn($CUSTOM_EMI_INFO_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
619&Check_ManualCheckIn($CUSTOM_SFI_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigen_flash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
620&Check_ManualCheckIn($CUSTOM_FLASH_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
621&Check_ManualCheckIn($FLASH_OPT_GEN_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
622&Check_ManualCheckIn($CUSTOM_FLASH_NORFDM5_H, "TRUE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
623&Check_ManualCheckIn($COMBO_FLASH_CONFIG_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
624&Check_ManualCheckIn($COMBO_FLASH_ID_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
625&Check_ManualCheckIn($COMBO_SFI_CONFIG_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
626&Check_ManualCheckIn($COMBO_SFI_DEFS_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
627&Check_ManualCheckIn($CUSTOM_SFI_CLOCK_DEFS_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
628&Check_ManualCheckIn($COMBO_NFI_CONFIG_H, "FALSE", "tools/emiGenMD.pl", "tools/emiGenSP.pl", "tools/emigenemi.pl", "tools/emigenflash.pl", "tools/emigenSF.pl", $THEMF, $CUSTOM_MEMORY_DEVICE_HDR, $MEMORY_DEVICE_LIST_XLS, $MEMORY_DEVICE_LIST_INT_XLS, $CUSTOM_FEATURE_CONFIG_HDR);
629
630my $is_existed_h = (-e $CUSTOM_EMI_H)? 1 : 0;
631my $is_existed_release_h = (-e $CUSTOM_EMI_RELEASE_H)? 1 : 0;
632my $is_existed_info_h = (-e $CUSTOM_EMI_INFO_H)? 1 : 0;
633my $is_existed_sfi_h = (-e $CUSTOM_SFI_H)? 1 : 0;
634my $is_existed_flash_h = (-e $CUSTOM_FLASH_H)? 1 : 0;
635my $is_existed_flash_opt_gen = (-e $FLASH_OPT_GEN_H)? 1 : 0;
636my $is_existed_flash_norfdm5 = (-e $CUSTOM_FLASH_NORFDM5_H)? 1 : 0;
637my $is_existed_combo_flash_cfg_h = (-e $COMBO_FLASH_CONFIG_H)? 1 : 0;
638my $is_existed_combo_flash_id_h = (-e $COMBO_FLASH_ID_H)? 1 : 0;
639my $is_existed_combo_sfi_cfg_h = (-e $COMBO_SFI_CONFIG_H)? 1 : 0;
640my $is_existed_combo_sfi_defs_h = (-e $COMBO_SFI_DEFS_H)? 1 : 0;
641my $is_existed_combo_nfi_config_h = (-e $COMBO_NFI_CONFIG_H)? 1 : 0;
642#****************************************************************************
643# Check for Serial Flash Platform file
644#****************************************************************************
645
646if($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
647{
648 if ( ($is_existed_h == 1) && ($is_existed_release_h == 1) && ($is_existed_info_h == 1) && ($is_existed_sfi_h == 1) && ($is_existed_flash_h == 1) && ($is_existed_flash_opt_gen == 1) && ($is_existed_flash_norfdm5 == 1) && ($is_existed_combo_flash_cfg_h == 1) && ($is_existed_combo_flash_id_h == 1) && ($is_existed_combo_sfi_cfg_h == 1) && ($is_existed_combo_sfi_defs_h == 1) )
649 {
650 print "\n\nALL flash_opt\.h, custom_EMI\.h, custom_EMI_release\.h, custom_EMI\.c, custom_SFI\.h, custom_SFI\.c, custom_flash\.c, custom_flash_norfdm5\.c, combo_flash_config\.h, combo_flash_id\.h, combo_sfi_config\.h, and combo_sfi_defs\.h are existed!!!\n\n\n";
651 exit;
652 }
653}
654else
655{
656 if ( ($is_existed_h == 1) && ($is_existed_release_h == 1) && ($is_existed_info_h == 1) && ($is_existed_flash_h == 1) && ($is_existed_flash_opt_gen == 1) && ($is_existed_flash_norfdm5 == 1) && ($is_existed_combo_flash_cfg_h == 1) && ($is_existed_combo_flash_id_h == 1) )
657 {
658 print "\n\nALL flash_opt_gen\.h, custom_EMI\.h, custom_EMI_release\.h, custom_EMI_INFO\.h, custom_flash\.h, combo_flash_config\.h, and combo_flash_id\.h are existed!!!\n\n\n";
659 exit;
660 }
661}
662
663#****************************************************************************
664# parse custom_MemoryDevice.h to extract MEMORY_DEVICE_TYPE & PART_NUMBER
665#****************************************************************************
666&Parse_Memory_Device();
667
668#****************************************************************************
669# parse custom_FeatureConfig.h to extract feature-related configurations
670#****************************************************************************
671&Parse_custom_FeatureConfig(\%CUSTOM_FEATURE_CFG_OPTIONS);
672
673if ($DebugPrint == 1)
674{
675 print "Device Type : $CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} , ";
676 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
677 {
678 print "$_: $MCP_LIST[$_]->{0}, $MCP_LIST[$_]->{1}\n";
679 }
680 print "Manual Configure ( $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_RAM_LIMIT} , $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_CODE_LIMIT}, $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_RAM_LIMIT_NFB} )\n";
681}
682
683#****************************************************************************
684# Check EMI exist
685#****************************************************************************
686if (&config_query_no_EMI() == 1)
687{
688 require "tools/emiGenSP.pl";
689 $emi_is_existed = 0;
690}
691
692#****************************************************************************
693# parse EMI database to get EMI settings
694#****************************************************************************
695&Parse_MDL(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST,\$MEMORY_DEVICE_LIST_XLS, \$MEMORY_DEVICE_LIST_INT_XLS);
696
697#****************************************************************************
698# Check Combo Memory configuration validity
699#****************************************************************************
700my $nor_size_Mb;
701&CheckConfigValid(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST,\$MEMORY_DEVICE_LIST_XLS, \$MEMORY_DEVICE_LIST_INT_XLS);
702
703print "Flash Size is $nor_size_Mb\n" if (defined $nor_size_Mb);
704my $blk_info_first;
705if ($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
706{
707 $blk_info_first = $MDL_INFO_LIST[1]->{1}->{'Device Geometry'}->{'Block Info.'};
708}
709elsif ($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE')
710{
711 $blk_info_first = $MDL_INFO_LIST[1]->{1}->{'NAND Block Size(KB)'};
712}
713
714if (defined $blk_info_first)
715{
716 $blk_info_first =~ s/\s+//g; # remove spaces
717 $blk_info_first =~ s/},/}/g; # remove , after }
718}
719for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
720{
721 ### NOR flash size should be the same among all devices when Combo Memory is enabled
722 ### NAND flash size is not considered because we don't have to use NAND flash size information, this is not right for MT6290!
723 my $cur_nor_size_Mb;
724 if ($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
725 {
726 $cur_nor_size_Mb = $MDL_INFO_LIST[$_]->{1}->{'Size (Mb)'};
727 if (!defined $nor_size_Mb)
728 {
729 $nor_size_Mb = $cur_nor_size_Mb;
730 }
731 else
732 {
733 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select flash with the same size when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ($nor_size_Mb != $cur_nor_size_Mb);
734 }
735 }
736 elsif($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE')
737 {
738 $cur_nor_size_Mb = $MDL_INFO_LIST[$_]->{1}->{'NAND Size(MB)'};
739 if (!defined $nor_size_Mb)
740 {
741 $nor_size_Mb = $cur_nor_size_Mb;
742 }
743 else
744 {
745 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select flash with the same size when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ($nor_size_Mb != $cur_nor_size_Mb);
746 }
747 }
748}
749#****************************************************************************
750# check consistency among FEATURE, MEMORY_DEVICE_TYPE, PLATFORM, MCU_CLOCK and MemoryDeviceList data
751#****************************************************************************
752$sfi_clk_config = $BBtbl_SFI_FAST_CLK{$MAKEFILE_OPTIONS{'platform'}};
753&Decide_MemClockSpeed();
754
755#****************************************************************************
756# get common MDL information from a list of MDL information for Combo Memory
757#****************************************************************************
758&get_common_MDL_info(\@MDL_INFO_LIST, \%CUSTOM_MEM_DEV_OPTIONS, \%COMM_MDL_INFO,\%MAKEFILE_OPTIONS, $LPSDRAM_CHIP_SELECT, $CUSTOM_MEMORY_DEVICE_HDR, $emi_is_existed);
759if ($DebugPrint == 1)
760{
761 print "COMM_MDL_INFO: Flash Size = $COMM_MDL_INFO{0}->{'Flash Size'}, NAND Block Size(KB) = $COMM_MDL_INFO{0}->{'NAND Block Size(KB)'}, Small Block Start = $COMM_MDL_INFO{0}->{'Small Block Start'}, Default FAT Base = $COMM_MDL_INFO{0}->{'Default FAT Base'}, Default FAT Size = $COMM_MDL_INFO{0}->{'Default FAT Size'}, RAM \"Size (Mb)\" = $COMM_MDL_INFO{1}->{'Size (Mb)'}, \"CS0 ADMUX\" = $COMM_MDL_INFO{0}->{'ADMUX'}, \"CS1 ADMUX\" = $COMM_MDL_INFO{1}->{'ADMUX'}, \"DRAM\" = $COMM_MDL_INFO{1}->{'DRAM'}, \"CS0 Comm. Series\" = $COMM_MDL_INFO{0}->{'Comm. Series'}, \"CS1 Comm. Series\" = $COMM_MDL_INFO{1}->{'Comm. Series'}, \"Bank\" = $COMM_MDL_INFO{0}->{'Bank'}, \"PBP->Y / N\" = $COMM_MDL_INFO{0}->{'PBP'}->{'Y / N'}, \"PBP->Size(W)\" = $COMM_MDL_INFO{0}->{'PBP'}->{'Size(W)'}\n";
762}
763
764#****************************************************************************
765# PROJECT EXPECTED CONFIGURE
766#****************************************************************************
767my $physical_ram_density;
768my $project_expected_ram_limit_common = (exists $MAKEFILE_OPTIONS{'nand_flash_booting'} and $MAKEFILE_OPTIONS{'nand_flash_booting'} ne 'NONE') ? $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_RAM_LIMIT_NFB} : $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_RAM_LIMIT};
769if (defined $project_expected_ram_limit_common)
770{
771 #ensure practical
772 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Cannot configure expected RAMSIZE larger than physical RAM size!", __FILE__, __LINE__)
773 if ( hex($project_expected_ram_limit_common) > ($COMM_MDL_INFO{1}->{'Size (Mb)'} * 1024 * 1024 / 8) );
774
775 #ensure 2^n
776 my $i;
777 for( $i = 1 ; $i < hex($project_expected_ram_limit_common) ; $i *= 2 ){1;}
778 if ( $i < ($COMM_MDL_INFO{1}->{'Size (Mb)'} * 1024 * 1024 / 8) )
779 {
780 $physical_ram_density = "// PHYSICAL RAM DENSITY $COMM_MDL_INFO{1}->{'Size (Mb)'} Mb\n";
781 $COMM_MDL_INFO{1}->{'Size (Mb)'} = $i * 8 / ( 1024 * 1024);
782 }
783}
784chomp $physical_ram_density if (defined $physical_ram_density);
785
786#****************************************************************************
787# get common entire geometry information for Combo Memory
788#****************************************************************************
789my (@entire_region_info_size_list, @entire_region_info_count_list, @entire_bank_info_size_list, @entire_bank_info_count_list);
790my (@entire_block_info_start_list, @entire_block_info_size_list);
791if ($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
792{
793 &get_common_MDL_Geo_info(\@MDL_INFO_LIST, $CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT}, $CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE}, 0, $COMM_MDL_INFO{0}->{'Flash Size'}, \@entire_region_info_size_list, \@entire_region_info_count_list, \@entire_bank_info_size_list, \@entire_bank_info_count_list);
794 &convert_regions_to_blocks(0, \@entire_region_info_size_list, \@entire_region_info_count_list, \@entire_block_info_start_list, \@entire_block_info_size_list);
795
796}
797#NAND Flash Also need to check FAT for MT6290, we may use NAND FAT Infomation
798&Calculate_FAT_Info(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \%COMM_MDL_INFO, \@MDL_INFO_LIST, \$NOR_FLASH_BASE_ADDRESS_VAL, \$NOR_ALLOCATED_FAT_SPACE_VAL, $nor_size_Mb, \%CUSTOM_FEATURE_CFG_OPTIONS, \@entire_block_info_start_list, \@entire_block_info_size_list);
799#****************************************************************************
800# get common FS geometry information for Combo Memory
801#****************************************************************************
802my (@fs_region_info_size_list, @fs_region_info_count_list, @fs_bank_info_size_list, @fs_bank_info_count_list);
803my (@fs_block_info_start_list, @fs_block_info_size_list);
804if ($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
805{
806 &get_common_MDL_Geo_info(\@MDL_INFO_LIST, $CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT}, $CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE}, $NOR_FLASH_BASE_ADDRESS_VAL, $NOR_FLASH_BASE_ADDRESS_VAL+$NOR_ALLOCATED_FAT_SPACE_VAL, \@fs_region_info_size_list, \@fs_region_info_count_list, \@fs_bank_info_size_list, \@fs_bank_info_count_list);
807 &convert_regions_to_blocks($NOR_FLASH_BASE_ADDRESS_VAL, \@fs_region_info_size_list, \@fs_region_info_count_list, \@fs_block_info_start_list, \@fs_block_info_size_list);
808 if ($DebugPrint == 1)
809 {
810 print "Entire RegionInfo: ";
811 for (0..$#entire_region_info_size_list)
812 {
813 print "\{$entire_region_info_size_list[$_], $entire_region_info_count_list[$_]\}, ";
814 }
815 print "\nEntire BankInfo: ";
816 for (0..$#entire_bank_info_size_list)
817 {
818 print "\{$entire_bank_info_size_list[$_], $entire_bank_info_count_list[$_]\}, ";
819 }
820 print "\nEntire BlockInfo: ";
821 for (0..$#entire_block_info_start_list)
822 {
823 print "\{$entire_block_info_start_list[$_], $entire_block_info_size_list[$_]\}, ";
824 }
825 print "\nFS RegionInfo: ";
826 for (0..$#fs_region_info_size_list)
827 {
828 print "\{$fs_region_info_size_list[$_], $fs_region_info_count_list[$_]\}, ";
829 }
830 print "\nFS BankInfo: ";
831 for (0..$#fs_bank_info_size_list)
832 {
833 print "\{$fs_bank_info_size_list[$_], $fs_bank_info_count_list[$_]\}, ";
834 }
835 print "\nFS BlockInfo: ";
836 for (0..$#fs_block_info_start_list)
837 {
838 print "\{$fs_block_info_start_list[$_], $fs_block_info_size_list[$_]\}, ";
839 }
840 print "\n";
841 }
842}
843
844### Validate FAT and NOR Raw disk overlapping case
845&Validate_FAT_NORRAWDISK_OVERLAP(\%CUSTOM_MEM_DEV_OPTIONS, \%COMM_MDL_INFO, \$NOR_FLASH_BASE_ADDRESS_VAL, \$NOR_ALLOCATED_FAT_SPACE_VAL, $CUSTOM_MEMORY_DEVICE_HDR);
846### Calculate NOR Raw disk Region Info
847&Calculate_NORRAWDISK_Region_Info(\%CUSTOM_MEM_DEV_OPTIONS);
848
849### Check CODE setting validity
850my $expected_code_limit;
851if (defined $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_CODE_LIMIT})
852{
853 #ensure practical
854 &error_handler("$CUSTOM_FEATURE_CONFIG_HDR: Cannot configure expected CODESIZE larger than (physical NOR flash size - FAT space)!", __FILE__, __LINE__)
855 if ( hex($CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_CODE_LIMIT}) > $NOR_FLASH_BASE_ADDRESS_VAL );
856}
857
858#****************************************************************************
859# generate custom_EMI.h
860#****************************************************************************
861if ($is_existed_h == 0)
862{
863 if ($MAKEFILE_OPTIONS{'platform'} eq 'MT6290')
864 {
865 open (CUSTOM_EMI_H, ">$CUSTOM_EMI_H") or &error_handler("CUSTOM_EMI_H: file error!", __FILE__, __LINE__);
866
867 print CUSTOM_EMI_H &copyright_file_header();
868 print CUSTOM_EMI_H &description_file_header("custom_EMI.h",
869 "This Module defines the EMI (external memory interface) related setting.",
870 $CUSTOM_EMI_H_OWNER . "EMI auto generator" . $EMIGEN_VERNO);
871 if ($emi_is_existed == 0) {
872 print CUSTOM_EMI_H &custom_EMI_h_file_body_for_sp($MAKEFILE_OPTIONS{'platform'});
873 } else {
874 print CUSTOM_EMI_H &custom_EMI_h_90_file_body(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST, \%COMM_MDL_INFO, \%PART_NUMBER, $CUSTOM_MEMORY_DEVICE_HDR, $LPSDRAM_CHIP_SELECT, $emi_clk_config);
875 }
876 close CUSTOM_EMI_H or &error_handler("$CUSTOM_EMI_H: file error!", __FILE__, __LINE__);
877 }
878}
879
880#****************************************************************************
881# generate custom_EMI_INFO.h
882#****************************************************************************
883if ($is_existed_info_h == 0)
884{
885 if($MAKEFILE_OPTIONS{'platform'} eq 'MT6290')
886 {
887 open (CUSTOM_EMI_INFO_H, ">$CUSTOM_EMI_INFO_H") or &error_handler("CUSTOM_EMI_INFO_H: file error!", __FILE__, __LINE__);
888
889 print CUSTOM_EMI_INFO_H &copyright_file_header();
890 print CUSTOM_EMI_INFO_H &description_file_header("custom_EMI_INFO.h",
891 "This Module defines the EMI (external memory interface) related setting.",
892 $CUSTOM_EMI_INFO_H_OWNER . "EMI auto generator" . $EMIGEN_VERNO);
893 if ($emi_is_existed == 0) {
894 print CUSTOM_EMI_INFO_H &custom_EMI_info_h_file_body_for_sp($MAKEFILE_OPTIONS{'platform'});
895 } else {
896 print CUSTOM_EMI_INFO_H &custom_EMI_info_h_90_file_body(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST, \%COMM_MDL_INFO, \%PART_NUMBER, $CUSTOM_MEMORY_DEVICE_HDR, $LPSDRAM_CHIP_SELECT, $emi_clk_config);
897 }
898 close CUSTOM_EMI_INFO_H or &error_handler("$CUSTOM_EMI_INFO_H: file error!", __FILE__, __LINE__);
899
900 print "\n$CUSTOM_EMI_INFO_H is generated\n";
901 }
902}
903#****************************************************************************
904# generate custom_EMI_release.h
905#****************************************************************************
906if ($is_existed_release_h == 0)
907{
908 open (CUSTOM_EMI_RELEASE_H, ">$CUSTOM_EMI_RELEASE_H") or &error_handler("CUSTOM_EMI_RELEASE_H: file error!", __FILE__, __LINE__);
909
910 print CUSTOM_EMI_RELEASE_H &copyright_file_header();
911 print CUSTOM_EMI_RELEASE_H &description_file_header("custom_EMI_release.h",
912 "This Module defines the EMI (external memory interface) related setting.",
913 $CUSTOM_EMI_RELEASE_H_OWNER . "EMI auto generator" . $EMIGEN_VERNO);
914 if ($emi_is_existed == 0) {
915 print CUSTOM_EMI_RELEASE_H &custom_EMI_release_h_file_body_for_sp(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST, \%COMM_MDL_INFO, $LPSDRAM_CHIP_SELECT, $emi_clk_config);
916 } else {
917 print CUSTOM_EMI_RELEASE_H &custom_EMI_release_h_90_file_body(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST, \%COMM_MDL_INFO, $LPSDRAM_CHIP_SELECT, $emi_clk_config);
918 }
919 close CUSTOM_EMI_RELEASE_H or &error_handler("$CUSTOM_EMI_RELEASE_H: file error!", __FILE__, __LINE__);
920
921 print "\n$CUSTOM_EMI_RELEASE_H is generated\n";
922}
923
924#****************************************************************************
925# generate flash_opt_gen.h
926#****************************************************************************
927if ($is_existed_flash_opt_gen == 0)
928{
929 open (FLASH_OPT_GEN_H, ">$FLASH_OPT_GEN_H") or &error_handler("$FLASH_OPT_GEN_H: file error!", __FILE__, __LINE__);
930
931 print FLASH_OPT_GEN_H &copyright_file_header();
932 print FLASH_OPT_GEN_H &description_file_header("flash_opt_gen.h",
933 "NOR flash related options",
934 $FLASH_OPT_GEN_H_OWNER . "EMI auto generator" . $EMIGEN_VERNO);
935 print FLASH_OPT_GEN_H &flash_opt_gen_h_file_body(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS,\@MDL_INFO_LIST, \%COMM_MDL_INFO, $CUSTOM_MEMORY_DEVICE_HDR, $THEMF, \@entire_bank_info_size_list, \@entire_bank_info_count_list, \@entire_block_info_start_list, \@entire_block_info_size_list, \@entire_region_info_size_list, \@entire_region_info_count_list);
936 close FLASH_OPT_GEN_H or &error_handler("$FLASH_OPT_GEN_H: file error!", __FILE__, __LINE__);
937
938 print "\n$FLASH_OPT_GEN_H is generated\n";
939}
940
941#****************************************************************************
942# generate custom_flash.h
943#****************************************************************************
944if ($is_existed_flash_h == 0)
945{
946 open (CUSTOM_FLASH_H, ">$CUSTOM_FLASH_H") or &error_handler("$CUSTOM_FLASH_H: file error!", __FILE__, __LINE__);
947
948 print CUSTOM_FLASH_H &copyright_file_header();
949 print "custom_flash.h $CUSTOM_MEMORY_DEVICE_HDR\n";
950 print CUSTOM_FLASH_H &description_file_header("custom_flash.h",
951 "This Module defines flash related settings.",
952 $CUSTOM_FLASH_H_OWNER . "EMI auto generator" . $EMIGEN_VERNO);
953 print CUSTOM_FLASH_H &custom_flash_h_file_body(\%MAKEFILE_OPTIONS,\%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO, \@MCP_LIST, $NOR_FLASH_BASE_ADDRESS_VAL, $NOR_ALLOCATED_FAT_SPACE_VAL, $LPSDRAM_CHIP_SELECT, $CUSTOM_MEMORY_DEVICE_HDR, $nor_size_Mb, \@entire_bank_info_size_list, \@entire_bank_info_count_list, \@entire_block_info_start_list, \@entire_block_info_size_list,\@fs_region_info_size_list, \@fs_region_info_count_list, \@entire_region_info_size_list, \@entire_region_info_count_list);
954 close CUSTOM_FLASH_H or &error_handler("$CUSTOM_FLASH_H: file error!", __FILE__, __LINE__);
955
956 print "\n$CUSTOM_FLASH_H is generated\n";
957}
958
959#****************************************************************************
960# generate custom_flash_norfdm5.h
961#****************************************************************************
962if (($is_existed_flash_norfdm5 == 0) and (defined $CUSTOM_MEM_DEV_OPTIONS{__NOR_FDM5__}))##Only __NOR_FDM5__ defined will gen custom_flash_norfdm5.h
963{
964 open (CUSTOM_FLASH_NORFDM5_H, ">$CUSTOM_FLASH_NORFDM5_H") or &error_handler("$CUSTOM_FLASH_NORFDM5_H: file error!", __FILE__, __LINE__);
965
966 print CUSTOM_FLASH_NORFDM5_H &copyright_file_header();
967 print CUSTOM_FLASH_NORFDM5_H &description_file_header("custom_flash_norfdm5.h",
968 "defines prototypes and data structure which will be used in NOR FDM 5.0",
969 $CUSTOM_FLASH_NORFDM5_H_OWNER . "EMI auto generator" . $EMIGEN_VERNO);
970 print CUSTOM_FLASH_NORFDM5_H &custom_flash_norfdm5_h_file_body(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO, $NOR_FLASH_BASE_ADDRESS_VAL, $NOR_ALLOCATED_FAT_SPACE_VAL,\@entire_bank_info_size_list, \@entire_bank_info_count_list);
971 close CUSTOM_FLASH_NORFDM5_H or &error_handler("$CUSTOM_FLASH_NORFDM5_H: file error!", __FILE__, __LINE__);
972
973 print "\n$CUSTOM_FLASH_NORFDM5_H is generated\n";
974}
975
976#****************************************************************************
977# generate combo_flash_config.h
978#****************************************************************************
979if ($is_existed_combo_flash_cfg_h == 0)
980{
981 open (COMBO_FLASH_CONFIG_H, ">$COMBO_FLASH_CONFIG_H") or &error_handler("$COMBO_FLASH_CONFIG_H: file error!", __FILE__, __LINE__);
982
983 print COMBO_FLASH_CONFIG_H &copyright_file_header();
984 print COMBO_FLASH_CONFIG_H &description_file_header("combo_flash_config.h",
985 "This Module defines the Flash configurations for Combo Memory.",
986 $COMBO_FLASH_CONFIG_H_OWNER . "EMI auto generator" . $EMIGEN_VERNO);
987 print COMBO_FLASH_CONFIG_H &combo_flash_config_h_file_body(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO);
988 close COMBO_FLASH_CONFIG_H or &error_handler("$COMBO_FLASH_CONFIG_H: file error!", __FILE__, __LINE__);
989
990 print "\n$COMBO_FLASH_CONFIG_H is generated\n";
991}
992
993#****************************************************************************
994# generate combo_flash_id.h
995#****************************************************************************
996if ($is_existed_combo_flash_id_h == 0)
997{
998 open (COMBO_FLASH_ID_H, ">$COMBO_FLASH_ID_H") or &error_handler("$COMBO_FLASH_ID_H: file error!", __FILE__, __LINE__);
999
1000 print COMBO_FLASH_ID_H &copyright_file_header();
1001 print COMBO_FLASH_ID_H &description_file_header("combo_flash_id.h",
1002 "This Module defines the Flash ID table for Combo Memory.",
1003 $COMBO_FLASH_ID_H_OWNER . "EMI auto generator" . $EMIGEN_VERNO);
1004 print COMBO_FLASH_ID_H &combo_flash_id_h_file_body(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO);
1005 close COMBO_FLASH_ID_H or &error_handler("$COMBO_FLASH_ID_H: file error!", __FILE__, __LINE__);
1006
1007 print "\n$COMBO_FLASH_ID_H is generated\n";
1008}
1009
1010if($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE')
1011{
1012 #****************************************************************************
1013 # generate combo_nfi_config.h
1014 #****************************************************************************
1015 if ($is_existed_combo_nfi_config_h == 0)
1016 {
1017 open (COMBO_SFI_DEFS_H, ">$COMBO_NFI_CONFIG_H") or &error_handler("$COMBO_NFI_CONFIG_H: file error!", __FILE__, __LINE__);
1018
1019 print COMBO_SFI_DEFS_H &copyright_file_header();
1020 print COMBO_SFI_DEFS_H &description_file_header("combo_nfi_config.h",
1021 "gen NAND Flash Related Configuration and Table",
1022 $COMBO_NFI_CONFIG_H_OWNER . "EMI auto generator" . $EMIGEN_VERNO);
1023 print COMBO_SFI_DEFS_H &combo_nfi_config_h_file_body(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO);
1024 close COMBO_SFI_DEFS_H or &error_handler("$COMBO_NFI_CONFIG_H: file error!", __FILE__, __LINE__);
1025
1026 print "\n$COMBO_NFI_CONFIG_H is generated\n";
1027 }
1028}
1029
1030if($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
1031{
1032 #****************************************************************************
1033 # generate combo_sfi_defs.h
1034 #****************************************************************************
1035 if ($is_existed_combo_sfi_defs_h == 0)
1036 {
1037 open (COMBO_SFI_DEFS_H, ">$COMBO_SFI_DEFS_H") or &error_handler("$COMBO_SFI_DEFS_H: file error!", __FILE__, __LINE__);
1038
1039 print COMBO_SFI_DEFS_H &copyright_file_header();
1040 print COMBO_SFI_DEFS_H &description_file_header("combo_sfi_defs.h",
1041 "defines flash ID table",
1042 $COMBO_SFI_DEFS_H_OWNER . "EMI auto generator" . $EMIGEN_VERNO);
1043 print COMBO_SFI_DEFS_H &combo_sfi_defs_h_file_body(\%MAKEFILE_OPTIONS, \%CUSTOM_MEM_DEV_OPTIONS, \@MDL_INFO_LIST, \%COMM_MDL_INFO);
1044 close COMBO_SFI_DEFS_H or &error_handler("$COMBO_SFI_DEFS_H: file error!", __FILE__, __LINE__);
1045
1046 print "\n$COMBO_SFI_DEFS_H is generated\n";
1047 }
1048}
1049
1050exit;
1051
1052#****************************************************************************
1053# find the correct EMI database
1054#****************************************************************************
1055sub Find_MDL
1056{
1057 my $MDL_DIR = "tools/MemoryDeviceList/";
1058 my $platform = $MAKEFILE_OPTIONS{'platform'};
1059 my $ver = 0000;
1060
1061 $MEMORY_DEVICE_LIST_XLS = "";
1062 $MEMORY_DEVICE_LIST_INT_XLS = "";
1063
1064 opendir(DIR, $MDL_DIR) or die $!;
1065
1066 if (defined($MAKEFILE_OPTIONS{'ram_support_type'}) && $MAKEFILE_OPTIONS{'ram_support_type'} eq 'NONE') {
1067 $platform = $MAKEFILE_OPTIONS{'ram_support_type'};
1068 }
1069 while (my $mdl = readdir(DIR)) {
1070 if ($mdl =~ /MemoryDeviceList_$platform\_SinceW(\w+)\.xls/) {
1071 if ($1 > $ver) {
1072 $ver = $1;
1073 $MEMORY_DEVICE_LIST_XLS = $MDL_DIR . $mdl;
1074 }
1075 } elsif ($mdl =~ /MemoryDeviceList_$platform\_Internal\.xls/) {
1076 $MEMORY_DEVICE_LIST_INT_XLS = $MDL_DIR . $mdl;
1077 }
1078 }
1079
1080 close(DIR);
1081
1082 if ((! -e $MEMORY_DEVICE_LIST_XLS) && (! -e $MEMORY_DEVICE_LIST_INT_XLS)) {
1083 &error_handler("MDL Excel is not exist for platform '$platform':$MEMORY_DEVICE_LIST_XLS and $MEMORY_DEVICE_LIST_INT_XLS", __FILE__, __LINE__);
1084 }
1085
1086 if ($DebugPrint == 1) {
1087 print "custom memory device header file:$CUSTOM_MEMORY_DEVICE_HDR\n";
1088 print "MDL Excel:$MEMORY_DEVICE_LIST_XLS, Internal MDL Excel:$MEMORY_DEVICE_LIST_INT_XLS\n";
1089 print "Makefile:$THEMF\n";
1090 }
1091}
1092
1093#****************************************************************************
1094# parse Project Makefile
1095#****************************************************************************
1096sub Parse_Makefile
1097{
1098 my $keyname;
1099
1100 &error_handler("$THEMF: NOT exist!", __FILE__, __LINE__) if (!-e $THEMF);
1101
1102 if ($THEMF =~ /make\\(\w+)_(\w+).mak/i) {
1103 $MAKEFILE_OPTIONS{'MODE'} = uc($2);
1104 }
1105
1106 open (FILE_HANDLE, "<$THEMF") or &error_handler("$THEMF: file error!", __FILE__, __LINE__);
1107 while (<FILE_HANDLE>) {
1108 if (/^(\w+)\s*=\s*(\S+)/) {
1109 $keyname = lc($1);
1110 defined($MAKEFILE_OPTIONS{$keyname}) && warn "$1 redefined in $THEMF!\n";
1111 $MAKEFILE_OPTIONS{$keyname} = uc($2);
1112 if ($DebugPrint == 1) {
1113 print "$1:$2\n";
1114 }
1115 }
1116 }
1117 close (FILE_HANDLE);
1118}
1119
1120#****************************************************************************
1121# parse Memory Device
1122#****************************************************************************
1123sub Parse_Memory_Device
1124{
1125 my $cs;
1126
1127 open CUSTOM_MEMORY_DEVICE_HDR, "<$CUSTOM_MEMORY_DEVICE_HDR" or &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: file error!", __FILE__, __LINE__);
1128 while (<CUSTOM_MEMORY_DEVICE_HDR>)
1129 {
1130 # error-checking
1131 if (/^#if|^#ifdef|^#ifndef|^#elif|^#else/)
1132 {
1133 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Not allowed to set conditional keywords $_ in custom_MemoryDevice.h!", __FILE__, __LINE__)
1134 unless (/^#ifndef\s+__CUSTOM_MEMORYDEVICE__/);
1135 }
1136
1137 if (/^#define\s+(\w+)\s+\(([\w|\-]*)\)/ || /^#define\s+(\w+)\s+([\w|\-]*)/)
1138 {
1139 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: $1 redefined in custom_MemoryDevice.h!", __FILE__, __LINE__) if defined($CUSTOM_MEM_DEV_OPTIONS{$1});
1140 if ((!defined $2) or ($2 eq ''))
1141 {
1142 $CUSTOM_MEM_DEV_OPTIONS{$1} = 'TRUE';
1143 }
1144 else
1145 {
1146 $CUSTOM_MEM_DEV_OPTIONS{$1} = $2;
1147 #print "$1 => $CUSTOM_MEM_DEV_OPTIONS{$1}\n";
1148 }
1149
1150 my $option = $1;
1151 my $content = $2;
1152 if ($option =~ /COMBO_MEM(\d+)_CS(\d+)_PART_NUMBER/)
1153 {
1154 next if ((!defined $MAKEFILE_OPTIONS{'combo_memory_support'}) or ($MAKEFILE_OPTIONS{'combo_memory_support'} eq 'FALSE'));
1155 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: COMBO_MEM_ENTRY_COUNT needs to be defined when COMBO_MEMORY_SUPPORT is turned on!", __FILE__, __LINE__) if (!defined $CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT});
1156 my %TMP_PART_NUMBER;
1157 my $mcp_idx = $1;
1158 $cs = $2;
1159 print "LPSDRAM_CHIP_SELECT:$LPSDRAM_CHIP_SELECT, cs:$cs\n";
1160 $LPSDRAM_CHIP_SELECT = $cs;
1161 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Only COMBO_MEM0n_CS0 or COMBO_MEM0n_CS1 is allowed!", __FILE__, __LINE__) if (($LPSDRAM_CHIP_SELECT != 0) && ($LPSDRAM_CHIP_SELECT != 1));
1162 $TMP_PART_NUMBER{$cs} = $content;
1163
1164 if (defined $MCP_LIST[$mcp_idx])
1165 {
1166 if (defined $MCP_LIST[$mcp_idx]->{$cs})
1167 {
1168 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: COMBO_MEM$mcp_idx\_CS$cs\_PART_NUMBER multiply defined!", __FILE__, __LINE__);
1169 }
1170 else
1171 {
1172 $MCP_LIST[$mcp_idx]->{$cs} = $TMP_PART_NUMBER{$cs};
1173 }
1174 }
1175 else
1176 {
1177 $MCP_LIST[$mcp_idx] = \%TMP_PART_NUMBER;
1178 }
1179 }
1180 elsif ($option =~ /CS(\d+)_PART_NUMBER/)
1181 {
1182 next if ($MAKEFILE_OPTIONS{'combo_memory_support'} eq 'TRUE'); # when COMBO_MEMORY_SUPPORT is turned on, CSx_PART_NUMBER is ignored
1183 my $cs = $1;
1184
1185 print "LPSDRAM_CHIP_SELECT:$LPSDRAM_CHIP_SELECT, cs:$cs\n";
1186 $LPSDRAM_CHIP_SELECT = $cs;
1187 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Only COMBO_MEM0n_CS0 or COMBO_MEM0n_CS1 is allowed!", __FILE__, __LINE__) if (($LPSDRAM_CHIP_SELECT != 0) && ($LPSDRAM_CHIP_SELECT != 1));
1188 $PART_NUMBER{$cs} = $content;
1189 }
1190 }
1191 }
1192
1193 $CUSTOM_MEM_DEV_OPTIONS{NOR_FDM4_ESB_PARAMETER_ERASE_QUEUE_SIZE} = (defined $CUSTOM_MEM_DEV_OPTIONS{NOR_FDM4_ESB_PARAMETER_ERASE_QUEUE_SIZE}) ? $CUSTOM_MEM_DEV_OPTIONS{NOR_FDM4_ESB_PARAMETER_ERASE_QUEUE_SIZE} : 5;
1194 $CUSTOM_MEM_DEV_OPTIONS{NOR_PARAMETER_SYSTEM_DRIVE_RESERVED_BLOCK} = (defined $CUSTOM_MEM_DEV_OPTIONS{NOR_PARAMETER_SYSTEM_DRIVE_RESERVED_BLOCK}) ? $CUSTOM_MEM_DEV_OPTIONS{NOR_PARAMETER_SYSTEM_DRIVE_RESERVED_BLOCK} : 3;
1195
1196 # No Combo MCP case
1197 if ($MAKEFILE_OPTIONS{'combo_memory_support'} ne 'TRUE')
1198 {
1199 $MCP_LIST[1] = \%PART_NUMBER;
1200 $CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT} = 1;
1201 }
1202
1203 # COMBO_MEM_ENTRY_COUNT and the number of COMBO_MEMxx_CSx_PART_NUMBER does not match
1204 if ($CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT} != $#MCP_LIST)
1205 {
1206 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: COMBO_MEM_ENTRY_COUNT and the number of COMBO_MEMxx_CSx_PART_NUMBER does not match!", __FILE__, __LINE__);
1207 }
1208
1209 ###Check MEMORY_DEVICE_TYPE correction
1210 if (($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} !~ /$MAKEFILE_OPTIONS{'ram_support_type'}/) ||
1211 (($MAKEFILE_OPTIONS{'ram_support_type'} =~ /DDR$/) && ($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} =~ /DDR\d+/))) {
1212 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: ram type of MEMORY_DEVICE_TYPE ($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE}) and ram_support_type ($MAKEFILE_OPTIONS{'ram_support_type'}) should be the same", __FILE__, __LINE__);
1213 }
1214
1215 close CUSTOM_MEMORY_DEVICE_HDR;
1216}
1217
1218#****************************************************************************
1219# parse EMI database to get EMI settings
1220#****************************************************************************
1221sub Parse_MDL
1222{
1223 my ($MAKEFILE_OPTIONS_LOCAL, $CUSTOM_MEM_DEV_OPTIONS_LOCAL, $MDL_INFO_LIST_LOCAL, $MEMORY_DEVICE_LIST_XLS_LOCAL, $MEMORY_DEVICE_LIST_INT_XLS_LOCAL) = @_;
1224 my ($result, $result0, $result1);
1225 my %tmp_hash;
1226
1227
1228 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Incorrect memory device type!", __FILE__, __LINE__) unless $CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE};
1229
1230 ##Parse DRAM Parameters
1231 my $dram_info_sheet = $CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE};
1232 if ($MAKEFILE_OPTIONS{'sip_ram_size'} ne 'NONE') {
1233 $dram_info_sheet = 'SIP_' . $dram_info_sheet;
1234 }
1235 if ($emi_is_existed == 1) {
1236 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1237 {
1238 $result = &get_info($MEMORY_DEVICE_LIST_XLS, $dram_info_sheet, $MCP_LIST[$_], \%tmp_hash);
1239 if (($result ne 'TRUE'))
1240 {
1241 print "INTERNAL FIND part number:$MCP_LIST[$_]->{0},$MCP_LIST[$_]->{1}\n";
1242 $result = &get_info($MEMORY_DEVICE_LIST_INT_XLS, $dram_info_sheet, $MCP_LIST[$_], \%tmp_hash);
1243 }
1244 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Part Number $MCP_LIST[$_]->{0} not found!", __FILE__, __LINE__) if ($result ne 'TRUE');
1245 $MDL_INFO_LIST[$_] = dclone \%tmp_hash;
1246 }
1247 } else {
1248 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1249 {
1250 $result = &get_info($MEMORY_DEVICE_LIST_XLS, 'RAM', $MCP_LIST[$_], \%tmp_hash);
1251 if (($result ne 'TRUE'))
1252 {
1253 print "INTERNAL FIND part number:$MCP_LIST[$_]->{0},$MCP_LIST[$_]->{1}\n";
1254 $result = &get_info($MEMORY_DEVICE_LIST_INT_XLS, 'RAM', $MCP_LIST[$_], \%tmp_hash);
1255 }
1256 &error_handler("Cannot find $MAKEFILE_OPTIONS{'platform'} in MDL!", __FILE__, __LINE__) if ($result ne 'TRUE');
1257 $MDL_INFO_LIST[$_] = dclone \%tmp_hash;
1258 }
1259 }
1260
1261 undef %tmp_hash;
1262 ##Parse Flash Parameters
1263 ###disctete type should parse flash info sheet
1264 if (($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} !~ /\w+_\w+_MCP/) && (($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE') || ($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE')))
1265 {
1266 ###Parse Flash MDL info
1267
1268 my $flash_sheet = '';
1269 if($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')#sheet "SERIAL_FLASH" in MDL
1270 {
1271 $flash_sheet = 'SERIAL_FLASH';
1272 }
1273 elsif($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE')
1274 {
1275 $flash_sheet = 'NAND_FLASH';
1276 }
1277
1278 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1279 {
1280 print "part number:$MCP_LIST[$_]->{0},$MCP_LIST[$_]->{1}\n";
1281 $result = &get_info($$MEMORY_DEVICE_LIST_XLS_LOCAL, $flash_sheet, $MCP_LIST[$_], \%tmp_hash);
1282 if ($result ne 'TRUE')
1283 {
1284 print "INTERNAL FIND part number:$MCP_LIST[$_]->{0},$MCP_LIST[$_]->{1}\n";
1285 $result = &get_info($MEMORY_DEVICE_LIST_INT_XLS, $flash_sheet, $MCP_LIST[$_], \%tmp_hash);
1286 }
1287 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: $flash_sheet Part Number $MCP_LIST[$_]->{1} not found!", __FILE__, __LINE__) if ($result ne 'TRUE');
1288 $MDL_INFO_LIST[$_]->{1} = dclone $tmp_hash{1};
1289 }
1290 }
1291 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1292 {
1293 &dump_mdl_info($MDL_INFO_LIST[$_], "\$MDL_INFO_LIST[$_]->");
1294 }
1295
1296}
1297
1298#****************************************************************************
1299# check emi clock driving config
1300#****************************************************************************
1301sub check_emi_clk_driving_cfg
1302{
1303 my ($emi_clk_driving, $bb_chip) = @_;
1304 if ($bb_chip eq 'MT6290')
1305 {
1306 if (($emi_clk_driving->{'DRAMC_ACTIM0_VAL'} !~ /0x[0-9a-fA-F]{8,8}/) || ($emi_clk_driving->{'DRAMC_DRVCTL0_VAL'} !~ /0x[0-9a-fA-F]{8,8}/) || ($emi_clk_driving->{'DRAMC_DRVCTL1_VAL'} !~ /0x[0-9a-fA-F]{8,8}/))
1307 {
1308 return 0;
1309 }
1310 }
1311 return 1;
1312}
1313
1314#****************************************************************************
1315# check consistency among FEATURE, MEMORY_DEVICE_TYPE, PLATFORM, MCU_CLOCK and MemoryDeviceList data
1316#****************************************************************************
1317sub Decide_MemClockSpeed
1318{
1319 my $emi_force_clk = 0;
1320 my $sfi_force_clk = 0;
1321 if ((defined $CUSTOM_MEM_DEV_OPTIONS{EMI_CLK}) and $CUSTOM_MEM_DEV_OPTIONS{EMI_CLK} ne 'DEFAULT')
1322 {
1323 $emi_clk_config = $emi_force_clk = $CUSTOM_MEM_DEV_OPTIONS{EMI_CLK};
1324 }
1325 if ((defined $CUSTOM_MEM_DEV_OPTIONS{SFI_CLK}) and $CUSTOM_MEM_DEV_OPTIONS{SFI_CLK}ne 'DEFAULT')
1326 {
1327 if ($CUSTOM_MEM_DEV_OPTIONS{SFI_CLK} eq '104M')
1328 {
1329 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: $MAKEFILE_OPTIONS{'platform'} does not support SFI clock as 104MHz! Please configure SFI_CLK as DEFAULT!", __FILE__, __LINE__) if ($BBtbl_SFI_FAST_CLK{$MAKEFILE_OPTIONS{'platform'}} != 104);
1330 $sfi_clk_config = $sfi_force_clk = 104;
1331 }
1332 elsif ($CUSTOM_MEM_DEV_OPTIONS{SFI_CLK} eq '78M')
1333 {
1334 $sfi_clk_config = $sfi_force_clk = 78;
1335 }
1336 else
1337 {
1338 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please configure SFI_CLK as 104M, 78M, or DEFAULT!", __FILE__, __LINE__);
1339 }
1340 }
1341
1342 if($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
1343 {
1344 my $sfi_104_support = 1; # assume all devices can support 104; set as 0 if found not support
1345 my $sfi_78_support = 1; # assume all devices can support 78; set as 0 if found not support
1346
1347 #print "test $CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE}\n";
1348 ### Check if all devices can support the required clock
1349 if ($sfi_force_clk != 0) # force specific clock
1350 {
1351 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1352 {
1353 if ((!defined &Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, $sfi_clk_config, $MAKEFILE_OPTIONS{'platform'}, 'SF_CTL', \@MDL_INFO_LIST)) or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, $sfi_clk_config, $MAKEFILE_OPTIONS{'platform'}, 'DRIVING', \@MDL_INFO_LIST) eq 'x') or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, $sfi_clk_config, $MAKEFILE_OPTIONS{'platform'}, 'DRIVING', \@MDL_INFO_LIST) eq ' ')) # unable to find the specified clock setting
1354 {
1355 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Device $_ not support $sfi_clk_config MHz settings!", __FILE__, __LINE__);
1356 }
1357 }
1358 }
1359 else
1360 {
1361 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1362 {
1363 #if ((!defined &Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 104, $MAKEFILE_OPTIONS{'platform'}, 'SF_CTL', \@MDL_INFO_LIST)) or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 104, $MAKEFILE_OPTIONS{'platform'}, 'SFI_MAC_CTL', \@MDL_INFO_LIST) eq 'x') or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 104, $MAKEFILE_OPTIONS{'platform'}, 'SFI_MAC_CTL', \@MDL_INFO_LIST) eq ' ')) # unable to find 104MHz clock setting
1364 if (!defined &Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 104, $MAKEFILE_OPTIONS{'platform'}, 'SF_CTL', \@MDL_INFO_LIST))
1365 {
1366 $sfi_104_support = 0;
1367 }
1368 #if ((!defined &Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 78, $MAKEFILE_OPTIONS{'platform'}, 'SF_CTL', \@MDL_INFO_LIST)) or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 78, $MAKEFILE_OPTIONS{'platform'}, 'SFI_MAC_CTL', \@MDL_INFO_LIST) eq 'x') or (&Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 78, $MAKEFILE_OPTIONS{'platform'}, 'SFI_MAC_CTL', \@MDL_INFO_LIST) eq ' ')) # unable to find 104MHz clock setting
1369 if (!defined &Lookup_SFI_setting_by_IDX_CLK_BB_REG($_, 78, $MAKEFILE_OPTIONS{'platform'}, 'SF_CTL', \@MDL_INFO_LIST))
1370 {
1371 $sfi_78_support = 0;
1372 }
1373 if (($sfi_104_support == 0) and ($sfi_78_support == 0))
1374 {
1375 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Unable to find valid SFI settings!", __FILE__, __LINE__);
1376 }
1377 elsif ($sfi_104_support != 0)
1378 {
1379 $sfi_clk_config = 104;
1380 }
1381 else # sfi_104_support == 0 and sfi_78_support != 0
1382 {
1383 $sfi_clk_config = 78;
1384 }
1385 }
1386 }
1387 print "SFI_CLK configured as $sfi_clk_config\n" if ($DebugPrint == 1);
1388 }
1389
1390 if ($emi_is_existed == 1) {
1391 ### Check if all devices can support the required clock
1392 if ($emi_force_clk != 0) # force specific clock
1393 {
1394 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1395 {
1396 my $mhz_emi_driving = $emi_clk_config . 'MHZ EMI Driving';
1397 my $emi_clk_driving = $MDL_INFO_LIST[$_]->{0}->{$MAKEFILE_OPTIONS{'platform'}}->{$mhz_emi_driving};
1398 if (&check_emi_clk_driving_cfg($emi_clk_driving, $MAKEFILE_OPTIONS{'platform'}) == 0)
1399 {
1400 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Device $_ not support $emi_clk_config MHz settings!", __FILE__, __LINE__);
1401 }
1402 }
1403 }
1404 else
1405 {
1406 my %emi_clk;
1407 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1408 {
1409 my $mdl_info_platform = $MDL_INFO_LIST[$_]->{0}->{$MAKEFILE_OPTIONS{'platform'}};
1410 foreach my $mdl_info_content (sort keys %{$mdl_info_platform})
1411 {
1412 if ($mdl_info_content =~ /(\d+)MHZ EMI Driving/)
1413 {
1414 if (!defined $emi_clk{$1})
1415 {
1416 $emi_clk{$1} = 'TRUE';
1417 }
1418 my $emi_clk_driving = $mdl_info_platform->{$mdl_info_content};
1419 if (&check_emi_clk_driving_cfg($emi_clk_driving, $MAKEFILE_OPTIONS{'platform'}) == 0)
1420 {
1421 $emi_clk{$1} = 'FALSE';
1422 }
1423 }
1424 }
1425 }
1426 undef $emi_clk_config;
1427 while( (my $clk_speed, my $value) = each %emi_clk)
1428 {
1429 if ($value eq 'TRUE')
1430 {
1431 next if ((defined $emi_clk_config) && ($emi_clk_config >= $clk_speed));
1432
1433 $emi_clk_config = $clk_speed;
1434 }
1435
1436 }
1437 if (!defined $emi_clk_config) {
1438 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Device $_ not support $emi_clk_config MHz settings!", __FILE__, __LINE__);
1439 }
1440 }
1441 print "EMI_CLK configured as $emi_clk_config\n" if ($DebugPrint == 1);
1442 }
1443}
1444
1445#****************************************************************************
1446# subroutine: dump_mdl_info
1447# return: none
1448# input: $mdl_ref: MDL hash reference
1449# $pre_string: to print prefix string
1450#****************************************************************************
1451sub dump_mdl_info
1452{
1453 my ($mdl_ref, $pre_string) = @_;
1454 my $prefix_string;
1455 foreach my $key (keys %{$mdl_ref})
1456 {
1457 $prefix_string = $pre_string if (defined $pre_string);
1458 $prefix_string = $prefix_string . "{$key}";
1459 if (ref $mdl_ref->{$key} eq 'HASH')
1460 {
1461 &dump_mdl_info($mdl_ref->{$key}, "$prefix_string->");
1462 }
1463 else
1464 {
1465 print "$prefix_string = " . $mdl_ref->{$key} . "\n";
1466 }
1467 }
1468}
1469
1470#****************************************************************************
1471# subroutine: fs_read_excel
1472# return: hash of matching rows and indexing rows
1473# input: $file: excel file to be read
1474# $sheet: sheet to open
1475# $target_href: the target patterns to be searched
1476#****************************************************************************
1477sub fs_read_excel
1478{
1479 my ($file, $sheet, $target_href, $BACKUP_MDL_PATH) = @_;
1480 my %mdl_list;
1481 my $copied_file;
1482 my $curr_time_str = &get_CurrTime_str();
1483 my $WorkSheet;
1484 my $Excel;
1485 my $Book;
1486 my $parser;
1487 my $workbook;
1488 my ($row_min, $row_max);
1489 my ($col_min, $col_max);
1490
1491 if (! -e $file) {
1492 return %mdl_list;
1493 }
1494
1495 ### copy and rename the current excel file to prevent concurrency build problem
1496 # remove ^.\ or ^\
1497 $BACKUP_MDL_PATH =~ s/^.\\|^\\//;
1498
1499 if($BACKUP_MDL_PATH =~ /build/)
1500 {
1501 print "BAKCUP_MDL_PATH match with /build/ PREMATCH:$`, MATCH:$&, POSTMATCH:$'\n";
1502 $BACKUP_MDL_PATH = $& . $';
1503 }
1504 print "file is $file\n";
1505 if($file =~ /^(\w+.*?)\.xls$/)
1506 {
1507 if($1 =~ /^(\w*.*?)tools(\w*.*?)MemoryDeviceList_(\w+)$/)
1508 {
1509 print "1:$1,2:$2,3:$3\n";
1510 $copied_file = $BACKUP_MDL_PATH . "\/". "MemoryDeviceList_" . $3;
1511 }
1512 }
1513 $copied_file = $copied_file . "_" . $sheet . "_" . $curr_time_str . $$ . ".xls";
1514 if($^O eq "MSWin32")
1515 {
1516 $file =~ s/\//\\/g;
1517 $copied_file =~ s/\//\\/g;
1518 print "copy $file $copied_file\n";
1519 system("copy /y \"$file\" \"$copied_file\"");
1520 }
1521 else
1522 {
1523 print "cp -f $file $copied_file\n";
1524 system("cp -f \"$file\" \"$copied_file\"");
1525 }
1526 $file = $copied_file;
1527
1528 $parser = Spreadsheet::ParseExcel->new();
1529 $workbook = $parser->parse($file) or die "cannot open MDL $!\n";
1530 $WorkSheet = $workbook->worksheet($sheet);
1531 ($row_min, $row_max) = $WorkSheet->row_range();
1532 ($col_min, $col_max) = $WorkSheet->col_range();
1533
1534 # get the sheet name
1535 my $name = $WorkSheet->get_name();
1536 print "[sheetname]: $name, row:{$row_min, $row_max}, col:{$col_min, $col_max}\n";
1537
1538 my $xls_content_row_start;
1539 my $xls_content_num;
1540 for my $col ($col_min..$col_max)
1541 {
1542 my @mdl_each_col_content = undef;
1543 my $array_content_row_start = undef;
1544 foreach my $row ($row_min..$row_max)
1545 {
1546 if (($col == 0) && (!defined $WorkSheet->get_cell($row, $col)->is_merged()) && (!defined $xls_content_row_start))
1547 {
1548 $xls_content_row_start = $row;
1549 $xls_content_num = $row_max - $xls_content_row_start + 1;
1550 }
1551 if (((defined $xls_content_row_start) && ($row >= $xls_content_row_start)) || (!defined $mdl_each_col_content[-1]) || ($mdl_each_col_content[-1] ne &xls_cell_value($WorkSheet, $row, $col)))
1552 {
1553 push(@mdl_each_col_content, &xls_cell_value($WorkSheet, $row, $col));
1554 }
1555 if ((defined $xls_content_row_start) && ($row == $xls_content_row_start))
1556 {
1557 $array_content_row_start = $#mdl_each_col_content;
1558 }
1559 }
1560 my @hash_tail_array;
1561 my $hash_pointer;
1562 for (1..$xls_content_num)
1563 {
1564 push(@hash_tail_array, \%{$mdl_list{$_}});
1565 }
1566 print "MDL_INFO_LIST " if ($DebugPrint == 1);
1567 foreach my $idx (1..$array_content_row_start-1)
1568 {
1569 my $data = $mdl_each_col_content[$idx];
1570 print "{$data}" if ($DebugPrint == 1);
1571 for my $content_idx (1..$xls_content_num)
1572 {
1573 $hash_pointer = shift(@hash_tail_array);
1574 if ($idx != $array_content_row_start-1)
1575 {
1576 print "->" if ($content_idx == 1) && ($DebugPrint == 1);
1577 if (!defined $hash_pointer->{$data})
1578 {
1579 $hash_pointer->{$data} = {};
1580 }
1581 $hash_pointer = $hash_pointer->{$data};
1582 #print "[$idx][$content_idx]hash_pointer:$hash_pointer\n";
1583 }
1584 push(@hash_tail_array, $hash_pointer);
1585 }
1586 }
1587 print "=" if ($DebugPrint == 1);
1588 foreach my $idx ($array_content_row_start..$#mdl_each_col_content)
1589 {
1590 my $mdl_idx = $idx - $array_content_row_start + 1;
1591 my $data = $mdl_each_col_content[$idx];
1592 $hash_pointer = shift(@hash_tail_array);
1593 $hash_pointer->{$mdl_each_col_content[$array_content_row_start-1]} = $data;
1594 print "$mdl_idx:$data" if ($DebugPrint == 1);
1595 if ($idx != $#mdl_each_col_content)
1596 {
1597 print ", " if ($DebugPrint == 1);
1598 }
1599 }
1600 print "\n" if ($DebugPrint == 1);
1601 }
1602
1603 return %mdl_list;
1604}
1605
1606#****************************************************************************
1607# subroutine: get_info
1608# input: $file: file path
1609# $sheet: sheet to open
1610# $target_href: the target patterns to be searched
1611# $href: output matching hash reference
1612#****************************************************************************
1613sub get_info
1614{
1615 my ($file, $sheet, $target_href, $href) = @_;
1616 my %mdl_list;
1617
1618 %mdl_list = &fs_read_excel($file, $sheet, $target_href, $LOAD_TMP_PATH);
1619
1620 if (keys(%mdl_list) == 0)
1621 {
1622 print "get_info return FALSE!\n" if ($DebugPrint == 1);
1623 return "FALSE";
1624 }
1625
1626 foreach my $idx (keys %mdl_list)
1627 {
1628 if ($sheet =~ /\w+_\w+_MCP/)
1629 {
1630 if ($target_href->{0} eq $mdl_list{$idx}->{'Part Number'})
1631 {
1632 $href->{0} = $mdl_list{$idx}->{'DRAM Parameters'};
1633 $href->{1} = $mdl_list{$idx}->{'Flash Parameters'};
1634 for my $keys (keys %{$mdl_list{$idx}})
1635 {
1636 if (($keys ne 'DRAM Parameters') && ($keys ne 'Flash Parameters'))
1637 {
1638 for (0..1)
1639 {
1640 $href->{$_}->{$keys} = $mdl_list{$idx}->{$keys};
1641 }
1642 }
1643 }
1644 }
1645 }
1646 else
1647 {
1648 my $tgt = 0;
1649 $tgt = $tgt + 1 if ($sheet =~ /\w+_FLASH/);
1650 if ($target_href->{$tgt} eq $mdl_list{$idx}->{'Part Number'})
1651 {
1652 $href->{$tgt} = $mdl_list{$idx};
1653 }
1654 }
1655 }
1656 &dump_mdl_info($href, "\$href->");
1657
1658 if (keys(%{$href}) == 0)
1659 {
1660 return "FALSE";
1661 }
1662
1663 return "TRUE";
1664}
1665
1666#****************************************************************************
1667# subroutine: SCHEME Configure Routines :: Query :: no EMI Family
1668# input: NONE
1669# Output: whether this chip belongs to no EMI Family
1670#****************************************************************************
1671sub config_query_no_EMI
1672{
1673 if ($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} eq 'NONE')
1674 {
1675 return 1;
1676 }
1677 else
1678 {
1679 return 0;
1680 }
1681}
1682
1683
1684#****************************************************************************
1685# subroutine: xls_cell_value
1686# return: excel cell value no matter it's in merge area or not
1687# input: $sheet: specified Excel Sheet
1688# $row: specified row number
1689# $col: specified column number
1690#****************************************************************************
1691sub xls_cell_value
1692{
1693 my ($sheet, $row, $col) = @_;
1694
1695 my $cell = $sheet->get_cell($row, $col);
1696 if ($cell)
1697 {
1698 if ((defined $cell->is_merged()) && ($cell->is_merged() == 1))
1699 {
1700 my $mareas =$sheet->get_merged_areas();
1701 # get merged areas' value if cell is merged
1702 for (0..$#$mareas)
1703 {
1704 if(($row >= $mareas->[$_]->[0] && $row <= $mareas->[$_]->[2]) && ($col >= $mareas->[$_]->[1] && $col <= $mareas->[$_]->[3]))
1705 {
1706 return $sheet->get_cell($mareas->[$_]->[0], $mareas->[$_]->[1])->value();
1707 }
1708 }
1709 } else {
1710 # cell is not merged cell => get cell value
1711 return $cell->value();
1712 }
1713 } else {
1714 my $value;
1715 return $value;
1716 }
1717}
1718
1719#****************************************************************************
1720# subroutine: dependency check
1721# return: None
1722#****************************************************************************
1723sub Check_ManualCheckIn
1724{
1725 my ($target, $force_del_new_file, @depends) = @_;
1726
1727 return unless (-e $target);
1728
1729 ## Now check if the $target file check-in or auto-gen
1730 ## Read whole file ##
1731 open SRC_FILE_R , "<$target" or &error_handler("$target: file error!", __FILE__, __LINE__);
1732 my $saved_sep = $/;
1733 undef $/;
1734 my $reading = <SRC_FILE_R>;
1735 close SRC_FILE_R;
1736 $/ = $saved_sep;
1737
1738 ## Look for check-in pattern ##
1739 if ($reading =~ /MANUAL-CHECKIN/i)
1740 {
1741 print "$target: Check-in message is found. No need to update.\n";
1742 return;
1743 }
1744
1745 unlink $target if (-e $target);
1746
1747 return;
1748}
1749
1750#****************************************************************************
1751# subroutine: CheckConfigValid
1752# return: None
1753#****************************************************************************
1754sub CheckConfigValid
1755{
1756 my ($MAKEFILE_OPTIONS_LOCAL, $CUSTOM_MEM_DEV_OPTIONS_LOCAL, $MDL_INFO_LIST_LOCAL, $MEMORY_DEVICE_LIST_XLS_LOCAL, $MEMORY_DEVICE_LIST_INT_XLS_LOCAL) = @_;
1757 my $dram_size = $MDL_INFO_LIST[1]->{0}->{'Density (Mb)'};
1758
1759 ###Check DRAM Size
1760 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1761 {
1762 if ($emi_is_existed == 1)
1763 {
1764 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select correct dram! dram_size is $dram_size.", __FILE__, __LINE__) if ((!defined $dram_size) || ($dram_size <= 0));
1765 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select dram with the same size ($dram_size vs. $MDL_INFO_LIST[$_]->{0}->{'Density (Mb)'}) when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ($dram_size ne $MDL_INFO_LIST[$_]->{0}->{'Density (Mb)'});
1766 }
1767 }
1768
1769 ###Check Combo Memory Supporting
1770 if($MAKEFILE_OPTIONS{'combo_memory_support'} eq 'TRUE')
1771 {
1772 my @combo_mem_part_number;
1773 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: MEMORY_DEVICE_TYPE supports only XXX_MCP when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ((($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} !~ /\w+_MCP/) && ($CUSTOM_MEM_DEV_OPTIONS{MEMORY_DEVICE_TYPE} ne 'NONE')) && ($MAKEFILE_OPTIONS{'sip_ram_size'} eq "NONE"));
1774 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1775 {
1776 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: COMBO MEM Part Number ($MCP_LIST[$_]->{0}) of DRAM should be the same that ($MCP_LIST[$_]->{1}) of Flash!", __FILE__, __LINE__) if (($MCP_LIST[$_]->{0} ne $MCP_LIST[$_]->{1}) && ($MAKEFILE_OPTIONS{'sip_ram_size'} eq "NONE"));
1777 for my $combo_mem_idx (0..$#combo_mem_part_number)
1778 {
1779 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Each COMBO MEM Part Number should be difference ($combo_mem_part_number[$combo_mem_idx]:COMBO_MEM0$combo_mem_idx and COMBO_MEM0$_)!", __FILE__, __LINE__) if ($MCP_LIST[$_]->{1} eq $combo_mem_part_number[$combo_mem_idx]);
1780 }
1781 push(@combo_mem_part_number, $MCP_LIST[$_]->{1});
1782 }
1783 }
1784
1785 ###Combo Flash Size Should be same
1786 if($MAKEFILE_OPTIONS{'combo_memory_support'} eq 'TRUE')
1787 {
1788 if($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE')
1789 {
1790 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1791 {
1792 my $cur_nor_size_Mb;
1793 $cur_nor_size_Mb = $MDL_INFO_LIST[$_]->{1}->{'Size (Mb)'};
1794 if (!defined $nor_size_Mb)
1795 {
1796 $nor_size_Mb = $cur_nor_size_Mb;
1797 }
1798 else
1799 {
1800 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select flash with the same size when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ($nor_size_Mb != $cur_nor_size_Mb);
1801 }
1802 }
1803 }
1804 elsif($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE')
1805 {
1806 my $nand_size_Mb;
1807 my $nand_block_size;
1808 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1809 {
1810 my $cur_nand_size_Mb;
1811 my $cur_nand_block_size;
1812 $cur_nand_size_Mb = $MDL_INFO_LIST[$_]->{1}->{'NAND Size(MB)'};
1813 $cur_nand_block_size = $MDL_INFO_LIST[$_]->{1}->{'NAND Block Size(KB)'};
1814 if (!defined $nand_size_Mb)
1815 {
1816 $nand_size_Mb = $cur_nand_size_Mb;
1817 $nand_block_size = $cur_nand_block_size;
1818 }
1819 else
1820 {
1821 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select flash with the same size when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ($nand_size_Mb != $cur_nand_size_Mb);
1822 &error_handler("$CUSTOM_MEMORY_DEVICE_HDR: Please select flash with the same block size when COMBO_MEMORY_SUPPORT is enabled!", __FILE__, __LINE__) if ($nand_block_size != $cur_nand_block_size);
1823 }
1824 }
1825 }
1826 }
1827 ###Serail Flash Support and NAND Support Should Not be TRUE at the same time
1828 if(($MAKEFILE_OPTIONS{'serial_flash_support'} eq 'TRUE') and ($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE'))
1829 {
1830 &error_handler("Serial Flash and NAND Flash Support at the same time, please check makefile setting!!", __FILE__, __LINE__);
1831 }
1832
1833 ###The Flash Name max length is 64
1834 if($MAKEFILE_OPTIONS{'nand_support'} eq 'TRUE')
1835 {
1836 for (1..$CUSTOM_MEM_DEV_OPTIONS{COMBO_MEM_ENTRY_COUNT})
1837 {
1838 my $vendor = uc($MDL_INFO_LIST[$_]->{1}->{'Vendor'});
1839 my $PartNumber = $MDL_INFO_LIST[$_]->{1}->{'Part Number'};
1840 my $flash_name .= "$vendor " if (defined $vendor);
1841 $flash_name .= "$PartNumber" if (defined $PartNumber);
1842 my $name_length = length($flash_name);
1843 if($name_length > 64)
1844 {
1845 &error_handler("Flash Name is too long, DA Support Max Length is 64 byte!!", __FILE__, __LINE__);
1846 }
1847 }
1848 }
1849
1850 return;
1851}
1852
1853
1854
1855#****************************************************************************
1856# subroutine: error_handler
1857# input: $error_msg: error message
1858#****************************************************************************
1859sub error_handler
1860{
1861 my ($error_msg, $file, $line_no) = @_;
1862
1863 my $final_error_msg = "EMIGEN ERROR: $error_msg at $file line $line_no\n";
1864 print $final_error_msg;
1865 die $final_error_msg;
1866}
1867
1868
1869#****************************************************************************
1870# subroutine: copyright_file_header
1871# return: file header -- copyright
1872#****************************************************************************
1873sub copyright_file_header
1874{
1875 my $template = <<"__TEMPLATE";
1876/*****************************************************************************
1877* Copyright Statement:
1878* --------------------
1879* This software is protected by Copyright and the information contained
1880* herein is confidential. The software may not be copied and the information
1881* contained herein may not be used or disclosed except with the written
1882* permission of MediaTek Inc. (C) 2006
1883*
1884* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
1885* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
1886* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
1887* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
1888* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
1889* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
1890* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
1891* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
1892* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
1893* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
1894* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
1895* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
1896*
1897* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
1898* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
1899* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
1900* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
1901* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
1902*
1903* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
1904* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
1905* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
1906* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
1907* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
1908*
1909*****************************************************************************/
1910
1911__TEMPLATE
1912
1913 return $template;
1914}
1915
1916#****************************************************************************
1917# subroutine: description_file_header
1918# return: file header -- description
1919# input: $filename: filename
1920# input: $description: one line description
1921# input: $author: optional
1922#****************************************************************************
1923sub description_file_header
1924{
1925 my ($filename, $description, $author) = @_;
1926 my @stat_ar;
1927 my ($sec, $min, $hour, $day, $month, $year);
1928
1929 if (-e $MEMORY_DEVICE_LIST_XLS) {
1930 @stat_ar = stat $MEMORY_DEVICE_LIST_XLS;
1931 ($sec, $min, $hour, $day, $month, $year) = localtime($stat_ar[9]);
1932 } elsif (-e "tools/emiGenSP.pl") {
1933 @stat_ar = stat "tools/emiGenSP.pl";
1934 ($sec, $min, $hour, $day, $month, $year) = localtime($stat_ar[9]);
1935 } else {
1936 ($sec, $min, $hour, $day, $month, $year) = localtime();
1937 }
1938 $month++;
1939 $year+=1900;
1940
1941 my $template = <<"__TEMPLATE";
1942/*****************************************************************************
1943 *
1944 * Filename:
1945 * ---------
1946 * $filename
1947 *
1948 * Project:
1949 * --------
1950 * MOLY
1951 *
1952 * Description:
1953 * ------------
1954 * $description
1955 *
1956 * Author:
1957 * -------
1958 * $author
1959 *
1960 * Memory Device database last modified on $year/$month/$day
1961 *
1962 *============================================================================
1963 * HISTORY
1964 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
1965 *------------------------------------------------------------------------------
1966 * \$Revision\$
1967 * \$Modtime\$
1968 * \$Log\$
1969 *
1970 *------------------------------------------------------------------------------
1971 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
1972 *============================================================================
1973 ****************************************************************************/
1974
1975__TEMPLATE
1976
1977 return $template;
1978}
1979
1980#******************************************************************************
1981# subroutine: get_CurrTime_str
1982# return: string of the current time
1983# input: None
1984#******************************************************************************
1985sub get_CurrTime_str
1986{
1987 my($sec, $min, $hour, $mday, $mon, $year) = localtime(time);
1988 return (sprintf "%04d_%02d_%02d_%02d_%02d_%02d", $year+1900, $mon+1, $mday, $hour, $min, $sec);
1989}
1990
1991#****************************************************************************
1992# subroutine: SCHEME Configure Routines :: Query :: MD Information
1993#****************************************************************************
1994sub query_MD_INFO
1995{
1996 my ($MAKEFILE_OPTIONS_LOCAL,$CUSTOM_MEM_DEV_OPTIONS_LOCAL,$COMM_MDL_INFO_LOCAL) = @_;
1997 open write_file, ">", "MD_INFO.txt" or die "open file error:$!";
1998 #if(($CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'} = 'LPDDR') || ($CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'} = 'LPDDR2') || ($CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'} = 'LPSDRAM'))
1999 #{
2000 #if(defined $MAKEFILE_OPTIONS{'sip_ram_size'})
2001 #{
2002 #print write_file "Memory device type:$CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'}";
2003 #print write_file "size:$COMM_MDL_INFO{1}->{'Size (Mb)'}"
2004 #}
2005 #else
2006 #{
2007 #print write_file "Memory device type:$CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'}";
2008 #print write_file "size:$COMM_MDL_INFO{1}->{'Size (Mb)'}"
2009 #}
2010
2011 #}
2012 #else
2013 #{
2014 #if(defined $MAKEFILE_OPTIONS{'sip_ram_size'})
2015 #{
2016 #print write_file "Memory device type:$CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'}";
2017 #print write_file "size:$COMM_MDL_INFO{1}->{'Size (Mb)'}"
2018 #}
2019 #else
2020 #{
2021 #print write_file "Memory device type:$CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'}";
2022 #print write_file "size:$COMM_MDL_INFO{1}->{'Size (Mb)'}"
2023 #}
2024 #}
2025
2026 print write_file "Memory device type:$CUSTOM_MEM_DEV_OPTIONS{'MEMORY_DEVICE_TYPE'}\n";
2027 print write_file "size:$COMM_MDL_INFO{1}->{'Size (Mb)'}\n";
2028 close(write_file);
2029}
2030
2031#****************************************************************************
2032# subroutine: Parse Custom Feature Configuration
2033#****************************************************************************
2034sub Parse_custom_FeatureConfig
2035{
2036 my ($CUSTOM_FEATURE_CFG_OPTIONS_LOCAL) = @_;
2037 open CUSTOM_FEATURE_CONFIG_HDR, "<$CUSTOM_FEATURE_CONFIG_HDR" or &error_handler("$CUSTOM_FEATURE_CONFIG_HDR: file error!", __FILE__, __LINE__);
2038
2039 while (<CUSTOM_FEATURE_CONFIG_HDR>)
2040 {
2041 # error-checking
2042 if (/^#if|^#ifdef|^#ifndef|^#elif|^#else/)
2043 {
2044 &error_handler("$CUSTOM_FEATURE_CONFIG_HDR: Not allowed to set conditional keywords $_ in custom_FeatureConfig.h!", __FILE__, __LINE__)
2045 unless (/^#ifndef\s+__CUSTOM_FEATURECONFIG_H__/);
2046 }
2047
2048 if (/^#define\s+(\w+)\s+\(([\w|\-]*)\)/ || /^#define\s+(\w+)\s+([\w|\-]*)/)
2049 {
2050 &error_handler("$CUSTOM_FEATURE_CONFIG_HDR: $1 redefined in custom_FeatureConfig.h!", __FILE__, __LINE__) if defined($CUSTOM_FEATURE_CFG_OPTIONS{$1});
2051 if ((!defined $2) or ($2 eq ''))
2052 {
2053 $CUSTOM_FEATURE_CFG_OPTIONS{$1} = 'TRUE';
2054 }
2055 else
2056 {
2057 $CUSTOM_FEATURE_CFG_OPTIONS{$1} = $2;
2058 }
2059 }
2060 }
2061
2062 close CUSTOM_FEATURE_CONFIG_HDR;
2063 my $clean_setting;
2064 if($INSIDE_MTK eq '0')
2065 {
2066 $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_RAM_LIMIT} = $clean_setting;
2067 $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_CODE_LIMIT} = $clean_setting;
2068 $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_RAM_LIMIT_NFB} = $clean_setting;
2069 }
2070 #$PROJECT_EXPECTED_RAM_LIMIT = $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_RAM_LIMIT};
2071 #$PROJECT_EXPECTED_CODE_LIMIT = $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_CODE_LIMIT};
2072 #$PROJECT_EXPECTED_RAM_LIMIT_NFB = $CUSTOM_FEATURE_CFG_OPTIONS{PROJECT_EXPECTED_RAM_LIMIT_NFB};
2073}
2074
2075return 1;