rjw | 6c1fd8f | 2022-11-30 14:33:01 +0800 | [diff] [blame] | 1 | #!/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) 2005 |
| 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 | #* |
| 38 | #* Filename: |
| 39 | #* --------- |
| 40 | #* Append2.pl |
| 41 | #* |
| 42 | #* Project: |
| 43 | #* -------- |
| 44 | #* Maui_Software |
| 45 | #* |
| 46 | #* Description: |
| 47 | #* ------------ |
| 48 | #* This script can append some information to a file |
| 49 | #* 1. its file name |
| 50 | #* 2. input strings |
| 51 | #* 3. flash configuration information |
| 52 | #* This script also can query flash configuration stored in FlashConf.c |
| 53 | #* |
| 54 | #*------------------------------------------------------------------------------ |
| 55 | #* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!! |
| 56 | #*============================================================================ |
| 57 | #****************************************************************************/ |
| 58 | BEGIN { push @INC, './tools/MemoryUtility/' } # add additional library path |
| 59 | BEGIN { push @INC, './tools/DSP/' } |
| 60 | BEGIN { push @INC, './tools/', './tools/AutoGen/postBuild/' } # add additional library path |
| 61 | |
| 62 | use File::stat; |
| 63 | use Math::BigInt; |
| 64 | use BasicMemInfoQuery; |
| 65 | use Parsing_DSP_array; |
| 66 | use EMI_MPUinfo; |
| 67 | use Parsing_ARM7_info; |
| 68 | use Parsing_VoLTE_Core_Info; |
| 69 | use Parsing_Ramdisk_Info; |
| 70 | use FreeRam_info; |
| 71 | use drdi_info; |
| 72 | use AMMS_POSinfo; |
| 73 | use CONSYS_info; |
| 74 | use NV_cache_shm_info; |
| 75 | use Parsing_Padding_Info; |
| 76 | use BAT_buffer_info; |
| 77 | |
| 78 | #************************************************************ |
| 79 | #endian example: |
| 80 | #************************************************************ |
| 81 | #int x = 0x76543210; |
| 82 | #char *c = (char*) &x; |
| 83 | # |
| 84 | #big-endian format: |
| 85 | #------------------ |
| 86 | #Byte address | 0x01 | 0x02 | 0x03 | 0x04 | |
| 87 | #Byte content | 0x76 | 0x54 | 0x32 | 0x10 | |
| 88 | # |
| 89 | #little-endian format: |
| 90 | #--------------------- |
| 91 | #Byte address | 0x01 | 0x02 | 0x03 | 0x04 | |
| 92 | #Byte content | 0x10 | 0x32 | 0x54 | 0x76 | |
| 93 | |
| 94 | #************************************************************ |
| 95 | #write hex with big-endian |
| 96 | #input argument: file handler, hex_value, total_hex_num |
| 97 | #************************************************************ |
| 98 | sub write_hex_with_big_endian |
| 99 | { |
| 100 | my($file_handler, $hex_value, $total_hex_num) = @_; |
| 101 | print $file_handler pack("H".$total_hex_num, $hex_value); # write hex digit, with big-endian order |
| 102 | } |
| 103 | |
| 104 | #************************************************************ |
| 105 | #convert string to hex, and write hex with big-endian |
| 106 | #input argument: file handler, string_value, total_char_num |
| 107 | #************************************************************ |
| 108 | sub write_string_with_big_endian |
| 109 | { |
| 110 | my($file_handler, $string_value, $total_char_num) = @_; |
| 111 | print $file_handler "$string_value"; |
| 112 | my $remain_hex_digit = 2*($total_char_num - length($string_value));# a char takes 2 hex digit to represent |
| 113 | &write_hex_with_big_endian($file_handler, "0", $remain_hex_digit); |
| 114 | } |
| 115 | |
| 116 | #************************************************************ |
| 117 | #convert number to hex, and write hex with little-endian |
| 118 | #input argument: file handler, number_value, total_int_num |
| 119 | #************************************************************ |
| 120 | sub write_number_with_little_endian |
| 121 | { |
| 122 | my($file_handler, $number_value, $total_int_num) = @_; |
| 123 | print $file_handler pack("V".$total_int_num, $number_value);# write hex digit, with little-endian order |
| 124 | } |
| 125 | |
| 126 | |
| 127 | |
| 128 | #************************************************************ |
| 129 | #main program |
| 130 | #************************************************************ |
| 131 | my ($FLASH_CFG, $file, $bin_name, $verno, $themf, $build_time_str, $tmpfolder, $scat, $sym_filename, $copro_sym_file, $infomake_log, $drdi_file) = @ARGV; |
| 132 | print "All input: @ARGV\n"; |
| 133 | &error_handler("BIN_NAME: $bin_name should NOT exceed 127 bytes", __FILE__, __LINE__) if(length($bin_name) > 127); |
| 134 | &error_handler("VERNO: $verno should NOT exceed 63 bytes", __FILE__, __LINE__) if(length($verno) > 63); |
| 135 | |
| 136 | $targetDir = $file; |
| 137 | |
| 138 | if($file =~ /\.bin$/ && -d "$file") |
| 139 | { |
| 140 | $file = $file."/ROM"; |
| 141 | } |
| 142 | &error_handler("$file does not exist!", __FILE__, __LINE__) if(!-e "$file"); |
| 143 | |
| 144 | $targetDir =~ s/\\/\//g; |
| 145 | if($targetDir =~ /(.+)\/(.+)/) |
| 146 | { |
| 147 | $targetDir = $1; |
| 148 | } |
| 149 | |
| 150 | $sym_file = $targetDir."/".$sym_filename; |
| 151 | $map_file = $sym_file; |
| 152 | |
| 153 | |
| 154 | |
| 155 | #**************************************************************************** |
| 156 | # parsing makefile |
| 157 | #**************************************************************************** |
| 158 | my %prj_fo_hash; |
| 159 | |
| 160 | open (FILE_HANDLE, "<$themf") or &error_handler("cannot open $themf!", __FILE__, __LINE__); |
| 161 | while (<FILE_HANDLE>) { |
| 162 | if ((/^([^\#]*)\#?.*/) && ($1 =~ /^(\w+)\s*=\s*(.*\S)\s*$/)) { |
| 163 | $keyname = lc($1); |
| 164 | $${keyname} = uc($2); |
| 165 | $prj_fo_hash{$keyname} = $${keyname}; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | $map_file =~ s/\.sym/\.map/; |
| 170 | |
| 171 | &error_handler("$map_file does not exist!", __FILE__, __LINE__) if(!-e "$map_file"); |
| 172 | &error_handler("$sym_file does not exist!", __FILE__, __LINE__) if(!-e "$sym_file"); |
| 173 | |
| 174 | #**************************************************************************** |
| 175 | # parsing flash configuration from a file or a string |
| 176 | #**************************************************************************** |
| 177 | my $full_hex_str = ''; |
| 178 | my $full_emi_str; |
| 179 | |
| 180 | open (FLASH_CFG, "<$FLASH_CFG") or &error_handler("cannot open $FLASH_CFG!", __FILE__, __LINE__); |
| 181 | $backup = $/; |
| 182 | undef $/; |
| 183 | $reading = <FLASH_CFG>; |
| 184 | $/ = $backup; |
| 185 | close FLASH_CFG; |
| 186 | |
| 187 | my $flash_name = ''; # part number |
| 188 | my @NORFlashID = (0, 0, 0, 0); # flash ID (manufacture ID, device ID, ext. device ID1, ext. device ID2) |
| 189 | my @NANDFlashID = (0, 0, 0, 0); # flash ID (manufacture ID, device ID, ext. device ID1, ext. device ID2) |
| 190 | my @EMMCFlashID = (0, 0, 0, 0); # flash ID (manufacture ID, device ID, ext. device ID1, ext. device ID2) |
| 191 | |
| 192 | my $fs_nor_addr = 0; |
| 193 | my $fs_nor_len = 0; |
| 194 | my $fs_nand_addr = 0; |
| 195 | my $fs_nand_len = 0; |
| 196 | my $fs_emmc_addr = 0; |
| 197 | my $fs_emmc_len = 0; |
| 198 | my $hex_str = ''; |
| 199 | |
| 200 | # get flash name(part number) |
| 201 | if ($reading =~ /const\s+kal_char\s+PART_NUMBER\w+\[\d*\]\s*=\s*\"(.*)\"\s*;/) |
| 202 | { |
| 203 | $flash_name = $1; |
| 204 | if ($bin_name !~ /\_FLN/) |
| 205 | { # there will be one more part number(NOR Flash with two and NAND with ONLY one) |
| 206 | # specified in custom memory device configuration file |
| 207 | $bin_name .= "_FLN" . $flash_name; |
| 208 | &error_handler("PLATFORM ID: \"$bin_name\" should NOT exceed 127 bytes!", __FILE__, __LINE__) if(length($bin_name) > 127); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | # get flash ID |
| 213 | my @flashID = (0, 0, 0, 0); |
| 214 | if ($reading =~ /const\s+kal_char\s+FLASH_ID\[\d*\]\s*=\s*\"\s*(?:\{\s*)?(\w+)\s*\,\s*(\w+)\s*(\,\s*(\w+))?\s*(\,\s*(\w+))?\s*(\,\s*(\w+))*\s*(?:\}\s*)?\"\s*;/) |
| 215 | { # Flash ID has four fields, manufacture ID, device ID, ext. device ID1 & ext. device ID2 |
| 216 | $flashID[0] = `perl -e "print ($1)" 2>&1` if ($1 ne ""); |
| 217 | $flashID[1] = `perl -e "print ($2)" 2>&1` if ($2 ne ""); |
| 218 | $flashID[2] = `perl -e "print ($4)" 2>&1` if ($4 ne ""); |
| 219 | $flashID[3] = `perl -e "print ($6)" 2>&1` if ($6 ne ""); |
| 220 | } |
| 221 | |
| 222 | if ($nand_flash_booting !~ /^NONE|FALSE$/) |
| 223 | { |
| 224 | @NANDFlashID = @flashID; |
| 225 | } |
| 226 | elsif ($emmc_booting !~ /^NONE|FALSE$/) |
| 227 | { |
| 228 | @EMMCFlashID = @flashID; |
| 229 | } |
| 230 | else |
| 231 | { |
| 232 | @NORFlashID = @flashID; |
| 233 | } |
| 234 | |
| 235 | # get nor flash base address if device exists |
| 236 | if ($reading =~ /int\s+fs_nor_base_address\s*=\s*(.*);/) |
| 237 | { |
| 238 | $fs_nor_addr = `perl -e "print ($1)" 2>&1`; |
| 239 | } |
| 240 | |
| 241 | # get nor flash FAT space if device exists |
| 242 | if ($reading =~ /int\s+fs_nor_length\s*=\s*(.*);/) |
| 243 | { |
| 244 | $fs_nor_len = `perl -e "print ($1)" 2>&1`; |
| 245 | } |
| 246 | |
| 247 | # get nand flash base address if device exists |
| 248 | if ($reading =~ /int\s+fs_nand_base_address\s*=\s*(.*);/) |
| 249 | { |
| 250 | $fs_nand_addr = `perl -e "print ($1)" 2>&1`; |
| 251 | } |
| 252 | |
| 253 | # get nand flash FAT space if device exists |
| 254 | if ($reading =~ /int\s+fs_nand_length\s*=\s*(.*);/) |
| 255 | { |
| 256 | $fs_nand_len = `perl -e "print ($1)" 2>&1`; |
| 257 | } |
| 258 | |
| 259 | # get emmc flash base address if device exists |
| 260 | if ($reading =~ /int\s+fs_emmc_base_address\s*=\s*(.*);/) |
| 261 | { |
| 262 | $fs_emmc_addr = `perl -e "print ($1)" 2>&1`; |
| 263 | } |
| 264 | |
| 265 | # get emmc flash FAT space if device exists |
| 266 | if ($reading =~ /int\s+fs_emmc_length\s*=\s*(.*);/) |
| 267 | { |
| 268 | $fs_emmc_len = `perl -e "print ($1)" 2>&1`; |
| 269 | } |
| 270 | |
| 271 | $hex_str = sprintf("%02X", 3); # flash device num. |
| 272 | $full_hex_str .= $hex_str; |
| 273 | |
| 274 | # 1st flash device info. --- NOR flash |
| 275 | $hex_str = sprintf("%04X%04X%04X%04X%08X%08X", $NORFlashID[0], $NORFlashID[1], $NORFlashID[2], $NORFlashID[3], $fs_nor_addr, $fs_nor_len); |
| 276 | $full_hex_str .= $hex_str; |
| 277 | |
| 278 | # 2nd flash device info. --- NAND flash |
| 279 | $hex_str = sprintf("%04X%04X%04X%04X%08X%08X", $NANDFlashID[0], $NANDFlashID[1], $NANDFlashID[2], $NANDFlashID[3], $fs_nand_addr, $fs_nand_len); |
| 280 | $full_hex_str .= $hex_str; |
| 281 | |
| 282 | # 3rd flash device info. --- eMMC flash |
| 283 | $hex_str = sprintf("%04X%04X%04X%04X%08X%08X", $EMMCFlashID[0], $EMMCFlashID[1], $EMMCFlashID[2], $EMMCFlashID[3], $fs_emmc_addr, $fs_emmc_len); |
| 284 | $full_hex_str .= $hex_str; |
| 285 | |
| 286 | |
| 287 | $flash_len = length($full_hex_str); |
| 288 | if ( ($flash_len == 2) || ((($flash_len-34)%32) !=0) || ($flash_len > 34+5*32) ) |
| 289 | { |
| 290 | &error_handler("The length of $full_hex_str ($flash_len) should be 34+32n. (5>=n>=0)", __FILE__, __LINE__); |
| 291 | } |
| 292 | $flash_device_count = hex(substr($full_hex_str, 0, 2)); |
| 293 | |
| 294 | if ((($flash_len-2)/32) != $flash_device_count) |
| 295 | { |
| 296 | &error_handler("$flash_len-2)/32 should be $flash_device_count", __FILE__, __LINE__); |
| 297 | } |
| 298 | |
| 299 | open (CFG,">$tmpfolder/~gfh_cfg_flash.tmp") or &error_handler("cannot open $tmpfolder/~gfh_cfg_flash.tmp", __FILE__, __LINE__); |
| 300 | print CFG "FLASH_DEV_CNT=$flash_device_count\n"; |
| 301 | |
| 302 | for ($i=0; $i<$flash_device_count; $i++) |
| 303 | { |
| 304 | $menuID = hex(substr($full_hex_str, 2+32*$i, 4)); |
| 305 | $devID = hex(substr($full_hex_str, 6+32*$i, 4)); |
| 306 | $extID1 = hex(substr($full_hex_str, 10+32*$i, 4)); |
| 307 | $extID2 = hex(substr($full_hex_str, 14+32*$i, 4)); |
| 308 | $fatAddr = hex(substr($full_hex_str, 18+32*$i, 8)); |
| 309 | $fatLen = hex(substr($full_hex_str, 26+32*$i, 8)); |
| 310 | |
| 311 | $regbase2 .= sprintf("0x%04X", $devID); |
| 312 | $regbase2 .= sprintf("%04X" , $menuID).","; |
| 313 | $regbase2 .= sprintf("0x%04X", $extID2); |
| 314 | $regbase2 .= sprintf("%04X" , $extID1).","; |
| 315 | $regbase2 .= sprintf("0x%08X", $fatAddr).","; |
| 316 | $regbase2 .= sprintf("0x%08X", $fatLen).","; |
| 317 | } |
| 318 | print CFG "FLASH_CFG_STR =".$regbase2."\n"; |
| 319 | close CFG; |
| 320 | |
| 321 | #************************************************************ |
| 322 | #Get original binary size(before appending info in tail) |
| 323 | #************************************************************ |
| 324 | my $img_rom_size = stat("$file")->size; |
| 325 | if(defined($amms_drdi_support) && $amms_drdi_support eq "TRUE") |
| 326 | { |
| 327 | $img_rom_size += stat("$drdi_file")->size; |
| 328 | } |
| 329 | |
| 330 | #************************************************************ |
| 331 | #Fill in PROJECT_NAME and PROJECT_FLAVOR to bin file |
| 332 | #************************************************************ |
| 333 | open (FILE, "+<$file") or &error_handler("cannot open $file!", __FILE__, __LINE__); |
| 334 | #binmode(FILE); #seems no use? |
| 335 | |
| 336 | # seek(FILE, x, y); |
| 337 | # move file cursor, y=>0: to new position x, y=>1: to current position + x, y=>2: to file tail + x |
| 338 | seek(FILE, 0, 2); |
| 339 | |
| 340 | print "original_project_name = $original_project_name\n"; |
| 341 | &write_string_with_big_endian(FILE, $original_project_name, 128); |
| 342 | |
| 343 | print "original_flavor = $original_flavor\n"; |
| 344 | &write_string_with_big_endian(FILE, $original_flavor, 36); |
| 345 | |
| 346 | if(defined $original_verno) |
| 347 | { |
| 348 | print "original_verno = $original_verno\n"; |
| 349 | &write_string_with_big_endian(FILE, $original_verno, 64); |
| 350 | } |
| 351 | else |
| 352 | { |
| 353 | print "verno = $verno\n"; |
| 354 | &write_string_with_big_endian(FILE, $verno, 64); |
| 355 | } |
| 356 | close FILE; |
| 357 | |
| 358 | #************************************************************ |
| 359 | #Start to write infomation to BIN file for MODEM |
| 360 | #************************************************************ |
| 361 | my $check_header = "CHECK_HEADER"; |
| 362 | my $header_verno = "06"; |
| 363 | |
| 364 | #Debug/Release mode check |
| 365 | #0x01: debug mode |
| 366 | #0x02: release mode |
| 367 | my $product_ver = ""; |
| 368 | if($production_release eq "FALSE") |
| 369 | { |
| 370 | $product_ver = "01"; |
| 371 | } |
| 372 | elsif($production_release eq "TRUE") |
| 373 | { |
| 374 | $product_ver = "02"; |
| 375 | } |
| 376 | else |
| 377 | { |
| 378 | $product_ver = "00"; |
| 379 | } |
| 380 | |
| 381 | my $image_type = ""; |
| 382 | #modem CHECK |
| 383 | #0x01: 2G |
| 384 | #0x02: 3G |
| 385 | #0x03: WG |
| 386 | #0x04: TG |
| 387 | #0x05: LWG same as ulwg |
| 388 | #0x06: LTG same as ultg |
| 389 | #0x07: sglte only in MOLY |
| 390 | #0x08: ultg |
| 391 | #0x09: ulwg |
| 392 | #0x0A: ulwtg |
| 393 | #0x0B: ulwcg |
| 394 | #0x0C: ulwctg |
| 395 | #0x0D: unlwtg |
| 396 | #0x0E: unlwctg |
| 397 | if($fiveg_mode_support eq "FIVEG_MODE" && $eutran_mode_support eq "EUTRAN_MODE" && $utran_mode_support eq "UTRAN_FDD_TDD_SUPPORT" && $geran_mode_support eq "GERAN_EGPRS_MODE" && (defined $c2k_mode_support && $c2k_mode_support ne "NONE")) |
| 398 | { |
| 399 | $image_type = "0E"; |
| 400 | } |
| 401 | elsif($fiveg_mode_support eq "FIVEG_MODE" && $eutran_mode_support eq "EUTRAN_MODE" && $utran_mode_support eq "UTRAN_FDD_TDD_SUPPORT" && $geran_mode_support eq "GERAN_EGPRS_MODE" && (!defined $c2k_mode_support || $c2k_mode_support eq "NONE")) |
| 402 | { |
| 403 | $image_type = "0D"; |
| 404 | } |
| 405 | elsif($eutran_mode_support eq "EUTRAN_MODE" && $utran_mode_support eq "UTRAN_FDD_TDD_SUPPORT" && $geran_mode_support eq "GERAN_EGPRS_MODE" && (defined $c2k_mode_support && $c2k_mode_support ne "NONE")) |
| 406 | { |
| 407 | $image_type = "0C"; |
| 408 | } |
| 409 | elsif($eutran_mode_support eq "EUTRAN_MODE" && $utran_mode_support eq "UTRAN_FDD_MODE" && $geran_mode_support eq "GERAN_EGPRS_MODE" && (defined $c2k_mode_support && $c2k_mode_support ne "NONE")) |
| 410 | { |
| 411 | $image_type = "0B"; |
| 412 | } |
| 413 | elsif($eutran_mode_support eq "EUTRAN_MODE" && $utran_mode_support eq "UTRAN_FDD_TDD_SUPPORT" && $geran_mode_support eq "GERAN_EGPRS_MODE" && (!defined $c2k_mode_support || $c2k_mode_support eq "NONE")) |
| 414 | { |
| 415 | $image_type = "0A"; |
| 416 | } |
| 417 | elsif($eutran_mode_support eq "EUTRAN_MODE" && $utran_mode_support eq "UTRAN_FDD_MODE" && $geran_mode_support eq "GERAN_EGPRS_MODE" && (!defined $c2k_mode_support || $c2k_mode_support eq "NONE")) |
| 418 | { |
| 419 | $image_type = "09"; |
| 420 | } |
| 421 | elsif($eutran_mode_support eq "EUTRAN_MODE" && $utran_mode_support eq "UTRAN_TDD128_MODE" && $geran_mode_support eq "GERAN_EGPRS_MODE" && (!defined $c2k_mode_support || $c2k_mode_support eq "NONE")) |
| 422 | { |
| 423 | $image_type = "08"; |
| 424 | } |
| 425 | elsif($utran_mode_support eq "UTRAN_TDD128_MODE" && $eutran_mode_support eq "NONE") |
| 426 | { |
| 427 | $image_type = "04"; |
| 428 | } |
| 429 | elsif($utran_mode_support eq "UTRAN_FDD_MODE" && $eutran_mode_support eq "NONE") |
| 430 | { |
| 431 | $image_type = "03"; |
| 432 | } |
| 433 | elsif($geran_mode_support eq "GERAN_GSM_MODE" || ($geran_mode_support eq "GERAN_EGPRS_MODE" && $utran_mode_support eq "NONE")) |
| 434 | { |
| 435 | $image_type = "01"; |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | $image_type = "00"; |
| 440 | } |
| 441 | |
| 442 | my $mcu_platform = $platform."_".$chip_ver; |
| 443 | |
| 444 | #append project_name and flavor to build time, and limit it's length to at most 64 bytes |
| 445 | my $build_time = $build_time_str."*".$original_project_name."*".$original_flavor; |
| 446 | if (length($build_time) > 64) |
| 447 | { |
| 448 | $build_time = substr($build_time, 0, 64); |
| 449 | } |
| 450 | my $build_ver = $verno; |
| 451 | |
| 452 | my $bind_sys_id = ""; |
| 453 | # 01: default value |
| 454 | # 02: MD2 |
| 455 | # 03: reserved |
| 456 | # 04: reserved |
| 457 | # 05: MD5 |
| 458 | if(defined $mdsys && $mdsys eq "MD5") |
| 459 | { |
| 460 | $bind_sys_id = "05"; |
| 461 | } |
| 462 | elsif(defined $mdsys && $mdsys eq "MD2") |
| 463 | { |
| 464 | $bind_sys_id = "02"; |
| 465 | } |
| 466 | else |
| 467 | { |
| 468 | $bind_sys_id = "01"; |
| 469 | } |
| 470 | |
| 471 | my $ext_attr = "00"; # 00:no shrink, 01:shrink |
| 472 | my $reserved = "\0"; # string \0 => 00 in hex digit |
| 473 | print "Get Total RAM Usage from LDS: $themf $scat $map_file $sym_file\n"; |
| 474 | my $mem_size = &BasicMemInfo::DispatchCommand("GetTotalRAMUsageFromLDS", $themf, $scat, $map_file, $sym_file, undef); |
| 475 | |
| 476 | my $md_img_size = $img_rom_size; |
| 477 | my $rpc_sec_mem_addr = "00"; |
| 478 | my $dspFlagSymbol = "dsp_bin_ro"; |
| 479 | my $dspSymbol = "dsp_bin_ro"; |
| 480 | print "Get DSP load address: $sym_file $platform $c2k_mode_support $infomake_log\n"; |
| 481 | my ($dsp_img_offset, $dsp_img_size) = Parsing_DSP_array::getDSPsymbol($sym_file, $platform, $c2k_mode_support, $infomake_log, $fs_ramdisk); |
| 482 | |
| 483 | print "Get EMI MPU info:$sym_file\n"; |
| 484 | my ($region_num, $aMPU_ref, $aDomain_ref) = &EMI_MPUinfo::retrieveEMI_MPU_info($sym_file, $themf); |
| 485 | my @region_offset; |
| 486 | my @region_size; |
| 487 | foreach my $regionAry_ref (@{$aMPU_ref}) |
| 488 | { |
| 489 | push @region_offset, $regionAry_ref->[0]; |
| 490 | push @region_size, $regionAry_ref->[1]; |
| 491 | } |
| 492 | my @domain_attr; |
| 493 | foreach my $attr (@{$aDomain_ref}) |
| 494 | { |
| 495 | push @domain_attr, $attr; |
| 496 | } |
| 497 | |
| 498 | print "Get volte address: $sym_file $infomake_log\n"; |
| 499 | my ($arm7_img_offset, $arm7_img_size) = Parsing_VoLTE_Core_Info::getVoLTECoresymbol($sym_file, $infomake_log); |
| 500 | |
| 501 | print "Get FreeRam info: $sym_file\n"; |
| 502 | my @raminfo = &Parsing_Padding_Info::get_padding_info($platform, $c2k_mode_support, $themf, $scat, $map_file, $sym_file); |
| 503 | |
| 504 | my @free_padding_block_start_offset; |
| 505 | my @free_padding_block_length; |
| 506 | foreach $free_padding_block_ref (@raminfo) |
| 507 | { |
| 508 | push @free_padding_block_start_offset, $free_padding_block_ref->[0]; |
| 509 | push @free_padding_block_length, $free_padding_block_ref->[1]; |
| 510 | } |
| 511 | |
| 512 | my $ap_md_smem_size = 0; |
| 513 | my $md_to_md_smem_size = 0; |
| 514 | print "Get Ramdisk info: $sym_file $infomake_log\n"; |
| 515 | my ($ramdisk_offset, $ramdisk_size) = Parsing_Ramdisk_Info::getRamdisksymbol($sym_file, $infomake_log); |
| 516 | |
| 517 | print "Get DRDI info: $sym_file\n"; |
| 518 | my ($drdi_offset, $drdi_size, $drdi_rt_offset ,$drdi_rt_size) = drdi_info::GetDRDIInfo($sym_file); |
| 519 | my $reserved_1 = "\0"; |
| 520 | my $size = 512; |
| 521 | |
| 522 | $amms_pos_support = "FALSE" if($amms_pos_support ne "TRUE"); |
| 523 | print "Get AMMS POS info: $amms_pos_support\n"; |
| 524 | print "Get MTK_MODEM_ARCH: $mtk_modem_arch\n"; |
| 525 | my $pos_size = AMMS_POSinfo::retrieveAMMS_POS_Support($amms_pos_support,$mtk_modem_arch); |
| 526 | |
| 527 | $mcif_support = "FALSE" if($mcif_support ne "TRUE"); |
| 528 | $mcif_wifi_support = "FALSE" if($mcif_wifi_support ne "TRUE"); |
| 529 | print "Get MTK_MODEM_ARCH: $mtk_modem_arch\n"; |
| 530 | my $consys_size = CONSYS_info::retrieveCONSYS_Support(\%prj_fo_hash, "$mtk_modem_arch"); |
| 531 | |
| 532 | my $nv_cache_shm_size = NV_cache_shm_info::retrieveNV_CACHE_Support(\%prj_fo_hash); |
| 533 | |
| 534 | $r15_deflate_udc_support = "FALSE" if($r15_deflate_udc_support ne "TRUE"); |
| 535 | print "Get R15_DEFLATE_UDC_SUPPORT info: $r15_deflate_udc_support\n"; |
| 536 | my $udc_support = 0; |
| 537 | $udc_support = 1 if($r15_deflate_udc_support eq "TRUE"); |
| 538 | |
| 539 | my $bat_buffer_info_ver = BAT_buffer_info::retrieveBAT_Buffer_Info(\%prj_fo_hash); |
| 540 | |
| 541 | print "\n\ncheck_header: $check_header\n"; |
| 542 | print "header_verno: $header_verno\n"; |
| 543 | print "product_ver: $product_ver\n"; |
| 544 | print "image_type: $image_type\n"; |
| 545 | print "mcu_platform: $mcu_platform\n"; |
| 546 | print "build_time: $build_time\n"; |
| 547 | print "build_ver: $build_ver\n"; |
| 548 | print "bind_sys_id: $bind_sys_id\n"; |
| 549 | print "ext_attr: $ext_attr\n"; |
| 550 | print "reserved: $reserved\n"; |
| 551 | print "mem_size: $mem_size\n"; |
| 552 | print "md_img_size: $md_img_size (amms_drdi_support = $amms_drdi_support)\n"; |
| 553 | print "rpc_sec_mem_addr: $rpc_sec_mem_addr\n"; |
| 554 | print "dsp_img_offset: $dsp_img_offset\n"; |
| 555 | print "dsp_img_size: $dsp_img_size\n"; |
| 556 | print "region_num: $region_num\n"; |
| 557 | for my $i (0 .. $#region_offset) |
| 558 | { |
| 559 | print "region_offset_$i: $region_offset[$i]\n"; |
| 560 | print "region_size_$i: $region_size[$i]\n"; |
| 561 | } |
| 562 | for my $i (0 .. $#domain_attr) |
| 563 | { |
| 564 | print "domain_attr_$i: $domain_attr[$i]\n"; |
| 565 | } |
| 566 | print "arm7_img_offset (volte address): $arm7_img_offset\n"; |
| 567 | print "arm7_img_size (volte size): $arm7_img_size\n"; |
| 568 | for my $i (0 .. $#free_padding_block_start_offset) |
| 569 | { |
| 570 | print "free_padding_block_start_offset_$i: $free_padding_block_start_offset[$i]\n"; |
| 571 | print "free_padding_block_length_$i: $free_padding_block_length[$i]\n"; |
| 572 | } |
| 573 | print "ap_md_smem_size: $ap_md_smem_size\n"; |
| 574 | print "md_to_md_smem_size: $md_to_md_smem_size\n"; |
| 575 | print "ramdisk_offset: $ramdisk_offset\n"; |
| 576 | print "ramdisk_size: $ramdisk_size\n"; |
| 577 | print "drdi_offset: $drdi_offset\n"; |
| 578 | print "drdi_size: $drdi_size\n"; |
| 579 | print "drdi_rt_offset: $drdi_rt_offset\n"; |
| 580 | print "drdi_rt_size: $drdi_rt_size\n"; |
| 581 | print "pos_size: $pos_size\n"; |
| 582 | print "consys_size: $consys_size\n"; |
| 583 | print "udc_support: $udc_support (r15_deflate_udc_support = $r15_deflate_udc_support)\n"; |
| 584 | print "nv_cache_shm_size: $nv_cache_shm_size\n"; |
| 585 | print "bat_buffer_info_ver: $bat_buffer_info_ver\n"; |
| 586 | print "reserved_1: $reserved_1\n"; |
| 587 | print "size: $size\n\n"; |
| 588 | |
| 589 | |
| 590 | # open in read/write mode with the file cursor at the beginning of the file, it won't create file if file not exist |
| 591 | open (FILE, "+<$file") or &error_handler("cannot open $file!", __FILE__, __LINE__); |
| 592 | #binmode(FILE); #seems no use? |
| 593 | |
| 594 | # seek(FILE, x, y); |
| 595 | # move file cursor, y=>0: to new position x, y=>1: to current position + x, y=>2: to file tail + x |
| 596 | seek(FILE, 0, 2); |
| 597 | |
| 598 | &write_string_with_big_endian(FILE, $check_header, 12); |
| 599 | &write_hex_with_big_endian(FILE, $header_verno, 8); |
| 600 | &write_hex_with_big_endian(FILE, $product_ver, 8); |
| 601 | &write_hex_with_big_endian(FILE, $image_type, 8); |
| 602 | |
| 603 | &write_string_with_big_endian(FILE, $mcu_platform, 16); |
| 604 | &write_string_with_big_endian(FILE, $build_time, 64); |
| 605 | &write_string_with_big_endian(FILE, $build_ver, 64); |
| 606 | |
| 607 | &write_hex_with_big_endian(FILE, $bind_sys_id, 2); |
| 608 | &write_hex_with_big_endian(FILE, $ext_attr, 2); |
| 609 | &write_string_with_big_endian(FILE, $reserved, 2); |
| 610 | |
| 611 | &write_number_with_little_endian(FILE, $mem_size, 1); |
| 612 | &write_number_with_little_endian(FILE, $md_img_size, 1); |
| 613 | &write_hex_with_big_endian(FILE, $rpc_sec_mem_addr, 8); |
| 614 | |
| 615 | &write_number_with_little_endian(FILE, $dsp_img_offset, 1); |
| 616 | &write_number_with_little_endian(FILE, $dsp_img_size, 1); |
| 617 | &write_number_with_little_endian(FILE, $region_num, 1); |
| 618 | for my $i (0 .. $#region_offset) |
| 619 | { |
| 620 | &write_number_with_little_endian(FILE, $region_offset[$i], 1); |
| 621 | &write_number_with_little_endian(FILE, $region_size[$i], 1); |
| 622 | } |
| 623 | for my $i (0 .. $#domain_attr) |
| 624 | { |
| 625 | &write_number_with_little_endian(FILE, $domain_attr[$i], 1); |
| 626 | } |
| 627 | &write_number_with_little_endian(FILE, $arm7_img_offset, 1); |
| 628 | &write_number_with_little_endian(FILE, $arm7_img_size, 1); |
| 629 | for my $i (0 .. $#free_padding_block_start_offset) |
| 630 | { |
| 631 | &write_number_with_little_endian(FILE, $free_padding_block_start_offset[$i], 1); |
| 632 | &write_number_with_little_endian(FILE, $free_padding_block_length[$i], 1); |
| 633 | } |
| 634 | &write_number_with_little_endian(FILE, $ap_md_smem_size, 1); |
| 635 | &write_number_with_little_endian(FILE, $md_to_md_smem_size, 1); |
| 636 | &write_number_with_little_endian(FILE, $ramdisk_offset, 1); |
| 637 | &write_number_with_little_endian(FILE, $ramdisk_size, 1); |
| 638 | &write_number_with_little_endian(FILE, $drdi_offset, 1); |
| 639 | &write_number_with_little_endian(FILE, $drdi_size, 1); |
| 640 | &write_number_with_little_endian(FILE, $drdi_rt_offset, 1); |
| 641 | &write_number_with_little_endian(FILE, $drdi_rt_size, 1); |
| 642 | &write_number_with_little_endian(FILE, $pos_size, 1); |
| 643 | &write_number_with_little_endian(FILE, $consys_size, 1); |
| 644 | &write_number_with_little_endian(FILE, $udc_support, 1); |
| 645 | &write_string_with_big_endian(FILE, $reserved_1, 4); |
| 646 | &write_number_with_little_endian(FILE, $nv_cache_shm_size, 1); |
| 647 | &write_string_with_big_endian(FILE, $reserved_1, 4); |
| 648 | &write_number_with_little_endian(FILE, $bat_buffer_info_ver, 1); |
| 649 | &write_string_with_big_endian(FILE, $reserved_1, 100); |
| 650 | &write_number_with_little_endian(FILE, $size, 1); |
| 651 | |
| 652 | close (FILE); |
| 653 | print "Done\n"; |
| 654 | exit 0; |
| 655 | |
| 656 | #************************************************************************************************* |
| 657 | # Error Handling Message |
| 658 | #************************************************************************************************* |
| 659 | sub error_handler { |
| 660 | my ($error_msg, $file, $line_no) = @_; |
| 661 | my $final_error_msg = "Error: $error_msg at $file line $line_no\n"; |
| 662 | print "$final_error_msg"; |
| 663 | die $final_error_msg; |
| 664 | } |