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

175 lines
5.4 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: Serial flash script for TCC7045-CR5 on TCC7022_25_35_45_MCU (RAM)
; @Description:
; MX25L64 is connected to the SFMC controller
;
; SRAM: 0x000000
; SFMC: 0xA0F00000
; SFMC memory mapped ADDRESS: 0x40000000
;
; Prerequisites:
; * Connect Debug Cable to JH10 "JTAG".
; * Connect the DC 12V/1A power adapter to J1 "12V".
; * Use board with VCP ROM image (tested with MCU BSP v0.9.0).
; * Set SW20 "Boot mode" to "normal".
; @Keywords: ARM, Cortex-R5
; @Props: Confidential
; @Author: PEG,JIM
; @Board: TCC7022_25_35_45_MCU
; @Chip: TCC7045
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: tcc70xx-cr5-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=0xA0F00000 ;SFMC Controller base address
WinCLEAR
; --------------------------------------------------------------------------------
; initialize and start the debugger
RESet
SYStem.CPU TCC7045-CR5
SYStem.MemAccess DAP
GOSUB ConfigureDebugPort
SYStem.Up
; --------------------------------------------------------------------------------
; Boot code seems to activate a peripheral interrupt; disabled for the demo
SYStem.Option INTDIS ON
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 A:0x0001000++0x3FFF
; ------------------------------------------------------------------------------
; Flash declaration
Break.RESet
FLASH.RESet
FLASH.Create 0x40000000++0x07FFFFF 0x10000 TARGET Byte
FLASH.TARGET 0x0001000 0x0003000 0x2000 ~~/demo/arm/flash/byte/snor_tcc70xx.bin /STACKSIZE 0x200
; 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 * 0x40000000
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 Mode Start Address, ex A:&SFMC_BASE+0x0880
Data.Set SD:&SFMC_BASE+0x0020 %LE %Long 0x00000800 ;Auto Mode Start Address
Data.Set SD:&SFMC_BASE+0x0024 %LE %Long 0x00000015 ;Serial Mode x
Data.Set SD:&SFMC_BASE+0x0028 %LE %Long 0x00042300
Data.Set SD:&SFMC_BASE+0x002C %LE %Long 0x00000500
Data.Set SD:&SFMC_BASE+0x0030 %LE %Long 0xC
//READ 1-1-1 (default)
Data.Set SD:&SFMC_BASE+0x0800 %LE %Long 0x84000003
Data.Set SD:&SFMC_BASE+0x0804 %LE %Long 0x48000001
Data.Set SD:&SFMC_BASE+0x0808 %LE %Long 0x28000000
Data.Set SD:&SFMC_BASE+0x080C %LE %Long 0xF4000000
Data.Set SD:&SFMC_BASE+0x0810 %LE %Long 0xF4000000
//READ 1-4-4 (QuadIO)
;GOSUB SET_SPI_ADDRMODE_3B
;GOSUB SET_SPI_ADDRMODE_4B
RETURN
)
ConfigureDebugPort:
(
; power-on-reset is required after debugging the CM0
SYStem.CONFIG AHBACCESSPORT 2
SYStem.MODE Prepare
IF Data.Long(EAHB:0x80)!=0x31C03DB9 ; check if TCC8050-CR5 is not selected
(
PRINT "Power-on-reset is required, then re-run this script!"
ENDDO
)
SYStem.CONFIG AHBACCESSPORT 0
RETURN
)