; -------------------------------------------------------------------------------- ; @Title: RZ/G2L board SPI FLASH Program script ; @Description: ; SPI FLASH Program script by the core (Cortex-A55) for the RZ/G2L EVB ; The AT25QL128 is on the SPI Multi I/O Bus controller ; ; Prerequisites: ; ; SRAM: 0x00020000 ; SPI Multi I/O Bus(controller) Base: 0x10060000 ; SPI Flash Mapped Address: 0x20000000 ; ; @Author: JIM ; @Chip: R9A07G044L ; @Copyright: (C) 1989-2023 Lauterbach GmbH, licensed for use with TRACE32(R) only ; -------------------------------------------------------------------------------- ; $Id: rzg2l-ca55-spi.cmm 12812 2023-12-06 01:15:18Z jjeong $ PRIVATE ¶meters ENTRY %LINE ¶meters PRIVATE ¶m_prepareonly ¶meters=STRing.UPpeR("¶meters") ¶m_prepareonly=(STRing.SCAN("¶meters","PREPAREONLY",0)!=-1) LOCAL &pdd &pdd=OS.PresentDemoDirectory() &QSPI_BASE=0x10060000 ; -------------------------------------------------------------------------------- ; Initialize and start the debugger RESet SYStem.RESet SYStem.CPU R9A07G044L SYStem.JtagClock 10MHz SYStem.Option.ResBreak OFF SYStem.MemAccess DAP CORE.ASSIGN 1. SYStem.Mode.Up Register.Set I 0 Register.Set M 0x5 ;EL1h Data.Set A:&QSPI_BASE %LE %Long 0x01fff300 ;enable RPC AHB read Data.Set A:&QSPI_BASE+0x010 %LE %Long (0x03<<16.) ;DRCMR, read 3byte address mode command Data.Set A:&QSPI_BASE+0x01C %LE %Long 0x4700 ;DRENR, 24bit address mode, (24bit==0x4700) Data.Set A:&QSPI_BASE+0x014 %LE %Long 0x0 ;DREAR, 24bit Extended External Address Valid Range, A[24:0] enabled ;Data.Set A:&QSPI_BASE+0x07C %LE %Long 0x80000260 ;PHYCNT ; ------------------------------------------------------------------------------ ; Flash Read ID Test AREA.CLEAR AREA.view GOSUB READ_ID_TEST ; ------------------------------------------------------------------------------ ; Init SRAM (16KB) for the flash algorithm Data.Set ENAXI:0x20000++0xFFFF % Long 0x0 LOCAL &pdd &pdd=OS.PresentDemoDirectory() ; ------------------------------------------------------------------------------ ; Flash declaration Break.RESet FLASH.RESet FLASH.Create 0x20000000++0xFFFFFF 0x010000 TARGET Byte FLASH.TARGET 0x20000 EAXI:0x22000 0x2000 &pdd/flash/byte/snor3b_rzg2l.bin /DUALPORT ; Flash script ends here if called with parameter PREPAREONLY IF ¶m_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 * 0x20000000 FLASH.ReProgram.off ; Reset device PRINT "Please power-cycle the board after flash program is complete" ) ENDDO READ_ID_TEST: ( &CMNCR=(&QSPI_BASE) &SMCR=(&QSPI_BASE+0x20) ; SMCR_0 , SPI mode control &SMCMR=(&QSPI_BASE+0x24) ; SMCMR_0 , SPI mode command setting register &SMADR=(&QSPI_BASE+0x28) ;address &SMOPR=(&QSPI_BASE+0x2C) ;option data setting &SMENR=(&QSPI_BASE+0x30) ;enable setting &SMRDR=(&QSPI_BASE+0x38) &SMRDR1=(&QSPI_BASE+0x3C) &SMWDR=(&QSPI_BASE+0x40) &SMWDR1=(&QSPI_BASE+0x44) &SMDMCR=(&QSPI_BASE+0x60) ;dummy cycle ®Data=Data.Long(A:&CMNCR) Data.Set A:&CMNCR %Long 0x80000000|®Data ;enable manual mode, disable AHB read Data.Set A:&SMCMR %Long (0x9f<<16.) ;read-id cmd Data.Set A:&SMADR %Long 0x0 ;address 0x0 Data.Set A:&SMOPR %Long 0x0 ;address 0x0 ;Data.Set A:&SMDMCR %l 0x7 ; dummy 8 cycle number &smenr=(0x1<<14.)|0xF; cmd enable, 4byte data read Data.Set A:&SMENR %Long &smenr //start spi transfer &smcr=0x1|(0x2<<1.) ; spie and spire , SPI Read data Data.Set A:&SMWDR %LE %Long 0x00000000 ; write Tx buffer init Data.Set A:&SMCR %Long &smcr &read_data=Data.Long(A:&SMRDR) PRINT "Read 1st: 0x" (&read_data)&0xFF " (Manufacturer) " PRINT "Read 2nd: 0x" (&read_data>>8.)&0xFF " (Device) " PRINT "Read 3rd: 0x" (&read_data>>16.)&0xFF PRINT "Read 4th: 0x" (&read_data>>24.)&0xFF Data.Set A:&CMNCR %Long ®Data ;disable manual mode, enable AHB read RETURN )