adapter driver ftdi
ftdi device_desc "Olimex OpenOCD JTAG ARM-USB-TINY-H"
ftdi vid_pid 0x15ba 0x002a

transport select jtag

adapter speed 20000

ftdi layout_init 0x0808 0x0a1b
ftdi layout_signal nSRST -oe 0x0200
ftdi layout_signal nTRST -data 0x0100 -oe 0x0100
ftdi layout_signal LED -data 0x0800

set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x00000cfd
 
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME

echo "configure work area .................."
$_TARGETNAME configure -work-area-phys 0x80000000 -work-area-size 0x80000000 -work-area-backup 0
echo "configure work area complete.................."

echo "configure flash bank.................."
flash bank onboard_spi_flash fespi 0x20000000 0 0 0 $_TARGETNAME 0x10010000 
echo "configure flash bank complete .................."

init
reset init
halt
