新增所有文件
This commit is contained in:
261
devices/script/Trace32/download.cmm
Normal file
261
devices/script/Trace32/download.cmm
Normal file
@@ -0,0 +1,261 @@
|
||||
|
||||
ON ERROR JUMPTO EXIT
|
||||
|
||||
LOCAL &flashloader_pathname §or_size
|
||||
Var.NEWLOCAL char[10][128] \download_file_pathname
|
||||
Var.NEWLOCAL char[10][128] \download_file_address
|
||||
|
||||
; User Config Download Options
|
||||
|
||||
;&flashloader_pathname="~~~~/../../E3104/flashloader/flashloader_norflash.out"
|
||||
;Var.set \download_file_pathname[0]="semi drive/e3/test/sfs.bin"
|
||||
;Var.set \download_file_address[0]="0x10000000"
|
||||
;Var.set \download_file_pathname[1]="semi drive/e3/test/rfd.bin"
|
||||
;Var.set \download_file_address[1]="0x100000F0"
|
||||
;Var.set \download_file_pathname[2]="semi drive/e3/test/boot0.bin"
|
||||
;Var.set \download_file_address[2]="0x100C0000"
|
||||
;Var.set \download_file_pathname[3]="semi drive/e3/test/boot1.bin"
|
||||
;Var.set \download_file_address[3]="0x104C0000"
|
||||
;Var.set \download_file_pathname[4]="semi drive/e3/test/boot2.bin"
|
||||
;Var.set \download_file_address[4]="0x108C0000"
|
||||
|
||||
&flashloader_pathname="~~~~/../../E3640/flashloader/flashloader_hyperflash.out"
|
||||
Var.set \download_file_pathname[0]="~~/semi drive/e3/test pathhavespace/sfs.bin"
|
||||
Var.set \download_file_address[0]="0x10000000"
|
||||
Var.set \download_file_pathname[1]="~~/semi drive/e3/test pathhavespace/rfd.bin"
|
||||
Var.set \download_file_address[1]="0x100000F0"
|
||||
Var.set \download_file_pathname[2]="~~/semi drive/e3/test pathhavespace/boot0.bin"
|
||||
Var.set \download_file_address[2]="0x100C0000"
|
||||
Var.set \download_file_pathname[3]="~~/semi drive/e3/test pathhavespace/boot1.bin"
|
||||
Var.set \download_file_address[3]="0x104C0000"
|
||||
Var.set \download_file_pathname[4]="~~/semi drive/e3/test pathhavespace/boot2.bin"
|
||||
Var.set \download_file_address[4]="0x108C0000"
|
||||
|
||||
;&flashloader_pathname="~~~~/../../E3104/flashloader/flashloader_norflash.out"
|
||||
;Var.set \download_file_pathname[0]="~~/semi drive/e3/test pathhavespace/sfs.bin"
|
||||
;Var.set \download_file_address[0]="0x10000000"
|
||||
;Var.set \download_file_pathname[1]="~~/semi drive/e3/test pathhavespace/rfd.bin"
|
||||
;Var.set \download_file_address[1]="0x100000F0"
|
||||
;Var.set \download_file_pathname[2]="~~/semi drive/e3/test pathhavespace/boot0.bin"
|
||||
;Var.set \download_file_address[2]="0x10007000"
|
||||
;Var.set \download_file_pathname[3]="~~/semi drive/e3/test pathhavespace/boot1.bin"
|
||||
;Var.set \download_file_address[3]="0x10407000"
|
||||
;Var.set \download_file_pathname[4]="~~/semi drive/e3/test pathhavespace/boot2.bin"
|
||||
;Var.set \download_file_address[4]="0x10807000"
|
||||
|
||||
;&flashloader_pathname="~~~~/../../E3104/flashloader/flashloader_norflash.out"
|
||||
;Var.set \download_file_pathname[0]="test_noflashloader/sfs.bin"
|
||||
;Var.set \download_file_address[0]="0x10000000"
|
||||
;Var.set \download_file_pathname[1]="test_noflashloader/rfd.bin"
|
||||
;Var.set \download_file_address[1]="0x100000F0"
|
||||
;Var.set \download_file_pathname[2]="test_noflashloader/boot0.bin"
|
||||
;Var.set \download_file_address[2]="0x100C0000"
|
||||
;Var.set \download_file_pathname[3]="test_noflashloader/boot1.bin"
|
||||
;Var.set \download_file_address[3]="0x104C0000"
|
||||
;Var.set \download_file_pathname[4]="test_noflashloader/boot2.bin"
|
||||
;Var.set \download_file_address[4]="0x108C0000"
|
||||
|
||||
;&flashloader_pathname="test_nobin/flashloader.out"
|
||||
;Var.set \download_file_pathname[0]="test_nobin/sfs.bin"
|
||||
;Var.set \download_file_address[0]="0x10000000"
|
||||
;Var.set \download_file_pathname[1]="test_nobin/rfd.bin"
|
||||
;Var.set \download_file_address[1]="0x100000F0"
|
||||
;Var.set \download_file_pathname[2]="test_nobin/boot0.bin"
|
||||
;Var.set \download_file_address[2]="0x100C0000"
|
||||
;Var.set \download_file_pathname[3]="test_nobin/boot1.bin"
|
||||
;Var.set \download_file_address[3]="0x104C0000"
|
||||
;Var.set \download_file_pathname[4]="test_nobin/boot2.bin"
|
||||
;Var.set \download_file_address[4]="0x108C0000"
|
||||
|
||||
GOSUB CHECK_FILE_IS_EXIST "&flashloader_pathname"
|
||||
GOSUB CHECK_FILES_IS_EXIST \download_file_pathname
|
||||
GOSUB INIT
|
||||
GOSUB DOWNLOAD_FILES \download_file_pathname \download_file_address §or_size
|
||||
|
||||
EXIT:
|
||||
IF OS.FILE(flashloader.bin)==TRUE()
|
||||
RM flashloader.bin
|
||||
ON ERROR inherit
|
||||
ENDDO
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
INIT:
|
||||
; jtag clock config
|
||||
SYStem.JtagClock 20MHz
|
||||
|
||||
; cpu config
|
||||
SYStem.CPU CortexR5F
|
||||
|
||||
; mem access port
|
||||
SYStem.CONFIG.apbaccessport 0
|
||||
SYStem.CONFIG.apbap1.base 0x2000
|
||||
SYStem.CONFIG.debugaccessport 0
|
||||
SYStem.CONFIG.debugap1.base 0x2000
|
||||
|
||||
; DBG
|
||||
SYStem.CONFIG.COREDEBUG.Base 0xF2081000
|
||||
|
||||
SYStem.attach
|
||||
|
||||
Break
|
||||
|
||||
PRIVATE &tcm_base &program_begin &program_end &arg_base
|
||||
|
||||
; disable mpu and cache
|
||||
Data.SET C15:0x0001 0x08E7087A
|
||||
Data.SET C15:0x0101 0x00000020
|
||||
|
||||
; init tcm
|
||||
Data.LOAD.Elf "&flashloader_pathname" /NoCode
|
||||
&tcm_base=ADDRESS.OFFSET(sYmbol.SECADDRESS(PrgCode))
|
||||
&program_begin=ADDRESS.OFFSET(sYmbol.SECADDRESS(T32CodeBegin))
|
||||
&program_end=ADDRESS.OFFSET(sYmbol.SECEND(T32CodeEnd))
|
||||
Data.SET C15:0x0019 (&tcm_base+0x10000)|0x1
|
||||
Data.SET C15:0x0119 &tcm_base|0x1
|
||||
|
||||
; generate flashloader.bin
|
||||
Data.LOAD.Elf "&flashloader_pathname"
|
||||
Data.SAVE.Binary flashloader.bin D:&program_begin--&program_end
|
||||
|
||||
; calc config para
|
||||
&info_base=ADDRESS.OFFSET(sYmbol.SECADDRESS(DevDscr))
|
||||
§or_size=DATA.Long(D:(&info_base+0xA0))
|
||||
&arg_base=&tcm_base+0x20000-0x2020
|
||||
|
||||
FLASH.RESet
|
||||
|
||||
FLASH.Create 1. 0x10000000--0x11FFFFFF §or_size TARGET LONG
|
||||
FLASH.TARGET &program_begin &arg_base 0x1000 flashloader.bin /STACKSIZE 0x1000
|
||||
; test error handle
|
||||
;FLASH.TARGET &program_begin &arg_base 0x1000++ flashloader.bin /STACKSIZE 0x1000
|
||||
|
||||
RETURN
|
||||
|
||||
|
||||
|
||||
CHECK_FILES_IS_EXIST:
|
||||
PRIVATE &i &file_pathname &file_pathname_len
|
||||
ENTRY &file_pathname_array
|
||||
&i=0.
|
||||
WHILE &i<10
|
||||
(
|
||||
&file_pathname_len=STRing.LENgth(Var.STRing(&file_pathname_array[&i]))
|
||||
IF &file_pathname_len!=0
|
||||
(
|
||||
&file_pathname = Var.STRing(&file_pathname_array[&i])
|
||||
GOSUB CHECK_FILE_IS_EXIST "&file_pathname"
|
||||
&i=&i+1
|
||||
)
|
||||
ELSE
|
||||
(
|
||||
IF &i!=0
|
||||
RETURN
|
||||
ELSE
|
||||
ENDDO
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
CHECK_FILE_IS_EXIST:
|
||||
ENTRY &file_pathname
|
||||
IF OS.FILE(&file_pathname)==FALSE()
|
||||
(
|
||||
PRINT &file_pathname " is not exist"
|
||||
ENDDO
|
||||
)
|
||||
ELSE
|
||||
RETURN
|
||||
|
||||
|
||||
|
||||
DOWNLOAD_FILES:
|
||||
PRIVATE &i &file_pathname &file_pathname_len &file_address
|
||||
ENTRY &file_pathname_array &file_address_array §or_size
|
||||
&i=0.
|
||||
WHILE &i<10
|
||||
(
|
||||
&file_pathname_len=STRing.LENgth(Var.STRing(&file_pathname_array[&i]))
|
||||
IF &file_pathname_len!=0
|
||||
(
|
||||
&file_pathname = Var.STRing(&file_pathname_array[&i])
|
||||
&file_address = Var.STRing(&file_address_array[&i])
|
||||
GOSUB DOWNLOAD_FILE "&file_pathname" &file_address §or_size
|
||||
&i=&i+1
|
||||
)
|
||||
ELSE
|
||||
(
|
||||
RETURN
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
||||
DOWNLOAD_FILE:
|
||||
PRIVATE &file_size §or_num &erase_address_end
|
||||
ENTRY &download_file_pathname &download_file_address &download_sector_size
|
||||
|
||||
IF &download_file_address%&download_sector_size==0
|
||||
(
|
||||
&file_size=OS.FILE.SIZE(&download_file_pathname)
|
||||
IF &file_size%&download_sector_size==0
|
||||
§or_num=&file_size/&download_sector_size
|
||||
ELSE
|
||||
§or_num=&file_size/&download_sector_size+1
|
||||
&erase_address_end=CONVert.INTTOHEX(&download_file_address+§or_num*§or_size-1)
|
||||
FLASH.Erase &download_file_address--&erase_address_end
|
||||
)
|
||||
FLASH.Program ALL
|
||||
Data.LOAD.Binary &download_file_pathname &download_file_address
|
||||
FLASH.Program OFF
|
||||
|
||||
RETURN
|
||||
|
||||
60
devices/script/Trace32/e3_attach_sf.cmm
Normal file
60
devices/script/Trace32/e3_attach_sf.cmm
Normal file
@@ -0,0 +1,60 @@
|
||||
; --------------------------------------------------------------------------------
|
||||
; @Title: Example for manual JTAG access, Debugger in DOWN Mode
|
||||
; @Description:
|
||||
;This script reads out the IDCODE of an ARM7 core when the debugger is in
|
||||
;DOWN mode.
|
||||
;Detailed knowledge about JTAG is required to use manual JTAG control signals!
|
||||
;Tested on an ARM7 target board.
|
||||
; @Keywords: idcode
|
||||
; @Author: PEG
|
||||
; @Props: Template
|
||||
; @Copyright: (C) 1989-2014 Lauterbach GmbH, licensed for use with TRACE32(R) only
|
||||
; --------------------------------------------------------------------------------
|
||||
; $Id: example1.cmm 6982 2023-02-22 11:10:17Z kjmal $
|
||||
; @Copyright: Semidrive semiconductor
|
||||
; @Title: Semidrive Secure Debug logic.
|
||||
; The debugger is in DOWN mode, the JTAG driver is tristated.
|
||||
|
||||
area
|
||||
SYStem.CPU CortexR5
|
||||
SYStem.CONFIG.apbaccessport 0
|
||||
SYStem.CONFIG.apbap1.base 0x2000
|
||||
SYStem.CONFIG.debugaccessport 0
|
||||
SYStem.CONFIG.debugap1.base 0x2000
|
||||
SYStem.CONFIG.COREDEBUG.Base 0xF2081000
|
||||
;e3
|
||||
;SYStem.CONFIG.COREDEBUG.Base 0xF0a01000
|
||||
SYStem.Option.TRST OFF
|
||||
SYStem.JtagClock 1MHz
|
||||
JTAG.PIN ENable
|
||||
; enable JTAG output driver
|
||||
JTAG.SHIFTTMS 1 1 1 1 1
|
||||
; soft reset of the JTAG interface, goto Test-Logic Reset state
|
||||
JTAG.SHIFTTMS 0 1 1 0 0
|
||||
; goto Shift-IR state
|
||||
JTAG.SHIFTREG 1 1 1 1
|
||||
; shift in UID instruction, goto exit1-ir
|
||||
JTAG.SHIFTTMS 1 1 0 0
|
||||
; goto Shift-DR state
|
||||
JTAG.SHIFTREG %long 0x0 0x0
|
||||
; shift in 64bit dummy code. shift out our uid, goto exit1-dr
|
||||
PRINT JTAG.SHIFT()
|
||||
; print the UID
|
||||
JTAG.SHIFTTMS 1 1 0 0
|
||||
; goto Shift-DR state
|
||||
JTAG.SHIFTREG %long 0x74657374 0x6b657930
|
||||
; Note: 0x74657374 --> SEC_DBG_CFG[31, 0]!!, 0x6b657930 --> SEC_DBG_CFG[63, 32]!!
|
||||
; shift in the corresponding key .shift out our uid, goto exit1-dr
|
||||
PRINT JTAG.SHIFT()
|
||||
JTAG.SHIFTTMS 1 1 1 1 1
|
||||
; goto Test-Logic Reset state
|
||||
JTAG.SHIFTTMS 0 1 0 0
|
||||
; goto Shift-DR state
|
||||
JTAG.SHIFTREG %long 0x0
|
||||
; shift our IDCODE, goto exit1-dr
|
||||
PRINT JTAG.SHIFT()
|
||||
JTAG.PIN Disable
|
||||
; Disable JTAG output driver
|
||||
SYStem.Mode Attach
|
||||
;attach
|
||||
ENDDO
|
||||
38
devices/script/Trace32/readme
Normal file
38
devices/script/Trace32/readme
Normal file
@@ -0,0 +1,38 @@
|
||||
## 简介
|
||||
|
||||
介绍通过Trac32使用secure debug功能
|
||||
该功能支持JTAG模式,不支持SWD模式
|
||||
芯片匹配debug key成功后开启debug接口
|
||||
|
||||
##硬件连接
|
||||
|
||||
- e3_gateway参考板
|
||||
- Trace32
|
||||
|
||||
##注意事项
|
||||
- 确认板子JTAG功能正常,对于e3 gateway参考板需要去掉TDO/TDI上的两个电阻。
|
||||
- 需要通过fuse工具烧UID,debug key和使能secure debug。
|
||||
- 接口如果是SWD,需要修改为JTAG。
|
||||
|
||||
##测试方法
|
||||
当板子以以下方式烧UID,debug key和使能secure debug.
|
||||
Debug Key:
|
||||
+-----------------------+------------+------------------+
|
||||
| name | fuse addr | fuse value |
|
||||
+-----------------------+------------+------------------+
|
||||
| UID[0, 31] | 0x1010 | 0x12345678 |
|
||||
| UID[32, 63] | 0x1014 | 0xABCDEF88 |
|
||||
| SEC_DBG_CFG[31, 0] | 0x1280 | 0x74657374(key0) |
|
||||
| SEC_DBG_CFG[63, 32] | 0x1284 | 0x6b657930(key1) |
|
||||
| MSIC_CFG3/SDBG_MODE | 0x12b0 | 0x00800000 |
|
||||
+-----------------------+------------+------------------+
|
||||
|
||||
脚本拖入trace32.exe并执行
|
||||
CD.DO 本地路径\e3_attach_sf.cmm
|
||||
|
||||
提供错误的debug key则无法执行通过。
|
||||
|
||||
##expected log
|
||||
0ABCDEF8812345678
|
||||
0ABCDEF8812345678
|
||||
4BA00477
|
||||
Reference in New Issue
Block a user