Files
Gen4_R-Car_Trace32/2_Trunk/demo/arm/flash/atsam4e.cmm
2025-10-14 09:52:32 +09:00

186 lines
5.6 KiB
Plaintext

; --------------------------------------------------------------------------------
; @Title: Example script for flash declaration of Atmel ATSAM4E internal flash.
;
; @Description:
; Script arguments:
;
; DO atsam4e [PREPAREONLY] [CPU=<cpu>]
;
; PREPAREONLY only declares flash but does not execute flash
; programming example
;
; CPU=<cpu> selects CPU derivative <cpu>
;
; Example:
;
; DO ~~/demo/arm/flash/atsam4e CPU=ATSAM4E16E PREPAREONLY
;
; List of ATSAM4E derivatives and their configuration:
;
; CPU-Type Flash size Page size SRAM size
; [Byte] [Byte] [Byte]
; --------------------------------------------------------------------------------
; ATSAM4E8C 0x80000 0x200 0x20000
; ATSAM4E8E 0x80000 0x200 0x20000
; ATSAM4E16C 0x100000 0x200 0x20000
; ATSAM4E16E 0x100000 0x200 0x20000
;
; The internal flash is located at 0x00400000
; The internal ROM is located at 0x00800000.
; The internal SRAM is located at 0x20000000
;
; The system always boot at address 0x0. If GPNVM bit 1 is set the
; internal flash is mirrored to address 0x0 otherwise ROM is mapped
; to address 0x0.
;
; 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.
;
; GPNVM bit values can be changed via atsam4-nvm.cmm script.
;
; @Author: WRD
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
; @Chip: ATSAM4E*
; --------------------------------------------------------------------------------
; $Rev: 10516 $
; $Id: atsam4e.cmm 10516 2022-02-02 11:39:30Z bschroefel $
LOCAL &parameters
ENTRY %LINE &parameters
LOCAL &param_prepareonly
&param_prepareonly=(STRing.SCAN(STRing.UPpeR("&parameters"),"PREPAREONLY",0)!=-1)
LOCAL &param_cpu
&param_cpu=STRing.SCANAndExtract(STRing.UPpeR("&parameters"),"CPU=","")
; ------------------------------------------------------------------------------
; Setup CPU
IF SYStem.MODE()<5
(
SYStem.RESet
IF "&param_cpu"!=""
SYStem.CPU &param_cpu
IF !CPUIS(ATSAM4E*)
SYStem.CPU ATSAM4E*
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 &param_prepareonly
ENDDO PREPAREDONE
; ------------------------------------------------------------------------------
; Flash NVM bit programming example
DIALOG.YESNO "Program flash NVM bits"
LOCAL &prognvm
ENTRY &prognvm
IF &prognvm
(
DO ~~~~/atsam4-nvm
)
; ------------------------------------------------------------------------------
; 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
IF CPUIS("ATSAM4E8?")
(
&FlashSize=0x80000
)
ELSE IF CPUIS("ATSAM4E16?")
(
&FlashSize=0x100000
)
ELSE
(
PRINT %ERROR "FLASH size of CPU type is unknown"
ENDDO
)
FLASH.Create 1. 0x00400000--0x00401fff 0x1000 TARGET Long
FLASH.Create 2. 0x00402000--0x00403fff 0x1000 TARGET Long
FLASH.Create 3. 0x00404000--0x0040ffff 0x1000 TARGET Long
FLASH.Create 4. 0x00410000--0x0041ffff 0x1000 TARGET Long
FLASH.Create 5. 0x00420000--0x0042ffff 0x1000 TARGET Long
FLASH.Create 6. 0x00430000--0x0043ffff 0x1000 TARGET Long
FLASH.Create 7. 0x00440000--0x0044ffff 0x1000 TARGET Long
FLASH.Create 8. 0x00450000--0x0045ffff 0x1000 TARGET Long
FLASH.Create 9. 0x00460000--0x0046ffff 0x1000 TARGET Long
FLASH.Create 10. 0x00470000--0x0047ffff 0x1000 TARGET Long
IF &FlashSize>=0x100000
(
FLASH.Create 11. 0x00480000--0x0048ffff 0x1000 TARGET Long
FLASH.Create 12. 0x00490000--0x0049ffff 0x1000 TARGET Long
FLASH.Create 13. 0x004a0000--0x004affff 0x1000 TARGET Long
FLASH.Create 14. 0x004b0000--0x004bffff 0x1000 TARGET Long
FLASH.Create 15. 0x004c0000--0x004cffff 0x1000 TARGET Long
FLASH.Create 16. 0x004d0000--0x004dffff 0x1000 TARGET Long
FLASH.Create 17. 0x004e0000--0x004effff 0x1000 TARGET Long
FLASH.Create 18. 0x004f0000--0x004fffff 0x1000 TARGET Long
)
FLASH.TARGET 0x20000000 0x20000800 0x1000 ~~/demo/arm/flash/long/eefcsam4e.bin
RETURN