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

184 lines
6.0 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: NXP QorIQ LS1046A RDB QSPI FLASH Programming Script (RCW Override)
; @Description:
; Script to program S25FS512S (Cypress) attached to CS#0 of a LS1046A from NXP.
;
; Internal SRAM: 0x10000000
; QuadSPI(controller) Base: 0x1550000
; FLASH BASE ADDRESS(Qspi mapped): 0x40000000
;
; Prerequisites:
; * Connect Debug Cable/Combiprobe to J22
; * Set SW5[1..8]+SW4[1]==RCW-SRC to
; QSPI 0y001000100
; * Set SW3[3..5]==QSPI_MAP to select the QSPI bank
; e.g. 0y000
;
; @Author: jjeong
; @Chip: LS1046A
; @Board: LS1046A-RDB
; @Keywords: S25FS512S Flash SPI QuadSPI
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: ls1046-spi-rcwovr.cmm 11733 2023-01-16 08:55:12Z bschroefel $
LOCAL &parameters &QSPI_BASE &param_prepareonly
ENTRY %LINE &parameters
&param_prepareonly=(STRing.SCAN(STRing.UPpeR("&parameters"),"PREPAREONLY",0)!=-1)
&QSPI_BASE=0x1550000
RESet
SYStem.RESet
SYStem.CPU LS1046A
SYStem.MemAccess DAP
SYStem.Option MemStatusCheck ON
SYStem.Option TRST OFF
CORE.ASSIGN 1. ; select only master core
Trace.DISable
SYStem.JtagClock CTCK 10MHz
; -------------------------------------------------------------------------------
; <temporarily override the RCW>
; The RCW is fetched while the boot phase and defines initial
; pinmux/serdes/qspi/nor/nand/... configurations.
; The RCW override requires to reset the SoC. Two methods are supported.
; Method 1: EnReset OFF && HRCWOVerRide ON /PORESET - do not assert the nReset line, issue a JTAG based PORESET
; Method 2: EnReset ON && HRCWOVerRide ON - assert the nReset line
; Steps - Override RCW_SRC only
; * set EnReset & HRCWOVerRide - Method 1/2
; * switch to SYStem.Mode Prepare
; * write the RCW_SRC value to EDBG:0x42000040
; * switch to SYStem.Up
; Steps - Override RCW completely
; * set EnReset & HRCWOVerRide - Method 1/2
; * switch to SYStem.Mode Prepare
; * write the RCW_SRC value HARDCODED to EDBG:0x42000040
; * write the RCW itself to EDBG:0x42000000 onwards
; * ensure in RCW[6]/EDBG:0x42000018 the PBL_SRC is reserved e.g. 0xfb8?????
; * switch to SYStem.Up
; The following RCW is used to connect to the device even with a empty flash.
; The pinmux is configured to map the QSPI pins.
SYStem.Option HRCWOVerRide ON
SYStem.Mode.Prepare
; Override RCW_SRC = Hardcoded
Data.Set EDBG:0x42000040 %Long 0x9e
; Override the RCW itself - values as from LS1046A default image
Data.Set EDBG:0x42000000 %Long 0x0c150010
Data.Set EDBG:0x42000004 %Long 0x0E000000
Data.Set EDBG:0x42000008 %Long 0x00000000
Data.Set EDBG:0x4200000c %Long 0x00000000
Data.Set EDBG:0x42000010 %Long 0x11335559
Data.Set EDBG:0x42000014 %Long 0x40005012
; Data.Set EDBG:0x42000018 %Long 0x40025000 ; PBL=?, IFC=0x25 (QSPI)
Data.Set EDBG:0x42000018 %Long 0xfb825000 ; PBL_SRC=reserved, IFC=0x25
Data.Set EDBG:0x4200001C %Long 0xC1000000
Data.Set EDBG:0x42000020 %Long 0x00000000
Data.Set EDBG:0x42000024 %Long 0x00000000
Data.Set EDBG:0x42000028 %Long 0x00000000
Data.Set EDBG:0x4200002C %Long 0x00238800
Data.Set EDBG:0x42000030 %Long 0x20124000
Data.Set EDBG:0x42000034 %Long 0x00003101
Data.Set EDBG:0x42000038 %Long 0x00000096
Data.Set EDBG:0x4200003C %Long 0x00000001
; </temporarily override the RCW>
MAP.BE &QSPI_BASE++0xFFFF
SYStem.Up
Data.Assemble 0x10000000 b $-0x0
Register.Set PC 0x10000000
Data.Set AD:0x1550000 %BE %Long 0xF0000 ; QSPI_MCR[END_CFG], 64BE
GOSUB READ_ID_TEST "&QSPI_BASE"
; QSPI AHB(A:0x40000000) read configuration
; 3byte read at 0x40000000
//Data.Set AD:0x1550310 %BE %Long (0x08180400|0x3)
; 4byte read at 0x40000000
Data.Set AD:0x1550310 %BE %Long (0x08200400|0x13)
Data.Set AD:0x1550314 %BE %Long 0x24001C08
; Flash declaration
(
PRIVATE &pdd
&pdd=OS.PresentDemoDirectory()
FLASH.RESet
; if CRV3[3]==1, for S25FS512S - create the uniform sector layout
FLASH.Create 0x40000000++0x01ffffff 0x40000 TARGET Byte
; if CRV3[3]==0, for S25FS512S - create the non-uniform sector layout
;FLASH.Create 0x40000000--0x40007FFF 0x01000 TARGET Byte
;FLASH.Create 0x40008000--0x4003FFFF 0x38000 TARGET Byte
;FLASH.Create 0x40040000--0x43FFFFFF 0x40000 TARGET Byte
FLASH.TARGET 0x10000000 0x10002000 0x1000 &pdd/flash/byte/snor_ls1000.bin
)
; Flash script ends here if called with parameter PREPAREONLY
IF &param_prepareonly
ENDDO PREPAREDONE
; -------------------------------------------------------------------------------
; Flash programming example
; -------------------------------------------------------------------------------
(
PRIVATE &progflash
DIALOG.YESNO "Program flash memory?"
ENTRY &progflash
IF &progflash
(
FLASH.ReProgram.ALL
Data.LOAD.auto *
;Data.LOAD.Binary * 0x40000000
FLASH.ReProgram.off
)
)
ENDDO
; --------------------------------------------------------------------------------
; Subroutines
READ_ID_TEST:
(
PRIVATE &QSPI_BASE &temp
PARAMETERS &QSPI_BASE
PRINT "READ_ID_TEST..."
&temp=Data.Long(AD:&QSPI_BASE)
Data.Set AD:&QSPI_BASE %Long %BE (&temp|0x0c00) ; Clear Tx/Rx buffer
Data.Set AD:(&QSPI_BASE+0x300) %Long %BE 0x5AF05AF0 ; LUTKEY
Data.Set AD:(&QSPI_BASE+0x304) %Long %BE 0x2 ; LCKCR
//SEQID 5
Data.Set AD:(&QSPI_BASE+0x360) %Long %BE 0x1c04049f ; LUT0, SEQID0
Data.Set AD:(&QSPI_BASE+0x364) %Long %BE 0x0
Data.Set AD:(&QSPI_BASE+0x368) %Long %BE 0x0
Data.Set AD:(&QSPI_BASE+0x36C) %Long %BE 0x0
Data.Set AD:(&QSPI_BASE+0x100) %Long %BE 0x40000000 ; SFAR , FLASH BASE ADDRESS
// assert Read id command
Data.Set AD:(&QSPI_BASE+0x008) %Long %BE (5.<<24.) ; (5.<<24.)
WAIT 100.ms
&temp=Data.Long(AD:&QSPI_BASE)
Data.Set AD:&QSPI_BASE %Long %BE (&temp|0x0800) //clear Tx buffer
PRINT "1st 0x" Data.Long(AD:&QSPI_BASE+0x200)>>24. " (Manufacturer)"
PRINT "2nd 0x" (Data.Long(AD:&QSPI_BASE+0x200)>>16.)&0xFF " (Device ID)"
PRINT "3rd 0x" (Data.Long(AD:&QSPI_BASE+0x200)>>8.)&0xFF
PRINT "4th 0x" Data.Long(AD:&QSPI_BASE+0x200)&0xFF
RETURN
)