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

214 lines
6.3 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: Flash declaration for Synergy R7FX internal flash derivativs
; @Description:
; Script arguments:
; DO r7fx [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/r7fx 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 R7FS* derivatives and their configuration:
; CPU-Type Code Flash Data Flash RamSize
; [KB] [KB] [KB]
; --------------------------------------------------------------------------------
; R7FS12476* 64 4 16
; R7FS12477* 128 4 16
; R7FS1JA78* 256 8 32
; R7FS3A77C* 1024 16 192
; R7FS5D57A* 512 32 384
; R7FS5D57C* 1024 32 384
; R7FS5D97C* 1024 64 384
; R7FS5D97E* 2048 64 384
; R7FS7G27G* 3072 64 640
; R7FS7G27H* 4096 64 640
;
; @Chip: R7FS*
; @Author: MAM
; @Copyright: (C) 1989-2023 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Rev: 12741 $
; $Id: r7fx.cmm 12741 2023-11-17 07:55:15Z mschaeffner $
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(R7F*))
SYStem.CPU R7F*
SYStem.MemAccess DAP
IF CABLE.TWOWIRE()
SYStem.CONFIG.DEBUGPORTTYPE SWD
ELSE
SYStem.CONFIG.DEBUGPORTTYPE JTAG
SYStem.Up
)
; --------------------------------------------------------------------------------
; 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 &IDBank &IDReport &SRAMAddress &FlashDriver &CodeFlashSize &CodeFlashSize1 &DataFlashSize &CodeSectorSize &CodeSectorSize1 &DataSectorSize
; Check for part numbering register (PNRn) via flash root table, FMIFRT.
&PNRBank=Data.Long(ASD:0x407FB19C)+0x24
&PNReport=STRing.TRIM(Data.STRingN(ASD:&PNRBank,0x10))
IF CPU()!="&PNReport"
(
PRINT %WARNING "Chip selected (" CPU() ") does not match self-reported ID: &PNReport"
)
; Assign parameters based on CPU assignment
IF CPUIS(R7FS1*)||CPUIS(R7FS3*)
(
&SRAMAddress=0x20000000
IF CPUIS(R7FS1*)
(
&FlashDriver="mf3sa.bin" ; MF3 single-access
&CodeSectorSize=0x400
)
ELSE
(
&FlashDriver="mf3.bin" ; MF3 double-access
&CodeSectorSize=0x800
)
&DataSectorSize=0x400
&CodeFlashSize1=0x0 ; Code flash region has no 8k sectors
&CodeSectorSize1=0x0
)
ELSE IF CPUIS(R7FS5*)||CPUIS(R7FS7*)
(
&SRAMAddress=0x20000000 ; SRAM0
IF CPUIS(R7F?7*)
&FlashDriver="rv40f_s7.bin" ; RV40F phase 1
ELSE
&FlashDriver="rv40f.bin" ; RV40F phase 2
&CodeSectorSize=0x8000
&DataSectorSize=0x40
&CodeFlashSize1=0x10000 ; Code flash region with 8k sectors
&CodeSectorSize1=0x2000
)
ELSE
(
PRINT %ERROR " Onchip FLASH of CPU type is not supported by the script"
ENDDO
)
IF CPUIS(R7FS????6*)
&CodeFlashSize=0x10000
ELSE IF CPUIS(R7FS????7*)
&CodeFlashSize=0x20000
ELSE IF CPUIS(R7FS????8*)
&CodeFlashSize=0x40000
ELSE IF CPUIS(R7FS????A*)
&CodeFlashSize=0x80000
ELSE IF CPUIS(R7FS????C*)
&CodeFlashSize=0x100000
ELSE IF CPUIS(R7FS????E*)
&CodeFlashSize=0x200000
ELSE IF CPUIS(R7FS????G*)
&CodeFlashSize=0x300000
ELSE IF CPUIS(R7FS????H*)
&CodeFlashSize=0x400000
ELSE
(
PRINT %ERROR "Code FLASH size of CPU type is not supported by the script"
ENDDO
)
; Determine data flash size by group name / number
IF CPUIS(R7FS124*)
&DataFlashSize=0x1000
ELSE IF CPUIS(R7FS1JA*)
&DataFlashSize=0x2000
ELSE IF CPUIS(R7FS3*)
&DataFlashSize=0x4000
ELSE IF CPUIS(R7FS5D5*)
&DataFlashSize=0x8000
ELSE IF CPUIS(R7FS5D9*)||CPUIS(R7FS7G2*)
&DataFlashSize=0x10000
ELSE
(
PRINT %ERROR "Data FLASH size of CPU type is not supported by the script"
ENDDO
)
IF (&CodeFlashSize1!=0)
(
FLASH.Create 1. 0x0++(&CodeFlashSize1-1) &CodeSectorSize1 TARGET Long
FLASH.Create 1. &CodeFlashSize1++(&CodeFlashSize-&CodeFlashSize1-1) &CodeSectorSize TARGET Long
)
ELSE
FLASH.Create 1. 0x0++(&CodeFlashSize-1) &CodeSectorSize TARGET Long
FLASH.Create 2. 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
RETURN
)