A CH32V003 Toolchain — If You Can Get One To Try It On

We’re in an exciting time for cheap microcontrollers, as with both the rise of RISC-V and the split between ARM and its Chinese subsidiary, a heap of super-cheap and very capable parts are coming to market. Sometimes these cheap chips come with the catch of being difficult to program though, but for one of them the ever-dependable [CNLohr] has brought together his own open-source toolchain. The part in question is the WCH CH32V003, which is a ten-cent RISC-V part that has an impressive array of capabilities. As always though, there’s a snag, in that we’re also told that while supplies are improving this part can be hard to find. The repository is ready for when you can get them again though, and currently also contains some demo work including addressable LED driver code.

As an alternative there’s a comparable and slightly cheaper ARM-based part, the Puya PY32. It’s reckoned to be the cheapest of the flash-based microcontrollers, and like the WCH part is bearing down on the crop of one-time-programmable chips such as the famous and considerably less powerful 3-cent Padauk. This end of the market is certainly heating up a little, and from our point of view this can only mean some exciting projects ahead.

40 thoughts on “A CH32V003 Toolchain — If You Can Get One To Try It On

  1. You need to buy a special one-wire flasher from WCH, but they released some code to make a flasher out of a CH32F103, we need people to port that code to an STM32 bluepill:


    WCH use Keil IDE instead of GCC+Makefiles, it could be converted with keil2gcc tool.

    See also this article by CNX:


    1. A kit with a dev board, a USB flasher interface board, and 5 bare 20 pin chips, costs $5.51 all up from the WCH store on Ali. Packs of 50 chips cost $5 for 8 pin to $7 for 20 pin. Both go in and out of stock, but are seldom out of stock for more than a few days.

    1. embeddedDOOM, which was made by, you guessed it, CNLohr, needs as few as 384kB of RAM. However, this chip contains, as written on the repo :

      2kB of RAM

      It’s not for today…

  2. In my house there are several items which say “Designed in Texas” or “Designed and engineered in California” etc. Every one of them also says “Made in China”. So there’s something wrong with this view of Chinese products.

    1. Who’s to say a little redesign and reengineer didn’t occur between the time the mask making instructions left Texas or California and the time the foundry started executing the dies, or perhaps a little auxiliary die is packaged along with the genuine die inside the carrier package. In the old days state actors did targeted attacks on parts for military and government use and the US government maintained (maintains?) labs which could decapsulate parts to verify what was inside was what supposed to be there. An attempt to limit exposure was made by specifying procurement of parts produced inside US borders. I suspect trying to enforce that now is pretty difficult. The US government also did or does maintain its own foundry to produce certain ASICs containing sensitive algorithms.

      A large company such as Apple has the financial capability and reputation at stake to be able to and probably does destructive analysis, sampling random production units to assure there are no software or hardware taints present, including inside chips.

      The Internet and rise of always connected IoT devices creates a huge opportunity for a sate sponsored program to create a massive army of devices which could contain a hidden intentional flaw which when triggered could perform a nationwide denial of service packet storm. A two Dollar LED lamp can contain a full blown extremely capable ESP32 processor and I doubt anybody has looked inside those processor packages and maybe not even inside the firmware.

      1. My company maintains state-side fabrication capability partially for prototyping but we make some money because we can provide completely verifiable chip fab to people who need that and want to be able to inspect every step.
        We make some microcontrollers, and I can tell you for sure all the production we do in china comes back as wafers first so we can inspect them (primarily so we can develop wafer test hardware for pre-packaging trim) and then as packaged parts that we often decap to check on the die bonding and localize failures during ESD testing.
        Fabless design centers might have much more serious verification challenges, but at least for us, it’s extremely unlikely anyone could make changes without being noticed. The profit margin on our chips is a direct function of the die size, and we have very talented layout people who use every square mil.

  3. heh i’m a little excited about RISC-V. and of course i love flash microcontrollers. i just feel like there’s not much point quibbling about the cheapest beyond a certain point. at $25 a board like the official stm32 discovery boards, i am gonna be a little bit concerned about price. but once we get down to the price of a raspberry pico rp2040 board, $4, it just doesn’t matter to me…if i need one, i’ll buy 2 more just to have a stock of them. at that price, i feel like i’m paying more for getting an integrated tested supported board from a reputable vendor than i am for the chip itself.

    if you’re looking at $4 for a pico board at adafruit vs less than $1 for a bare chip, or worse, $2 for a defective board from aliexpress, i just don’t see it as being all that compelling. even when i was a kid and first started my quest for a flash microcontroller, and found out the DS5000 (battery-backed SRAM!) was $50…if it had been $5 instead, i would have been eager to buy two even just with the $30 i got from installing a modem for someone after school.

    obviously if you’re buying a thousand of them for production then you’ll feel totally differently :)

    1. How much money people budget to their hobbies varies. My family monthly budget currently has a $30 line item for discretionary “fun” spending for each of me and my wife. $5 is a nonnegligible part of this budget. (Fortunately, I’m set for a bunch of MCU projects due to a fairly recent order of a bunch of surprisingly genuine blue pills from AliExpress.) And I have other hobbies besides electronics.

  4. Funny how people are more scared of *possible* (but extremely unlikely) chinese backdoors in chips, than *actual* backdoors put in (or overseen by) by the American government (Intel Managment Engine, AMD Platform Security Processor).
    I guess the yellow peril propaganda is working.

  5. I really liked CH32V003 MCU given that the documentation and support is available from the manufacturer, most of the time that is the biggest hinderance for any one to start using MCU, especially a Chinese one.

    I have started creating a series of Article on CH32V003 Programming where I will be covering all the interfaces (GPIO as output, GPIO Input polling and interrupt, UART, I2C, SPI, etc.)

    Here is the link if you might be interested: https://pallavaggarwal.in/2023/09/20/ch32v003-programming-guide/

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.