; -------------------------------------------------------------------------------- ; @Title: LS1012A Quad SPI FLASH Program script ; @Description: ; The S25FS512S (Spansion) is on the QuadSPI controller ; ; SRAM: 0x10000000 ; QuadSPI(controller) Base: 0x1550000 ; FLASH BASE ADDRESS(Qspi mapped): 0x40000000 ; ; Prerequisites: ; * Connect Debug Cable/Combiprobe to J9 ; ; @Author: jjeong ; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only ; @Board: FRDM-LS1012A ; @Chip: LS1012A ; @Keywords: S25FS512S Flash SPI QuadSPI ; -------------------------------------------------------------------------------- ; $Id: ls1012-qspi-rcwovr.cmm 11733 2023-01-16 08:55:12Z bschroefel $ PRIVATE &arg1 ENTRY &arg1 &arg1=STRing.UPpeR("&arg1") // for example "PREPAREONLY" &QSPI_BASE=0x1550000 RESet SYStem.RESet SYStem.CPU LS1012A SYStem.MemAccess DAP SYStem.Option MemStatusCheck ON SYStem.Option HRCWOVerRide OFF SYStem.Option TRST OFF SYStem.Option EnReset ON 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 EnReset OFF SYStem.Option HRCWOVerRide ON /PORESET SYStem.Mode.Prepare ; override RCW_SRC = Hardcoded Data.Set EDBG:0x42000040 %Long 0x9a ; override the RCW itself - values as from LS1012 hardcoded+qspi settings Data.Set EDBG:0x42000000 %Long 0x08000008 Data.Set EDBG:0x42000004 %Long 0x00000000 Data.Set EDBG:0x42000008 %Long 0x00000000 Data.Set EDBG:0x4200000c %Long 0x00000000 Data.Set EDBG:0x42000010 %Long 0x00000000 Data.Set EDBG:0x42000014 %Long 0xC0000008 ;Data.Set EDBG:0x42000018 %Long 0x40000000 ; PBL=QSPI, IFC=0x0 Data.Set EDBG:0x42000018 %Long 0xfb800000 ; PBL_SRC=reserved, IFC=0x0 Data.Set EDBG:0x4200001C %Long 0x01003800 Data.Set EDBG:0x42000020 %Long 0x00800000 Data.Set EDBG:0x42000024 %Long 0x00000000 Data.Set EDBG:0x42000028 %Long 0x00000000 Data.Set EDBG:0x4200002C %Long 0x00000000 Data.Set EDBG:0x42000030 %Long 0x00000000 Data.Set EDBG:0x42000034 %Long 0x00000180 Data.Set EDBG:0x42000038 %Long 0x00000096 Data.Set EDBG:0x4200003C %Long 0x00000000 ; SYStem.Up ; we should now have access to the QSPI & SD card pins ;-) Data.Assemble 0x10000000 b $-0x0 Register.Set PC 0x10000000 MAP.BE &QSPI_BASE++0xFFFF Data.Set AD:&QSPI_BASE %BE %Long 0xF0000 ; QSPI_MCR[END_CFG], 64BE GOSUB READ_ID_TEST 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 "&arg1"=="PREPAREONLY" ENDDO ; ------------------------------------------------------------------------------- ; 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 )