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

189 lines
5.4 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: Flash declaration for ST Mircoelectronics STM32WB internal flash
; @Description:
; Script arguments:
; DO stm32wb [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/stm32wb 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 STM32WB55RG derivatives and their configuration:
; CPU-Type Flash RamSize
; [byte] [byte]
; --------------------------------------------------------------------------------
; STM32WB55xC 256K 128K x=C/R/V
; STM32WB55xE 512K 256K x=C/R/V
; STM32WB55xG 1M 256K x=C/R/V
; STM32WB15CC 320K 48K
; STM32WBA52xG 1M 128K x=C/K
; STM32WBA52xE 512K 96K x=C/K
;
; @Chip: STM32WB*
; @Author: PHI
; @Copyright: (C) 1989-2023 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Rev: 12874 $
; $Id: stm32wb.cmm 12874 2023-12-22 12:02:05Z 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=","0")
; --------------------------------------------------------------------------------
; Initialize and start the debugger
IF !SYStem.Up()
(
SYStem.RESet
IF "&param_cpu"!=""
SYStem.CPU &param_cpu
IF !CPUIS(STM32WB????-CM4*)
SYStem.CPU STM32WB*
IF CPUIS(STM32WB????-CM0+)
(
PRINT %ERROR "Flash programming only suppoerted from CM4 core"
ENDDO
)
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 &FlashDriver &flashsize_unsecured &sector_size &flash_size &tzen
IF CPUIS(STM32WB55?C-CM4)
(
&FlashDriver="stm32wb.bin"
&flashsize_unsecured=(Data.Long(ASD:0x58004080)&0xFF)*0x1000
&flash_size=0x40000 ;256KB
&sector_size=0x1000
)
ELSE IF CPUIS(STM32WB55?E-CM4)
(
&FlashDriver="stm32wb.bin"
&flashsize_unsecured=(Data.Long(ASD:0x58004080)&0xFF)*0x1000
&flash_size=0x80000 ;512KB
&sector_size=0x1000
)
ELSE IF CPUIS(STM32WB55?G-CM4)
(
&FlashDriver="stm32wb.bin"
&flashsize_unsecured=(Data.Long(ASD:0x58004080)&0xFF)*0x1000
&flash_size=0x100000 ;1MByte
&sector_size=0x1000
)
ELSE IF CPUIS(STM32WB15CC-CM4)
(
&FlashDriver="stm32wb15.bin"
&flashsize_unsecured=(Data.Long(ASD:0x58004080)&0xFF)*0x800
&flash_size=0x50000 ;320KB
&sector_size=0x800
)
ELSE IF CPUIS(STM32WBA52?G)
(
&FlashDriver="stm32wba5.bin"
&flash_size=0x100000 ;1MB
&sector_size=0x2000
&tzen=FALSE()
)
ELSE IF CPUIS(STM32WBA52?E)
(
&FlashDriver="stm32wba5.bin"
&flash_size=0x80000 ;512KB
&sector_size=0x2000
&tzen=FALSE()
)
ELSE
(
PRINT "CPU not supported by this script"
ENDDO
)
IF CPUIS(STM32WBA52??)
(
&tzen=(Data.Long(ZD:0x40022040)&0x80000000)==0x80000000
; Flash declaration, if Trustzone is not activated
IF (!&tzen)
(
FLASH.Create 1. 0x08000000++(&flash_size-0x1) &sector_size TARGET quad
FLASH.CreateALIAS 0x0C000000++(&flash_size-0x1) 0x08000000 /INFO "Secured flash"
)
ELSE
(
PRINT "TrustZone security is active. Please contact techninal support"
ENDDO
)
)
ELSE
(
FLASH.Create 1. 0x8000000++(&flashsize_unsecured-0x1) &sector_size TARGET quad
FLASH.Create 2. (0x8000000+&flashsize_unsecured)--(0x8000000+(&flash_size-0x1)) &sector_size NOP quad /INFO "Secured flash"
)
IF (("&param_dualport"!="1")||SYStem.ACCESS.DENIED())
FLASH.TARGET 0x20000000 0x20001000 0x1000 ~~/demo/arm/flash/byte/&FlashDriver
ELSE
FLASH.TARGET 0x20000000 E:0x20001000 0x1000 ~~/demo/arm/flash/byte/&FlashDriver /DualPort
RETURN
)