Files
Gen4_R-Car_Trace32/2_Trunk/demo/arm/flash/omapl138-nand2g08.cmm
2025-10-14 09:52:32 +09:00

114 lines
3.0 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: OMAP-L138 NAND FLASH Programming Script
; @Description:
; NAND FLASH(MT29F2G08) is connected to CS3
;
; Internal SRAM : 0x80000000
; Command Register : 0x62000010
; Address Register : 0x62000008
; Data Register : 0x62000000
;
; @Author: jjeong
; @Chip: OMAP-L138
; @Keywords: MT29F2G08 Flash NAND
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: omapl138-nand2g08.cmm 10516 2022-02-02 11:39:30Z bschroefel $
LOCAL &arg1
ENTRY &arg1
&arg1=STRing.UPpeR("&arg1") // for example "PREPAREONLY"
SYStem.RESet
SYStem.CPU OMAP-L138
SYStem.Option EnReset OFF
SYStem.CONFIG.Slave OFF
SYStem.JtagClock RTCK
SYStem.Mode Up
PER.Set.simple C15:0x1 %Long 0x00052078 ; disable MMU & Cache
GOSUB enable_NAND
; GOSUB DISABLE_NAND_ECC // if NAND needs the internal ecc disable (ex. MICRON MT29F)
GOSUB READ_ID_TEST
FLASHFILE.RESet
//FLASHFILE.config <Cmd_reg> <Addr_reg> <Data_reg>
FLASHFILE.CONFIG 0x62000010 0x62000008 0x62000000
//FLASHFILE.target <Code_range> <Data_range> <Algorithm file>
FLASHFILE.TARGET 0x80000000++0x1FFF 0x80002000++0x1FFF ~~/demo/arm/flash/byte/nand2g08.bin /KEEP
FLASHFILE.GETID ; Read FLASH Manufacture and Device ID
//End of the test prepareonly
IF "&arg1"=="PREPAREONLY"
ENDDO
//FLASHFILE.ERASE 0x0--0xFFFFF ; Erase the flash 0x0--0xFFFFF
//FLASHFILE.LOAD * 0x0 ; Write a file to the flash
//FLASHFILE.LOAD * 0x0 /ComPare ; Verify
FLASHFILE.DUMP 0x0 ; Read out from the flash
ENDDO
enable_NAND:
(
// Enable Function for PSC0
Data.Set SD:0x1C10A0C %LE %Long 0x3 ;PSC0_MDCTL
Data.Set SD:0x1C10120 %LE %Long 0x1 ;PSC0_PTCMD
WAIT 1.ms
Data.Set SD:0x1C1413C %LE %Long 0x10110010 ; PINMUX7
Data.Set SD:0x1C14144 %LE %Long 0x11111111 ; PINMUX9
Data.Set SD:0x1C14150 %LE %Long 0x01100000 ; PINMUX12
Data.Set SD:0x68000010 %LE %Long 0x3FFFFFFC ; EMIF25_ACFG2
Data.Set SD:0x68000060 %LE %Long 0x12 ; EMIF25_NANDFCR
RETURN
)
READ_ID_TEST:
(
&NAND_BASE=0x62000000
&NAND_ALE =0x62000008
&NAND_CLE =0x62000010
Data.Set &NAND_CLE %Byte 0x90 ;command reg
WAIT 100.ms
Data.Set &NAND_ALE %Byte 0x00 ; addr reg
WAIT 100.ms
PRINT "read 1st : 0x" Data.Byte(A:&NAND_BASE) " (Manufacture ID)"
PRINT "read 2nd : 0x" Data.Byte(A:&NAND_BASE) " (Device ID)"
PRINT "read 3rd : 0x" Data.Byte(A:&NAND_BASE)
PRINT "read 4th : 0x" Data.Byte(A:&NAND_BASE)
PRINT "read 5th : 0x" Data.Byte(A:&NAND_BASE)
PRINT "read 6th : 0x" Data.Byte(A:&NAND_BASE)
GOSUB enable_NAND
RETURN
)
DISABLE_NAND_ECC:
(
Data.Set &NAND_CLE %Byte 0xEF ;command reg
WAIT 100.ms
Data.Set &NAND_ALE %Byte 0x90 ; addr reg
WAIT 100.ms
Data.Set &NAND_BASE %Byte 0x00 ; data reg, enable ecc 0x08
Data.Set &NAND_BASE %Byte 0x00 ; data reg
Data.Set &NAND_BASE %Byte 0x00 ; data reg
Data.Set &NAND_BASE %Byte 0x00 ; data reg
RETURN
)