navienginebsp/tools/testreference/lauterbach/Platforms/ne1_tb/flash.cmm
changeset 0 5de814552237
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/navienginebsp/tools/testreference/lauterbach/Platforms/ne1_tb/flash.cmm	Tue Sep 28 18:00:05 2010 +0100
@@ -0,0 +1,109 @@
+//
+// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
+// All rights reserved.
+// This component and the accompanying materials are made available
+// under the terms of "Eclipse Public License v1.0"
+// which accompanies this distribution, and is available
+// at the URL "http://www.eclipse.org/legal/epl-v10.html".
+//
+// Initial Contributors:
+// Nokia Corporation - initial contribution.
+//
+// Contributors:
+//
+// Description:  
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// NaviEngine NOR flash download script
+//
+// Change History:
+//
+// 11/11/2008 1.0 : Initial version
+// 12/02/2009 1.1 : Merged working script in from old naviengine_flash.cmm
+// 08/05/2009 1.2 : Updated to accept the image name and address passed as parameters
+//
+//////////////////////////////////////////////////////////////////////////////
+
+&scriptversion=1.2
+entry &imageName &imageAddr &skipHeader
+
+print "======================================================================="
+print "&Platform NOR flashing script &scriptversion"
+
+; Stop all CPU cores on the board to prevent them interfering with the flashing
+do &PlatformsDir\&Platform\stopcpus.cmm
+
+; Reset the Lauterbach flash configuration
+flash.reset
+
+; Configure the flash to either use a helper executable on the machine (faster) or
+; to use the Lauterbach (slower) to perform the writing
+if "&FlashOptionTarget"=="yes"
+	(
+		; Target controlled flashing requires a binary downloaded to the development board
+		print "Using target assisted flashing"
+		flash.create 1. &FlashStart--&FlashEnd &FlashBlockSize TARGET &FlashWidth
+
+		; Determine where to store the target binary (and how big it is)
+		flash.target &RamAddr &RamAddr+0x1000 0x1000 ../demo/arm/flash/&FlashWidth/&FlashType.bin
+	)
+	else
+	(
+		; Emulator controlled flashing is controlled from the host and is a lot slower
+		print "Using basic emulator flashing (slow)"
+		flash.create 1. &FlashStart--&FlashEnd &FlashBlockSize &FlashType &FlashWidth
+	)
+
+; Determine the size of the image to be written
+&fileSize=os.file.size(&imageName)
+
+print "Flash Configuration:"
+print "-----------------------------"
+print "RAM address:       &RamAddr"
+print "Image name:        &imageName"
+print "Image Size:        &fileSize"
+print "Image Skip Header: &skipHeader"
+print "Flash Start:       &imageAddr"
+print "Flash End:         &FlashEnd"
+print "Flash Type:        &FlashType"
+print "Flash Block Size:  &FlashBlockSize"
+print "Flash Width:       &FlashWidth"
+print "-----------------------------"
+
+flash.unlock &imageAddr++&fileSize
+flash.erase &imageAddr++&fileSize
+flash.program &imageAddr++&fileSize
+
+if "&skipHeader"=="true"
+	(
+	print "Skipping EPOC header"
+	data.load.binary "&imageName" &imageAddr /SKIP 100
+	)
+else
+	(
+	data.load.binary &imageName &imageAddr /WORD
+	)
+
+; Programming done, relock the flash
+flash.program off
+flash.lock 1.
+
+; Compare what we wrote against what is there now
+print "Verifying image..."
+if "&skipHeader"=="true"
+	(
+	data.load.binary "&imageName" &imageAddr /SKIP 100 /compare
+	)
+else
+	(
+	data.load.binary "&imageName" &imageAddr /compare
+	)
+
+; On an error the script will abort before printing OK (and print the error)
+print "Verified OK.  Flash programming completed"
+
+; Disconnect the JTAG as the user is likely to power cycle the board and it might confuse us
+sys.down
+
+enddo