; -------------------------------------------------------------------------------- ; @Title: Example Script for programming of GigaDevice GD32F3x0 internal flash ; ; @Description: ; Script arguments: ; ; DO gd32f3x0 [PREPAREONLY] [CPU=] ; ; PREPAREONLY only declares flash but does not execute flash programming example ; ; CPU= selects CPU derivative ; ; Example: ; ; DO ~~/demo/arm/flash/gd32f3x0 CPU=GD32F310K8 PREPAREONLY ; ; List of GD32F3x0 derivatives and their configuration: ; ; CPU-Type Flash size ; [kByte] ; -------------------------------------------------------------------------------- ; GD32F3x0x4 16. ; GD32F3x0x6 32. ; GD32F3x0x8 64. ; GD32F3x0xB 128. ; ; Flash base address is 0x08000000 ; SRAM base address is 0x20000000 ; System memory is located at 0x1FFFEC00--0x1FFFF7FF ; Option bytes are located at 0x1FFFF800--0x1FFFF80F ; ; Depending on the boot mode main flash memory, system memory or embedded SRAM ; is mirrored to address 0x00000000. Boot modes are defined by nBOOT1 and ; BOOT0 pins after reset or when exiting standby mode: ; ; nBOOT1 BOOT0 Boot mode ; -------------------------------------------------------------------------------- ; x 0 Main Flash memory ; 1 1 System memory ; 0 1 Embedded SRAM ; ; ; @Author: ALI ; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only ; @Chip: GD32F3* ; -------------------------------------------------------------------------------- ; $Rev: 11230 $ ; $Id: gd32f3x0.cmm 11230 2022-08-26 10:07:00Z alintner $ LOCAL ¶meters ENTRY %LINE ¶meters LOCAL ¶m_prepareonly ¶m_prepareonly=(STRing.SCAN(STRing.UPpeR("¶meters"),"PREPAREONLY",0)!=-1) LOCAL ¶m_cpu ¶m_cpu=STRing.SCANAndExtract(STRing.UPpeR("¶meters"),"CPU=","") ; ------------------------------------------------------------------------------ ; CPU setup IF SYStem.MODE()<5 ( SYStem.RESet IF "¶m_cpu"!="" SYStem.CPU ¶m_cpu IF !CPUIS(GD32F3*) SYStem.CPU GD32F3* SYStem.Up ) ; ------------------------------------------------------------------------------ ; Flash declaration FLASH.RESet GOSUB FlashDeclaration ; 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 &FlashSize &FlashDriver &FlashDriver="gd32f3x0.bin" IF CPUIS("GD32F3???4") &FlashSize=0x4000 ELSE IF CPUIS("GD32F3???6") &FlashSize=0x8000 ELSE IF CPUIS("GD32F3???8") &FlashSize=0x10000 ELSE IF CPUIS("GD32F3???B") &FlashSize=0x20000 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 FLASH.TARGET 0x20000000 0x20001000 0x800 ~~/demo/arm/flash/long/&FlashDriver RETURN