嘉楠勘智K210开发之旅(2)Ubuntu下安装GNU Toolchain、J-Link和OpenOCD

一、安装RISC-V GNU Compiler Toolchain

二、安装并设置 J-Link

  • 安装USB接口支持、FTDI芯片支持、人机交互设备支持
    sudo apt install libusb-dev libftdi-dev libhidapi-dev -y

  • 下载 J-Link Software and Documentation Pack 并安装
    sudo dpkg -i JLink_Linux_V662d_x86_64.deb

  • 运行
    /opt/SEGGER/JLink_V662d/JLinkExe

    ,并在标识符处填入SEGGER J-Link设备序列号

三、安装并启动 Kendryte OpenOCD

  • 下载 kendryte-openocd-0.2.3-ubuntu64.tar.gz
  • 解压缩
    tar -zxvf kendryte-openocd-0.2.3-ubuntu64.tar.gz -C /home/splash/kendryte/

  • 进入目录
    cd /home/splash/kendryte/kendryte-openocd/

  • 调试 K210 Core 0(默认)
    ./bin/openocd -f ./tcl/kendryte.cfg -m 0


    或者调试 K210 Core 1

    ./bin/openocd -f ./tcl/kendryte.cfg -m 1

  • OpenOCD 启动后,连接 GDB
    (gdb) target remote localhost:3333

附录一 SEGGER J-Link仿真器配置文件:kendryte.cfg

# debug adapter
interface jlink

jlink serial 261000986
transport select jtag
adapter_khz 3000

# server port
gdb_port 3333
telnet_port 4444

# add cpu target
set _CHIPNAME riscv

jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x04e4796b

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME

# command
init
halt

附录二 嘉楠 FTDI 仿真器配置文件:openocd_ft232.cfg

interface ftdi
# for canaan's ftdi
ftdi_vid_pid 0x0403 0x6014
ftdi_layout_init 0x00e8 0x00eb

transport select jtag
ftdi_tdo_sample_edge falling
adapter_khz 64000

gdb_port 3333
telnet_port 4444

set _CHIPNAME riscv

jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x04e4796b

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME

init
halt

附录三 参考资料

Comments are closed.