# SiPEED USB-JTAG/TTL based on FT2232D
adapter driver ftdi
ftdi_vid_pid 0x0403 0x6010
# http://blog.sipeed.com/p/727.html
ftdi_channel 0
transport select jtag
adapter speed     8000

ftdi_layout_init 0x0508 0x0f1b
ftdi_layout_signal nTRST -data 0x0200 -noe 0x0100
ftdi_layout_signal nSRST -data 0x0800 -noe 0x0400

set _CHIPNAME riscv
#jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000001
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x0

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME
#$_TARGETNAME.0 configure -work-area-phys 0x80000000 -work-area-size 10000 -work-area-backup 1
#$_TARGETNAME.0 configure -work-area-phys 0x50000000 -work-area-size 32768 -work-area-backup 0
$_TARGETNAME.0 configure -work-area-phys 0x22020000 -work-area-size 0x10000 -work-area-backup 0
riscv set_reset_timeout_sec 10
riscv set_prefer_sba on
##riscv set_command_timeout_sec 1000
echo "SiPEED USB-JTAG/TTL Ready for Remote Connections"
