📄 jnand.bak
字号:
;============================================================================
; Name:
; JNAND.CMM
;
; Description:
; FLASH Programming Script file for Lauterbach JTAG/ICD TRACE32.
;
; There is a combination of JTAG/ICD FLASH.* commands and our own
; extensions to those commands used. Because of the nature of the NAND
; flash, we must send a "preparation" command before FLASH.program
; command, and then a "finish" command after, to tell the JNAND program
; that the last page of code should be flushed to the NAND flash
; and to write the boot information block.
;
; Execution:
; Inside the debugger, type at the command line: "do jnand". Make
; menu choices as directed.
;
; Command line args handled by JNAND:
;
; JNAND [DEBUG] [NOMENU | FACTORY] [BUILDID]
;
; DEBUG is optional but MUST be first if used. Will make JNAND verbose
;
; NOMENU is used by JNLOAD and will cause both bootloader and code
; build to be loaded with no intervention and JNAND to become
; very quiet
;
; FACTORY is used to put JNAND into Factory Programming Mode
; (FACTORY mode does not use the BUILDID parameter at all)
;
; (NOMENU and FACTORY are mutually exclusive and must be first
; or second, but DEBUG still must be first if present)
;
; BUILDID is a valid ELF file and can be in the format of:
; SNTA
; SNTA.elf
; ..\..\somedirectory\somewhere\SNTA (or SNTA.elf)
; C:\somepath\somedir\SNTA (or SNTA.elf)
;
; If no path is given, JNAND will assume ..\..\build\ms
; If no BUILDID is given, JNAND will provide a file chooser window
; with its base in ..\..\build\ms
;
;
; Copyright (c) 2002-2004 by QUALCOMM, Incorporated. All Rights Reserved.
;----------------------------------------------------------------------------
;============================================================================
;
; EDIT HISTORY FOR MODULE
;
; $Header: //depot/asic/MSMSHARED/tools/jnand/jnand.cmm#12 $ $DateTime: 2004/04/10 08:58:33 $ $Author: dionh $
;
; when who what, where, why
; ------- --- --------------------------------------------------------
; 04/10/04 drh Fix bug that causes failure when code size overlaps
; parameter block address
; 10/23/03 drh Move knowledge of size of DMSS image to generated file
; Merge JNLOAD changes in. JNLOAD is now only a shell
; 09/16/03 drh Allow programming of first 8mb of NAND flash
; 07/25/03 drh Fix minor typo in Area window clearing variable.
; Allow programming of first 8mb of NAND flash
; 07/01/03 drh Add variable to control AREA window clearing
; Take out warning about SYS.U
; 06/18/03 drh Added warnings for work arounds on Jaguar
; 03/25/04 drh Close all windows except area window.
; 02/06/03 pg Moved from ASWP402 server to ASWP401 server.
; 12/18/02 drh Change erase length to 6mb.
; Get boot_loader.elf from its home directory
; 10/03/02 drh Correct comments about how to invoke this script
; 09/20/02 drh Changed path to where to find DMSS images
; 07/13/02 drh Added copyright notice to tool banner
; 07/12/02 drh Major rewrite to account for two programming modes, DMSS
; and boot block programming. Made things very subroutine
; call oriented.
; 07/08/02 drh Moved all sys.* directives out of this file and into
; jnand_msm_init.cmm since some of them have to be done
; after some basic hardware setup.
; 07/06/02 drh Take out all hard coded addresses and CPU type. Read
; in from jnand_param.cmm which is generated during build
; process
; 07/05/02 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 &ELFname
local &ELFdir
local &ElfImage
local &arg1 &arg2 &arg3
local &MenuMode
local &DoDebug
local &ProcessElfName
local &Verbose
local &OSPwd
local &SymbolArg
local &ClearWin
local &Choice
;============================================================================
; Set up some defaults for some variables
;============================================================================
&MenuMode="STD" ; Present normal JNAND menu
&DoDebug="no" ; Do not do debugging
&ProcessElfName="yes" ; Processs the ELF file name
&Verbose="no" ; Do not present status messages as we process
&ClearWin="yes" ; Remove all windows before starting
&SymbolArg="/NOSYMBOL" ; Don't load any symbols.
;============================================================================
; Get the arguments passed in.
;============================================================================
ENTRY &arg1 &arg2 &arg3
gosub ProcessCmdLine
;============================================================================
; 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
)
;TEST JKMIN
;TERM.VIEW
;TERM.WRITE TERM.OUT
;============================================================================
; 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 correct menu or no menu
;============================================================================
if "&MenuMode"=="FACTORY"
(
gosub FactoryMenu
)
else
(
if "&MenuMode"=="NOMENU"
(
gosub DoNoMenu
)
else
(
if "&MenuMode"=="STD"
(
gosub NormalMenu
)
else
(
print "Invalid menu mode &MenuMode selected"
enddo
)
)
)
enddo
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;
; SUBROUTINES
;
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
;=====================================================
; --- Function to Program DMSS Image
;=====================================================
CodeImage:
; set up addresses used with FLASH.* commands
&RomBegin=&JnandCodeRomBegin
&RomEnd=&JnandCodeRomEnd
gosub CreateRom
;--------------------------------------------------------
; Initialize the JNAND program - must succeed
; will probe flash and set up first block for writing
; 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 "Probing flash and validating boot info blocks"
)
&Command="Flash Initialize for Code Image Programming"
data.set &ParmCmd %LONG &InitCmd
data.set &ParmAddr %LONG 0x8000
r.s pc &StartAddr
go
gosub check_status ;; will not return if error
&ElfImage="&ELFdir\&ELFname"
gosub DoProgramming
;--------------------------------------------------------
; Verify spans and checksum
;--------------------------------------------------------
;
;if "&Verbose"=="yes"
;(
; print "Verifying flash image with spans from boot info block"
; )
; &Command="Flash Verify"
; data.set &ParmCmd %LONG &VerifyCmd
; r.s pc &StartAddr
; go
; gosub check_status ;; will not return if error
; gosub CleanUp
; if "&Verbose"=="yes"
; (
;; print "Flash is programmed and verified"
; )
;return
;=====================================================
; --- Function to Program Boot Block
;=====================================================
BootOnly:
; set up addresses used with FLASH.* commands
&RomBegin=&JnandBootRomBegin
&RomEnd=&JnandBootRomEnd
gosub CreateRom
;--------------------------------------------------------
; Initialize the JNAND program - must succeed
; will probe flash and set up first block for writing
; 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 "Probing flash and validating boot info blocks"
)
&Command="Flash Initialize for Boot Block Programming"
data.set &ParmCmd %LONG &InitBootCmd
r.s pc &StartAddr
go
gosub check_status ;; will not return if error
&ElfImage=".\boot_loader.elf"
gosub DoProgramming
;--------------------------------------------------------
; Verify spans and checksum
;--------------------------------------------------------
;
if "&Verbose"=="yes"
(
print "Verifying flash image in boot block"
)
&Command="Flash Verify"
data.set &ParmCmd %LONG &VerifyCmd
r.s pc &StartAddr
go
gosub check_status ;; will not return if error
gosub CleanUp
if "&Verbose"=="yes"
(
print "Flash Boot Block is programmed"
)
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 report statistics
;=====================================================
report_stats:
if "&Verbose"=="no"
(
return
)
print " Statistics Report:"
&ReportInt=data.long(A:&ReportBytesGap)
print " Gaps due to gaps in image &ReportInt"
&ReportInt=data.long(A:&ReportBlocksGap)
print " Gaps due to bad blocks &ReportInt"
&ReportInt=data.long(A:&ReportImageSize)
print " Total size of code image &ReportInt"
return
;=====================================================
; --- Function to Program flash part but not verify
;=====================================================
DoProgramming:
;--------------------------------------------------------
; Call erase function. Will only erase blocks 1 and 2
; where we will put the boot info block. If either of
; these fail, then the flash is unusable and we bail out
; The parameters passed are ignored but to satisfy the JTAG
; ICD, they must match the flash.create command above
;--------------------------------------------------------
;
if "&Verbose"=="yes"
(
print "Erasing Flash Boot Info Blocks"
)
&Command="Flash Erase Boot Info Blocks"
flash.erase &RomBegin--&RomEnd
gosub check_status ;; will not return if error
;--------------------------------------------------------
; put into program mode
;--------------------------------------------------------
flash.program all
;--------------------------------------------------------
; actual flash programming happens here
;--------------------------------------------------------
&Command="Flash Program"
; print "Select file to program in browser: "
d.load.elf &ElfImage &SymbolArg
gosub check_status ;; will not return if error
;--------------------------------------------------------
; OK we're finished, turn off programming mode.
; If we do not turn it off, any data writes within
; the address range of the defined ROM will be taken
; as flash programming commands and this will cause
; failures if the code size overlaps the parameter
; block address.
;--------------------------------------------------------
flash.program off
;--------------------------------------------------------
; Finalize the JNAND program - must succeed
; writes out the last code block and any boot info blocks
; 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 "Finalizing flash programming"
)
&Command="Flash Finalize"
data.set &ParmCmd %LONG &FinishCmd
r.s pc &StartAddr
go
gosub check_status ;; will not return if error
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -