1adapter speed  10000
2adapter driver ftdi
3
4ftdi device_desc "Dual RS232-HS"
5ftdi vid_pid 0x0403 0x6010
6ftdi layout_init 0x0008 0x000b
7ftdi layout_signal nSRST -data 0x0020 -oe 0x0020
8
9set _CHIPNAME riscv
10jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10e31913
11
12set _TARGETNAME $_CHIPNAME.cpu
13target create $_TARGETNAME riscv -chain-position $_TARGETNAME
14$_TARGETNAME configure -work-area-phys 0x80000000 -work-area-size 10000 -work-area-backup 1
15
16flash bank onboard_spi_flash fespi 0x20000000 0 0 0 $_TARGETNAME
17
18proc hifive1-load {file} {
19        flash protect 0 64 last off
20        flash write_image erase $file
21}
22
23proc hifive1-reset-halt {} {
24	halt
25}
26
27proc hifive1-post-verify {} {
28	# `reset halt` not correctly works.
29	# toggles the nSRST directly.
30	ftdi set_signal nSRST 0
31	ftdi set_signal nSRST z
32	shutdown
33}
34
35$_TARGETNAME configure -event gdb-attach {
36        halt
37        gdb_breakpoint_override hard
38}
39
40$_TARGETNAME configure -event gdb-detach {
41        resume
42        shutdown
43}