Ubuntu22.04, 使用WCH-LinkE通过openocd操作提示Hart 0 unexpectedly reset

环境:

Ubuntu22.04

WCH定制的openocd, 解压自 MRS_Toolchain_Linux_x64_V1.60.tar.xz

CH32V003F4P6开发板

WCH-LinkE


连接:

3V3  -> VCC

GND -> GND

SWDIO -> PD1


问题:

已经按压缩包中的readme, 将动态链接库和udev权限配置好, openocd能正常运行, 


./openocd -f wch-riscv.cfg -c init -c halt  -c exit

Open On-Chip Debugger 0.11.0+dev-02215-gcc0ecfb6d-dirty (2022-10-10-10:35)

Licensed under GNU GPL v2

For bug reports, read

http://openocd.org/doc/doxygen/bugs.html

Info : only one transport option; autoselect 'jtag'

Ready for Remote Connections

Info : WCH-LinkE-CH32V307  mod:RV version 2.7 

Info : wlink_init ok

Info : This adapter doesn't support configurable speed

Info : JTAG tap: riscv.cpu tap/device found: 0x00000001 (mfg: 0x000 (), part: 0x0000, ver: 0x0)

Warn : Bypassing JTAG setup events due to errors

Info : [riscv.cpu.0] datacount=2 progbufsize=8

Info : Examined RISC-V core; found 1 harts

Info :  hart 0: XLEN=32, misa=0x40800014

[riscv.cpu.0] Target successfully examined.

Info : starting gdb server for riscv.cpu.0 on 3333

Info : Listening on port 3333 for gdb connections


但是在操作CH32V003时报错:


擦写


./openocd -f wch-riscv.cfg -c init -c halt -c "flash erase_sector wch_riscv 0 last" -c exit

Open On-Chip Debugger 0.11.0+dev-02215-gcc0ecfb6d-dirty (2022-10-10-10:35)

Licensed under GNU GPL v2

For bug reports, read

http://openocd.org/doc/doxygen/bugs.html

Info : only one transport option; autoselect 'jtag'

Ready for Remote Connections

Info : WCH-LinkE-CH32V307  mod:RV version 2.7 

Info : wlink_init ok

Info : This adapter doesn't support configurable speed

Info : JTAG tap: riscv.cpu tap/device found: 0x00000001 (mfg: 0x000 (), part: 0x0000, ver: 0x0)

Warn : Bypassing JTAG setup events due to errors

Info : [riscv.cpu.0] datacount=2 progbufsize=8

Info : Examined RISC-V core; found 1 harts

Info :  hart 0: XLEN=32, misa=0x40800014

[riscv.cpu.0] Target successfully examined.

Info : starting gdb server for riscv.cpu.0 on 3333

Info : Listening on port 3333 for gdb connections

Info : device id = 0x17a8abcd

Info : flash size = 16kbytes

Info : Hart 0 unexpectedly reset!

erased sectors 0 through 15 on flash bank 0 in 0.022614s



烧录

./openocd -f wch-riscv.cfg -c init -c halt -c "program /home/mil/ch32v003-template/Build/app.elf" -c exit

Open On-Chip Debugger 0.11.0+dev-02215-gcc0ecfb6d-dirty (2022-10-10-10:35)

Licensed under GNU GPL v2

For bug reports, read

http://openocd.org/doc/doxygen/bugs.html

Info : only one transport option; autoselect 'jtag'

Ready for Remote Connections

Info : WCH-LinkE-CH32V307  mod:RV version 2.7 

Info : wlink_init ok

Info : This adapter doesn't support configurable speed

Info : JTAG tap: riscv.cpu tap/device found: 0x00000001 (mfg: 0x000 (), part: 0x0000, ver: 0x0)

Warn : Bypassing JTAG setup events due to errors

Info : [riscv.cpu.0] datacount=2 progbufsize=8

Info : Examined RISC-V core; found 1 harts

Info :  hart 0: XLEN=32, misa=0x40800014

[riscv.cpu.0] Target successfully examined.

Info : starting gdb server for riscv.cpu.0 on 3333

Info : Listening on port 3333 for gdb connections

Info : JTAG tap: riscv.cpu tap/device found: 0x00000001 (mfg: 0x000 (), part: 0x0000, ver: 0x0)

Warn : Bypassing JTAG setup events due to errors

** Programming Started **

Info : device id = 0x17a8abcd

Info : flash size = 16kbytes

Info : Hart 0 unexpectedly reset!

** Programming Finished **


这会是什么原因?


您好,您说的这个信息是info开头的提示信息,实际命令行的擦除和烧写操作指令应该已经正常完成了,这个是可以通过程序是否运行来验证的。


检查了一下, 确实擦写和烧录是成功的, 之前写入了但是没运行


但是 Hart 0 unexpectedly reset! 这样的输出是不是有误导的嫌疑


应该给研发提一个bug?


另外,wlink_reset_resume 这个参数是不是废弃了 -c wlink_reset_resume 并不重启芯片, 测试了很多遍, 只有使用-c reset -c resume 这样的组合才能重启芯片


您好,感谢您的反馈。wlink_reset_resume没有废弃,但目前在linux下表现的效果是复位后暂停,没有运行,现版本可在其后在加一条-c resume来恢复执行。 后续我们会尽快更正此问题。


好的, 再请教一个问题,  wlink_reset_resume 和 reset 这两个参数有什么区别吗? 观察到的效果都是重启


reset 内核复位,只复位内核寄存器。wlink_reset_resume 软件复位不仅复位内核寄存器,代码重新跑,所有外设也复位。


只有登录才能回复,可以选择微信账号登录