在很久之前买了了sipeed的荔枝糖FPGA,就是安陆哪个片子,送了一个这个调试器,但是我个人来说就会fpga点个灯,太难的就不会了,这个调试器也就是一个摆设。今天逛淘宝看这个调试器已经涨到47块,加上10块的快递费,需要57,我那个时候35包邮?还是25?这么贵一定要用一下,要不然浪费了。
我手里还有一块longan,也是RISC-V内核的MCU,所以我就想用这个调试器作为jlink调试longan。
需要使用的软件有:
MounRiver Studio,UsbDriverTool
UsbDriverTool下载路径:Automatic USB driver installer for FTDI and LibUSB drivers
安装:usb driver
打开软件
到这一步驱动就配置好了,下一步我们就配置MounRiver Studio的debug信息
编译器原生的openocd配置文件不适合我们的logan,所以我就找了一个,放到了下边,需要就自己建一个文件弄进去,放到下边的文件夹。
adapter_khz 1000
reset_config srst_only
#adapter_nsrst_assert_width 1000
interface ftdi
ftdi_vid_pid 0x0403 0x6010
## If ftdi_device_desc not specified, the device description is ignored during device selection.
## So if you want to specify a dedicated FTDI device, you can select following device description:
## "Dual RS232-HS" is for RVSTAR V1 on-board debugger
## "USB <-> JTAG-DEBUGGER" is for RVSTAR V2 on-board debugger
## Uncomment one which match your device description
# ftdi_device_desc "Dual RS232-HS"
# ftdi_device_desc "USB <-> JTAG-DEBUGGER"
ftdi_layout_init 0x0008 0x001b
ftdi_layout_signal nSRST -oe 0x0020 -data 0x0020
# These signals are used for cJTAG escape sequence on initialization only
ftdi_layout_signal TCK -data 0x0001
ftdi_layout_signal TDI -data 0x0002
ftdi_layout_signal TDO -input 0x0004
ftdi_layout_signal TMS -data 0x0008
ftdi_layout_signal JTAG_SEL -data 0x0100 -oe 0x0100
transport select jtag
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5
# Work-area is a space in RAM used for flash programming
if { [info exists WORKAREASIZE] } {
set _WORKAREASIZE $WORKAREASIZE
} else {
set _WORKAREASIZE 0x5000
}
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME gd32vf103 0x08000000 0 0 0 $_TARGETNAME
# Expose Nuclei self-defined CSRS range
# See https://github.com/riscv/riscv-gnu-toolchain/issues/319#issuecomment-358397306
# Then user can view the csr register value in gdb using: info reg csr775 for CSR MTVT(0x307)
riscv expose_csrs 770-800,835-850,1984-2032,2064-2070
riscv set_reset_timeout_sec 1
init
halt
弄好之后就可以在线调试了。
这样就OK了
原理说明:
ft22332d这个芯片本身来说的话就是两个串口,所谓的openocd也就是通过一个openocd软件控制ft2232d去模拟一个jlink,或者模拟其他的调试器。所以使用ft22232d这个芯片作为调试器,需要usb driver tool去更改驱动,然后再去通过openocd软件去调用硬件和配置文件。
最后大家如果想要一个longan的工程可以去下边的路径去下载一份GD32VF103-RT_ThreadNano: gd32vf103cbt6移植了th-thread nano,暂存一下,以后还有别的用处