190 lines
5.2 KiB
Plaintext
190 lines
5.2 KiB
Plaintext
; --------------------------------------------------------------------------------
|
|
; @Title: FDX Communication Demo for ARM7/9/11, XSCALE, CortexA/R/M (32/64-bit)
|
|
; @Description:
|
|
; This script shows how to use the FDX communication on ARM.
|
|
; The demo code is compiled as position independent code and should run on
|
|
; every ARM platform. Per default we use DCC as transfer channel. As e.g.
|
|
; CortexM does not support DCC, we use the RunTimeMemoryAccess to
|
|
; demonstrate FDX on CortexM.
|
|
; For more information about FDX, please refer to general_ref_f.pdf
|
|
;
|
|
; Prerequisites:
|
|
; * System is connected
|
|
; * RAM is accessible Read/Write/Execute
|
|
;
|
|
; Usage:
|
|
; DO ~~/demo/arm/fdx/fdxtarget <RamStart>
|
|
; e.g. DO ~~/demo/arm/fdx/fdxtarget 0x1000
|
|
; @Author: MAZ AME
|
|
; @Copyright: (C) 1989-2022 Lauterbach GmbH, licensed for use with TRACE32(R) only
|
|
; --------------------------------------------------------------------------------
|
|
; $Id: fdxtarget.cmm 18850 2022-01-26 18:41:29Z bschroefel $
|
|
|
|
PRIVATE ¶m &offset
|
|
ENTRY ¶m
|
|
|
|
; Prerequisites: Simulator? Connected? RemoteAPI activated?
|
|
IF INTERFACE.SIM()
|
|
(
|
|
PRINT %ERROR "Error: This demo does not work with the simulator."
|
|
ENDDO FALSE()
|
|
)
|
|
IF !SYSTEM.UP()
|
|
(
|
|
PRINT %ERROR "Error: Please connect to the CPU first."
|
|
ENDDO FALSE()
|
|
)
|
|
IF RCL.PORT(0)!=20000.
|
|
(
|
|
PRINT %ERROR "Error: This example requires the RemoteAPI to run on PORT 20000."
|
|
ENDDO FALSE()
|
|
)
|
|
|
|
GOSUB ParseParameters ¶m
|
|
ENTRY &offset
|
|
|
|
IF (CPU.FEATURE(SPR))
|
|
(
|
|
; AArch64 capable CPU
|
|
; detect AArch mode by checking bit4 of the M field of CPSR
|
|
IF ((Register(M)&0x10)==0x0)
|
|
(
|
|
Data.LOAD.Elf ~~~~/fdxtarget_pic_aarch64.elf &offset /RelPATH /Verify
|
|
)
|
|
ELSE IF (((Register(M)&0x10)!=0x0)&&Register(E)==0.)
|
|
(
|
|
; AArch32 mode
|
|
IF Register(T)==0.
|
|
Data.LOAD.Elf ~~~~/fdxtarget_pic_arm11_cortex.elf &offset /RelPATH /Verify
|
|
ELSE
|
|
Data.LOAD.Elf ~~~~/fdxtarget_pic_thumb_ii_v7.elf &offset /RelPATH /Verify
|
|
)
|
|
ELSE
|
|
(
|
|
PRINT %ERROR "Error: Coretype not supported by this script."
|
|
ENDDO FALSE()
|
|
)
|
|
)
|
|
ELSE IF (STRing.SCAN(CORENAME(),"ARM7",0)>=0)||(STRing.SCAN(CORENAME(),"ARM9",0)>=0)
|
|
(
|
|
Data.LOAD.Elf ~~~~/fdxtarget_pic_arm7_arm9.elf &offset /RelPATH /Verify
|
|
)
|
|
ELSE IF (STRing.SCAN(CORENAME(),"ARM11",0)>=0)||(STRing.SCAN(CORENAME(),"CORTEXA",0)>=0)
|
|
(
|
|
Data.LOAD.Elf ~~~~/fdxtarget_pic_arm11_cortex.elf &offset /RelPATH /Verify
|
|
)
|
|
ELSE IF (STRing.SCAN(CORENAME(),"CORTEXM0",0)>=0)||(STRing.SCAN(CORENAME(),"CORTEXM1",0)>=0)
|
|
(
|
|
Data.LOAD.Elf ~~~~/fdxtarget_pic_thumb_v6m.elf &offset /RelPATH /Verify
|
|
)
|
|
ELSE IF (STRing.SCAN(CORENAME(),"CORTEXM3",0)>=0)||(STRing.SCAN(CORENAME(),"CORTEXM4",0)>=0)||(STRing.SCAN(CORENAME(),"CORTEXM7",0)>=0)
|
|
(
|
|
Data.LOAD.Elf ~~~~/fdxtarget_pic_thumb_ii_v7m.elf &offset /RelPATH /Verify
|
|
)
|
|
ELSE IF (STRing.SCAN(CORENAME(),"XSCALE",0)>=0)
|
|
(
|
|
Data.LOAD.Elf ~~~~/fdxtarget_pic_xscale.elf &offset /RelPATH /Verify
|
|
)
|
|
ELSE IF (STRing.SCAN(CORENAME(),"CORTEXR",0)>=0)
|
|
(
|
|
IF ((Data.Long(C15:0x1)&0x80000000)!=0x0)
|
|
Data.LOAD.Elf ~~~~/fdxtarget_pic_arm11_cortex_be.elf &offset /RelPATH /Verify
|
|
ELSE
|
|
Data.LOAD.Elf ~~~~/fdxtarget_pic_arm11_cortex.elf &offset /RelPATH /Verify
|
|
)
|
|
ELSE
|
|
(
|
|
PRINT %ERROR "Error: Coretype not supported by this script."
|
|
ENDDO FALSE()
|
|
)
|
|
|
|
; preboot executable - run to *main*
|
|
Go main
|
|
WAIT !STATE.RUN()
|
|
|
|
; --------------------------------------------------------------------------------
|
|
; The actual FDX stuff starts here
|
|
|
|
; clear windows
|
|
WinCLEAR FDXOC
|
|
WinCLEAR FDXIC
|
|
|
|
; fdx transfer method configuration
|
|
; as CortexM has no DCC, check if the T32_TsMon_ReceiveStatus is available
|
|
; yes -> use DCC
|
|
; no -> use Memory Buffer with RuntimeMemory Access
|
|
IF sYmbol.EXIST(T32_TsMon_ReceiveStatus)
|
|
(
|
|
; select FDX method - must match the T32_FDX_DCCx define
|
|
FDX.METHOD DCC4
|
|
|
|
; open and show channels
|
|
WinPOS 0 0 ,,,,, FDXOC
|
|
FDX.OutChannel
|
|
WinPOS 0 20. ,,,,, FDXIC
|
|
FDX.InChannel
|
|
)
|
|
ELSE
|
|
(
|
|
SYStem.MemAccess DAP
|
|
FDX.DISable
|
|
FDX.METHOD BUFFERE
|
|
|
|
; open and show channels
|
|
WinPOS 0 0 ,,,,, FDXOC
|
|
FDX.OutChannel FdxTestSendBuffer
|
|
WinPOS 0 20. ,,,,, FDXIC
|
|
FDX.InChannel FdxTestReceiveBuffer
|
|
)
|
|
|
|
WAIT 1s
|
|
|
|
;Start FDX test application
|
|
LOCAL &systempath &t32fdxhostparam
|
|
&systempath=OS.PSD()
|
|
&t32fdxhostparam="localhost"
|
|
|
|
IF OS.VERSION(0)<0x10
|
|
OS.Command cmd /k "&systempath\demo\api\capi\test\t32fdxhost.exe &t32fdxhostparam"
|
|
ELSE
|
|
(
|
|
IF OS.FILE.EXIST("&systempath/demo/api/capi/test/t32fdxhost")
|
|
(
|
|
OS.Command "&systempath/demo/api/capi/test/t32fdxhost &t32fdxhostparam"
|
|
)
|
|
ELSE
|
|
(
|
|
PRINT %ERROR "Host executable ""&systempath/demo/api/capi/test/t32fdxhost"" not found"
|
|
ENDDO
|
|
)
|
|
)
|
|
|
|
PRINT "Press Go to start test"
|
|
|
|
ENDDO TRUE()
|
|
|
|
; --------------------------------------------------------------------------------
|
|
; SUBROUTINES
|
|
;
|
|
ParseParameters: ;(param)
|
|
LOCAL ¶m &offset
|
|
ENTRY ¶m
|
|
&offset=STRing.SCANAndExtract("¶m","0x","")
|
|
IF "&offset"==""
|
|
(
|
|
PRINT %ERROR "Error: Missing Argument - Usage DO fdxtarget.cmm 0x<offset> "
|
|
ENDDO FALSE()
|
|
)
|
|
; ensure parameter is HEX and round down to the nearest LONG
|
|
&offset="0x&offset"
|
|
&offset=(&offset)&~0x3
|
|
|
|
IF !SYStem.Up()
|
|
(
|
|
PRINT %ERROR "Error: Not connected to target. - Please use SYStem.Up before."
|
|
ENDDO FALSE()
|
|
)
|
|
|
|
RETURN &offset
|
|
|