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

200 lines
6.2 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: Serial flash script for TCC8030-CA7 on TCC803x EVB (RAM)
; @Description:
; MX25L256 is connected to the SFMC controller
;
; SRAM: 0xC0001000
; SFMC: 0x1B9100000
; SFMC memory mapped ADDRESS: 0xD0000000
;
; Prerequisites:
; * Power-on-reset is required after debugging the CA53 or CM4
; * 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-A7, SPI
; @Author: PEG, JIM
; @Board: TCC803x EVB
; @Chip: TCC8030
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: tcc8030-ca7-spi.cmm 11733 2023-01-16 08:55:12Z bschroefel $
PRIVATE &parameters
ENTRY %LINE &parameters
PRIVATE &param_prepareonly
&parameters=STRing.UPpeR("&parameters")
&param_prepareonly=(STRing.SCAN("&parameters","PREPAREONLY",0)!=-1)
&SFMC_BASE=0x1B910000 ;SFMC Controller base address
WinCLEAR
; --------------------------------------------------------------------------------
; initialize and start the debugger
RESet
SYStem.CPU TCC8030-CA7
SYStem.Option EnReset OFF
SYStem.MemAccess DAP
Trace.DISable
GOSUB ConfigureDebugPortAndMore
SYStem.Up
Data.Set C15:0x1 %Long Data.Long(C15:0x1)&~1 ; disable MPU
; ------------------------------------------------------------------------------
; 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 &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 * 0xD0000000
FLASH.ReProgram.off
PRINT "Please power-cycle the board after flash program is complete"
)
ENDDO
ConfigureDebugPortAndMore:
(
; --------------------------------------------------------------------------------
; activate CA7 and configure debug port for CA7
; works if it was configured for debugging CR5 (default after power-on-reset) or CA7
; power-on-reset is required after debugging the CA53 or CM4
SYStem.CONFIG AHBACCESSPORT 2
SYStem.MODE Prepare
IF Data.Long(EAHB:0x80)==0x31C03DB9 ; check if TCC8050-CR5 is selected
(
SYStem.Down
SYStem.CPU TCC8030-CR5
SYStem.Mode Up
; disable CR5 watchdog
Data.Set SD:0x1b934014 %Long 0x8030ace5 ; WDT_WR_PW (MICOM)
Data.Set SD:0x1b934000 %Long 0x00000000 ; WDT_EN (MICOM)
; patch an endless loop at reset vector of CA7
Data.Assemble SR:0xf1000000 b 0xf1000000
; release CA7 core reset
Data.Set SD:0x17000004 %Long Data.Long(SD:0x17000004)|0x20000 ; SWRESETN
; configure debug port for CA7
SYStem.CONFIG AHBACCESSPORT 2
ON ERROR CONTinue ; ignore error because communication will break down
Data.Set EAHB:0x4 %Long 0x1 ; DEBUG_SEL, configure JTAG interface for TCC8030-CA7
SYStem.MODE Down ; communication will break down on the command before
ON ERROR DEFault ; normal error handling
SYStem.Down
SYStem.CPU TCC8030-CA7
RETURN
)
ELSE
(
IF Data.Long(EAHB:0x0)!=0 ; check if TCC8030-CM4 is not selected
(
SYStem.CONFIG AHBACCESSPORT 0
RETURN
)
ELSE
(
PRINT "Power-on-reset is required, then re-run this script!"
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
)