310 lines
7.3 KiB
Plaintext
310 lines
7.3 KiB
Plaintext
; --------------------------------------------------------------------------------
|
|
; @Title: NXP S32K1x FlexNVM partition tool
|
|
;
|
|
; @Description:
|
|
;
|
|
; The script allows defining the EEPROM and DFlash size of the FlexNVM.
|
|
; If an EEPROM size > 0 is selected, then automatically the FlexRAM will be
|
|
; configured for EEPROM usage, and it is disabled automatically when
|
|
; the FlexNVM is not used for EEPROM emulation.
|
|
;
|
|
; Script arguments:
|
|
;
|
|
; DO ~~/demo/arm/flash/s32k-eeprom-part.cmm
|
|
;
|
|
; Opens the S32K1x FlexNVM partition dialog.
|
|
;
|
|
; The dialog offers a button "Show" that generates a script snippet with
|
|
; all made settings, that you can embed into your own scripts.
|
|
;
|
|
; DO ~~/demo/arm/flash/s32k-eeprom-part.cmm PROGRAM PARTITIONCODE=xxxx
|
|
; [FORCE]
|
|
;
|
|
; Program the selected partition code.
|
|
; PARTITIONCODE Value of the device specific partition code
|
|
; (see S32K1xx manual)
|
|
; FORCE Force programming without asking for confirmation.
|
|
;
|
|
; CAUTION: For each change of the partitioning the debugger will force a
|
|
; mass erase of the device. So the partitioning should be done BEFORE
|
|
; any other flash operation!
|
|
;
|
|
; @Author: STK
|
|
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
|
|
; --------------------------------------------------------------------------------
|
|
; $Rev: 10715 $
|
|
; $Id: s32k-eeprom-part.cmm 10715 2022-03-15 16:17:34Z bwright $
|
|
|
|
LOCAL ¶ms
|
|
ENTRY %LINE ¶ms
|
|
|
|
LOCAL &script
|
|
LOCAL &cpu &list &selected &depart &string &warning
|
|
LOCAL &entry0 &entry0 &entry1 &entry2 &entry3 &entry4 &entry5 &entry6
|
|
|
|
&cpu=CPU()
|
|
&script=OS.PresentPracticeFile()
|
|
|
|
&entry0=""
|
|
&entry1=""
|
|
&entry2=""
|
|
&entry3=""
|
|
&entry4=""
|
|
&entry5=""
|
|
&entry6=""
|
|
|
|
&warning=""
|
|
|
|
IF !CPUIS("S32K1*")
|
|
(
|
|
PRINT %ERROR "Wrong CPU selected!"
|
|
ENDDO
|
|
)
|
|
ELSE IF CPUIS(S32K11*)
|
|
(
|
|
&entry0="0000: 32KB DFlash 0KB EEPROM"
|
|
&entry1="0011: 0KB DFlash 32KB EEPROM"
|
|
&entry2="1000: 0KB DFlash 32KB EEPROM"
|
|
&entry3="0001: 8KB DFlash 24KB EEPROM"
|
|
&entry4="1011: 32KB DFlash 0KB EEPROM"
|
|
&list="&entry0,&entry1,&entry2,&entry3,&entry4"
|
|
)
|
|
ELSE IF CPUIS(S32K148*)
|
|
(
|
|
&entry0="0000: 512KB DFlash 0KB EEPROM"
|
|
&entry1="0100: 448KB DFlash 64KB EEPROM"
|
|
&entry2="1111: 512KB DFlash 0KB EEPROM"
|
|
&list="&entry0,&entry1,&entry2"
|
|
)
|
|
ELSE
|
|
(
|
|
&entry0="0000: 64KB DFlash 0KB EEPROM"
|
|
&entry1="0011: 32KB DFlash 32KB EEPROM"
|
|
&entry2="0100: 0KB DFlash 64KB EEPROM"
|
|
&entry3="1000: 0KB DFlash 64KB EEPROM"
|
|
&entry4="1010: 16KB DFlash 48KB EEPROM"
|
|
&entry5="1011: 32KB DFlash 32KB EEPROM"
|
|
&entry6="1100: 64KB DFlash 0KB EEPROM"
|
|
&list="&entry0,&entry1,&entry2,&entry3,&entry4,&entry5,&entry6"
|
|
|
|
)
|
|
|
|
|
|
IF "¶ms"!=""
|
|
(
|
|
PRIVATE &program &partitioncode &string &force
|
|
|
|
&program=(STRing.SCAN(STRing.UPpeR("¶ms"),"PROGRAM",0)!=-1)
|
|
&partitioncode=STRing.SCANAndExtract(STRing.UPpeR("¶ms"),"PARTITIONCODE=","")
|
|
&force=(STRing.SCAN(STRing.UPpeR("¶ms"),"FORCE",0)!=-1)
|
|
|
|
|
|
IF (&program)&&("&partitioncode"!="")
|
|
(
|
|
GOSUB GetSelectString "&partitioncode"
|
|
RETURNVALUES &string
|
|
IF "&string"!=""
|
|
(
|
|
IF !&force
|
|
(
|
|
DIALOG.YESNO "Erase device and update FlexNVM partition?"
|
|
ENTRY &program
|
|
IF &program
|
|
GOSUB Program "&partitioncode"
|
|
ENDDO
|
|
)
|
|
)
|
|
|
|
)
|
|
)
|
|
|
|
IF !SYStem.Up()
|
|
(
|
|
PRINT %ERROR "Debugger needs to be in Up state!"
|
|
ENDDO
|
|
)
|
|
|
|
|
|
WinCLEAR "FlexNVMPartition"
|
|
|
|
WinPOS ,,44.
|
|
DIALOG
|
|
(&
|
|
NAME "FlexNVMPartition"
|
|
|
|
HEADER "FlexNVM for &cpu"
|
|
POS 1. 1. 11. 1.
|
|
TEXT "DEPART code:"
|
|
|
|
POS 12. 0. 30. 1.
|
|
WARNING: DYNTEXT ""
|
|
|
|
POS 12. 1. 30. 1.
|
|
SELECT: PULLDOWN "&list"
|
|
(
|
|
DIALOG.Set WARNING ""
|
|
)
|
|
|
|
POS 12. 3. 30. 1.
|
|
AUTOLOAD: CHECKBOX "FlexRAM loaded during reset" ""
|
|
|
|
POS 1. 5. 8. 1.5
|
|
BUTTON "Program"
|
|
(
|
|
PRIVATE &partitioncode
|
|
|
|
&partitioncode=STRing.MID(DIALOG.STRing("SELECT"),0.,4.)
|
|
|
|
DO &script PROGRAM PARTITIONCODE=&partitioncode
|
|
)
|
|
|
|
POS 10. 5. 8. 1.5
|
|
BUTTON "Show"
|
|
(
|
|
PRIVATE &tmpfilename &partitioncode
|
|
|
|
&partitioncode=STRing.MID(DIALOG.STRing("SELECT"),0.,4.)
|
|
|
|
&tmpfilename=OS.PresentTemporaryDirectory()
|
|
&tmpfilename="&tmpfilename/"+"flexnvm_programming.cmm"
|
|
|
|
OPEN #1 "&tmpfilename" /CREATE
|
|
|
|
WRITE #1 "// Generated by s32k-eeprom-part.cmm, "+DATE.DATE()+", "+DATE.TIME()
|
|
WRITE #1 ""
|
|
|
|
WRITE #1 "DO ~~/demo/arm/flash/s32k-eeprom-part.cmm PROGRAM &partitioncode"
|
|
WRITE #1 ""
|
|
WRITE #1 "ENDDO"
|
|
|
|
CLOSE #1
|
|
|
|
; Show file content
|
|
PEDIT "&tmpfilename"
|
|
)
|
|
|
|
POS 35. 5. 8. 1.5
|
|
BUTTON "Cancel" "DIALOG.END"
|
|
)
|
|
|
|
// Get values from target
|
|
&depart=FORMAT.Binary(4.,(Data.Long(ASD:0x4004804C)>>12.)&0xF) // SIM.FCFG1[DEPART]
|
|
|
|
GOSUB GetSelectString "&depart"
|
|
RETURNVALUES &string
|
|
|
|
IF "&string"==""
|
|
&warning="Warning: Target DEPART config invalid!"
|
|
|
|
DIALOG.Set SELECT "&string"
|
|
DIALOG.Set WARNING "&warning"
|
|
DIALOG.Set AUTOLOAD TRUE()
|
|
|
|
ENDDO
|
|
|
|
|
|
|
|
GetSelectString:
|
|
(
|
|
PARAMETERS &depart
|
|
PRIVATE &string &index &valid &rentry
|
|
|
|
&string=""
|
|
|
|
&valid=FALSE()
|
|
&index=0
|
|
WHILE (&index<7)&&!(&valid)
|
|
(
|
|
&rentry="&"+"entry"+FORMAT.UDecimal(1.,&index)
|
|
&&rentry="&rentry"
|
|
|
|
IF "&rentry"==""
|
|
(
|
|
&index=10. // Abort loop
|
|
)
|
|
ELSE IF "&depart"==STRing.MID("&rentry",0.,4.)
|
|
(
|
|
&valid=TRUE()
|
|
&string="&rentry"
|
|
)
|
|
|
|
&index=&index+1
|
|
)
|
|
|
|
RETURN "&string"
|
|
)
|
|
|
|
|
|
|
|
Program:
|
|
(
|
|
PRIVATE &program &datasizecode &partitioncode
|
|
PARAMETERS &partitioncode
|
|
|
|
IF "&partitioncode"==""
|
|
RETURN
|
|
|
|
FLASH.UNSECUREerase
|
|
SYStem.Up
|
|
|
|
&datasizecode=0xF
|
|
&partitioncode="0x"+FORMAT.HEX(2.,0y&partitioncode)
|
|
IF CPUIS("S32K11*")
|
|
(
|
|
IF (&partitioncode!=0x0)&&(&partitioncode!=0xB)
|
|
&datasizecode=0x3
|
|
)
|
|
ELSE IF CPUIS("S32K148*")
|
|
(
|
|
IF (&partitioncode==0x4)
|
|
&datasizecode=0x2
|
|
)
|
|
ELSE
|
|
(
|
|
IF (&partitioncode!=0x0)&&(&partitioncode!=0xC)
|
|
&datasizecode=0x2
|
|
)
|
|
|
|
// repartition DFlash to EEPROM
|
|
// disable Prefetch Buffer OCMDRx
|
|
Data.Set AD:0x40001400 %Long 0xXFFF
|
|
Data.Set AD:0x40001404 %Long 0xXFFF
|
|
Data.Set AD:0x40001408 %Long 0xXFFF
|
|
|
|
// issue Program Partition command
|
|
Data.Set AD:0x40020007 %Byte 0x80 // Program Partition
|
|
Data.Set AD:0x40020006 %Byte 0 // no CSEC
|
|
Data.Set AD:0x40020005 %Byte 0 // no SFE
|
|
IF DIALOG.BOOLEAN("AUTOLOAD")
|
|
Data.Set AD:0x40020004 %Byte 0 // auto load EEPROM on Reset
|
|
ELSE
|
|
Data.Set AD:0x40020004 %Byte 1 // no auto load EEPROM on Reset
|
|
Data.Set AD:0x4002000B %Byte &datasizecode // 4k EEPROM
|
|
Data.Set AD:0x4002000A %Byte &partitioncode // DEPART=4 -> 448k DFlash
|
|
|
|
// FCNFG - clear errors
|
|
IF (Data.Byte(AD:0x40020000)&0x71)!=0
|
|
Data.Set AD:0x40020000 %Byte Data.Byte(AD:0x40020000)&0x71
|
|
|
|
// FCNFG - start
|
|
Data.Set AD:0x40020000 %Byte 0x80
|
|
WAIT (Data.Byte(AD:0x40020000)&0x80)!=0 1s
|
|
|
|
IF (Data.Byte(AD:0x40020000)&0x80)==0
|
|
(
|
|
PRINT %ERROR "FlexNVM partitioning failed!"
|
|
)
|
|
ELSE
|
|
(
|
|
PRINT "FlexNVM partitioning done!"
|
|
)
|
|
|
|
// Reset and update flash configuration
|
|
SYStem.Up
|
|
|
|
DO ~~/demo/arm/flash/s32k.cmm PREPAREONLY
|
|
|
|
|
|
RETURN
|
|
)
|