- This instruction testing only wtih WCH-LinkE
-
Download or build from source OpenOcd. I preferred to use the prebuilt binary from this repo.
-
Add to sys env PATH path to some_path/xpack-openocd-0.12.0-3/bin/
-
Check openocd working
openocd --help
-
Create in PATH_TO/xpack-openocd-VERSION/openocd/scripts
-
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"
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.
- 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
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.
I'm using the CMake build system and I get some variables from it. For debugging need plugin cortex-debug). Check launch.json.
For flashing, I wrote a special task in tasks.json.
- My demo project for ch32f205 chip
- List of svd files