⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 erasenand.cmm

📁 QUALCOMM JNAND DRIVER
💻 CMM
字号:
;============================================================================
;  Name:
;    ERASENAND.CMM
;
;  Description:
;    Lauterbach JTAG/ICD TRACE32 script to erase entire NAND flash.
;
;  Execution:
;    Inside the debugger, type at the command line: "do erasenand".  Make
;    menu choices as directed.
;
;
;
; Copyright (c) 2002-2003 by QUALCOMM, Incorporated.  All Rights Reserved.
;----------------------------------------------------------------------------
;============================================================================
;
;                        EDIT HISTORY FOR MODULE
;
; $Header: //depot/asic/msmshared/tools/jnand/erasenand.cmm#1 $ $DateTime: 2004/02/26 14:43:26 $ $Author: dionh $
;
; when       who     what, where, why
; -------    ---     --------------------------------------------------------
; 02/26/04   drh     Created
;============================================================================;


; This structure is used to communcate between TRACE32 Debugger and
; our FLASH plug-in.
; struct type_jtag_flash_param {
;    uint32 flashaddr;   // offset 0x00
;    uint32 flashwidth;  // offset 0x04
;    uint32 width;       // offset 0x08
;    uint32 offset;      // offset 0x0C
;    uint32 addr;        // offset 0x10 in: address of the flash to write/erase
;    uint32 size;        // offset 0x14 in: size of data to write/erase
;    uint32 reserved;    // offset 0x18
;    uint32 status;      // offset 0x1C in: 1=program, 2=erase, 5=erase, out: 0=o.k., 0x100=fail
;    byte   data[0x20000]; /offset 0x20	// give 128K worth of buffer
;                            // this is where TRACE32 will store data that
;                            // we'll be writing to the FLASH
; };






;============================================================================
; Declare variables used
;============================================================================
local &MenuMode
local &DoDebug 
local &Verbose
local &ClearWin
local &Choice
 


;============================================================================
; Set up some defaults for some variables
;============================================================================
&DoDebug="no"         ; Do not do debugging      
&ClearWin="yes"       ; Remove all windows before starting
&Verbose="yes"        ; Tell the user what is happening

;============================================================================
; For normal use set up the screen with only area window for reports 
; For debug purposes, don't clear
; In both cases, make sure we have an area window
;============================================================================

if "&ClearWin"=="yes"  
  (  
    WinCLEAR
    WinPage.Reset
    WINPOS 0. 0. 80% 80%
  )

area 

if "&ClearWin"=="yes"  
  (  
    area.RESET 
  )


;============================================================================
; Set some MSM specific variables used later in flash.target command
;    &JnandCodeAddr=
;    &JnandParamAddr=
;    &JnandCpuType=
;============================================================================
 do jnand_param


;============================================================================
; 1) Set variables used to set up the JTAG debugger for this MSM
; 2) Init important MSM/ASB registers
;    use existing external script that is MSM specific
;============================================================================
 do jnand_msm_init

;-------------------------------------------------------------------------------
; Set some variables used later on to peek and poke parameter block
;   This script file is sourced by both jnand.cmm and jnandtest.cmm
;-------------------------------------------------------------------------------
do jnand_addr_init.cmm


;============================================================================
; Present User with prompt
;============================================================================

print
print " You are about to erase the entire NAND flash"
print " "
print " "
print
print " Please enter YES to continue, any other value will abort::     "
  
&t32_cmm_stopped=1
;enter &Choice
&Choice="YES"
&t32_cmm_stopped=0
print
print
	 
if "&Choice"=="YES" 
  (  
    print "Erasing entire flash....."
    if "&DoDebug"=="yes"  
      (  
        term.size 60 1000
        term.scroll on
        WinPOS 45 8
        term.view
        term.write term.out
      )
    gosub EraseChip
  )
else
  (
    print "Bailing out, correct answer not given" 
  )
  
if "&DoDebug"=="yes"  
  (  
    term.close
  )

enddo
 
 

;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
;  SUBROUTINES
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 
 

;=====================================================
; --- Function to Erase entire chip
;=====================================================
EraseChip: 

	 ; set up addresses used with FLASH.* commands
	 &RomBegin=&JnandBootRomBegin
	 &RomEnd=&JnandBootRomEnd
	 gosub CreateRom
	 
	 
	 ;--------------------------------------------------------
	 ; We have to set this command up by hand as it is one
	 ;  that we added to the flash.* protocol and JTAG does
	 ;  not know about it.
	 ;--------------------------------------------------------
	 ;
   if "&Verbose"=="yes"
   (
	   print "Erasing entire chip"
	 )
   &Command="Erase Chip"
	 data.set &ParmCmd %LONG &EraseChipCmd
	 r.s pc &StartAddr
	 go

	 gosub check_status  ;; will not return if error 
	 
   if "&Verbose"=="yes"
   (
	   print "Entire Chip is Erased"                                             
   )
return





;=====================================================
; --- Function to check command status return
;       and exit if 0x100
;=====================================================
check_status:
	 wait !run()
	
	 &Result=data.long(A:&ParmStatus)
	 if &Result==0x100
	 (
	   print " " 
	   print "---- &Command failed"
	   &Result=data.long(A:&ParmReserved)
	   print "     Extended status is &Result"
	   print " "
	   print "EXITING due to failed command:: &Command"
	   end
	 )
	 else
	 (
     if "&Verbose"=="yes"
     (
       print "+++++ &Command Succeeded"  
     )
	 )
return



;=====================================================
; --- Function to create the FLASH map
;=====================================================
CreateRom:
	;======================================================
	; Map flash readonly - must encompass the addresse
	;     of the image being loaded
	;======================================================
	 map.readonly &RomBegin--&RomEnd
	
	;======================================================
	; Load our flash programming routine and prepare flash
	;======================================================
	 d.load.elf "jnand.elf"
	 
	 ; need this breakpoint as per Lauterbach Spec so that we
	 ; can hand back control to the Debugger
	 break.delete /ALL
	 break.set swbp

	 ;--------------------------------------------------------
	 ; reset our flash command
	 ;--------------------------------------------------------
	 flash.res
	 
	 ;--------------------------------------------------------
	 ; Let flash command know where our routine and buffer is located
	 ; code at &JnandCodeAddr, data at &JnandParamAddr, buffer size = 16K
	 ; Earlier versions of JTAG s/w would allow larger buffer of 64k
	 ; but now we seem to be limited to 16k
	 ;--------------------------------------------------------
	 ;
	 flash.target &JnandCodeAddr &JnandParamAddr 4000 
	 
	 ;--------------------------------------------------------
	 ; Define our flash range and tell flash command we're using
	 ; our own flash programming routine via keyword "target"
	 ; right now, we are defining 3 MBytes for code which in
	 ; the NAND environment is meaningless, as this has to do
	 ; with memory mapping in the flash, but we have to use it
	 ; to use the other FLASH.* functions
	 ;--------------------------------------------------------
	 ;
	 flash.create &RomBegin--&RomEnd target word
return


END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -