;------------------------------------------------------------------------------------
; 10 Feb 20 - Richard Woodruff - launch for pdk test
; 10 Mar 20 - Richard Woodruff - paths for both Linux/Windows
; 19 Aug 20 - Richard Woodruff - Use TRACE32 terminals
;------------------------------------------------------------------------------------
; Launch for DSP C7000 core
;
; 0: The script J721E.cmm should set &__DMSC_FLOW=(1.) to run this
; 1: Update Paths & core selection to match what test should be loaded.
; 2: Select proper port for test. For example: UART (MCU or MAIN) for test.  Not the same UART for all CORES.

 &sys_bios = "yes"
 &SCIR5="SCIR5"; "SCIR5" for SDK >=7.03 : "" for SDK<=7.02

; Add Linux or Windows paths to component symbols
 &opath="d:"
;&opath="/opt"

 LOCAL &uart_tst &cpu &test

; Add paths to component symbols
 IF ("&SCIR5"=="SCIR5") 
   &uart_tst="&opath/syms/sysbios/sci_UART_TestApp/UART_TestApp/bin/j721e_evm/7_03"
 ELSE
   &uart_tst="&opath/syms/sysbios/sci_UART_TestApp/UART_TestApp/bin/j721e_evm"
 
 &sysbios_base="&opath/syms/sysbios/bios_6_76_03_01"
 &ndk_base="&opath/syms/sysbios/pdk"

 &cpu="DRA829-C71X"  ; DRA829-C71X
 &test="&uart_tst/UART_j721e_evm_c7x_1TestApp_release.xe71"

 DO ~~~~/pdk_launch_js_common.cmm &SCIR5

 IF !INTERCOM.PING(C71)
        TargetSystem.NewInstance C71 /ARCHitecture C7000
 InterCom C71 TITLE "TRACE32 for J721E-C71 - SLAVE"
 InterCom C71 SYStem.CPU &cpu
 InterCom C71 SYStem.CONFIG CORE 12. 1.
 InterCom C71 SYStem.Option EnReset OFF

 ; release C71 from reset
	Data.Set EDBG:0x40000320 %Long 0yxxxxxxxxxxxxxx1000xxxxxxxxxxxxxx

 InterCom C71 SYStem.Up
 InterCom.WAIT C71

 InterCom C71 Break
 InterCom C71 TRACE.Method.onchip
 InterCom C71 tpiu.PortMode.Continuous
 InterCom C71 Data.LOAD.elf "&test" /plusvm
 InterCom.WAIT C71

; Open 1st terminal on UART for uart test input/output
; the script could be extended to run the test automatically
 InterCom C71 term.reset
 InterCom C71 term.method #1 com \\.\COM24 115200. 8 NONE 1STOP NONE
 InterCom C71 term.size #1 80. 24. 500.
 InterCom C71 term.mode #1 vt100
 InterCom C71 term.scroll #1 on
 InterCom C71 WinPOS ,,,,,, uart, Normal "UART Test input/output"
 InterCom C71 term.gate #1

; load up source paths
 ; InterCom symbol.sourcepath.setrecursedir &sysbios_base
 ; InterCom symbol.sourcepath.setrecursedir + &ndk_base

 InterCom C71 Register /sl
 InterCom C71 data.list

 ;InterCom C71 b.s exit /onchip
 InterCom C71 b.s abort /onchip

 InterCom C71 FramePOS ,,,, Top
 InterCom C71 wintop uart

 InterCom C71 go main /onchip            ; Run till main and stop
 InterCom.WAIT C71 !RUN()
 IF ("&sys_bios"=="yes")
 (
   ; Load SYS/BIOS awareness
   InterCom C71 MAP.DENYACCESS 0x100000000--0xffffffffffffffff
   InterCom C71 task.config ~~/demo/c7000/kernel/sysbios/sysbios.t32
   InterCom C71 menu.reprogram ~~/demo/c7000/kernel/sysbios/sysbios.men
   InterCom C71 HELP.FILTER.Add rtossysbios
   InterCom C71 TASK.STacK.PATtern 0xbe        ; stack fill pattern

   ; open up semi-host term for debug output
   InterCom C71 TERM.size #2 80. 50. 200.
   InterCom C71 TERM.METHOD #2 CCIO C$$IO$$ _CIOBUF_
   InterCom C71 WinPOS ,,,,,, semihost, Normal "SemiHost Console"
   InterCom C71 TERM.GATE #2
   InterCom C71 Break.Set C$$IO$$
 )

 InterCom C71 go

 enddo
