; -------------------------------------------------------------------------------- ; @Title: Example for flash declaration of Atmel ATSAMG internal flash. ; ; @Description: ; Script arguments: ; ; DO atsamg [PREPAREONLY] [CPU=] ; ; PREPAREONLY only declares flash but does not execute flash programming ; ; CPU= selects CPU derivative ; ; Example: ; ; DO ~~/demo/arm/flash/atsamg CPU=ATSAMG51 PREPAREONLY ; ; List of ATSAMG derivatives and their configuration: ; ; CPU-Type Flash size Page size SRAM size ; [Byte] [Byte] [Byte] ; -------------------------------------------------------------------------------- ; ATSAMG51 0x40000 0x200 0x10000 ; ATSAMG53 0x80000 0x200 0x10000 ; ATSAMG54 0x80000 0x200 0x10000 ; ATSAMG55 0x80000 0x200 0x10000 ; ; The internal flash is located at 0x00400000 ; The internal SRAM is located at 0x20000000 ; ; HINTS: ; ; Locked pages can be unlocked with FLASH.UNLOCK command and can be ; locked again with FLASH.LOCK command. ; ; Watchdog is critical for flash programming. The flash algorithm is ; serving the watchdog if the watchdog is not used in window mode. ; ; If the watchdog is setup to window mode by a running application ; the watchdog should be either disabled after first power-up or the ; board should be power-up before every flash programming. If the ; watchdog is disabled after power-up it cannot be enabled again by ; the application because WDT_MR register is write once. Please see ; below the command to disable the watchdog. ; ; @Author: WRD ; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only ; @Chip: ATSAMG* ; -------------------------------------------------------------------------------- ; $Rev: 10516 $ ; $Id: atsamg.cmm 10516 2022-02-02 11:39:30Z bschroefel $ LOCAL ¶meters ENTRY %LINE ¶meters LOCAL ¶m_prepareonly ¶m_cpu ¶m_prepareonly=(STRing.SCAN(STRing.UPpeR("¶meters"),"PREPAREONLY",0)!=-1) ¶m_cpu=STRing.SCANAndExtract(STRing.UPpeR("¶meters"),"CPU=","") ; ------------------------------------------------------------------------------ ; Setup CPU IF SYStem.MODE()<5 ( SYStem.RESet IF "¶m_cpu"!="" SYStem.CPU ¶m_cpu IF !CPUIS(ATSAMG*) SYStem.CPU ATSAMG* SYStem.Option.ResBreak OFF IF CABLE.TWOWIRE() SYStem.CONFIG.DEBUGPORTTYPE SWD ELSE SYStem.CONFIG.DEBUGPORTTYPE JTAG SYStem.Up ) ; Disable watchdog for flash programming if watchdog may be used in ; window mode. //DATA.SET 0x400E1454 %LONG DATA.LONG(ASD:0x400E1454)|0x00008000 ; ------------------------------------------------------------------------------ ; Flash declaration FLASH.RESet GOSUB FlashDeclaration ; Setup EEFC wait states in EEFC_FMR register //Data.Set ASD:0x400E0800 %Long (Data.Long(ASD:0x400E0800)&0xFFFFF0FF)|0x00000300 ; 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 ( ; Unlock locked pages if necessary //FLASH.UNLOCK ALL FLASH.ReProgram.ALL Data.LOAD.auto * FLASH.ReProgram.off ; Reset device SYStem.Down SYStem.Up ) ENDDO ; -------------------------------------------------------------------------------- ; Flash declaration depending on selected CPU FlashDeclaration: LOCAL &FlashSize &FlashDriver IF CPUIS("ATSAMG51") ( &FlashSize=0x40000 &FlashDriver="eefcsamg.bin" ) ELSE IF CPUIS("ATSAMG53")||CPUIS("ATSAMG54") ( &FlashSize=0x80000 &FlashDriver="eefcsamg.bin" ) ELSE IF CPUIS("ATSAMG55") ( &FlashSize=0x80000 &FlashDriver="eefcsamg55.bin" ) ELSE ( PRINT %ERROR "FLASH size of CPU type is unknown" ENDDO ) FLASH.Create 1. 0x00400000--0x00401FFF 0x2000 TARGET Long FLASH.Create 2. 0x00402000--0x00403FFF 0x2000 TARGET Long FLASH.Create 3. 0x00404000--0x0040FFFF 0x2000 TARGET Long FLASH.Create 4. 0x00410000--0x0041FFFF 0x2000 TARGET Long FLASH.Create 5. 0x00420000--0x0042FFFF 0x2000 TARGET Long FLASH.Create 6. 0x00430000--0x0043FFFF 0x2000 TARGET Long IF &FlashSize>=0x80000 ( FLASH.Create 7. 0x00440000--0x0044FFFF 0x2000 TARGET Long FLASH.Create 8. 0x00450000--0x0045FFFF 0x2000 TARGET Long FLASH.Create 9. 0x00460000--0x0046FFFF 0x2000 TARGET Long FLASH.Create 10. 0x00470000--0x0047FFFF 0x2000 TARGET Long ) FLASH.TARGET 0x20000000 0x20001000 0x1000 ~~/demo/arm/flash/long/&FlashDriver RETURN