Files
Gen4_R-Car_Trace32/2_Trunk/demo/arm/flash/rcarv4h-cr52-hyper.cmm
2025-10-14 09:52:32 +09:00

179 lines
5.6 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: R-CarV4H for R8A779G-CR52 on WhiteHawk QSPI Flash script
; @Description:
; SPI FLASH Program script by the core (CR52) for the Evaluation
; The S26KS512SDPBHV02(U26) is on the SPI Multi I/O Bus controller (RPC-IF)
;
; Prerequisites:
; * Cortex-R52 boot
; MD6 = 1 (SW1[1] = OFF)
; MD7 = 1 (SW1[2] = OFF)
; * QSPI boot mode (HyperFlash ROM boot at 160 MHz (320 Mbps) using DMA)
; MD4 = 0 (SW1[5] = ON)
; MD3 = 0 (SW1[6] = ON)
; MD2 = 1 (SW1[7] = OFF)
; MD1 = 0 (SW1[8] = ON)
;
; * activate S25FS512 flash
; SW13 = x: on/off don't matter
; SW57 = 1: HyperFlash(U26)
;
; SRAM: 0xE6328000
; SPI Multi I/O Bus(controller) Base: 0xEE200000
;
; @Keywords: ARM, Cortex-R52, HyperFlash, S26KS512
; @Props: Confidential
; @Author: JIM
; @Board: WhiteHawk
; @Chip: R8A779G
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Id: rcarv4h-cr52-hyper.cmm 12050 2023-04-20 12:36:22Z bschroefel $
PRIVATE &parameters
ENTRY %LINE &parameters
PRIVATE &param_prepareonly
&parameters=STRing.UPpeR("&parameters")
&param_prepareonly=(STRing.SCAN("&parameters","PREPAREONLY",0)!=-1)
&BASE=0xEE200000
; ------------------------------------------------------------------------------
; Setup CPU
; --------------------------------------------------------------------------------
; Initialize and start the debugger
RESet
SYStem.RESet
SYStem.CPU R8A779G-CR52
SYStem.MemAccess DAP
SYStem.JtagClock 10MHz
CORE.ASSIGN 1.
SYStem.Option.ResBreak OFF
Trace.DISable
SYStem.Mode.Prepare
IF Data.Long(ENAXI:0xE6170304)==0x0
SYStem.Mode.Up
ELSE
(
// CR52_0 is held in reset and needs to be released for flash programming.
Data.Set ENAXI:0xE6300000 %Long 0xEAFFFFFE // Endless loop in OCM (32bit ARM code)
// Release CR52_0 from power down
Data.Set ENAXI:0xE6170330 %LE %Long 0xE6300000
Data.Set ENAXI:0xE6170338 %LE %Long 0xE6300000
Data.Set ENAXI:0xE6170304 %LE %Long 0
SYStem.Mode.Attach
Break.direct
)
; --------------------------------------------------------------------------------
; DRCR.RBE=0 (RPC Read cache = OFF) for flash region access
Data.Set AD:0xEE20000C %LE %Long 0yXXXXxxxxXXXXxxxxXXXXxxx0XXXXxxxx
; ------------------------------------------------------------------------------
; Flash Controller Power & Clock Enable
; ------------------------------------------------------------------------------
; Flash Pin Mux Configuration
; ------------------------------------------------------------------------------
; Flash Controller Init
GOSUB RPC_INIT
; ------------------------------------------------------------------------------
; Flash Read ID Test
GOSUB READ_ID_TEST
; ------------------------------------------------------------------------------
; Init SRAM (16KB) for the flash algorithm
Data.Test 0xE6328000++0x3FFF
; ------------------------------------------------------------------------------
; Flash declaration
FLASH.RESet
FLASH.Create 0x08000000++0x3FFFFFF 0x40000 TARGET Word
FLASH.TARGET 0xE6328000 E:0xE632A000 0x2000 ~~/demo/arm/flash/word/hyper_rcarv4.bin /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 * 0x08000000
FLASH.ReProgram.off
; Reset device
PRINT "Please power-cycle the board after flash program is complete"
)
ENDDO
; --------------------------------------------------------------------------------
READ_ID_TEST:
(
&calibration_data=0x80070263 ;RcarV3H RPC for HyperFlash memory
Data.Set A:&BASE+0x007C %Long &calibration_data ;physical calibration.
Data.Set A:&BASE+0x0000 %Long 0x81fff301
Data.Set A:&BASE+0x0024 %Long 0x0 ;write memory
Data.Set A:&BASE+0x0028 %Long 0x555
Data.Set A:&BASE+0x002C %Long 0x0
Data.Set A:&BASE+0x0064 %Long 0x5101
Data.Set A:&BASE+0x0030 %Long 0xA2225408
Data.Set A:&BASE+0x0040 %Long 0x98000000 ; CFI Enter(0x98)
Data.Set A:&BASE+0x0020 %Long 0x3 ;write access
Data.Set A:&BASE+0x007C %Long &calibration_data ;physical calibration.
Data.Set A:&BASE+0x0000 %Long 0x81fff301
Data.Set A:&BASE+0x0024 %Long 0x00800000 ;read memory
Data.Set A:&BASE+0x0028 %Long 0x0 ;addr
Data.Set A:&BASE+0x002C %Long 0x0
Data.Set A:&BASE+0x0060 %Long 0xE ;dummy cycle
Data.Set A:&BASE+0x0064 %Long 0x5101
Data.Set A:&BASE+0x0030 %Long 0xA222D40C ; 32bit read with dummy cycle
Data.Set A:&BASE+0x0020 %Long 0x5 ;read access
WAIT 10.ms
//print "read_buffer[31:0]: 0x" data.long(A:&BASE+0x0038)
&temp=Data.Long(A:&BASE+0x0038)
PRINT "Read 0x" &temp
PRINT "Read 1st: 0x" (&temp>>8.)&0xFF " (Manufacture)"
PRINT "Read 2nd: 0x" (&temp>>24.)&0xFF " (Device ID)"
GOSUB RPC_INIT
RETURN
)
RPC_INIT:
(
&calibration_data=0x80070263 ;RcarV3H RPC for HyperFlash memory
Data.Set A:&BASE+0x00 %Long 0x01FF5301 ; HyperBoot MD[4:1]0010
Data.Set A:&BASE+0x007C %Long &calibration_data ;Physical calibration Enable
Data.Set A:&BASE+0x0000 %Long 0x81fff301
Data.Set A:&BASE+0x0024 %Long 0x0 ;write memory
Data.Set A:&BASE+0x0028 %Long 0x555
Data.Set A:&BASE+0x002C %Long 0x0
Data.Set A:&BASE+0x0064 %Long 0x5101
Data.Set A:&BASE+0x0030 %Long 0xA2225408
Data.Set A:&BASE+0x0040 %Long 0xF0000000 ; Reset(0xF0)
Data.Set A:&BASE+0x0020 %Long 0x3 ;write access
RETURN
)