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

138 lines
4.1 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: Internal FLASH Programming Script of ST STM32C0xx Derivatives
; @Description:
; Script arguments:
; DO stm32c0xx [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/stm32c0xx 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 STM32C0* derivatives and their configuration:
; CPU-Type FlashSize RamSize
; [KB] [KB]
; ------------------------------------------
; STM32C011D6 32. 12.
; STM32C011F4 16. 12.
; STM32C011F6 32. 12.
; STM32C011J4 16. 12.
; STM32C011J6 32. 12.
; STM32C031C4 16. 12.
; STM32C031C6 32. 12.
; STM32C031F4 16. 12.
; STM32C031F6 32. 12.
; STM32C031G4 16. 12.
; STM32C031G6 32. 12.
; STM32C031K4 16. 12.
; STM32C031K6 32. 12.
;
; @Chip: STM32C0*
; @Author: NEZ
; @Copyright: (C) 1989-2024 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Rev: 13527 $
; $Id: stm32c0xx.cmm 13527 2024-06-05 09:29:00Z nzouari $
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(STM32C0*))
SYStem.CPU STM32C0*
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 &SRAMAddress &FlashDriver &FlashSize &SectorSize
IF CPUIS("STM32C0???4")
&FlashSize=0x4000
ELSE IF CPUIS("STM32C0???6")
&FlashSize=0x8000
ELSE
(
PRINT %ERROR "FLASH size of CPU type is unknown"
ENDDO
)
&FlashDriver="stm32c0.bin"
&SectorSize=0x800
FLASH.Create 1. 0x08000000++(&FlashSize-1) &SectorSize TARGET Byte
IF (("&param_dualport"!="1")||SYStem.ACCESS.DENIED())
FLASH.TARGET 0x20000000++0xFFF 0x20001000++0xFFF ~~/demo/arm/flash/byte/&FlashDriver
ELSE
FLASH.TARGET E:0x20000000++0xFFF 0x20001000++0xFFF ~~/demo/arm/flash/byte/&FlashDriver /DualPort
RETURN
)