RISC-V技术william hill官网
直播中

杨丽

7年用户 1325经验值
私信 关注
[经验]

使用蜂鸟调试器,无法用cjtag协议调试CM32M433R芯片是怎么回事?

1.问题简述

使用RV_STAR上集成的蜂鸟调试器,连接到CM32M433R-START开发板上的jtag端口,使用cjtag协议来调试MCU,但在openocd配置文件里开启nscan1_mode后,开启openocd连接到板子时,会报错,连接不上。
(我使用普通的4线jtag协议时,即nscan1_mode off,可以正确连接开发板,读出TAP ID等信息,在软件配置和接线上应该大致无错。保持接线不变,仅在openocd配置文件里开启nscan1_mode后,openocd不能连接板子读出TAP ID,报错all read zero。因cjtag连接已经报错,没有进行程序下载和调试的尝试。)
2.调试时的配置


  • 调试器:RV_STAR开发板上集成的调试器
  • 被调试芯片:CM32M433R-START开发板上的CM32M433R芯片
  • 连接方式:用跳线连接,RV_STAR开发板上调试器jtag端口,到CM32M433R-START开发板上MCU的jtag调试端口。在jtag和cjtag调试中,都连接GND,TCK,TMS,TDI,TDO五条线,没有连接RST线
  • 开发环境

    • 系统:win11
    • openocd版本:从nuclei官网下载的nuclei openocd 2024.02.28

3.调试时连接图

3.1 设备管理器截图: (COM12为连接的RV_STAR开发板上集成的ft2232HL芯片调试器)


3.2板子跳线连接图

3.2.1 RV_STAR板载调试器连接


3.2.2 CM32M433R-START jtag接口连接


4.使用的openocd配置文件

adapter speed     1000adapter driver ftdi#If you use the cJTAG interface, you should set the following options to on#ftdi nscan1_mode offftdi nscan1_mode on    ftdi vid_pid 0x0403 0x6010#ftdi layout_init 0x0030 0x001bftdi layout_init 0x0008 0x001bftdi layout_signal nSRST -oe 0x0020 -data 0x0020ftdi layout_signal TCK -data 0x0001ftdi layout_signal TDI -data 0x0002ftdi layout_signal TDO -input 0x0004ftdi layout_signal TMS -data 0x0008ftdi layout_signal JTAG_SEL -data 0x0100 -oe 0x0100transport select jtagset _CHIPNAME riscvjtag newtap $_CHIPNAME cpu -irlen 5 set _TARGETNAME $_CHIPNAME.cputarget create $_TARGETNAME riscv -chain-position $_TARGETNAME$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 10000 -work-area-backup 1#set _FLASHNAME $_CHIPNAME.flash#flash bank $_FLASHNAME cm32m4xxr 0x08000000 0 0 0 $_TARGETNAMEinit#reset#if {[ info exists pulse_srst]} {#  ftdi_set_signal nSRST 0#  ftdi_set_signal nSRST z#}#halt
5.报错log

cjtag,开启nscan1_mode,不能正确连接,不能读出tap id等信息,在debug level 2时,打印log如下:
E:CuiSECFPGA_debugmy_riscv555NucleiOpenOCD2024.02.28bin>openocd -f E:CuiSECFPGA_debugmy_riscv555NucleiOpenOCD2024.02.28scriptstargetcm32m4xxr.cfgOpen On-Chip Debugger 0.11.0+dev-02405-ga383d1d03 (2024-02-28-02:57)Licensed under GNU GPL v2For bug reports, read        http://openocd.org/doc/doxygen/bugs.htmlInfo : libusb_open() failed with LIBUSB_ERROR_NOT_FOUNDInfo : no device found, trying D2xx driverInfo : D2xx device count: 2Info : Connecting to "(null)" using D2xx mode...Info : clock speed 1000 kHzInfo : cJTAG timing not satisfied please check constraint or underclocking.Info : cJTAG timing not satisfied please check constraint or underclocking.Error: JTAG scan chain interrogation failed: all zeroesError: Check JTAG interface, timings, target power, etc.Error: Trying to use configured scan chain anyway...Error: riscv.cpu: IR capture error; saw 0x00 not 0x01Info : cJTAG timing not satisfied please check constraint or underclocking.Warn : Bypassing JTAG setup events due to errorsError: dtmcontrol is 0. Check JTAG connectivity/board power.Warn : target riscv.cpu examination failedError: dtmcontrol is 0. Check JTAG connectivity/board power.Error: dtmcontrol is 0. Check JTAG connectivity/board power.Info : starting gdb server for riscv.cpu on 3333Info : Listening on port 3333 for gdb connectionsInfo : Listening on port 6666 for tcl connectionsInfo : Listening on port 4444 for telnet connectionsError: dtmcontrol is 0. Check JTAG connectivity/board power.Error: dtmcontrol is 0. Check JTAG connectivity/board power.jtag,关闭nscan1_mode,可以正确连接,读出tap id等信息,在debug level 2时,打印log如下:
E:CuiSECFPGA_debugmy_riscv555NucleiOpenOCD2024.02.28bin>openocd -f E:CuiSECFPGA_debugmy_riscv555NucleiOpenOCD2024.02.28scriptstargetcm32m4xxr.cfgOpen On-Chip Debugger 0.11.0+dev-02405-ga383d1d03 (2024-02-28-02:57)Licensed under GNU GPL v2For bug reports, read        http://openocd.org/doc/doxygen/bugs.htmlInfo : libusb_open() failed with LIBUSB_ERROR_NOT_FOUNDInfo : no device found, trying D2xx driverInfo : D2xx device count: 2Info : Connecting to "(null)" using D2xx mode...Info : clock speed 1000 kHzInfo : JTAG tap: riscv.cpu tap/device found: 0x13080a6d (mfg: 0x536 (Nuclei System Technology Co Ltd), part: 0x3080, ver: 0x1)Info : [riscv.cpu] datacount=4 progbufsize=2Info : Examined RISC-V core; found 1 hartsInfo :  hart 0: XLEN=32, misa=0x40149125[riscv.cpu] Target successfully examined.Info : starting gdb server for riscv.cpu on 3333Info : Listening on port 3333 for gdb connectionsInfo : Listening on port 6666 for tcl connectionsInfo : Listening on port 4444 for telnet connections5.1 疑点

cjtag的log中,在Error前,有提到 cJTAG timing not satisfied please check constraint or underclocking.看似是时序问题导致信号错误。
个人认为这种时钟不满足应该只在调试fpga上的软核SoC可能出现,不应该出现在开发板上,而且1000KHz的TCK并不快,在JTAG调试中也使用的同样频率TCK,没有报错。cjtag调试时,把TCK降低到100KHz也会报TCK时序不满足的错。
我还使用逻辑分析仪抓取了cjtag调试时的信号,发现调试器开始时一直在 jtag状态机的IR状态上进行类似zero bit scan的操作,但按照规范,这种操作应该在DR状态上进行。
                                                                                

更多回帖

×
20
完善资料,
赚取积分