navienginebsp/tools/testreference/lauterbach/flashimage.cmm
changeset 0 5de814552237
equal deleted inserted replaced
-1:000000000000 0:5de814552237
       
     1 //
       
     2 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 // All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 //
       
     9 // Initial Contributors:
       
    10 // Nokia Corporation - initial contribution.
       
    11 //
       
    12 // Contributors:
       
    13 //
       
    14 // Description:  
       
    15 //
       
    16 //////////////////////////////////////////////////////////////////////////////
       
    17 //
       
    18 // Generic NOR Flash writing script.
       
    19 //
       
    20 // Change History:
       
    21 //
       
    22 // 01/01/2008 1.0 : Initial version
       
    23 // 12/02/2009 1.1 : Updated to initialise board and load globals before doing
       
    24 //                  anything else
       
    25 //
       
    26 //////////////////////////////////////////////////////////////////////////////
       
    27 
       
    28 &scriptversion=1.1
       
    29 
       
    30 print "======================================================================="
       
    31 print "Generic NOR flashing script version &scriptversion"
       
    32 
       
    33 ; Declare the global variables used by the system and read the current config into them
       
    34 do globals.cmm
       
    35 
       
    36 ; Make sure that flashing is supported on the target platform
       
    37 if os.file("&PlatformsDir\&Platform\flash.cmm")
       
    38 	(
       
    39 	local &result
       
    40 
       
    41 	; Make sure the user really does want to overwrite out their NOR flash!
       
    42 	if "&FlashWriteProtect"!="OFF"
       
    43 	(
       
    44 		dialog.yesno "Are you *sure* you want to erase NOR flash and write this image: &FlashImage?"
       
    45 		entry &result
       
    46 	)
       
    47 	else
       
    48 	(
       
    49 		&result=(0==0)
       
    50 	)
       
    51 
       
    52 	if &result
       
    53 		(
       
    54 		; Attach to the board and reset its hardware completely
       
    55 		do init.cmm
       
    56 
       
    57 		; Make sure a filename has been specified
       
    58 		if "&FlashImage"==""
       
    59 			(
       
    60 			print "Select ROM image to flash"
       
    61 
       
    62 			dialog.file "*.bin;*.img"
       
    63 			entry &FlashImage
       
    64 
       
    65 			if "&FlashImage"==""
       
    66 				(
       
    67 				print "*** Aborted (no ROM image filename specified) ***"
       
    68 				enddo
       
    69 				)
       
    70 			)
       
    71 
       
    72 		print "&Platform hardware configured for flashing"
       
    73 
       
    74 		; Load first few bytes of the image into ram and see whether it has an EPOC header on the front
       
    75 		data.load.binary "&FlashImage" &RamAddr++0x200
       
    76 		&firstWord=(data.long(sd:&RamAddr))
       
    77 		&skipHeader="false"
       
    78 
       
    79 		if ((&firstWord)==0x434F5045)
       
    80 			(
       
    81 			print "File &FlashImage has EPOC header (will skip it)"
       
    82 			&skipHeader="true"
       
    83 			)
       
    84 		else
       
    85 			(
       
    86 			print "No EPOC header present on file &FlashImage"
       
    87 			)
       
    88 
       
    89 		; Now do the platform specific operations
       
    90 		do &PlatformsDir\&Platform\flash.cmm "&FlashImage" &FlashAddr &skipHeader
       
    91 		)
       
    92 	)
       
    93 else
       
    94 	(
       
    95 	dialog.ok "NOR flashing not supported for platform &Platform"
       
    96 	)
       
    97 
       
    98 enddo