Code Size: Are most embedded apps still small?

In myJanuary 14 column I tried to show just how big a million lines of code really is.Conventional wisdom states that code sizes are growing at dizzyingrates. Some pundits estimate that firmware doubles in size every tenmonths to two years.

But is conventional wisdom wise? The poll accompanying that piece isreproduced here:

These polls are completely unscientific, but, like animpressionistic painting, give a sense of the way things are. The datasuggests that a third of all embedded projects are less than 10K linesof code. Tiny – a 10 KLOC program just does not do very much.

Only 14% are in the “these are scary-big” category of over a halfmillion lines of code, with just a further 8% in the 100-500 KLOCrange. I wonder how much of that is COTS versus in-house firmware.

32 bits is everywhere. But I've got an ARM9-based system running onmy desk that has less than 10 KLOC of code buried in it. It's a prettydarn powerful CPU, but, despite being a 32 bitter, is a microcontrollersporting only 32 KB of on-board flash. It maxes out on smallapplications.

Microchip Technology sells about a billion PIC-series processors ayear now, along with a variety of other chips and products. That'ssomething like 15% of all processors sold worldwide. Most PIC chipshave a pretty limited address space; the smaller ones can only addressa few hundred words of memory so even 10 KLOC is an impossible dream.

That make's the survey results sound reasonable, though equatingnumber of CPUs sold with number of development projects is perilous.But Microchip did sell 100k development systems last fiscal year, whichaverages one to every five firmware engineers worldwide. (Last yearMicrochip's revenue was about a billion dollars, suggesting the averageselling price for a PIC is under a buck.)

I see some programs that are no more than a few dozen lines of code.One company buried a processor in their flashlight, as they found analternate action switch costs more than momentary contacts plus an 8051that remembers the selected state.

Another outfit put a processor in sneakers to blink LEDs. Dedicatedlogic wasn't an option purely because marketing could never make uptheir mind what the blink pattern should be. Plenty of other companiesdistribute small controllers with smaller programs over a PCB toencapsulate access to I/O devices.

But most pundits think gigantic code sizes are the norm. The polldata suggest that just isn't so. What sorts of project do you do, andhow much code do they consume?

Jack G. Ganssle is a lecturer and consultant on embeddeddevelopment issues. He conducts seminars on embedded systems and helpscompanies with their embedded challenges. Contact him at . His website is .

Leave a Reply

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