mmtestenv/mmtesttools/Build/mmbuildrom.pl
changeset 0 b8ed18f6c07b
equal deleted inserted replaced
-1:000000000000 0:b8ed18f6c07b
       
     1 # Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # mmrombuild.pl
       
    15 # 
       
    16 #
       
    17 
       
    18 use strict;
       
    19 use warnings;
       
    20 use Env qw(EPOCROOT);
       
    21 use File::Copy;
       
    22 
       
    23 # literals
       
    24 my $auto_param =  "-a";
       
    25 my $dp_param   =  "-d";
       
    26 my $wdp_param  =  "-w";
       
    27 my $all_param  =  "-f";
       
    28 my $help_param =  "-h";
       
    29 my $icl_param  =  "-i";
       
    30 my $plus_icl_param = "+i";
       
    31 my $keep_param =  "-k";
       
    32 my $mmf_param  =  "-m";
       
    33 my $nand_param =  "-n";
       
    34 my $addnl_param = "-p";
       
    35 my $test_param =  "-t";
       
    36 my $extra_param = "-x";
       
    37 my $gce_param  =  "-g";
       
    38 my $eabi_param =  "-eabi";
       
    39 my $h2_param =    "-h2";
       
    40 my $h4_param =    "-h4";
       
    41 my $h6_param =    "-h6";
       
    42 my $lab_param =    "-lab";
       
    43 my $lbk_param =   "-lbk";
       
    44 my $x86_param =   "-x86pc";
       
    45 my $ne_param =    "-ne";
       
    46 my $smp_param =    "-smp";
       
    47 my $uni_param =    "-uni";
       
    48 
       
    49 my $KRomDir     = "epoc32\\rom";
       
    50 my $KLubbockImg = "la_001.techview.IMG";
       
    51 my $KH2Img =      "om_001.techview.IMG";
       
    52 my $KH4Img =      "h4hrp_001.techview.IMG";
       
    53 my $KH4RofsImg =      "h4hrp_001.techview.rofs.IMG";
       
    54 my $KH6Img =      "34xx_sdp_001.techview.IMG";
       
    55 my $KH6NandImg =	"34xx_sdp_001.techview.nand.IMG";
       
    56 my $KH6NandRofsImg =	"34xx_sdp_001.techview.nand.rofs.IMG";
       
    57 my $KLabImg =      "lab_001.techview.IMG";
       
    58 my $KLabNandImg =	"lab_001.techview.nand.IMG";
       
    59 my $KLabNandRofsImg =	"lab_001.techview.nand.rofs.IMG";
       
    60 my $KH4NandImg =  "h4hrp_001.techview.nand.img";
       
    61 my $KH4NandRofsImg = "h4hrp_001.techview.nand.rofs.img";
       
    62 my $KH6NandBootLoader =	"h6.nandloader.reltest.img";
       
    63 my $KLabNandBootLoader =	"lab_001.nandloader.reltest.img";
       
    64 my $KH4NandBootLoader = "h4.nandloader.reltest.img";
       
    65 my $KMmcBootLoader = "h4.mmcloader.reltest.img";
       
    66 my $CoreImg =     "core.img";
       
    67 my $Rofs1Img =    "rofs1.img";
       
    68 my $KBinName	= 'sys$rom.bin'; # be careful about '$'
       
    69 my $KZipName	= 'sys$rom.zip'; # be careful about '$'
       
    70 my $KX86Img     =  "x86pc_001.techview.IMG";
       
    71 my $KNEImg     =  "NE1_TB_001.techview.IMG";
       
    72 
       
    73 my $extras = "";
       
    74 my $gce = "";
       
    75 my $test = "";
       
    76 my $component = "";
       
    77 my $keep = "";
       
    78 my $auto = "";
       
    79 my $eabi = "";
       
    80 my $addnl_ibys = "";
       
    81 my $dp = "";
       
    82 my $wdp = "";
       
    83 my $nand = "";
       
    84 my $img = "";
       
    85 my $target = ""; # default target is h6 but start as blank so we can distinguish multiple target requests
       
    86 my $default_target = "h6";
       
    87 my $arm = "";
       
    88 my $smp = "";
       
    89 my $uni = "";
       
    90 my $wrong_ne_param = 0;
       
    91 my $include_icl_tests = "";
       
    92 
       
    93 my $eka2IdentifyFile  = "$ENV{EPOCROOT}epoc32\\release\\winscw\\udeb\\winsgui.dll"; # if file present, is EKA2 build
       
    94 my $PlatSecIdentifyFile  = "$ENV{EPOCROOT}epoc32\\release\\armv5\\udeb\\mmfdevsoundproxy.dll"; # if file present, is a build with platsec
       
    95 my $StreamingCafIdentifyFile = "$ENV{EPOCROOT}epoc32\\release\\armv5\\udeb\\sraserver.exe";
       
    96 
       
    97 my $OptionalFile = "";
       
    98 # if any of these .iby files are present, then we'll add them to the ROM.
       
    99 my @OptionalFiles = ("$ENV{EPOCROOT}epoc32\\rom\\include\\XviDPU.iby",
       
   100 			       "$ENV{EPOCROOT}epoc32\\rom\\include\\XviDhw.iby",
       
   101 			       "$ENV{EPOCROOT}epoc32\\rom\\include\\oggvorbiscodec.iby",
       
   102 			       "$ENV{EPOCROOT}epoc32\\rom\\include\\omxoggvorbiscodec.iby",
       
   103 			       "$ENV{EPOCROOT}epoc32\\rom\\include\\pvopt.iby",
       
   104 			       "$ENV{EPOCROOT}epoc32\\rom\\include\\pvtestsopt.iby",
       
   105 			       "$ENV{EPOCROOT}epoc32\\rom\\include\\RtaUtils.iby",
       
   106 			       "$ENV{EPOCROOT}epoc32\\rom\\include\\TestExecute.iby",
       
   107 				   "$ENV{EPOCROOT}epoc32\\rom\\include\\streamingcaf.iby");
       
   108 
       
   109 my $OggVorbisCodecPresent = 0;
       
   110 
       
   111 my $targetToolsDir = "..\\..\\..\\..\\..\\TargetTools\\Build";
       
   112 my $targetToolsExists = 0;
       
   113 if (-d $targetToolsDir)
       
   114 	{
       
   115 	$targetToolsExists = 1;
       
   116 	print "TargetTools directory exists: $targetToolsDir\n"
       
   117 	}
       
   118 
       
   119 # main:
       
   120 	{
       
   121 	# Process command-line
       
   122 
       
   123 	&ReadArgs();
       
   124 	
       
   125 	&ProcessArgs();
       
   126 	
       
   127 	&BuildRom();
       
   128 	}
       
   129 
       
   130 #
       
   131 # Subroutines
       
   132 #
       
   133 
       
   134 sub ReadArgs()
       
   135 	{
       
   136 	while (@ARGV)
       
   137 		{
       
   138 		my $param = $ARGV[0]; shift @ARGV; # grab first param and shift along
       
   139 		
       
   140 		if ($param eq "") # ignore blank parameters
       
   141 			{
       
   142 			next;
       
   143 			}
       
   144 
       
   145 		if ($param eq $icl_param || 
       
   146 		    $param eq $mmf_param || $param eq $all_param)
       
   147 			{
       
   148 			$component = $param;
       
   149 			}
       
   150 		elsif ($param eq $plus_icl_param)
       
   151 			{
       
   152 			$include_icl_tests = $param;
       
   153 			}
       
   154 		elsif ($param eq $test_param)
       
   155 			{
       
   156 			$test = $param;
       
   157 			}
       
   158 		elsif ($param eq $extra_param)
       
   159 			{
       
   160 			$extras = $param;
       
   161 			}
       
   162 		elsif ($param eq $gce_param)
       
   163 			{
       
   164 			$gce = $param;
       
   165 			}
       
   166 		elsif ($param eq $auto_param)
       
   167 			{
       
   168 			$auto = $param;
       
   169 			}
       
   170 		elsif ($param eq $eabi_param)
       
   171 			{
       
   172 			$eabi = $param;
       
   173 			}
       
   174 		elsif ($param eq $dp_param)
       
   175 			{
       
   176 			$dp = $param;
       
   177 			$nand = $param; # demand paging implies nand
       
   178 			}
       
   179 		elsif ($param eq $wdp_param)
       
   180 			{
       
   181 			$wdp = $param;
       
   182 			$dp = $param; # writable data paging implies standard demand paging
       
   183 			}
       
   184 		elsif ($param eq $nand_param)
       
   185 			{
       
   186 			$nand = $param;
       
   187 			}
       
   188 		elsif ($param eq $addnl_param)
       
   189 			{
       
   190 			$addnl_ibys .= " " . $ARGV[0]; shift @ARGV; # grab next param and shift along
       
   191 			}
       
   192 		elsif ($param eq $h2_param)
       
   193 			{
       
   194 			&Usage() if ($target ne "");
       
   195 			$target = "h2";
       
   196 			$eabi = $eabi_param; # H2 always EABI
       
   197 			}
       
   198  		elsif ($param eq $h4_param)
       
   199  			{
       
   200 			&Usage() if ($target ne "");
       
   201 			$target = "h4";
       
   202  			$eabi = $eabi_param; # H4 always EABI
       
   203  			}
       
   204  		elsif ($param eq $h6_param)
       
   205 			{
       
   206 			&Usage() if ($target ne "");
       
   207 			$target = "h6";
       
   208 			$eabi = $eabi_param; # H6 always EABI
       
   209 			}
       
   210 		elsif ($param eq $lab_param)
       
   211 			{
       
   212 			&Usage() if ($target ne "");
       
   213 			$target = "lab";
       
   214 			$eabi = $eabi_param; # Lab always EABI
       
   215 			}
       
   216 		elsif ($param eq $lbk_param)
       
   217 			{
       
   218 			&Usage() if ($target ne "");
       
   219 			$target = "lbk";
       
   220 			}
       
   221 		elsif ($param eq $x86_param)
       
   222 			{
       
   223 			&Usage() if ($target ne "");
       
   224 			&Usage() if (($eabi ne "") || ($nand ne ""));
       
   225 			$target = "x86";
       
   226 			}			
       
   227 		elsif ($param eq $ne_param)
       
   228 			{
       
   229 			&Usage() if ($target ne "");
       
   230 			&Usage() if ($nand ne "");
       
   231 			$target = "naviengine";
       
   232 			$eabi = $eabi_param; # NaviEngine always EABI
       
   233 			}
       
   234 		elsif ($param eq $smp_param)
       
   235 			{
       
   236 			# Only NaviEngine can be configured to build SMP enabled image
       
   237 			&Usage() if ($target ne "naviengine");
       
   238 			$smp = "smp";
       
   239 			}						
       
   240 		elsif ($param eq $uni_param)
       
   241 			{
       
   242 			# '-uni'-flag valid only for NaviEngine
       
   243 			&Usage() if ($target ne "naviengine");
       
   244 			$uni = "uni";
       
   245 			}									
       
   246 		elsif ($param eq $help_param)
       
   247 			{
       
   248 			&Usage();
       
   249 			}
       
   250 		else
       
   251 			{
       
   252 			# unknown setting
       
   253 			&Usage();
       
   254 			}
       
   255 		}
       
   256 	&CheckArgs();
       
   257 	}
       
   258 
       
   259 sub CheckArgs()
       
   260 	{
       
   261 	# check that the arguments make sense
       
   262 	
       
   263 	$target = $default_target if ($target eq "");
       
   264 	
       
   265 	}
       
   266 	
       
   267 sub ProcessArgs()
       
   268 	{
       
   269 	if ($target eq "h2")
       
   270 		{
       
   271 		$img = $KH2Img;
       
   272 		}
       
   273 	elsif ($target eq "lkb")
       
   274 		{
       
   275 		$img = $KLubbockImg;
       
   276 		}
       
   277 	elsif ($target eq "h4")
       
   278 		{
       
   279 		$img = $KH4Img if ($nand eq "");
       
   280 		$img = $KH4NandImg if ($nand ne "");
       
   281 		}
       
   282 	elsif ($target eq "h6")
       
   283 		{
       
   284 		$img = $KH6Img;
       
   285 		}
       
   286 	elsif ($target eq "lab")
       
   287 		{
       
   288 		$img = $KLabImg;
       
   289 		}
       
   290 	elsif ($target eq "x86")
       
   291 		{
       
   292 		$img = $KX86Img;
       
   293 		}	
       
   294 	elsif ($target eq "naviengine")
       
   295 		{
       
   296 		$img = $KNEImg;
       
   297 		}			
       
   298 	else
       
   299 		{
       
   300 		die "Internal error: unknown image type";
       
   301 		}	
       
   302 	if($target eq "naviengine" && $smp eq "" && $uni eq "" )
       
   303 		{
       
   304 		$wrong_ne_param = 1;
       
   305 		&Usage();
       
   306 		}
       
   307 	if($target eq "h2" || $target eq "lkb" || $target eq "h4" || $target eq "naviengine" || $target eq "h6" || $target eq "lab")
       
   308 		{
       
   309 		# procedure to build arm target different so identify a ARM based target
       
   310 		$arm ="arm";
       
   311 		}
       
   312 	}
       
   313 	
       
   314 sub BuildRom()
       
   315 	{
       
   316 	my $command;
       
   317 	# note from build 4713 -D_STARTUPMODE5 is replaced with -D_SSMSTARTUPMODE=5. Don't mix
       
   318 	if($target ne "naviengine")
       
   319 		{
       
   320 		$command = "tools\\buildrom -D__NOWATCHER__ -D_DEBUG -D_SSMSTARTUPMODE=5";
       
   321 		}
       
   322 	else
       
   323 		{
       
   324 		#Currently startupmode flag is not used for NaviEngine.
       
   325 		$command = "tools\\buildrom -D_DEBUG";
       
   326 		$command .= " -DSYMBIAN_MDASOUNDADAPTER_FORCE_STEREO";
       
   327 		}		
       
   328 	if($target ne "x86" && $target ne "naviengine")
       
   329 		{
       
   330 		$command .= " -D_SERIAL_DOWNLOAD";
       
   331 		}
       
   332 	if($smp ne "")
       
   333 		{
       
   334 		$command .= " -DSMP";
       
   335 		}
       
   336 	if($uni ne "")
       
   337 		{
       
   338 		#Use Flexible Memory Model for UniCore
       
   339 		#Until base have fixed the issue related to this keep commented out.
       
   340 		#$command .= " -DWITH_FLEXIBLE_MM";
       
   341 		}
       
   342 	
       
   343 	$command .= " -D_NAND2" if ($nand ne "" && $arm ne "");
       
   344 	$command .= " -DUSE_24BPP_DISPLAY_VARIANT" if ($target eq "h6" || "lab");
       
   345 	if($wdp ne "")
       
   346 		{
       
   347 		$command .= " -DWITH_FLEXIBLE_MM -DUSE_SDIO_SD_MMC -D_INTERNAL_MMC -DUSE_DATA_PAGING"
       
   348 		}
       
   349 	$command .= " -DSYMBIAN_BASE_USE_GCE -DSYMBIAN_GRAPHICS_USE_GCE" if ($gce ne "");
       
   350 
       
   351 	# Needed to prevent Xml.iby errors if these flags are added to techview.oby for example, then remove them here
       
   352 	$command .= " -DSYMBIAN_EXCLUDE_LIBXML2 -DSYMBIAN_EXCLUDE_LIBXML2_SAX_CPARSER_PLUGIN -DSYMBIAN_EXCLUDE_LIBXML2_DOM_XPATH_API";
       
   353 	
       
   354 	# select instruction set type, only applicable for ARM based platforms
       
   355 	#The below flags are currently not used for NaviEngine
       
   356 	if($arm ne "" && $target ne "naviengine")
       
   357 	{
       
   358 	if ($eabi ne "" || -f $eka2IdentifyFile)
       
   359 		{
       
   360 		$command .= " -DRVCT -D_EABI=ARMV5";
       
   361 		}
       
   362 	else
       
   363 		{
       
   364 		$command .= " -D_THUMB";
       
   365 		}
       
   366 	}	
       
   367 
       
   368 	# Use the default FeatureManager database, not yet supported for x86
       
   369 	if($arm ne "")
       
   370 		{
       
   371 		$command .= " -fm=$ENV{EPOCROOT}epoc32\\rom\\include\\featuredatabase.xml"; 
       
   372 		}
       
   373 	else
       
   374 		{
       
   375 		$command .= ' -nofm'; #-fm option not supported as of 0708.
       
   376 		}
       
   377 	
       
   378 	# select development board (now we build h4 by default)
       
   379 	if ($target eq "lbk")
       
   380 		{
       
   381 		$command .= " lubbock";
       
   382 		}
       
   383  	elsif ($target eq "h2")
       
   384  		{
       
   385  		$command .= " h2";
       
   386  		}
       
   387 	 elsif ($target eq "x86")
       
   388  		{
       
   389  		$command .= " x86pc";
       
   390  		}	
       
   391  	elsif ($target eq "naviengine")
       
   392  		{
       
   393  		$command .= " naviengine";
       
   394  		}	
       
   395  	elsif ($target eq "h6")
       
   396  		{
       
   397  		$command .= " pagedrom" if ($dp ne "");
       
   398  		$command .= " 34xx_sdp";
       
   399  		}
       
   400 	elsif ($target eq "lab")
       
   401  		{
       
   402  		$command .= " pagedrom" if ($dp ne "");
       
   403  		$command .= " lab";
       
   404  		}
       
   405  	elsif ($target eq "h4")
       
   406  		{
       
   407  		$command .= " pagedrom" if ($dp ne "");
       
   408 	 	$command .= " h4hrp";
       
   409  		}
       
   410 	else
       
   411 		{
       
   412 		die "target does not exist!!"
       
   413 		}
       
   414 		
       
   415 	# devkit.oby not included for NaviEngine currently	
       
   416 	if($target ne "naviengine")
       
   417 		{
       
   418 		$command .= " devkit";
       
   419 		}
       
   420 	$command .= " techview";
       
   421 	
       
   422 	$command .= " misc.iby";
       
   423 	
       
   424 	# use platform security, if appropriate
       
   425 	if (-f $PlatSecIdentifyFile)
       
   426 		{
       
   427 		$command .= " platsec";
       
   428 		}
       
   429 
       
   430 	if ($extras ne "")
       
   431 		{
       
   432 		$command .= " mmfOpt.iby" ; # mmfOpt.iby should include optional stuff
       
   433 		$command .= " iclOpt.iby" ; # iclOpt.iby should include optional stuff
       
   434 		$command .= " miscOpt.iby" ; # miscOpt.iby should include optional stuff
       
   435 		
       
   436 		if ($test ne "")
       
   437 			{
       
   438 			$command .= " mmfOptTest.iby" ; # mmfOptTest.iby should include tests of optional stuff
       
   439 			$command .= " iclOptTest.iby" if $include_icl_tests ne ""; # iclOptTest.iby should include tests of optional stuff
       
   440 			$command .= " miscOptTests.iby"; # miscOptTests.iby should include tests of optional stuff
       
   441 			}
       
   442 			
       
   443 		# Open source code delivered separately to Symbian OS
       
   444 		foreach $OptionalFile (@OptionalFiles)
       
   445 			{
       
   446 			if (-f $OptionalFile)
       
   447 				{
       
   448 				$OptionalFile =~ s/^.*\\//; # get only the filename
       
   449 				
       
   450 				if ($OptionalFile eq "oggvorbiscodec.iby" 
       
   451 					|| $OptionalFile eq "omxoggvorbiscodec.iby")
       
   452 					{
       
   453 					$OggVorbisCodecPresent = 1;
       
   454 					}
       
   455 				
       
   456 				$command .= " ";
       
   457 				$command .= $OptionalFile;
       
   458 				}
       
   459 			else
       
   460 				{
       
   461 				print "**** WARNING: $OptionalFile not added to ROM ****\n"
       
   462 				}
       
   463 			}
       
   464 
       
   465 		# Add oggvorbis to ROM only if oggvorbiscodec and omxoggvorbiscodec exist to prevent ROM build errors
       
   466 		if ($OggVorbisCodecPresent)
       
   467 			{
       
   468 			$command .= " oggvorbis.iby";
       
   469 			}
       
   470 		}
       
   471 	
       
   472 	if ($gce ne "")
       
   473 		{
       
   474 		$command .= " videorenderer.iby";
       
   475 		
       
   476 		if ($test ne "")
       
   477 			{
       
   478 			$command .= " tsu_mmf_videorenderer.iby";
       
   479 			}
       
   480 		}
       
   481 	
       
   482 	if ($test ne "")
       
   483 		{
       
   484 		if ($component eq $icl_param)
       
   485 			{
       
   486 			$command .= " iclIntTests.iby";
       
   487 			$command .= " iclUnitTests.iby";
       
   488 			}
       
   489 		elsif ($component eq $mmf_param)
       
   490 			{
       
   491 			$command .= " mmfUnitTests.iby";
       
   492 			if ($extras eq "")
       
   493 				{
       
   494 				$command .= " mmfNotOptTest.iby";
       
   495 				}
       
   496 			}
       
   497 		else
       
   498 			{ 
       
   499 			# -f or default
       
   500 			$command .= " MiscUnitTests.iby";
       
   501 			$command .= " MiscIntTests.iby";
       
   502 			$command .= " MMFUnitTests.iby";
       
   503 			$command .= " MMFIntTests.iby";
       
   504 			$command .= " ICLUnitTests.iby" if $include_icl_tests ne "";
       
   505 			$command .= " ICLIntTests.iby" if $include_icl_tests ne "";
       
   506 			if ($targetToolsExists)
       
   507 				{
       
   508 				$command .= " ExtraMultimediaTests.iby ecam.iby";
       
   509 				$command .= " timageviewer.iby timagedisplay.iby tphotoeditor.iby timagetran.iby" if $include_icl_tests ne "";
       
   510 				}
       
   511 			if ($extras eq "")
       
   512 				{
       
   513 				$command .= " mmfNotOptTest.iby";
       
   514 				}
       
   515 			}
       
   516 		}
       
   517 	if ($targetToolsExists)
       
   518 		{
       
   519 		if ($auto ne "") 
       
   520 			{
       
   521 			$command .= " MMAutoExec.iby";
       
   522 			}
       
   523 		}
       
   524 
       
   525 	#pvdecoderaac.iby is somehow not getting included into naviengine roms, the way it is in case of H4 and the rest.
       
   526 	if($target eq "naviengine")
       
   527 		{
       
   528 		$command .= " pvdecoderaac.iby";
       
   529 		}
       
   530 	
       
   531 	$command .= $addnl_ibys;
       
   532 	
       
   533 	if ($gce eq "" and $dp eq "")
       
   534 		{
       
   535 		$command .= " surfacemanager_ref.iby" if ($target eq "h6" || "lab" || "naviengine");
       
   536 		}
       
   537 		
       
   538 	print $command, "\n";
       
   539 
       
   540 	die "EPOCROOT is not set" unless ($EPOCROOT ne "");
       
   541 	my $romDir = $EPOCROOT . $KRomDir;
       
   542 	die "$romDir does not exist" unless -d $romDir;
       
   543 	chdir ($romDir) or die "Could not cd to $romDir - $!";
       
   544 
       
   545 	# delete the expected image, so clear whether worked or not
       
   546 	if (-f $img)
       
   547 		{
       
   548 		my $count = unlink $img;
       
   549 		die "Could not delete $KH2Img" unless $count == 1;
       
   550 		}
       
   551 
       
   552 	# delete any existing zip, otherwise we could end up with multiple ROMs in our zip file
       
   553 	if ($arm ne "" && -f $KZipName)
       
   554 		{
       
   555 		my $count = unlink $KZipName;
       
   556 		die "Could not delete $KZipName" unless $count == 1;
       
   557 		}
       
   558 		
       
   559 	my $result = system($command);
       
   560 	if ($result != 0)
       
   561 		{
       
   562 		print "Command failed ($result)\n";
       
   563 		exit 1;
       
   564 		}
       
   565 	if($arm ne "")
       
   566 		{
       
   567 		if ($nand eq "" and $wdp eq "") # for nand etc you need to use the rofs loder, otherwise conver to sys$rom.zip
       
   568 			{
       
   569 			my $zipCommand = "zip " . $KZipName . " " . $img;
       
   570 		
       
   571 			print $zipCommand, "\n";
       
   572 			$result = system($zipCommand);
       
   573 			if ($result != 0)
       
   574 				{
       
   575 				print "Command failed ($result)\n";
       
   576 				exit 1;
       
   577 				}
       
   578 			}	
       
   579 		elsif ($nand ne "" or $wdp ne "")
       
   580 			{	
       
   581 			if ($target eq "h6")
       
   582 				{
       
   583 				if ($nand ne "")
       
   584 					{
       
   585 					copy($KH6NandBootLoader,$KBinName) or die "Copy failed: $!";
       
   586 					copy($KH6NandImg,$CoreImg) or die "Copy failed: $!";
       
   587 					copy($KH6NandRofsImg,$Rofs1Img) or die "Copy failed: $!";
       
   588 					}
       
   589 				else # if ($wdp ne "") - not supported yet but ready for future releases
       
   590 					{
       
   591 					print "\nWDP is not supported yet on H6\n";
       
   592 					exit 1;
       
   593 #					copy($KMmcBootLoader,$KBinName) or die "Copy failed: $!";
       
   594 #					copy($KH6Img,$CoreImg) or die "Copy failed: $!";
       
   595 #					copy($KH6RofsImg,$Rofs1Img) or die "Copy failed: $!";
       
   596 					}
       
   597 				}
       
   598 			elsif ($target eq "lab")
       
   599 				{
       
   600 				if ($nand ne "")
       
   601 					{
       
   602 					copy($KLabNandImg,$CoreImg) or die "Copy failed: $!";
       
   603 					copy($KLabNandRofsImg,$Rofs1Img) or die "Copy failed: $!";
       
   604 #					copy($KLabNandBootLoader,$KBinName) or die "Copy failed: $!"; Lab Nandloader is still not part of the CBR release hence commenting this command for time being
       
   605 					}
       
   606 				else # if ($wdp ne "") - not supported yet but ready for future releases
       
   607 					{
       
   608 					print "\nWDP is not supported yet on Labrador\n";
       
   609 					exit 1;
       
   610 #					copy($KMmcBootLoader,$KBinName) or die "Copy failed: $!";
       
   611 #					copy($KLabImg,$CoreImg) or die "Copy failed: $!";
       
   612 #					copy($KLabRofsImg,$Rofs1Img) or die "Copy failed: $!";
       
   613 					}		
       
   614 				}				
       
   615 			else
       
   616 				{
       
   617 				if ($nand ne "")
       
   618 					{
       
   619 					copy($KH4NandBootLoader,$KBinName) or die "Copy failed: $!";
       
   620 					copy($KH4NandImg,$CoreImg) or die "Copy failed: $!";
       
   621 					copy($KH4NandRofsImg,$Rofs1Img) or die "Copy failed: $!";
       
   622 					}
       
   623 				else # if ($wdp ne "")
       
   624 					{
       
   625 					copy($KMmcBootLoader,$KBinName) or die "Copy failed: $!";
       
   626 					copy($KH4Img,$CoreImg) or die "Copy failed: $!";
       
   627 					copy($KH4RofsImg,$Rofs1Img) or die "Copy failed: $!";
       
   628 					}
       
   629 				}
       
   630 			print "Generated " . $CoreImg . ", " . $Rofs1Img . " and " . $KBinName . "\n";
       
   631 			$command = "dir " . $CoreImg . " " . $Rofs1Img . " " . $KBinName;
       
   632 			system($command);
       
   633 			}
       
   634 		}
       
   635 	}	
       
   636 
       
   637 sub Usage
       
   638 	{
       
   639 	# print usage statement and exit
       
   640 	print <<ENDHERESTRING;
       
   641 usage:
       
   642  	mmrombuild {-i|-m|-f} [+i] [-d] [-x] [-t] [-a] [-eabi] [-h2] [-h4] [-h6] [-lab] [-lbk] [-p <ibyfile>] [-ne <-uni/-smp>]
       
   643 
       
   644 mmbuildrom will build a lubbock / H2 / H4 / NaviEngine / Labrador ROM for multimedia testing
       
   645 
       
   646 It will always build a standard rom for the given platform, the various flags
       
   647 support what test and optional software is installed in addition.
       
   648 The parameters are as follows:
       
   649 
       
   650 -d) Build demand-paging NAND rom - instead of standard NOR build. Implies -n
       
   651 -w) Build writable data paging NAND rom - implies -d but not -n!
       
   652 -i) Build ICL test (unit and integration) software only, if -t is set
       
   653 -m) Build MMF unit test software only, if -t is set
       
   654 +i) ICL tests are now disabled unless this parameter is also given
       
   655 -n) Build NAND rom - otherwise builds NOR
       
   656 -f) Add all tests software, it -t is set (default)
       
   657 -t) Add test software
       
   658 -x) Add optional Multimedia modules
       
   659 -g) Add optional Graphics Composition Engine enabled components
       
   660 -eabi) Builds rom for armv5
       
   661 -h2) Builds for H2 board
       
   662 -h4) Builds for H4 board
       
   663 -x86pc) Builds rom for X86 Platform
       
   664 -lab) Builds for labrador board
       
   665 -ne) Builds rom for NaviEngine board(NE (uni/smp) does not support demand paging yet)
       
   666 -smp) Builds an SMP-enabled Rom Image(Valid only if -ne flag is used)
       
   667 -uni) Builds UniCore Rom Image(Valid only if -ne flag is used)
       
   668 -lbk) Builds for lubbock board (default is h2)
       
   669 -p <ibyfile>) Append .iby file to list
       
   670 
       
   671 ENDHERESTRING
       
   672 	if ($targetToolsExists)
       
   673 		{
       
   674 		print "-a) Add MMAutoExec iby file (internal Symbian use only)"
       
   675 		}
       
   676 	if($wrong_ne_param)
       
   677 		{
       
   678 		print "\n \n*Did you forget to specify whether you want a UniCore image or an SMP image?*\n\n";
       
   679 		}
       
   680 	exit 1;
       
   681 	}
       
   682