; -------------------------------------------------------------------------------- ; @Title: Serial flash script for TCC8030-CA53 on TCC803x EVB (RAM) ; @Description: ; MX25L256 is connected to the SFMC controller ; ; SRAM: 0xC0001000 ; SFMC: 0x1B9100000 ; SFMC memory mapped ADDRESS: 0xD0000000 ; ; Prerequisites: ; * Connect the DC 12V/10A power adapter to the DC-JACK (J7) on main board. ; * Connect Debug Cable to JTAG header (J10D1) on TCC8030 CPU board. ; * Use board with Android SDK firmware and default SNOR boot mode. ; ; @Keywords: ARM, Cortex-A53, SPI ; @Author: PEG, JIM ; @Board: TCC803x EVB ; @Chip: TCC8030 ; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only ; -------------------------------------------------------------------------------- ; $Id: tcc8030-ca53-spi.cmm 11733 2023-01-16 08:55:12Z bschroefel $ PRIVATE ¶meters ENTRY %LINE ¶meters PRIVATE ¶m_prepareonly ¶meters=STRing.UPpeR("¶meters") ¶m_prepareonly=(STRing.SCAN("¶meters","PREPAREONLY",0)!=-1) &SFMC_BASE=0x1B910000 ;SFMC Controller base address WinCLEAR ; -------------------------------------------------------------------------------- ; initialize and start the debugger RESet SYStem.CPU TCC8030-CA53 CORE.ASSIGN 1. SYStem.Option.EnReset OFF SYStem.MemAccess DAP Trace.DISable GOSUB ConfigureDebugPort SYStem.Mode Attach GOSUB DisableWatchdog Break Data.Set SPR:0x30100 %Long Data.Long(SPR:0x30100)&~1 ; disable MMU ; ------------------------------------------------------------------------------ ; Flash Pin Mux Configuration ; ------------------------------------------------------------------------------ ; Flash Controller Init GOSUB SPI_Init ; ------------------------------------------------------------------------------ ; Flash Read ID Test GOSUB READ_ID_TEST ; ------------------------------------------------------------------------------ ; Init SRAM (16KB) for the flash algorithm Data.Test EA:0xC0001000++0x3FFF ; ------------------------------------------------------------------------------ ; Flash declaration Break.RESet FLASH.RESet FLASH.Create 0xD0000000++0x01FFFFFF 0x10000 TARGET Byte FLASH.TARGET 0xC0001000 E:0xC0003000 0x2000 ~~/demo/arm/flash/byte/snor_tcc80xx.bin /STACKSIZE 0x200 /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 * 0xD0000000 FLASH.ReProgram.off PRINT "Please power-cycle the board after flash program is complete" ) ENDDO READ_ID_TEST: ( &offset=Data.Long(A:&SFMC_BASE+0x001C) ;get the manual base address Data.Set A:(&SFMC_BASE+0x0000+&offset)+0x0 %Long 0x8400009F Data.Set A:(&SFMC_BASE+0x0000+&offset)+0x4 %Long 0x20004000|((&offset-0x800+0x10)>>2) Data.Set A:(&SFMC_BASE+0x0000+&offset)+0x8 %Long 0xF4000000 Data.Set SD:0x0:&SFMC_BASE+0x001C %LE %Long &offset // Set Manual Addr Data.Set SD:0x0:&SFMC_BASE+0x0010 %LE %Long 0x00000001 // CMD manual RUN WAIT 100.ms &read_data=Data.Long(A:(&SFMC_BASE+0x0000+&offset+0x10)) PRINT "Read 1st: 0x" (&read_data)&0xFF " (Manufacturer)" PRINT "Read 2nd: 0x" (&read_data>>8.)&0xFF " (Device ID)" PRINT "Read 3rd: 0x" (&read_data>>16.)&0xFF " (Device ID)" PRINT "Read 4th: 0x" (&read_data>>24.)&0xFF RETURN ) SET_SPI_ADDRMODE_3B: ( Data.Set A:&SFMC_BASE+0x0800 %LE %Long 0x840000EB Data.Set A:&SFMC_BASE+0x0804 %LE %Long 0x4A000001 Data.Set A:&SFMC_BASE+0x0808 %LE %Long 0x86000000 Data.Set A:&SFMC_BASE+0x080C %LE %Long 0x46002000 Data.Set A:&SFMC_BASE+0x0810 %LE %Long 0x2A000000 Data.Set A:&SFMC_BASE+0x0814 %LE %Long 0xF4000000 RETURN ) SET_SPI_ADDRMODE_4B: ( //4Byte read Data.Set A:&SFMC_BASE+0x0800 %LE %Long 0x840000EC ; 4Byte read cmd Data.Set A:&SFMC_BASE+0x0804 %LE %Long 0x4a000000 ; write AHB address to Serial NOR (4bytea address) Data.Set A:&SFMC_BASE+0x0808 %LE %Long 0x46003000 ; dummy cycles (3*8)/4qpi == 6 cycles Data.Set A:&SFMC_BASE+0x080C %LE %Long 0x2A000000 ; read out ahb quad Data.Set A:&SFMC_BASE+0x0810 %LE %Long 0xF4000000 ; stop RETURN ) SPI_Init: ( Data.Set SD:&SFMC_BASE+0x001C %LE %Long 0x00000880 ;Manual Base define A:&SFMC_BASE+0x0880 Data.Set SD:&SFMC_BASE+0x0024 %LE %Long 0x00000011 ;Serial Mode 0 Data.Set SD:&SFMC_BASE+0x0028 %LE %Long 0x00140300 Data.Set SD:&SFMC_BASE+0x002C %LE %Long 0x00000500 Data.Set SD:&SFMC_BASE+0x0030 %LE %Long 0xC ;GOSUB SET_SPI_ADDRMODE_3B GOSUB SET_SPI_ADDRMODE_4B RETURN ) ConfigureDebugPort: ( ; configure debug port for TCC8030-CA53 ; not needed if it was configured for debugging CA7 ; works if it was configured for debugging CR5 (default after power-on-reset) ; power-on-reset is required after debugging the CM4 SYStem.CONFIG.AHBACCESSPORT 2 SYStem.Mode Prepare IF Data.Long(EAHB:0x80)==0x31C03DB9 ; check if TCC8030-CR5 is selected ( ON ERROR CONTinue ; ignore error because communication will break down Data.Set EAHB:0x4 %Long 0x1 ; DEBUG_SEL, configure JTAG interface for TCC8030-CA53 SYStem.Mode Down ; communication will break down on the command before ON ERROR DEFault ; normal error handling ) SYStem.Mode Prepare IF Data.Long(EAHB:0x0)==0 ; check if TCC8030-CA53 is not selected ( PRINT "Power-on-reset is required, then re-run this script!" ENDDO ) SYStem.CONFIG.AHBACCESSPORT 0 RETURN ) DisableWatchdog: ( ; disable the Watchdog Data.Set EAHB:0x1b934014 %Long 0x8030ace5 ; WDT_WR_PW (MICOM) Data.Set EAHB:0x1b934000 %Long 0x00000000 ; WDT_EN (MICOM) RETURN )