Files
2025-10-14 09:52:32 +09:00

173 lines
5.3 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: Flash declaration for Renesas RA2L internal flash derivativs
; @Description:
; Script arguments:
; DO ra2l [PREPAREONLY] [CPU=<cpu>] [DUALPORT=<0|1>]
; PREPAREONLY only declares flash but does not execute flash programming
; CPU=<cpu> selects CPU derivative <cpu>
; DUALPORT=<0|1> use dual port memory access, default 1
; Example:
; DO ~~/demo/arm/flash/ra2l PREPAREONLY
; Note:
; This file must NOT be modified.
; This file is intended to stay within TRACE32 installation.
; Usage examples are available in the ~~/demo/arm/hardware/... subdirectories.
;
; List of RA2L* derivatives and their configuration:
; CPU-Type Code Flash Data Flash RamSize
; [KB] [KB] [KB]
; --------------------------------------------------------------------------------
; R7FA2L1A9* 128 8 32
; R7FA2L1AB* 256 8 32
;
; @Chip: R7FA2L*
; @Author: STK
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Rev: 11638 $
; $Id: ra2l.cmm 11638 2022-12-12 19:35:55Z skrausse $
PRIVATE &parameters
ENTRY %LINE &parameters
PRIVATE &param_prepareonly &param_cpu &param_dualport
&parameters=STRing.UPpeR("&parameters")
&param_prepareonly=(STRing.SCAN("&parameters","PREPAREONLY",0)!=-1)
&param_cpu=STRing.SCANAndExtract("&parameters","CPU=","")
&param_dualport=STRing.SCANAndExtract("&parameters","DUALPORT=","1")
; --------------------------------------------------------------------------------
; Initialize and start the debugger
IF !SYStem.Up()
(
SYStem.RESet
IF "&param_cpu"!=""
SYStem.CPU &param_cpu
IF (!CPUIS(R7FA2L*))
SYStem.CPU R7FA2L*
SYStem.MemAccess DAP
IF CABLE.TWOWIRE()
SYStem.CONFIG.DEBUGPORTTYPE SWD
ELSE
SYStem.CONFIG.DEBUGPORTTYPE JTAG
SYStem.Up
GOSUB SetupClock
)
; --------------------------------------------------------------------------------
; Flash declaration
FLASH.RESet
GOSUB FlashDeclaration "&param_dualport"
; Flash script ends here if called with parameter PREPAREONLY
IF &param_prepareonly
ENDDO PREPAREDONE
; --------------------------------------------------------------------------------
; Flash programming example
DIALOG.YESNO "Program flash memory?"
PRIVATE &progflash
ENTRY &progflash
IF &progflash
(
FLASH.ReProgram ALL /Erase
Data.LOAD.auto *
FLASH.ReProgram off
; Reset device
SYStem.Down
SYStem.Up
)
ENDDO
; --------------------------------------------------------------------------------
; SUBROUTINES
; --------------------------------------------------------------------------------
; Flash declaration depending on selected CPU
;
; Please do NOT modify the TRACE32 flash declaration.
;
; Modifications can result in unpredictable behavior.
; Please contact support@lauterbach.com for any changes.
FlashDeclaration: ;(param_dualport)
(
PARAMETERS &param_dualport
PRIVATE &SRAMAddress &FlashDriver &CodeFlashSize &DataFlashSize &CodeSectorSize &DataSectorSize &flash1_opt &flash2_opt
&FlashDriver="ra2l1.bin"
&CodeSectorSize=0x800
&DataSectorSize=0x400
&SRAMAddress=0x20000000
IF CPUIS(R7FA2L1?9*)
&CodeFlashSize=0x20000
ELSE IF CPUIS(R7FA2L1?B*)
&CodeFlashSize=0x40000
ELSE
(
PRINT %ERROR "Code FLASH size of CPU type is not supported by the script"
ENDDO
)
; Determine data flash size
IF CPUIS(R7FA2L1*)
&DataFlashSize=0x2000
ELSE
(
PRINT %ERROR "Data FLASH size of CPU type is not supported by the script"
ENDDO
)
; Determine the location of the option setting memory inside the program flash
&flash1_opt=""
&flash2_opt=""
IF (Data.Long(ASD:0x01010010)&0x80000000)==0x80000000 ; AWS.BTFLG
&flash1_opt="/CENSORSHIP 0x0400--0x043B"
ELSE
&flash2_opt="/CENSORSHIP 0x2400--0x243B"
FLASH.Create 1. 0x00000000--0x00001FFF &CodeSectorSize TARGET Long &flash1_opt
FLASH.Create 1. 0x00002000--0x00003FFF &CodeSectorSize TARGET Long &flash2_opt
FLASH.Create 1. 0x00004000--(&CodeFlashSize-1) &CodeSectorSize TARGET Long
FLASH.Create 2. 0x01010010++0x3 NOP Long /INFO "AWS"
FLASH.Create 2. 0x01010018++0x3 NOP Long /INFO "OCDID0"
FLASH.Create 2. 0x01010020++0x3 NOP Long /INFO "OCDID1"
FLASH.Create 2. 0x01010028++0x3 NOP Long /INFO "OCDID2"
FLASH.Create 2. 0x01010030++0x3 NOP Long /INFO "OCDID3"
FLASH.Create 3. 0x40100000++(&DataFlashSize-1) &DataSectorSize TARGET Long
IF (("&param_dualport"!="1")||SYStem.ACCESS.DENIED())
FLASH.TARGET &SRAMAddress &SRAMAddress+0x1000 0x1000 ~~/demo/arm/flash/long/&FlashDriver
ELSE
FLASH.TARGET &SRAMAddress E:&SRAMAddress+0x1000 0x1000 ~~/demo/arm/flash/long/&FlashDriver /DualPort
; Enable core clock measurement
FLASH.CLocK AUTO
RETURN
)
SetupClock:
(
; Setting up core clock using the Middle-speed On-chip Osscilator (MOCO)
; with a divider of 1/1 (8MHz)
Data.Set AD:0x4001E3FE %Word 0xA501 ; Unlock write access via SYSC.PRCR
Data.Set AD:0x4001E026 %Byte 0x01 ; SYSC.SCKSCR[CKSEL]=MOCO
Data.Set AD:0x4001E020 %Long 0xX0xxXXxx ; SYSC.SCKDIVCR[ICK]=1/1
Data.Set AD:0x4001E3FE %Word 0xA500 ; Lock again write access via SYSC.PRCR
RETURN
)