Skip to content

Mcublog/wch-link-instruction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WCH-link with OpenOCD instruction

img

  • This instruction testing only wtih WCH-LinkE

Installing and connection

  1. Download or build from source OpenOcd. I preferred to use the prebuilt binary from this repo.

  2. Add to sys env PATH path to some_path/xpack-openocd-0.12.0-3/bin/

  3. Check openocd working

    openocd --help

    result

  4. Create in PATH_TO/xpack-openocd-VERSION/openocd/scripts

  5. Next, need .cfg file for adapter and target. The target .cfg file more likely already exists in directory openocd/scripts/target. For a WCH link compatible with cms-dap.cfg, but I modify it a little. Check it: wch-cmsis-dap.cfg. I recommend copying this file to the openocd_root/openocd/scripts/interface folder. Next, we try to connect to target using SWD transport and target, in my case this is stm32f4.

    openocd -f "interface/wch-cmsis-dap.cfg" -f "target/stm32f4x.cfg"

    connection_result

Manual working

For testing some scripts and etc may be helpfull manual working with adapter.

  • A telnet connection must be established to send a command to the adapter. By default this is port 4444. After connecting the adapter to the target, run the script below:
telnet localhost 4444

After then, you may send command to the adapter.

example

  • If using degub output with RTT, need to find, start and connect to RTT server. Run commands below from the telnet connection. Check 15.6 Real Time Transfer (RTT).
rtt setup 0x20000000 2048 "SEGGER RTT"
rtt start
rtt server start 9090 0

example

I was created to specify a script for these commands and run it when connected. Check the file rtt.tcl.

  • GDB connection uses port 3333 by default.

Visual Studio Code integration

I'm using the CMake build system and I get some variables from it. For debugging need plugin cortex-debug). Check launch.json.

example

For flashing, I wrote a special task in tasks.json.

example

Useful links

About

Notes on WCH-link connection

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages