Reusing mask/OTP-ROM uCs

A project log for Random Tricks and Musings

Electronics, Physics, Math... Tricks/musings I haven't seen elsewhere.

Eric HertzEric Hertz 12/02/2022 at 23:4510 Comments

The 8x51 series *has* internal ROM, even the 8051. The 8031/8032 are allegedly "ROMless" versions of the 8x51/52.

What that means to designers/hobbiests is, e.g.: 

You can design for an 8031, with an external ROM, then drop-in any old 8x51, even if its (OTP, mask, etc.) ROM was programmed with code from an entirely different product, or buggy, or whatever.
Find some old 8x51 in some old piece of trash, think it's worthless because it's already been programmed...? Tie one pin to a voltage rail and use it as an 8031 in your own project.

What that probably meant from Intel's perspective:

"Hey, a customer ordered a bunch of preprogrammed 8051's, but discovered a bug before we shipped" and/or "We got a batch of 8051's with flaky ROMs" and "we're sitting on 1000's of otherwise useless 8051's. What should we do with them?" "Remarket them as ROMless 8031's, and let the new customer supply their own ROM chip!"

Forward-thinking, reusability, reduction of eWaste...

And, in this new era of old paper datasheets now scanned and uploaded as pdfs (as opposed to my earlier experience where pdfs only existed for products designed in the pdf-era (THANK YOU to those who take the time and provide that effort!)), I've discovered that many previously zero-search-result ICs on old PCBs scavenged from VCRs, CD players, TVs, Stereo Components, and whatnot, now have full-on datasheets detailed down to instruction-sets and hex operands... 

And many of those, similar to the 8051, have a pin which can be tied to a voltage rail to disable the internal mask-ROM, enabling them, like the 8031, to run off an external ROM.

Wow! SO MANY uC designers, of so many various architectures, even 4-bit, considered this worthwhile! And even if it was purely because they wanted to sell otherwise defective/wrongly-programmed uCs, it *still* benefits the likes of the customer and even the alleged us, that are hardware hackers.

I dunno, I thought it was darn-relevant in the "chip shortage era."

[Inspired by the lack of response to my comment at and the fact it seems to be blocking my adding the above as a clarification-reply.

Fact is, I've been meaning to document my box full of scavenged PCBs with such uCs, and maybe even turn each into a "NOPulator"]


Oh, it finally appeared there, twice, numerous hours later. Heh.

I even got a response suggesting looking into Collapse OS:

(Very Intriguing).


Lots more thoughts and My Collection, now over at:

#Repurposing OTP/mask-ROM microcontrollers 


RunnerPack wrote 12/14/2022 at 19:33 point

I like your theory, but I'm more inclined to believe that the feature is added so that code can be developed on EPROM/Flash, then moved to the internal OTP/Mask ROM for production.  Either way, your point is valid, and I love being able to reuse scavenged parts from what would otherwise be garbage.

When I read the title of your post, I was hoping you had been experimenting with a technique I've thought of, which is programming _over_ the contents of an OTP, turning existing opcodes into NOPs and JMPs so that new code can be shoehorned into the unused "FFs" of the ROM (since bits can only be cleared).  Either that or decapping the chip to expose the die to UV ;)

  Are you sure? yes | no

Ken Yap wrote 12/14/2022 at 23:53 point

I already did this for years with 8042, 8048 and 8051 MCUs extracted from old equipment in a few of my projects published on HaD without a second thought about what was already on the chip since what is inaccessible effectively does not exist.

The drawback is really how to extract the MCU from the equipment. If they are socketed then no problem. If they are TH soldered or surface mounted then a bit harder. Reusing them in-situ has issues too since you need an extra 373 latch to use Intel MCUs with external (E)EPROM, and the wiring to the GPIO pins may not be entirely suitable.

Ironically the 8051s may be the least suitable because of the wide availability of cheap ($1-$2) modern variants with flash memory, higher clock rates, more features, better specs (e.g. active pull-up outputs), that it's hardly worthwhile to recycle old 8051s.

  Are you sure? yes | no

Eric Hertz wrote 12/15/2022 at 00:49 point

Of course you have, Ken... I should've known to consult you first on the matter!

Extracting through-hole stuff is easy, blast the solder-side with a heat-gun, then tap the board on the edge of the table... they fall right out. (unless, of course, they bent a few pins before soldering, but that's just a few seconds with a soldering iron to fix).

In situ is where I'm mostly leaning with many of my non-socketted scavengings due to things like crystals and support components onboard. Also some of these chips are really weird, like 0.05in-spaced staggered pins, which i find quite intriguing. Nevermind surfacemounts I'd rather not design a one-off PCB for. I also kinda like the idea of keeping them in their original PCBs to showcase their origins. Many are single-sided, so i figure trace-cuts are easy.

I've got chip-clips for regular DIPs, but am thinking there may be other more permanent methods... e.g. I've seen regular "flat-pin" IC sockets which extend *around* the DIP, and make contact not only by squeezing against the tips of the pins, like normal sockets, but also have spring-contacts that push against the sides of the pins, where they bend into the chip package. I *think* those could be turned upside-down and placed atop the chips, instead, and soldered on the underside of a PCB. Maybe with some added structural support to squeeze the sides with more force. Kinda like a .1in-spaced two-sided plcc socket squeezed atop a chip that's surfacemount soldered.  They were *so* cheap... Why'd I hesitate? But, alas, all the surplus was bought-out before I thought to figure out a part number/brand :/

The weird-shaped chips, though... I mean, I guess I'm imagining lots of bodge-wires... and a separate board, dangling. Or maybe finding some empty space and/or stripping most of the unused original components and cutting traces and drilling holes to turn it into custom perfboard... dunno yet.

As far as practicality, well... I guess it depends on one's definition.

Yeah, findings like dozens of desocketted preprogrammed uCs make for many actual useful design possibilities. OTOH, in a pinch, or just for the sake of learning, I guess if someone needs a timer for their chicken coop, a little cutting, drilling, and bodging might do the job nicely.

But, I dunno how I feel about your "hardly worth" evaluation re: 8051's... In fact these new-to-me "discoveries," combined with supply-chain issues with my particular variant of countless-variant uCs, have me feeling a bit like if the project has space and power and can be satisfied by an 8031, why not use something reusable, easy to find, and still made in countless pin-and-code compatible variants?

I'mma have to look through your projects again more closely. Hadn't realized you'd been doing this in those. Cool!

  Are you sure? yes | no

Eric Hertz wrote 12/15/2022 at 03:40 point

Hard to keep comment threads organized, with notifications, when they're only allowed three deep... So, replying to below...

Oh! I didn't get the impression you were trying to claim "first!" on these ideas. Did it sound like I was trying to claim first?

 Regardless, indeed... I've been at this stuff for 20-30years, and for things like this to have slipped past me for so long suggests that they're not as common knowledge as the common-thread [I've been lucky to stumble on] in the datasheets of the era would seem to suggest. And, are probably long-lost in the products today (where I haven't seen/noticed such things in their datasheets in all my years). Likewise, with folk often sticking with one brand/architecture or another, even many of them, who made use of features like these, may've been unaware that the features their uC-of-choice provided were also available in so many others...

Something like the EA pin is especially relevant, because it opens up the possibility to explore many architectures and their other similarities that folk may otherwise consider incompatible. At some level, not much deeper than a pin-remap and learning different mnemonics, these things are very similar; could almost build systems with a simple daughter-board with a universal pinout to support any processor. Code it in a minimal/unchanging subset of C, and one could even compile the same code for whatever architecture/brand CPU happens to be available.

 If we continued to think along those lines, then till now, newer features available to newer systems based on those same principles could improve the situation even more... e.g. now we have the technology to  throw the original C code as a file in FLASH... Twenty years from now your CPU-Of-Choice starts flaking, and is no longer available? big deal, grab the code from the onboard flash, recompile for whatever is available...

I dunno, I try to think bigger than the project du juor's expected usefulness. Not claiming to be good at it.

But "less fossil fuels", heh... I wonder about that sorta thing sometimes. 

If you're making a TV remote in the millions that has two huge DIPs and they eat through batteries, then yeah, it'd have a comparatively huge environmental impact in physical resources, shipping that heavy thing, powering it, manufacture/disposal of so many batteries, etc. compared to a tiny TQFP which barely will empty a coin cell in the expected lifespan of the product.

So then the answer seems crystal-clear. Go with the tiniest product made from the fewest resources, sipping as little power as necessary, and requiring the fewest support components.

[heh, no comment on solar calculators, and how that logic could apply to TV remotes!]

OTOH, if you're making a  system in the tens or hundreds that are expected to work day-in and day-out for 20 years, it might be wise to think about power-consumption as a huge contributer to its ecological/economical impact...

But what is the impact of using a ROHS tqfp-100 flash-uC with a one-model pinout providing inbuilt peripherals that're going to be outdated and forgotten in 5 years, and a new silicon process that hasn't even existed (nevermind tested) for 5 years, from a chip-fab who plays loose with revisions in every new batch?

If you coulda just used an 8031, an EPROM, and a UART, every part could be repaired/replaced, still now, 40 years later.. If they had flash, at the time, the sourcecode and a backup ihex file could be there ready to go. So it consumes a little more electricity? And we compare that to the manufacture and shipping and disposal of the five new 'efficient' systems needed to replace it in the same time-frame?

  Are you sure? yes | no

Eric Hertz wrote 12/15/2022 at 04:25 point

Oooh.... you just got me thinking with "What's inaccessible essentially doesn't exist"

I wonder how fast that EA pin acts, (willing to bet it's not documented to this extent) if it's latched at boot, or essentially nothing more than a 'chip select'...

If the latter, the internal OTP high-bit low-bit overwrite technique could be combined with an external ROM for whatever purpose (say storing lookup tables internally).

Or, maybe the external ROM could be replaced with a RAM, to enable booting from internal rom, then executing programs (say loaded from disk) from RAM on the otherwise Harvard-architecture of the 8031/51...

Of course, now that I say it, I realize that *of course* code could be loaded into and executed from a ram chip attached to the rom bus. Just gotta throw a couple gpios at the problem. Or, heck, doesn't the 8051 have external ram as an option, too? could just "glue" the ram-select and rom-select pins together to a ram (and tiny bit of decode for mapping an external boot rom) No EA hackery necessary. Still... weird concept with possibilities.

  Are you sure? yes | no

Eric Hertz wrote 12/15/2022 at 06:52 point

Ouch. Wow.

The "carbon footprint of keeping someone alive".

Nice one, again, Ken. Do you ever actually listen to your own words?

I think I should stop there. Lest... no, I need to stop.

BTW, you've come and gone in my projects many a time... have you read the bits about my life-situation? Because, I mean... Wow. That one... Hard not to take personal... let's kick em while they're trying to get up, eh? 

Not the first time, either.


As for "retro." Of course you'll see that at the forefront... same with dang-near everything. Even something as important as elections are little more than elaborate superbowls to far too many folk. We live in a world where a "midlife crisis" is something not only accepted, but expected accepted and accomodated, and yet really means little more than "when I was a kid I wanted to be a... but now I'm 50 and I never got my way, so now I'm throwing a tantrum until I get it."

Worst part is, I accepted and spent far too much effort trying to understand because I thought it was more along the lines of some sort of awakening to 50 years of wisdom-gained from countless seemingly disparate experiences and suddenly understood to fit together in some cohesive whole.

Maybe that is the cohesive whole... "just have fun!"?


Yeah, that comment of yours is hitting doubly-hard, now, as I've seen it too. I try to contribute some hard-earned wisdom, try to make boring things seem a little more fun, and what I see instead is its being misunderstood and yet still misused for toys, then I see the toymakers considered experts and watch as they displace truly dedicated folk, then I see them complain about chip shortages like school-kids complain about a snow-day... and it makes me wonder why I even bother.

Nah, you're right. They don't deserve this knowledge; all they'd do with it is increase the demand, and jack up the prices on what trash they left for the likes of us to try to make something useful of.


But, thankfully, there are a handful who have other reasons... They're near impossible to see amongst the droves.

  Are you sure? yes | no

Eric Hertz wrote 12/15/2022 at 00:08 point

Only thing about your pre-mask dev theory is that *so many* pins (and peripherals?) would be unusable in the end-product., because they wouldn't be testable in the external-ROM prototyping/programming phase.

But, uCs were pretty new, so maybe that was just expected.

Long ago I acquired a couple "piggyback" microcontrollers, which are beautiful 6809(?)-based purple ceramic 40pin DIPs with gold machine-pin sockets atop, for piggybacking a ROM. I later learned that was actually a pretty common 'devkit' option for many mask-progrogrammed microcontrollers. For exactly the purpose of keeping all the normal pins free. Really cool. I can't help but think of throwing quite a bit more on that exposed bus, e.g. RAM, maybe mem-mapped I/O...


Actually, I did write about a buddy of mine who did quite a bit of exactly what you describe (overwriting with NOP, etc.)... "NOW, THAT'S A HACK"

Great thinking!

And decapping/erasing, wow, hadn't heard of that one before. That'd be quite something.

Glad to meet a fellow repurposer!

  Are you sure? yes | no

Ken Yap wrote 12/15/2022 at 01:31 point

Many experimenters before me have used the EA pin to enable external program storage and published on the Internet so I can't claim that credit. Still it's good that you're reminding others of this possibility.

Same for the heat gun technique, I read it somewhere long ago and that's how I got my large collection of logic chips.

As for worthwhile it depends on what you're after. If it floats your boat to experiment then go for it. After all I did that too. But if wanting to get something going then one would spend less time and probably less fossil fuels using a modem descendant of the 8051. Those chips are not in short supply.

  Are you sure? yes | no

Ken Yap wrote 12/15/2022 at 04:16 point

No, I don't mean the fossil fuel embedded in the product lifecycle, but the carbon footprint of keeping the experimenter alive through the hours of hacking an old piece of equipment to do what would be trivial with a modern MCU. Look, I'm just as guilty of this; I don't really need another clock say made from an old nixie thermometer, but I enjoyed the challenge of seeing old parts come alive again, albeit in another configuration, and I learnt things. Pretty much all the retro projects on HaD would have be justified by: because it's fun, we felt nostalgic and we can. Anyway enjoy.

  Are you sure? yes | no

Ken Yap wrote 12/15/2022 at 07:21 point

Oh dear you do have a knack of assuming ill-will. I'll leave you to it. All the best and enjoy.

  Are you sure? yes | no