windows环境
安装exe文件之后将安装路径添加到环境变量中

openocd必须用MRS提供的版本才可以支持wchlink,目前沁恒并没有将wchlink的功能提交至riscv-openocd上游分支,我只从网上找到MRS的二进制文件
linux环境
解压好各工具之后,将路径添加到环境变量中
export PATH:$PATH=/home/$USER/opt/cmake/bin
export PATH:$PATH=/home/$USER/opt/ninja/bin
export PATH:$PATH=/home/$USER/opt/openocd/bin
export PATH:$PATH=/home/$USER/opt/toolchain/bin
在terminal中开发赤菟
测试各工具

编译Integrated_Test用例。
在terminal中输入make build APP=Integrated_Test
。
$ make build APP=Integrated_Test
cmake -E make_directory build.ninja
cd build.ninja && cmake .. -G"Ninja" -DAPP=Integrated_Test
-- TOOLCHAIN_PATH:E:\MounRiver\MounRiver_Studio\toolchain\RISC-V Embedded GCC\bin\riscv-none-embed-gcc.exe
-- The C compiler identification is GNU 8.2.0
-- The CXX compiler identification is GNU 8.2.0
-- The ASM compiler identification is GNU
-- Found assembler: E:/MounRiver/MounRiver_Studio/toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: E:/MounRiver/MounRiver_Studio/toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: E:/MounRiver/MounRiver_Studio/toolchain/RISC-V Embedded GCC/bin/riscv-none-embed-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- [register library component: SRC ], path:C:/Users/salieri/Desktop/opench-ch32v307/firmware/SRC
[run app:Integrated_Test],path:C:/Users/salieri/Desktop/opench-ch32v307/firmware/Integrated_Test
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/salieri/Desktop/opench-ch32v307/build.ninja
ninja -C build.ninja -j8
ninja: Entering directory `build.ninja'
[40/40] Linking C executable ..\cmake_output\Integrated_Test\Integrated_Test.elf
text data bss dec hex filename
53440 208 2080 55728 d9b0 C:/Users/salieri/Desktop/opench-ch32v307/cmake_output/Integrated_Test/Integrated_Test.elf
二进制文件输出在cmake_output
路径下

烧写flash固化代码
键入make program APP=Integrated_Test
等待数秒后,flash编程完成。按下赤菟复位按键执行新程序。
$ make program APP=Integrated_Test
ninja programtask -C build.ninja -j8
ninja: Entering directory `build.ninja'
[1/1] cmd.exe /C "cd /D C:\Users\salieri\Desktop\opench-ch32v307\build.ninja && openoc...eri/Desktop/opench-ch32v307/cmake_output/Integrated_Test/Integrated_Test.hex" -c exit"
Open On-Chip Debugger 0.10.0+dev-gb0ae840-dirty (2021-06-19-14:16)
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-Link version 2.1
Info : wlink_init ok
Info : This adapter doesn't support configurable speed
Info : JTAG tap: riscv.cpu tap/device found: 0x20000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x2)
Warn : Bypassing JTAG setup events due to errors
Info : datacount=2 progbufsize=8
Info : Examined RISC-V core; found 1 harts
Info : hart 0: XLEN=32, misa=0x40901125
Info : Listening on port 3333 for gdb connections
Info : device id = 0x20000410
erased sectors 0 through 511 on flash bank 0 in 0.140874s
Open On-Chip Debugger 0.10.0+dev-gb0ae840-dirty (2021-06-19-14:16)
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-Link version 2.1
Info : wlink_init ok
Info : This adapter doesn't support configurable speed
Info : JTAG tap: riscv.cpu tap/device found: 0x20000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x2)
Warn : Bypassing JTAG setup events due to errors
Info : datacount=2 progbufsize=8
Info : Examined RISC-V core; found 1 harts
Info : hart 0: XLEN=32, misa=0x40901125
Info : Listening on port 3333 for gdb connections
Info : JTAG tap: riscv.cpu tap/device found: 0x20000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x2)
Warn : Bypassing JTAG setup events due to errors
** Programming Started **
Info : device id = 0x20000410
** Programming Finished **
Open On-Chip Debugger 0.10.0+dev-gb0ae840-dirty (2021-06-19-14:16)
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-Link version 2.1
Info : wlink_init ok
Info : This adapter doesn't support configurable speed
Info : JTAG tap: riscv.cpu tap/device found: 0x20000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x2)
Warn : Bypassing JTAG setup events due to errors
Info : datacount=2 progbufsize=8
Info : Examined RISC-V core; found 1 harts
Info : hart 0: XLEN=32, misa=0x40901125
Info : Listening on port 3333 for gdb connections
Info : Verify Success
输出eclipse工程
以Integrated_Test用例示范,键入make build_eclipse APP=Integrated_Test
工程文件输出在opench-ch32v307/build.eclipse
目录,打开任意基于eclipse开发的软件,以MRS为例。
在菜单中找到file-->import-->General-->Existing Projects into Workspace

之后进行正常编译调试吧~

此处MRS有个BUG,外部导入的工程文件,无法添加调试配置页,建议用上游分支eclipse-cdt😅

verimake的板子越来越精致了!估计这个价格,华强北抄板商家看了都要流泪。¥118,交个朋友! 🤣