Files
2025-10-14 09:52:32 +09:00

164 lines
4.9 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;-------------------------------------------------------------------------------
; @Title: Flash declaration for Kinetes k32l2b internal flash derivatives
; @Description:
; Script arguments:
; DO k32l2b [PREPAREONLY] [CPU=<cpu>] [DUALPORT=<0|1>]
; PREPAREONLY only declares flash but does not execute flash programming
; CPU=<cpu> selects CPU derivative <cpu>
; DUALPORT=<0|1> use dual port memory access, default 1
; Example:
; DO ~~/demo/arm/flash/k32l2b PREPAREONLY
; Note:
; This file must NOT be modified.
; This file is intended to stay within TRACE32 installation.
; Usage examples are available in the ~~/demo/arm/hardware/... subdirectories.
;
; List of k32l2b* derivatives and their configuration:
;
; CPU-Type Program Sector RamSize Block0 Block1
; Flash[KB] size[KB] [KB]
; ----------------------------------------------------------------------------
; K32L2B1* 64 1 32 0x0- 0x7FFF 0x8000 - 0xFFFF
; K32L2B2* 128 1 32 0x0- 0xFFFF 0x10000 - 0x1FFFF
; K32L2B3* 256 1 32 0x0-0x1FFFF 0x20000 - 0x3FFFF
;
; Program Flash IFR Map:
; Byte address Width Description
; ----------------------------------------------------------------------------
; 0x0--0xBF 192 Reserved
; 0xC0--0xFF 64 Program Once Field
;
; Flash Configuration Field:
;
; Byte address Width Description
; ----------------------------------------------------------------------------
; 0x0400--0x0407 8 Backdoor Comparison Key.
; 0x0408--0x040B 4 Program flash protection bytes (FPROT0-3).
; 0x040F 1 Reserved
; 0x040E 1 Reserved
; 0x040D 1 Flash nonvolatile option byte (FOPT).
; 0x040C 1 Flash security byte (FSEC).
;
; Flash Configuration Field can be programmed using FLASH.AUTO command
; with /CENSORSHIP option.
;
; @Chip: K32L2B*
; @Author: FAL
; @Copyright: (C) 1989-2023 Lauterbach GmbH, licensed for use with TRACE32(R) only
; --------------------------------------------------------------------------------
; $Rev: 12687 $
; $Id: k32l2b.cmm 12687 2023-11-03 07:57:58Z flouati $
PRIVATE &parameters
ENTRY %LINE &parameters
PRIVATE &param_prepareonly &param_cpu &param_dualport
&parameters=STRing.UPpeR("&parameters")
&param_prepareonly=(STRing.SCAN("&parameters","PREPAREONLY",0)!=-1)
&param_cpu=STRing.SCANAndExtract("&parameters","CPU=","")
&param_dualport=STRing.SCANAndExtract("&parameters","DUALPORT=","1")
; --------------------------------------------------------------------------------
; Initialize and start the debugger
IF !SYStem.Up()
(
SYStem.RESet
IF "&param_cpu"!=""
SYStem.CPU &param_cpu
IF (!CPUIS(K32L2B*))
SYStem.CPU K32L2B*
SYStem.MemAccess DAP
IF CABLE.TWOWIRE()
SYStem.CONFIG.DEBUGPORTTYPE SWD
ELSE
SYStem.CONFIG.DEBUGPORTTYPE JTAG
Trace.METHOD none
SYStem.Up
GOSUB DisableWatchdog
)
; --------------------------------------------------------------------------------
; Flash declaration
FLASH.RESet
GOSUB FlashDeclaration "&param_dualport"
; Flash script ends here if called with parameter PREPAREONLY
IF &param_prepareonly
ENDDO PREPAREDONE
; --------------------------------------------------------------------------------
; Flash programming example
DIALOG.YESNO "Program flash memory?"
PRIVATE &progflash
ENTRY &progflash
IF &progflash
(
FLASH.ReProgram ALL /Erase
Data.LOAD.auto *
FLASH.ReProgram off
; Reset device
SYStem.Down
SYStem.Up
)
ENDDO
; --------------------------------------------------------------------------------
; SUBROUTINES
; --------------------------------------------------------------------------------
; Flash declaration depending on selected CPU
;
; Please do NOT modify the TRACE32 flash declaration.
;
; Modifications can result in unpredictable behavior.
; Please contact support@lauterbach.com for any changes.
FlashDeclaration: ;(param_dualport)
(
PARAMETERS &param_dualport
PRIVATE &SectorSize &SRAMAddress &FlashDriver &PFlashSize
IF CPUIS(K32L2B1*)
(
&PFlashSize=0x10000
)
ELSE IF CPUIS(K32L2B2*)
(
&PFlashSize=0x20000
)
ELSE IF CPUIS(K32L2B3*)
(
&PFlashSize=0x40000
)
&SectorSize=0x400 ;1KB sectors
&SRAMAddress=0x20000000
&FlashDriver="k32l2b.bin"
;Program FLASH Memory
; Protecting sensetive sectors
FLASH.Create 1. 0x0--((&PFlashSize/2)-1) 0x400 TARGET Long /CENSORSHIP 0x0--0x3ff /CENSORSHIP 0x400--0x7ff
FLASH.Create 2. (&PFlashSize/2)--(&PFlashSize-1) &SectorSize TARGET Long
IF (("&param_dualport"!="1")||SYStem.ACCESS.DENIED())
FLASH.TARGET &SRAMAddress &SRAMAddress+0x1000 0x1000 ~~/demo/arm/flash/long/&FlashDriver
ELSE
FLASH.TARGET &SRAMAddress E:&SRAMAddress+0x1000 0x1000 ~~/demo/arm/flash/long/&FlashDriver /DualPort
RETURN
)
DisableWatchdog:
(
; disable the Watchdog
Data.Set ESD:0x40048100 %LE %Long 0x0
RETURN
)