{"id":48,"date":"2025-09-13T00:20:27","date_gmt":"2025-09-12T17:20:27","guid":{"rendered":"https:\/\/blog.bacphan.dev\/?p=48"},"modified":"2025-09-13T00:20:27","modified_gmt":"2025-09-12T17:20:27","slug":"develop-with-ch32v003-mcu-setting-up-environment","status":"publish","type":"post","link":"https:\/\/blog.bacphan.dev\/index.php\/2025\/09\/13\/develop-with-ch32v003-mcu-setting-up-environment\/","title":{"rendered":"Develop with CH32V003 MCU: Setting up Environment"},"content":{"rendered":"\n<p>Recently i came across this Little MCU: CH32V003. It&#8217;s RISC-V MCU, having small flash and RAM. My Mcu is So8 variant with 16KB of flash and 2 KB of ram, even smaller than the Atmega328 on Arduino Uno, but that maybe enough for some usecases.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1024\" src=\"https:\/\/blog.bacphan.dev\/wp-content\/uploads\/2025\/09\/image.png\" alt=\"\" class=\"wp-image-49\" style=\"width:441px;height:auto\" srcset=\"https:\/\/blog.bacphan.dev\/wp-content\/uploads\/2025\/09\/image.png 1024w, https:\/\/blog.bacphan.dev\/wp-content\/uploads\/2025\/09\/image-300x300.png 300w, https:\/\/blog.bacphan.dev\/wp-content\/uploads\/2025\/09\/image-150x150.png 150w, https:\/\/blog.bacphan.dev\/wp-content\/uploads\/2025\/09\/image-768x768.png 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>So let setup the software.<\/p>\n\n\n\n<p>WCH has an IDE called <a href=\"http:\/\/www.mounriver.com\/download\" data-type=\"link\" data-id=\"http:\/\/www.mounriver.com\/download\">moun river<\/a>. While it&#8217;s on the better side of vendor-provided IDE(Thanks God it&#8217;s based on modern VSCode, instead of that Eclipse), i still want a setup that is not vendor dependent. I decided to use docker to containize my setup and be able to quickly recover if i screw up something.<\/p>\n\n\n\n<p>Quick search on the internet, there is already a docker image that include toolchain and necessary tool to work with this MCU and WCH-LinkE(The debugger): <a href=\"https:\/\/hub.docker.com\/r\/islandc\/wch-riscv-devcontainer\">https:\/\/hub.docker.com\/r\/islandc\/wch-riscv-devcontainer<\/a>. But unfortunately, this image does not include SDK, so we will have to pull the SDK later.<\/p>\n\n\n\n<p>We also use VScode dev container extension to setup dev enviroment inside that container. <\/p>\n\n\n\n<p>The first step we need is creating a directory that is our project root, in this example, i will called it <strong><em>hello_world<\/em><\/strong>.<\/p>\n\n\n\n<p>Next, cd to proj root and create a dir called &#8216;.devcontainer&#8217;, this store our docker config file.<\/p>\n\n\n\n<p>Then add devcontainer.json to tell dev container ext how to setup the image. I ask Claude for this because tbh i&#8217;m not expert in Docker.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"name\": \"WCH RISC-V Development\",\n  \"image\": \"islandc\/wch-riscv-devcontainer:latest\",\n  \n  \/\/ Features and settings\n  \"features\": {},\n  \n  \/\/ VS Code customizations\n  \"customizations\": {\n    \"vscode\": {\n      \"extensions\": &#91;\n        \"ms-vscode.cpptools\",\n        \"ms-vscode.cmake-tools\",\n        \"marus25.cortex-debug\"\n      ],\n      \"settings\": {\n        \"cmake.configureOnOpen\": true,\n        \"C_Cpp.default.configurationProvider\": \"ms-vscode.cmake-tools\"\n      }\n    }\n  },\n\n  \/\/ Container configuration\n  \"privileged\": true,  \/\/ Required for USB debugging\n  \"mounts\": &#91;\n    \/\/ Mount USB devices for debugging\n    \"source=\/dev,target=\/dev,type=bind\"\n  ],\n  \n  \/\/ Port forwarding (if needed)\n  \"forwardPorts\": &#91;],\n  \n  \/\/ Post-create command\n  \"postCreateCommand\": \"echo 'WCH RISC-V Dev Container Ready!'\",\n  \n  \/\/ Keep container running\n  \"overrideCommand\": false,\n  \n  \/\/ User settings\n  \"remoteUser\": \"root\"\n}<\/code><\/pre>\n\n\n\n<p>Now use Dev Container ext and &#8220;reopen in container&#8221;, in theory, it should work fine, and we are in the container now<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"375\" src=\"https:\/\/blog.bacphan.dev\/wp-content\/uploads\/2025\/09\/image-1-1024x375.png\" alt=\"\" class=\"wp-image-50\" srcset=\"https:\/\/blog.bacphan.dev\/wp-content\/uploads\/2025\/09\/image-1-1024x375.png 1024w, https:\/\/blog.bacphan.dev\/wp-content\/uploads\/2025\/09\/image-1-300x110.png 300w, https:\/\/blog.bacphan.dev\/wp-content\/uploads\/2025\/09\/image-1-768x282.png 768w, https:\/\/blog.bacphan.dev\/wp-content\/uploads\/2025\/09\/image-1-1536x563.png 1536w, https:\/\/blog.bacphan.dev\/wp-content\/uploads\/2025\/09\/image-1.png 1724w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next part will be pulling the SDK and setup a hello_world project<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently i came across this Little MCU: CH32V003. It&#8217;s RISC-V MCU, having small flash and RAM. My Mcu is So8 variant with 16KB of flash and 2 KB of ram, even smaller than the Atmega328 on Arduino Uno, but that maybe enough for some usecases. So let setup the software. WCH has an IDE called [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.bacphan.dev\/index.php\/wp-json\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.bacphan.dev\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.bacphan.dev\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.bacphan.dev\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.bacphan.dev\/index.php\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":1,"href":"https:\/\/blog.bacphan.dev\/index.php\/wp-json\/wp\/v2\/posts\/48\/revisions"}],"predecessor-version":[{"id":51,"href":"https:\/\/blog.bacphan.dev\/index.php\/wp-json\/wp\/v2\/posts\/48\/revisions\/51"}],"wp:attachment":[{"href":"https:\/\/blog.bacphan.dev\/index.php\/wp-json\/wp\/v2\/media?parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.bacphan.dev\/index.php\/wp-json\/wp\/v2\/categories?post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.bacphan.dev\/index.php\/wp-json\/wp\/v2\/tags?post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}