by kragen | 2025-07-19 01:28:26+00:00
The STM32 family is awesome! There's nothing wrong with it as a target! But, basically, by trying to use Uxn on most STM32s you're turning a Pentium-133 into a 386-40, with a corresponding reduction in the kind of functionality you can deliver. Also, you have to write all your software in assembly language.

The most popular model of STM32 is probably the STM32F103C8T6 https://www.st.com/en/microcontrollers-microprocessors/stm32... used on the Blue Pill, which is a 72 MHz Cortex-M3 with 64KiB of Flash and 20KiB of SRAM, consuming up to almost 0.2 watts at full speed. The Cortex-M3 is 1.24 Dhrystone MIPS per MHz https://developer.arm.com/Processors/Cortex-M3 so that's about 89 Dhrystone MIPS. Looking at historical Dhrystone results https://netlib.org/performance/html/dhrystone.data.col0.html similarly powerful CPUs include a 133MHz Pentium, a 66MHz PowerPC 602 (as used in a PowerMac 7100 or an RS/6000 250), a 100MHz PA-RISC HP 9000/715, and a 110MHz μSPARC-II as used in the SPARCstation 5.

We ran web browsers and did video playback on these; they're totally adequate for personal computing as I understand it.

As another piece of context, remember that the original Macintosh had 128KiB of RAM, 64KiB of ROM, and a 7.8MHz 68000 that achieved roughly 0.4 DMIPS (according to the above link). It could run a WIMP GUI, MacPaint, MacWrite, and a WYSIWYG version of Microsoft Word, despite its only mass storage being slow floppies, thousands of times slower and smaller than SD cards.

Currently popular personal computing machines are significantly faster. The Raspberry Pi 3 is about 2.5 DMIPS/MHz, 2201 DMIPS http://www.roylongbottom.org.uk/Raspberry%20Pi%20Benchmarks..... So if you take CPU-bound software that barely runs fast enough on the Pi 3 and run it on the STM32F103C8T6, it will run about 250 times slower. A response that it manages in 100 milliseconds on the Pi 3 will take almost 30 seconds.

But that's assuming it's not memory-bound! The Blue Pill only has 20KiB of RAM, while the bigger machines it's being compared to typically had 2–64 MiB of RAM. You can run 64KiB of code (or data) from Flash, but not self-modifying code, because Flash can only be erased blockwise. (A minimum of ten thousand times, so this is a viable thing to do a few times a day.) You can access off-chip memories, but not at anywhere near 72 MIPS. With the LDM and STM instructions you can theoretically read and write the on-chip memory at something like 250 megabytes per second, 2 gigabits per second, while off-chip SPI (which supports DMA!) tops out at 0.018 gigabits per second, roughly 100× slower. Still, the original Macintosh's floppy was closer to 0.0001 gigabits per second.

Here are the top five most popular STM32 models listed on Digi-Key, with 53000 units or more in stock https://www.digikey.com/en/products/filter/microcontrollers/...:

US$1.73 STM32F030R8T6 (48MHz, 8KiB RAM, 64KiB Flash, Cortex-M0) https://www.digikey.com/en/products/detail/stmicroelectronic...

US$1.21 STM32G030K8T6 (64MHz, 8KiB RAM, 64KiB Flash, Cortex-M0+) https://www.digikey.com/en/products/detail/stmicroelectronic...

92¢ STM32G030F6P6 (64MHz, 8KiB RAM, 32KiB Flash, Cortex-M0+) https://www.digikey.com/en/products/detail/stmicroelectronic...

US$3.08 STM32L071CZT6TR (32MHz, 20KiB RAM, 192KiB Flash, Cortex-M0+) https://www.digikey.com/en/products/detail/stmicroelectronic...

US$3.25 STM32L071RZH6 (32MHz, 20KiB RAM, 192KiB Flash, Cortex-M0+, tiny BGA form factor) https://www.digikey.com/en/products/detail/stmicroelectronic...

So any of these devices is probably pretty capable of running the kinds of apps Uxn is directed at, if you hook up a screen and speaker to them. They have less RAM than the original Macintosh, but their CPU is around 100 times faster, and they can swap to off-chip memory, including MicroSD cards, which consume no power for memory retention, just reading and writing. When I was a kid, I ran word processors, high-level-language interpreters and compilers, spreadsheets, databases, and IDEs on machines that were less powerful than these chips in every way, including having less memory (though usually it was almost all RAM).

Take a look at https://rossumblog.com/2011/10/08/8-bit-device-kindles-ebook... and the rest of Rossum's blog by Peter Barrett to see the kinds of things all that CPU power can do despite the small RAM.

Power consumption seems worth a mention, because "minimization of energy usage" figures prominently in the permacomputing ethos as explained in https://wiki.xxiivv.com/site/ethics.html. Running at full speed, the higher-speed STM32 parts use more power, up to hundreds of milliwatts, while the lower-speed, lower-power STM32L parts are more like tens of milliwatts. By suspending execution, though, this power consumption is proportional to CPU load down to a few thousandths of a milliwatt. A Chromebook uses about 10000 milliwatts; a cellphone about 3000; and, according to https://www.eetimes.com/nintendo-gameboy-eases-down-the-road..., a Game Boy Advance uses about 200 milliwatts playing Donkey Kong.

(In human terms, 100 milliwatts is the amount of mechanical work per unit time done by pulling the pull cord to start a chainsaw or lawnmower about every 15 minutes. So, if you hooked up an electrical generator to such a pull cord, very roughly, you could keep a Chromebook running by yanking on the pull cord about every 10 seconds, a cellphone about twice a minute, a Game Boy Advance about twice an hour, or a 1-milliwatt STM32 about once a day.)

But these chips are probably not capable of running the apps Uxn is written for if they're running Uxn! I mean, if you're moving sprites around the screen or sounding tones with ADSR envelopes, that's handled by Varvara's "devices", which you can implement in native code, so they're just as lightweight as they would be in any other form. But your own application code is being interpreted by the Uxn bytecode interpreter, so 95% (my guess) of the CPU time is devoted to stack manipulation and interpretation overhead. So instead of 89 Dhrystone MIPS like a SPARC 5, you get 5 DMIPS. CPUs in this class from the above list include the 25MHz SPARCStation 1+, a 40MHz AMD 80386, an Amiga 2000, and a deskside 16.7MHz 68020 Sun 3/160C server http://www.obsolyte.com/sun3/, which was one of the very first Sun-3 models http://www.sun3zoo.de/en/history.html.

And you can't usefully JIT-compile Uxn code because it idiomatically relies on pervasive self-modification in order to squeeze a bit more performance out of the inherently expensive bytecode-interpreter strategy. Uxn is also not very suitable as a compilation target for higher-level languages like C.

So, the STM32 family is great as a target, but except for the higher-end members of the family like the 168MHz STM32F746 used in the Playdate (US$14.33 https://www.digikey.com/en/products/detail/stmicroelectronic...), Uxn is not great as a way to make them useful.

It's wonderful as a way to inspire us to imagine what could be, though!

I'll address your comments about the bootstrapping path in a second comment.