; -------------------------------------------------------------------------------- ; @Title: Example for flash declaration of Atmel ATSAM4C internal flash. ; ; @Description: ; ; Script arguments: ; ; DO atsamd2 [PREPAREONLY] [CPU=] ; ; PREPAREONLY only declares flash but does not execute flash programming ; ; CPU= selects CPU derivative ; ; Example: ; ; DO ~~/demo/arm/flash/atsam4c CPU=ATSAM4C16C-CORE0 PREPAREONLY ; ; List of ATSAM4C* derivatives and their configuration: ; ; CPU-Type Flash size Page size SRAM size ; [Byte] [Byte] [Byte] ; ATSAM4C8C 0x80000 0x200 128+16+8 Kbytes ; ATSAM4CMP8C 0x80000 0x200 128+16+8 Kbytes ; ATSAM4CMS8C 0x80000 0x200 128+16+8 Kbytes ; ATSAM4C16C 0x100000 0x200 128+16+8 Kbytes ; ATSAM4CMP16C 0x100000 0x200 128+16+8 Kbytes ; ATSAM4CMS16C 0x100000 0x200 128+16+8 Kbytes ; ; @Author: FLC ; @Chip: ATSAM4C* ; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only ; -------------------------------------------------------------------------------- ; $Rev: 12049 $ ; $Id: atsam4c.cmm 12049 2023-04-20 12:32:16Z 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("ATSAM4C*C-CORE?") SYStem.CPU "ATSAM4C*C-CORE?" SYStem.Up ) ; Disable watchdog Data.Set C:0x400E1454 %Long Data.Long(C:0x400E1454)&~0x8000 ; ------------------------------------------------------------------------------ ; 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 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("ATSAM4C*8C-CORE?") ( &FlashSize=0x80000 &FlashDriver="atsam4c8.bin" ) ELSE IF CPUIS("ATSAM4C*16C-CORE?") ( &FlashSize=0x100000 &FlashDriver="atsam4c16.bin" ) ELSE ( PRINT %ERROR "FLASH size of CPU type is unknown" ENDDO ) IF &FlashSize>=0x80000 FLASH.Create 1. 0x00000000--0x00001FFF 0x2000 TARGET Long FLASH.Create 1. 0x00002000--0x00003FFF 0x2000 TARGET Long FLASH.Create 1. 0x00004000--0x0000FFFF 0xC000 TARGET Long FLASH.Create 2. 0x00010000--0x0007FFFF 0x10000 TARGET Long IF &FlashSize>=0x100000 FLASH.Create 2. 0x00080000--0x000FFFFF 0x10000 TARGET Long FLASH.TARGET 0x20000000 0x20000800 0x10000 ~~/demo/arm/flash/long/&FlashDriver RETURN