; -------------------------------------------------------------------------------- ; @Title: SPI FLASH Program script for STA8100GA on Teseo-V EVB (RAM) ; @Description: ; The MX25L3233 (MACRONIX) is connected to the SFC/SQIO controller ; ; SRAM: 0x20001000 (TCM 64KB) ; SQIO(controller) Base: 0xD0000000 ; SQIO memory mapped ADDRESS: 0x10000000 ; ; GPIO[22:29] - SFC_SIO[0:7] ; GPIO61 - SFC_CSN ; GPIO62 - SFC_CLK ; GPIO63 - SFC_DQS ; ; Prerequisites: ; * Connect Debug Cable to J506 using Adapter LA-3770 ; or ; Connect Combiprobe/uTrace to J506 ; * If necessary, move resistor R550 to R551 to preplace teh pull-down on ; nTRST by an pull-down. ; * If necessary to have a reset signal connected to the debug header ; instead of nTRST: ; - Remove jumper from J702. ; - Set a wire from J702 pin 2 to CN800 pin 1 ; - Set a wire from J702 pin 3 to CN800 pin 5 ; ; @Keywords: ARM, Cortex-M7, SPI, SQI ; @Author: STK, JIM ; @Board: Teseo-V EVB ; @Chip: STA8100GA ; @Copyright: (C) 1989-2023 Lauterbach GmbH, licensed for use with TRACE32(R) only ; -------------------------------------------------------------------------------- ; $Id: teseov-spi.cmm 12264 2023-06-29 08:45:56Z jjeong $ &SQI_BASE=0xD0000000 PRIVATE ¶meters ENTRY %LINE ¶meters PRIVATE ¶m_prepareonly ¶m_cpu ¶m_dualport ¶m_prepareonly=(STRing.SCAN(STRing.UPpeR("¶meters"),"PREPAREONLY",0)!=-1) ¶m_cpu=STRing.SCANAndExtract(STRing.UPpeR("¶meters"),"CPU=","") ¶m_dualport=STRing.SCANAndExtract(STRing.UPpeR("¶meters"),"DUALPORT=","0") ; -------------------------------------------------------------------------------- ; initialize and start the debugger RESet SYStem.CPU STA8100GA IF hardware.COMBIPROBE()||hardware.UTRACE() ( SYStem.CONFIG.CONNECTOR MIPI20T ) SYStem.Option.DUALPORT ON SYStem.MemAccess DAP Trace.DISable SYStem.Up ; ------------------------------------------------------------------------------ ; clk enable GOSUB PRCC_CONFIG ; ------------------------------------------------------------------------------ ; pin mux setting (alternative function setting) PER.Set.simple ASD:0x50028020 %Long 0xFFC00000 ; GPIO0_AFSLA GPIO[22:29] PER.Set.simple ASD:0x5000C020 %Long 0x60000000 ; GPIO1_AFSLA, GPIO[61:63] ; ------------------------------------------------------------------------------ ; spi controller setting GOSUB SQI_INIT ; enable memory map mode (ahb: 0x1000_0000) GOSUB READ_ID_TEST ; ------------------------------------------------------------------------------ ; Flash declaration GOSUB FlashDeclaration "¶m_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 ( GOSUB FLASH_UNLOCK FLASH.ReProgram.ALL Data.LOAD.Binary * 0x10000000 ;Data.LOAD.auto * FLASH.ReProgram.off ; Reset device SYStem.Down SYStem.Up ) ENDDO FLASH_UNLOCK: ( ;Read Status Register FLASH.SPI.CMD 2. 0x05 /READ 1. VM:0x0 &SR = Data.Byte(VM:0x0) IF ((&SR)&0x3C)!=0x00 ( FLASH.SPI.CMD 2. 0x06 ;Write enable FLASH.SPI.CMD 2. 0x01 ((&SR)&0xC3) ;Write status with BP bits set to 0 ) FLASH.SPI.CMD 2. 0x05 /READ 1. RETURN ) READ_ID_TEST: ( Data.Set A:&SQI_BASE+0x104 %Long (0x3<<24.)|0x0 ;length 4Bytes read data ®Data=(0x2<<12.)|0x9F ; cmd + cmd_type:cmd->data Data.Set A:&SQI_BASE+0x100 %Long ®Data ;command execute &temp=Data.Long(A:&SQI_BASE+0x108) PRINT "1st 0x" (&temp>>24.)&0xFF " (Manufacturer)" PRINT "2nd 0x" (&temp>>16.)&0xFF " (Device ID)" PRINT "3rd 0x" (&temp>>8.)&0xFF PRINT "4th 0x" (&temp)&0xFF GOSUB SQI_INIT ; enable memory map mode (ahb: 0x5000_0000) RETURN ) SQI_INIT: ( ®Data=(0x03<<16.) ;SPI READ OPCODE for AHB ®Data=®Data|(0x01<<24.); WR_CNF_OPCD ®Data=®Data|(0x0<<12.) ; CMD type <