119 lines
3.3 KiB
Plaintext
119 lines
3.3 KiB
Plaintext
; --------------------------------------------------------------------------------
|
|
; @Title: Example Script for programming of GigaDevice GD32F103 internal flash
|
|
;
|
|
; @Description:
|
|
; Script arguments:
|
|
;
|
|
; DO gd32f1x [PREPAREONLY] [CPU=<cpu>] [DUALPORT=0|1]
|
|
;
|
|
; PREPAREONLY only declares flash but does not execute flash programming
|
|
;
|
|
; CPU=<cpu> selects CPU derivative <cpu>
|
|
;
|
|
; DUALPORT default value is 0 (disabled). If DualPort mode is enabled
|
|
; flash algorithm stays running until flash programming is
|
|
; finished. Data is tranferred via dual port memory access.
|
|
;
|
|
; Example:
|
|
;
|
|
; DO ~~/demo/arm/flash/gd32f1x CPU=GD32F10x PREPAREONLY
|
|
;
|
|
; List of GD32F10x derivatives and their configuration:
|
|
;
|
|
; CPU-Type Flash size
|
|
; [kByte]
|
|
; --------------------------------------------------------------------------------
|
|
; GD32F10x 256KB
|
|
; @Author: LBA
|
|
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
|
|
; @Chip: GD32F1*
|
|
; --------------------------------------------------------------------------------
|
|
; $Rev: 12607 $
|
|
; $Id: gd32f1x.cmm 12607 2023-10-12 08:02:09Z bwright $
|
|
|
|
LOCAL ¶meters
|
|
ENTRY %LINE ¶meters
|
|
|
|
LOCAL ¶m_prepareonly ¶m_cpu ¶m_dualport
|
|
¶meters=STRing.UPpeR("¶meters")
|
|
¶m_prepareonly=(STRing.SCAN("¶meters","PREPAREONLY",0)!=-1)
|
|
¶m_cpu=STRing.SCANAndExtract(STRing.UPpeR("¶meters"),"CPU=","")
|
|
¶m_dualport=STRing.SCANAndExtract("¶meters","DUALPORT=","0")
|
|
|
|
; ------------------------------------------------------------------------------
|
|
; CPU setup
|
|
|
|
IF SYStem.MODE()<5
|
|
(
|
|
SYStem.RESet
|
|
IF "¶m_cpu"!=""
|
|
SYStem.CPU ¶m_cpu
|
|
IF !CPUIS(GD32F1*)
|
|
SYStem.CPU GD32F1*
|
|
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?"
|
|
LOCAL &progflash
|
|
ENTRY &progflash
|
|
|
|
IF &progflash
|
|
(
|
|
FLASH.ReProgram.ALL /Erase
|
|
Data.LOAD.auto *
|
|
FLASH.ReProgram.off
|
|
|
|
; Reset device
|
|
SYStem.Down
|
|
SYStem.Up
|
|
)
|
|
|
|
ENDDO
|
|
|
|
|
|
; --------------------------------------------------------------------------------
|
|
; Flash declaration depending on selected CPU
|
|
|
|
FlashDeclaration:
|
|
LOCAL &DualPort
|
|
ENTRY &DualPort
|
|
LOCAL &FlashSize &FlashDriver
|
|
|
|
&FlashDriver="gd32f1x.bin"
|
|
|
|
IF CPUIS("GD32F103VC")
|
|
&FlashSize=0x40000
|
|
ELSE
|
|
(
|
|
PRINT %ERROR "FLASH size of CPU type is unknown"
|
|
ENDDO
|
|
)
|
|
|
|
FLASH.Create 1. 0x08000000++(&FlashSize-1) 0x400 TARGET Long
|
|
|
|
; For Main Flash memory boot mode flash memory is aliased to address 0x0
|
|
; Because SYSCFG_CFGR1:MEM_MODE[1:0] is not indicating active memory remap
|
|
; we are comparing flash reset vector against reset vector at alias address
|
|
Data.ComPare 0x0--0x7 0x08000000
|
|
IF !FOUND()
|
|
FLASH.CreateALIAS 0x00000000++(&FlashSize-1) 0x08000000
|
|
|
|
IF &DualPort==0
|
|
FLASH.TARGET 0x20000000 0x20001000 0x800 ~~/demo/arm/flash/long/&FlashDriver
|
|
ELSE
|
|
FLASH.TARGET 0x20000000 0x20001000 0x800 ~~/demo/arm/flash/long/&FlashDriver /DualPort
|
|
RETURN
|