; -------------------------------------------------------------------------------- ; @Title: Flash declaration for ST Mircoelectronics STM32WB internal flash ; @Description: ; Script arguments: ; DO stm32wb [PREPAREONLY] [CPU=] [DUALPORT=<0|1>] ; PREPAREONLY only declares flash but does not execute flash programming ; CPU= selects CPU derivative ; 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 ¶meters ENTRY %LINE ¶meters PRIVATE ¶m_prepareonly ¶m_cpu ¶m_dualport ¶meters=STRing.UPpeR("¶meters") ¶m_prepareonly=(STRing.SCAN("¶meters","PREPAREONLY",0)!=-1) ¶m_cpu=STRing.SCANAndExtract("¶meters","CPU=","") ¶m_dualport=STRing.SCANAndExtract("¶meters","DUALPORT=","0") ; -------------------------------------------------------------------------------- ; Initialize and start the debugger IF !SYStem.Up() ( SYStem.RESet IF "¶m_cpu"!="" SYStem.CPU ¶m_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 "¶m_dualport" ; Flash script ends here if called with parameter PREPAREONLY IF ¶m_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 ¶m_dualport PRIVATE &FlashDriver &flashsize_unsecured §or_size &flash_size &tzen IF CPUIS(STM32WB55?C-CM4) ( &FlashDriver="stm32wb.bin" &flashsize_unsecured=(Data.Long(ASD:0x58004080)&0xFF)*0x1000 &flash_size=0x40000 ;256KB §or_size=0x1000 ) ELSE IF CPUIS(STM32WB55?E-CM4) ( &FlashDriver="stm32wb.bin" &flashsize_unsecured=(Data.Long(ASD:0x58004080)&0xFF)*0x1000 &flash_size=0x80000 ;512KB §or_size=0x1000 ) ELSE IF CPUIS(STM32WB55?G-CM4) ( &FlashDriver="stm32wb.bin" &flashsize_unsecured=(Data.Long(ASD:0x58004080)&0xFF)*0x1000 &flash_size=0x100000 ;1MByte §or_size=0x1000 ) ELSE IF CPUIS(STM32WB15CC-CM4) ( &FlashDriver="stm32wb15.bin" &flashsize_unsecured=(Data.Long(ASD:0x58004080)&0xFF)*0x800 &flash_size=0x50000 ;320KB §or_size=0x800 ) ELSE IF CPUIS(STM32WBA52?G) ( &FlashDriver="stm32wba5.bin" &flash_size=0x100000 ;1MB §or_size=0x2000 &tzen=FALSE() ) ELSE IF CPUIS(STM32WBA52?E) ( &FlashDriver="stm32wba5.bin" &flash_size=0x80000 ;512KB §or_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) §or_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) §or_size TARGET quad FLASH.Create 2. (0x8000000+&flashsize_unsecured)--(0x8000000+(&flash_size-0x1)) §or_size NOP quad /INFO "Secured flash" ) IF (("¶m_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 )