https://github.com/123swk123/openocd-wch-linke-multilink
Openocd for WCH-LinkE with support for multi-WCHLinkE debugging
https://github.com/123swk123/openocd-wch-linke-multilink
ch32v003 openocd openocd-riscv wch wch-link
Last synced: over 1 year ago
JSON representation
Openocd for WCH-LinkE with support for multi-WCHLinkE debugging
- Host: GitHub
- URL: https://github.com/123swk123/openocd-wch-linke-multilink
- Owner: 123swk123
- License: gpl-3.0
- Created: 2023-05-25T17:14:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-25T17:39:04.000Z (over 3 years ago)
- Last Synced: 2025-01-29T08:21:45.246Z (over 1 year ago)
- Topics: ch32v003, openocd, openocd-riscv, wch, wch-link
- Language: C
- Homepage:
- Size: 3.43 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Openocd for multi-WCHLinkE debugging
configuration to connect first enumerated WCH-LinkE device; file: [wch-riscv.cfg](bin/wch-riscv.cfg)
```tcl
#interface wlink
adapter driver wlinke
# use index 0, 1, 2... to select each wchlink
wlink_set_index 0
adapter speed 6000
transport select sdi
wlink_set_address 0x00000000
set _CHIPNAME wch_riscv
sdi newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x00001
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME.0 wch_riscv -chain-position $_TARGETNAME
$_TARGETNAME.0 configure -work-area-phys 0x20000000 -work-area-size 10000 -work-area-backup 1
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME wch_riscv 0x00000000 0 0 0 $_TARGETNAME.0
lappend post_init_commands {echo "Ready for Remote Connections"}
```
configuration to connect second enumerated WCH-LinkE device; file: [wch-1-riscv.cfg](bin/wch-1-riscv.cfg)
```tcl
#interface wlink
adapter driver wlinke
# use index 0, 1, 2... to select each wchlink
wlink_set_index 1
adapter speed 6000
transport select sdi
wlink_set_address 0x00000000
set _CHIPNAME wch_riscv
sdi newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x00001
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME.0 wch_riscv -chain-position $_TARGETNAME
$_TARGETNAME.0 configure -work-area-phys 0x20000000 -work-area-size 10000 -work-area-backup 1
set _FLASHNAME $_CHIPNAME.flash
flash bank $_FLASHNAME wch_riscv 0x00000000 0 0 0 $_TARGETNAME.0
lappend post_init_commands {
echo "Ready for Remote Connections"
}
```
## openocd configuration setup in Eclipse or similar IDE
*Note: Make sure for each openocd instance use differenct port numbers for telnet/tcl/gdb*

## To manually read Flash info
*for example on ch32v003, run this from openocd bin dir*
`openocd.exe -f .\wch-riscv.cfg -c 'wch_riscv.cpu.0 configure -event reset-end {flash probe 0}' -c init -c reset -c exit`
```log
Open On-Chip Debugger 0.11.0+dev-snapshot (2023-04-23-01:01)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'sdi'
Warn : Transport "sdi" was already selected
{echo "Ready for Remote Connections"}
Info : WCH-LinkE mode:RV version 2.9
Info : wlink_init ok
Info : clock speed 6000 kHz
Info : [wch_riscv.cpu.0] datacount=2 progbufsize=8
Info : [wch_riscv.cpu.0] Examined RISC-V core; found 1 harts
Info : [wch_riscv.cpu.0] XLEN=32, misa=0x40800014
[wch_riscv.cpu.0] Target successfully examined.
Info : starting gdb server for wch_riscv.cpu.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : device id = 0x83a7abcd
Info : flash size = 16kbytes
```