Skip to content
Chalandi Amine edited this page Jan 22, 2023 · 2 revisions

Welcome to the WCH_V307_RISC-V wiki!

How to flash and debug the WCH_V307_RISC-V firmware ?

There is three ways to flash the firmare :

1- Using the flash-only tool WCH-LinkUtility (Windows)

Run the tool WCH-LinkUtility.exe located in the floder /Tools/WCH-LinkUtility

image

2- Using the Segger Embedded Studio for RISC-V (Windows, Linux)

Please follow the steps below :

  1. Download and install Embedded Studio for RISC-V from Segger website: https://www.segger.com/downloads/embedded-studio/#ESforRISCV.

  2. Extract OpenOCD.7z from the folder /Tools/openOCD-Config to your prefered location on the disk and add {your_path}/openOCD/bin to the environemnt variable PATH.

  3. Run the script create-env-variable.win.bat to set the environemnt variable OPENOCD_SCRIPTS used by openOCD to search for the target config file wch-riscv.cfg.

  4. Double-click on the file /Debug/DebugSession.Segger.emProject to open the project with Segger Embedded Studio.

  5. Once the project is opened, simply press F5 to start the debug session the tool will automatically flash the firmware and stop at the entry point :

image

3- Using openOCD (Windows, Linux)

Erase all :

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

Erase all and program :

openOCD -f wch-riscv.cfg -c init -c halt -c "program xxx.hex\bin\elf " -c exit

Verify :

openOCD -f wch-riscv.cfg -c init -c halt -c "verify_image xxx.hex\bin\elf" -c exit

Reset and resume :

openOCD -f wch-riscv.cfg -c init -c halt -c wlink_reset_resume -c exit