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.
Arduino support for puya py32 would be awesome
Here you are :trollface: … https://twitter.com/patrick_riscv/status/1638385086004596736
Thanks, I was asking for puya py32 support not this WCH,but I appreciate the effort
I could do that with a 555
/s
555s cost 5-10 times more, need external components that cost as much again, have high power consumption, low operating frequency, poor precision…
You missed the “/s”?
TTL forever!
+5V: God’s voltage.
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:
https://twitter.com/patrick_riscv/status/1630134151763357696
https://github.com/openwch/ch32v003/tree/main/CH32V003_1Line_Base_on_CH32F103
WCH use Keil IDE instead of GCC+Makefiles, it could be converted with keil2gcc tool.
See also this article by CNX:
https://www.cnx-software.com/2023/02/22/ch32v003-risc-v-mcu-gets-1-5-development-board-open-source-gcc-toolchain-and-flasher-utility/
They also describe the protocol in a PDF in that Github repository and the commit message links to a YouTube video where they talk about the basics.
I’d be shocked if someone hasn’t written a protocol adapter with an RP2040 yet.
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.
If you could get it to play Doom, it would prove the tool chain is worth it.
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…
External serial RAM to the rescue…?
So $2 in 512k external serial ram? Is that a go? Could an entire computer be made with this chip?
Yes, it can run Linux, search for linux-ch32v003.
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.
You know, “Imagined, designed, engineered and assembled in the West” and “can haz backdoor for Mao” are not mutually exclusive.
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.
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.
It is more likely to backdoor components designed and manufactured in the US than in China.
we already have precedents.
https://www.youtube.com/watch?v=Rr8ljRgcJNM
Backdoors in microcontrollers with open source toolchains? Sure….
Also, backdoors in microchips that have no network connectivity? How would that work?
My house had a backdoor long before it got any network connectivity :)
Don’t be so sure. People always forget about nosy neighbors. Bandwidth and latency upgrade if said neighbors are old Italian ladies.
See here in different form factors:
https://www.aliexpress.com/item/1005005262154401.html
The Puya PY32 seems to be available now. No love with the other chip though.
May have to get a stack of those in TSSOP-20 to see how they perform.
I’m sure Xi Jinping is fascinated by the frequency you blink a LED at.
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 :)
For hobbyists yea, but once you enter mass production, you start caring about fractions of cents.
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.
You didn’t tell her what you _actually_ make did you?
She just got the tax number?
Two sets of books, minimum…
Kids these days.
Didn’t I see that CH32V003 mentioned in the TinyUSB changekog?
Oh, that was the WCH CH32V307. Excuse me
Seem to be available here:
https://www.aliexpress.us/item/3256804850399956.html
999 percent of the time a 555 will do the job had it has been doing for over 50 years
8 cents! I can get a faster, cheaper Chinese clone of this Chinese uC for 0 cents! It even has the WiFi!
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.
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/
We integrated this CH32V003 in our free IDE for microcontrollers:
https://embeetle.com/#supported-hardware/wch/boards/ch32v003f4p6-evt-r0-1v1
On this webpage you can also see how to wire up the board.