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

172 lines
5.4 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: Freescale QorIQ LS1043A QSPI FLASH Programming Script
; @Description:
; Example script to program a S25FS512S (Cypress) attached to CS#0 of a LS1043A
; from NXP.
;
; Internal SRAM: 0x10000000
; QuadSPI(controller) Base: 0x1550000
; FLASH BASE ADDRESS(Qspi mapped): 0x40000000
;
; Prerequisites
; * Connect Debug Cable/Combiprobe is connected
; * Set RCW-SRC to QSPI 0y001000100
;
; @Author: AME
; @Chip: LS1043A
; @Board: -
; @Keywords: S25FS512S Flash SPI QuadSPI
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: ls1043-spi-rcwovr.cmm 11733 2023-01-16 08:55:12Z bschroefel $
LOCAL &parameters
ENTRY %LINE &parameters
LOCAL &param_prepareonly
&param_prepareonly=(STRing.SCAN(STRing.UPpeR("&parameters"),"PREPAREONLY",0)!=-1)
&QSPI_BASE=0x1550000
RESet
SYStem.RESet
SYStem.CPU LS1043A
SYStem.MemAccess DAP
SYStem.Option MemStatusCheck ON
SYStem.Option HRCWOVerRide OFF
SYStem.Option TRST OFF
SYStem.Option EnReset ON
CORE.ASSIGN 1. ; select only master core
Trace.DISable
SYStem.JtagClock CTCK 10MHz
; <temporarily override the RCW>
; 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 EnReset OFF
SYStem.Option HRCWOVerRide ON /PORESET
SYStem.Mode.Prepare
; override RCW_SRC = Hardcoded
Data.Set EDBG:0x42000040 %Long 0x9e
; override the RCW itself - values as in hardcoded + patch
Data.Set EDBG:0x42000000 %Long 0x080D0012
Data.Set EDBG:0x42000004 %Long 0x0F000000
Data.Set EDBG:0x42000008 %Long 0x00000000
Data.Set EDBG:0x4200000C %Long 0x00000000
Data.Set EDBG:0x42000010 %Long 0x14550002
Data.Set EDBG:0x42000014 %Long 0x80004012
Data.Set EDBG:0x42000018 %Long 0xFB804000 ; PBL_SRC=reserved, IFC=0x04
Data.Set EDBG:0x4200001c %Long 0xC1002000
Data.Set EDBG:0x42000020 %Long 0x00000000
Data.Set EDBG:0x42000024 %Long 0x00000000
Data.Set EDBG:0x42000028 %Long 0x00000000
Data.Set EDBG:0x4200002C %Long 0x00000000
Data.Set EDBG:0x42000030 %Long 0x20120000
Data.Set EDBG:0x42000034 %Long 0x24667982
Data.Set EDBG:0x42000038 %Long 0x00000064
Data.Set EDBG:0x4200003c %Long 0x00000001
; </temporarily override the RCW>
SYStem.Up
Data.Assemble 0x10000000 b $-0x0
Register.Set PC 0x10000000
MAP.BE &QSPI_BASE++0xFFFF
Data.Set AD:0x1550000 %BE %Long 0xF0000 ; QSPI_MCR[END_CFG], 64BE
GOSUB READ_ID_TEST
//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
LOCAL &pdd
&pdd=OS.PresentDemoDirectory()
FLASH.RESet
FLASH.Create 0x40000000++0x01ffffff 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
; -------------------------------------------------------------------------------
DIALOG.YESNO "Program flash memory?"
LOCAL &progflash
ENTRY &progflash
IF &progflash
(
FLASH.ReProgram.ALL
Data.LOAD.auto *
;Data.LOAD.Binary * 0x40000000
FLASH.ReProgram.off
)
ENDDO
; --------------------------------------------------------------------------------
READ_ID_TEST:
(
PRINT "READ_ID_TEST..."
&temp=Data.Long(A:&QSPI_BASE)
Data.Set A:&QSPI_BASE %Long %BE (&temp|0x0c00) //clear Tx/Rx buffer
Data.Set A:(&QSPI_BASE+0x300) %Long %BE 0x5AF05AF0 ; LUTKEY
Data.Set A:(&QSPI_BASE+0x304) %Long %BE 0x2 ; LCKCR
//SEQID 5
Data.Set A:(&QSPI_BASE+0x360) %Long %BE 0x1c04049f ; LUT0, SEQID0
Data.Set A:(&QSPI_BASE+0x364) %Long %BE 0x0
Data.Set A:(&QSPI_BASE+0x368) %Long %BE 0x0
Data.Set A:(&QSPI_BASE+0x36C) %Long %BE 0x0
Data.Set A:(&QSPI_BASE+0x100) %Long %BE 0x40000000 ; SFAR , FLASH BASE ADDRESS
// assert Read id command
Data.Set A:(&QSPI_BASE+0x008) %Long %BE (5.<<24.) ; (5.<<24.)
WAIT 100.ms
&temp=Data.Long(A:&QSPI_BASE)
Data.Set ZSD:&QSPI_BASE %Long %BE (&temp|0x0800) //clear Tx buffer
PRINT "1st 0x" Data.Long(A:&QSPI_BASE+0x200)>>24. " (Manufacturer)"
PRINT "2nd 0x" (Data.Long(A:&QSPI_BASE+0x200)>>16.)&0xFF " (Device ID)"
PRINT "3rd 0x" (Data.Long(A:&QSPI_BASE+0x200)>>8.)&0xFF
PRINT "4th 0x" Data.Long(A:&QSPI_BASE+0x200)&0xFF
RETURN
)