Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
The cheapest flash microcontroller you can buy is actually an Arm Cortex-M0+ (jaycarlson.net)
187 points by jaydcarlson on Feb 5, 2023 | hide | past | favorite | 65 comments


I think he's doing an important analysis, but not for DIY hobbyists: knowing how cheap your SoC is only makes sense when you're finalizing a BOM for mass production, even if they're small runs. The SoC is only one component of at least a dozen required to make a working microcontroller board.

If you're doing DIY hobbyist yourself, you'll want to buy pre-mounted SoCs in a known form factor (as in, it is on a tiny daughter board, and that board has a known pin-out that remains consistent across clones). Example: the Pro Micro.

A Raspberry Pi branded Cortex-M0+ on a Pro Micro clone board sold under the Sparkfun brand is $11: https://www.sparkfun.com/products/18288 All the components to have a fully working microcontroller out of the box is included; the SoC, RAM, flash, USB connector, the rest, and it's all machine placed and soldered, and individually tested.

The dev board of the SoC he selected is $5, but get shipped from China and seem to be incomplete dev kits (no USB, no flash reprogramming pins, and the docs aren't great); it also doesn't seem to be a standard/popular form factor.

The analysis in the article is only the part that would lead you to "if I wanted to make my own Pro Micro-sized microcontroller, which SoC is cheap but good"; you still need the cheap but good equivalents for the rest of the components and then actually be able to solder it (SMD components suck for humans to hand place).


It was an interesting read for me, as I build professional boards from scratch using LPC and STM series chips at work, and so have the tooling to play around with cheapy things like this on a DIY hobby basis. I usually don't like to go with the pre-built SoC boards because they do it differently than I like, and since I have the resources to do it my way, I can.


RP2040 has zero flash on board and is a terrible chip to use as an example. Its actually a lot more complex to boot up than other chips, and I personally consider it closer to a microprocessor than a microcontroller (its somewhere in between).

STM32F0 is a cheap Cortex M0+ that has on-board flash and on-board oscillator. Other Cortex M0+ parts are similar (with the RP2040 as a massive exception). This means that the board design is extremely simple.

---------

> the SoC, RAM, flash, USB connector, the rest, and it's all machine placed and soldered, and individually tested.

Case in point: STM32F0 has RAM, Flash, Oscillator all on the SoC. Just apply Vcc + Ground and your code is running.

I guess programming is somewhat difficult, but sockets do exist for a variety of form factors. ZIF sockets for DIP are cheap, looks like the sockets for STM32F0 (64 quad flat package) are a bit pricy though.

But an "on board" chip programmer is simple in my experience. STM32 / Microchip SAM Cortex chips are designed to be easily programmed and prototyped.

--------

I think you're right in that hobbyists ought to start with developer boards. USB "makes sense" to a lot of people.

But I also want to encourage hobbyists, even advanced beginners, to mess with chips directly. Some chips are much easier to bootstrap than others. Yes, even on a breadboard.

https://www.brennantymrak.com/articles/programming-avr-with-...


The linked board includes flash.

If you're going down the route of buying a board why should you worry about the complexity of putting it all together?


A lot of uCs have flash on chip, that makes integration easier.

RP2040 is harder because it won't even boot until you add flash. Other chips however will boot with just Vcc and Gnd (aka + and - power applied).

That's my point. Many many chips are actually really easy to build a board around. But not RP2040.


Update: Adafruit sells a RP2040 in a Pro Micro clone for $9: https://www.adafruit.com/product/5302, otherwise seemingly identical as the Sparkfun RP2040 Pro Micro clone.

That makes it about as cheap as real ATmega32u4-based Pro Micros, which are still hard to find due to the chip crunch.


I'm not sure why people try and go for the cheapest microcontroller. These things all have unit prices in the single digit dollars or less in actual production costs. Finding a cheap microcontroller is entirely about finding a cheap reseller of whatever you're trying to get rather than finding a cheap part specifically. Only when you get to truly large volumes such that you can get volume discounts does unit price really start to matter.

Especially if you're a hobbyist, price should just basically not be a factor in what you're choosing as they're all in the same ballpark from resellers.


As a person who's financial weak, I always go with the cheapest option that I can find, especially if this is my entrance ticket into the specific space.

Yes, the cheapest option will probably have more issues then the more expensive one. But that's actually good, because if I can't deal with them, I probably would give up with a more expensive one. And this also allows me to experience what really matters to me and what I don't care about, so that if I decide to upgrade I can be much more specific on regards to what I need and what I don't need.

About a year ago I entered the space of microscopy, I was lucky enough to be able to get an old one for free from the university, one that they've deemed no longer suitable for the students (probably because it doesn't have a light), but for me it is perfect, it does everything that I need it for. As for the light, I just use an LED or phones flash.

Zero cost entry, and honestly I don't really feel the need to upgrade, I did buy an additional lense that comes with a holder for a phone so that I can view the slides on the phone's display and even record them!

My philosophy is that you should spend as little money as possible to enter a hobby.

Or in other words, don't buy tools to do a hobby. Do a hobby to buy the tools.


It's a good philosophy to have although I think the parent commenter was referring to microcontrollers specifically. You're better off getting a decently capable one for a little more than trying to make do with the cheapest version because the difference in cost is probably a few cents and the variance between resellers will be higher than that.


This won't be cheap in practice.

These are 10-cents to 70-cent SMT parts. See the link from the blogpost: https://www.lcsc.com/products/Microcontroller-Units-MCUs-MPU...

This means you need a hotair rework station and soldering iron. If you want to breadboard, you'll want a set of breakout boards to place these parts.

I suggest to beginners: work with DIP instead, so that it works on your breadboard without the need of more expensive tools. I remember back when I was in college, all I could afford was a breadboard and some chips (not even a soldering iron: too expensive for my cheap self back then).

Similarly, I expect today's cheap beginners to start on DIP + breadboards, and _maybe_ get a soldering iron, eventually. SMT parts are just outside of the reach for such cheap EEs, which is fine, DIP parts (though lower performance), still exist and still have a huge variety of important projects you can do. (OpAmps, Transistors like 2N2222 and 2N7000, voltage regulators, current regulators, references, even uCs like AVR64DD28)

-----------

Spending $0.70 on parts you literally can't use is a waste of your time and money. Buying custom pcbs is like $100 for single runs. Buying breakout boards is +$3 each plus the additional tools (hot air rework) needed to work with them.

Spending $3 on a 28-DIP package (like AVR64DD28) is in fact, the cheapest way to enter this hobby. Or alternatively, find other DIP packages (maybe something else exists: I'm not very familiar with these cheaper Chinese parts), but not the parts discussed in this particular blogpost.


>Buying custom pcbs is like $100 for single runs.

You can easily get small custom PCBs for <$10, delivered.

There's a really good price comparison site at https://pcbshopper.com/

5 boards - 5cm x 5cm, 2 layer, delivered for US$9.90.


    Yes, the cheapest option will probably have more issues then the more
    expensive one. But that's actually good, because if I can't deal with them,
    I probably would give up with a more expensive one.
I don't see how that follows. A cheap electronic component is much more likely to be out of specification, requiring hacks or workarounds to deal with the fact that it's out of spec. A more expensive component is more likely to be within its advertised specifications, and thus Just Work™, when used in a design. It seems to me that using the cheapest, bottom of the barrel, dodgiest components is a recipe for more frustration, and thus more likely to lead to giving up than using components that are modestly more expensive, but actually work to the standards which are advertised.


I entertained the idea of using WLCSP in a PCB just because I like pain. If I can do WLCSP then I can do anything.


Sure but does your financial situation change if you pay 10¢ for your microprocessor versus paying $5 for your microprocessor?


Well.. yes? A relative of mine is a student and is into electronics. His monthly income (with various bonuses for good academic performance) is around $100 per month IIRC. $5 is a significant sum for someone like that.

Especially when developing something. I let out magic smoke from many a chip over the years (or partially destroyed one of the internal components, rendering the whole chip pretty much useless).


Right. Also $0.1 part you can easily get a few so you have spares at hand or for follow-on projects, with limited loss if it doesn't turn out great. Whereas dumping $50 on 10 of an expensive part is much more of a risk. Especially bad in places where getting parts means expensive international shipping each time: You want to order enough at a time to not pay shipping multiple times (and/or have long waits), but the parts need to be cheap for that to be viable.


Who's giving out two-digit monthly bonuses for academic performance? Parents? That's a weird way to describe allowance though.


Government in a country where $300 a month is considered to be decent salary.


One of those can be spun into a product, the other one can't.


I think the main appeal is to work with small devices that have well defined resources. Just consider the popularity of the ATtiny85.

However, low end 32bit devices are also available from reputed suppliers. In fact, STM just announced the STM32C* series which is also aimed at replacing 8 bit controllers.

The cost benefit may only be true for low numbers and when sourcing from distributors. I am fairly certain that the price advantage is much less when talking about actual production volumes

*https://www.st.com/en/microcontrollers-microprocessors/stm32...


Can I buy STM32 in some decent numbers, or are they still made out of unobtanium?


Generally the newer STM32s are easier to find because, I assume, they aren't being snatched up by the billions to make designs that were finalized well before these chips were released. I didn't have trouble finding STM32G0 during the height of the shortages.


This is the problem when building around a specific part, no matter how cheap. The hobbyist community has selected certain daughter boards to clone, and then place SoCs on them that can run Linux (or any other hobbyist OS). If one SoC vanishes from the market, you can drop another one in, and often with zero changes to your design, keep going.


Sometimes you just don't want to run full stack OS on a chip to switch relays, while consuming 10 times more energy than running FreeRTOS on MCU.


I get what you are saying. For a typical hobbyist with a project or two, a few-cent (or even few-dollar) saving will most likely not make an economic difference.

However, there are other aspects: 1. Golf. Just like code golf, running some task in the least resources possible (price, memory space, PCB space, flops) is a fun challenge in and of itself. 2. Professional. Some of us do (or used to) have a career in hardware/firmware engineering where the cent-level cost or millimeter-level space actually matters. And it affects how we look at hardware components. 3. General fascination at how far the technology has come along.


Even if you're not a hobbyist, development costs will dwarf BOM costs until volumes are in the 10s of thousands - saving even a dollar per item isn't worth it if you add a few months of development time due to obscure tooling or silicon bugs.


Saving a dollar per chip(what is an item?) is going to add up to 10s of dollars per unit. I am confused.

I get what you mean regarding development costs. The cost of putting a bunch of popular/well supported components on a custom PCB is way too high. Just like the market for glue languages like python is big in the software industry I think the market for glue design tools is big in the electrical engineering industry.

If you can cut the cost of development down by 50%, the number of projects that are worth doing goes up by more than 100%. Each individual project might be less important than the next but since the cost is low it is worth it.


It makes sense if you have volumes in the millions.


I wonder if some of it is a reaction to "growing out of" the narrow AVR ecosystem. When you have a billion options, it's neat to pick something percieved better "because I can"

I have a project that uses the now-deprecated (officially sold through, but you can find an awful lot of them of questionable authenticity on Aliexpress) Teensy++.

The Teensy++ was always expensive for what you got ($24 for an AT90USB1286), but now you can get ARM and RISC-V boards with comparable or more RAM, flash, and GPIO counts, while bumping from an 8-bit 16MHz CPU to a 32-bit 100+MHz CPU, and still pay less money. I've been fiddling with the nanoCH32V305 just because, at $6 per unit, I could put aside a fair stock of boards if I decide in a few years I want to build more of the project.


A few potential reasons:

I could imagine working in the industry professionally, it might become just as second nature to bean-count parts cost as say, to optimise compiled code size as a result of typically constrained memory environments.

Hobbyists who don't work in the industry, may yet aspire to in the future. So, would therefore be wise to develop that ethos, or - who knows - maybe that hobby project could later become something produced in high volumes?

Why needlessly limit a design, when designing something from scratch? It's rewarding to go for optimum goals. It'd be rewarding to aim to design an "optimum cost" system just as it would be for any other optimums one might target.


One of big problems today is availability. Even if other microcontrollers do cost single dollars (which isn't often a case, some for example stm32 chips that were cheap are now going for $40 they're so rare). If you're paying $0.1 per unit you can buy a hundred (or more) for a lifetime supply if they meet your requirements.


If I could throw a dozen $0.50 microcontroller boards at a project instead of trying to optimize on ATmega32U4, that could remove some barriers for some projects, e.g. VR Lighthouse tracking. Indeed it isn't a huge issue at quantity of exactly one per project/device.


It's not even the price that's an issue for me, it's the breadth of the ecosystem. Something like the Teensy (just as an example) leverages the entire Arduino ecosystem from IDE to libraries — never mind community support in terms of forums, blogs, etc.


embedded systems can often be made in their millions.

At those numbers, costs matter. This is why design choices in embedded systems are often unusual.


Here are a couple of factors.

* As other mentioned just like code golfing, minimizing size, cost, resource usage can be valid ways to make hobby project more interesting. I remember having a lot of fun during high school trying to squeeze in code for the project into micro with 1k memory and the whole device into matchbox.

* Not everyone is a silicon valley programmer with 100k salary. While cost of food and other living expenses is mostly also lower in the rest of world, the relative cost of various electronic gadgets and other things for hobbies is a lot more fixed. And with 50x price difference even at small quantities, you will always find some part of world where one side is affordable, but other side if not expensive then at least something that's not cheap anymore and you wouldn't want to waste too many times.

* When you make are hobby project you don't just buy single piece of each component. You buy at least 2-3 in case you mess up, so that you can try again. Especially for highschooler or student difference between $0.13 and $35=$15 can difference between something that is still throwaway and something you would think twice whether you are getting the right thing. Add 2-3 iterations and that $15 becomes $45.

* Just because it's a hobby project doesn't mean it contains single submodule. If you are making a grid of modular things, having a matrix of 10x10 is still cheap with a 0.1 micro, but 500$ is already serious money for a hobby project. You don't need to be mass manufacturing for 50x price difference to matter. Having a small cheap option, opens opportunity for new kind of projects.

* Some people mentioned the time cost of time factor, and that 5$ difference isn't worth it means spending more time. I disagree. The fact that you are doing a hardware hobby project already means that you are wasting time. If you only cared about end result in many cases it would be more efficient to just buy off the shelf product. In many cases the whole point of hobby is to waste time in enjoyable way and it doesn't matter if project is finished in 1 week or 2. And if you can learn more, by solving interesting problems during a process, doing things the hard way is a benefit not a downside.

* A lot of projects could be made even simpler and cheaper (if you take into account cost of development time). If you instead of replacing 0.1$ micro with 5$, replaced whole thing with 100 line python script running on a computer with screen. You can make a lot more impressive visual things on a computer, than blinky LED widgets. But it's so easy it's not fun anymore (there are plenty of fun with computer graphics but it's a completely different kind of thing). Similar thing with people messing with pen plotters. Just pressing print on inkjet printer will produce much better results much faster. People are still making their own CPUs from relays, transistors or logic blocks in computer games, even though

* People have different interests and they can find different aspects of process enjoyable. interesting. It can even vary between projects what challenges the person wants to focus on, and which ones they choose to skip by spending more money.


> The PY32F030 parts advertise a typical low-power stop mode current consumption of 4.5 µA when using a 1.0V setting with the internal regulator, and I was able to get the part to drop down to 5 µA in my testing. Meanwhile, the STM32F030 uses less than half of that in stop mode

I've had the same experience with cheap (Chinese) microcontrollers - power consumption is usually higher across all modes.


It's due to leakage current due to the design being produced on a less refined silicon process.

Live with it, or have external circuitry to power down the whole chip when not in use.


I wonder if the low price could be helped by the core being licensed from "rogue" Arm China. They still seem to be operating independently. https://www.datacenterdynamics.com/en/news/ousted-arm-china-...


The reprogrammable 8 bit Padauk PFS122 is around 6 cents, though out of stock. That's less then PY32 though admittedly not by much.

https://www.lcsc.com/mobile/product-detail/Microcontroller-U...


Like most Arm parts from the East, Puya’s SDK has set them up for Keil MDK development. You can definitely go grab a free version of Keil MDK and get going immediately, but I wanted a VSCode / Cortex-Debug / GCC-based solution, which took a bit more fiddling.

marus25's Cortex-Debug plugin for VSCode is wonderful and I'm starting to see it used more and more in the mainstream. ARM or one of the chipmakers (except possibly Nordic who seems to have their own plugin) should really give this person a salary and help push this plugin along because it shouldn't all depend on one person (c.f. xkcd#2347)

https://marketplace.visualstudio.com/items?itemName=marus25....


I thought this was about a microcontroller to control Flash storage, not a microcontroller with flash built in.

I was all ready for a conversation about replacing computer subsystems with standard parts + open source. Tsk.


Is this legitimately licensed IP, or at this point stolen IP?


The clones tend to be reimplemented from scratch.

It turns out a team of 10 in a few months can reimplement a small microcontroller from just the public documentation of a competitor. By being 100% compatible, customers can move across without any engineering work, and you can reuse the same toolchain.

I doubt either the manufacturer or their customers will have any legal issues.

On the other hand, you probably will have issues when the original and the clone differ slightly or have different bugs.


TFA says this one isn't STM32 clone though. Just the peripherals are similar.

Not sure about ARM license.


> Not sure about ARM license.

I wouldn't be surprised if that's legit. The Cortex-M0/M0+ core is fairly inexpensive to license and use. It's effectively a loss-leader for ARM.


Why would it be a loss leader?

Surely it's because 0.1c X a bajillion chips is still a lot.


Because there are a lot of other tiny microcontroller ISA's, and there isn't much value in using one over another.

If they charged much at all, then people would just use another.


It is supported by Astrobe, for those that would like a bit of Oberon and safety fun while targeting it.

https://www.astrobe.com/astrobe.htm


There's something to be said for EPROM embedded devices. No update-induced bugs.


And lots of parts sales to fix initial bugs! \o/


Wanna bet? Vendors just used to mail you new EPROMs or send you the hex file.


Competitive with CH32V, I wonder.


That's directly addressed in the actual post.


I don't necessarily agree with their take; When your focus is unit cost, tooling is more important.

But it is true that CH32V tooling is, right now, quite sad. Particularly, the only way to flash these devices is to use proprietary tools. That's a major stopper.


do sourcing chips from china have some risks these days?


I'd guess the main risk is that these are fairly small companies with shaky financials that may go under.


For hobbyist I'd say risk here is near zero - comparatively at least. These are going to get wiped and don't have an obvious persistent attack vector and likely deployed behind a NAT. There are a bunch of much softer targets in the average home that don't (IoTs, routers, software etc).

Unless using commercially or you're someone special I don't think it's worth worrying


They're so inexpensive that perhaps you could just purchase a lifetime supply right out the gate? :P


LCSC seems pretty decent. Dave from EEVBlog tested some cheap regulators from there and they performed in spec. Not a huge sample size but still.


Everything is from China.


Most chips (and these probably included?) are actually from Taiwan.

I know that AVR, PIC, microcontrollers directly ship out of Taiwan for instance.


Well not the chips or the microcontroller IP, but maybe the packaged product.


I read today that 8% of US good consumption is from China.


I'm looking for a cheap ARM MCU with I2S support and one that I found was a Chinese part from GigaDevices which is $0.50.

On the other hand, lots of software is written for STM devices so spending a couple of bucks more for their parts will save you development costs and time.


From an employer's perspective, the extra cost of a ready-to-roll development target is always worth it in terms of productivity.

Today's constraints are not tomorrow's constraints; I'd rather be hustling to acquire the skills necessary to earn 500x (or greater) that $100 USD per month.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: