Skip to content

A bare-minimum template for your next project using the ultra low-cost WCH CH32V003 RISC-V MCU!

Notifications You must be signed in to change notification settings

islandcontroller/template-ch32v003

Repository files navigation

template-ch32v003 Discord server link

A bare-minimum template for your next project using the ultra low-cost WCH CH32V003 RISC-V MCU!

You can find a fully working example at islandcontroller/hello-ch32v003!

Requirements

  • Hardware
    • WCH CH32V003 microcontroller
    • WCH-LinkE Debugger
  • Software

Getting Started

  • Click on "Use this template" to create your own fork of this template.
  • Clone the forked repository using the following command. Note the use of the --recursive tag.
    git clone --recursive https://github.com/<your username here>/template-ch32v003
    
  • Open the folder in VSCode
  • Connect WCH-Link debug probe
    • (WSL only) attach to WSL using usbipd attach --wsl --busid <...>. This needs to be completed before starting the Dev Container.
  • Run the command "Dev Containers: Reopen in Container"
    • On first launch, you may need to install some udev rules on your host machine. Copy the files to your workspace by running setup-devcontainer inside the container.

    • Re-open the workspace on your host and run the install-rules script inside the .vscode/setup folder.

      cd .vscode/setup
      sudo ./install-rules
      
    • Afterwards, restart the devcontainer.

  • Upon prompt, select the "WCH RISC-V Toolchain x.x" CMake Kit.
  • Run "CMake: Configure"
  • Build using "CMake: Build [F7]"

Serial Monitor

A serial port monitor is included in the devcontainer. To launch the serial monitor, use:

cu -l /dev/ttyACM0 -s <baudrate>

To close the connection later on, press ESC/ENTER, type ~. (tilde, dot) and wait for 3 seconds.

Customization

  • CMakeLists.txt
    • Change the name and description in the project(...) command.
    • Place additional include directories in the include_directories(...) command.
    • Source files are added automatically if they have a .c or .S file extension.
  • .vscode/launch.json
    • Adjust the ELF binary in the program field to match the project name.

Help and References

If you're looking for further information about WCH products, check out their community Discord server: Discord server link

About

A bare-minimum template for your next project using the ultra low-cost WCH CH32V003 RISC-V MCU!

Topics

Resources

Stars

Watchers

Forks