By Jack Ganssle

Code Size - Are most embedded apps still small?

In my January 14th column I tried to show just how <i>big</i> a million lines of code really is. Conventional wisdom states that code sizes are growing at dizzying rates. Some pundits estimate that firmware doubles in size every ten months to two years.

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

code size

These polls are completely unscientific, but, like an impressionistic painting, give a sense of the way things are. The data suggests that a third of all embedded projects are less than 10K lines of 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 half million lines of code, with just a further 8% in the 100-500 KLOC range. 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 on my desk that has less than 10 KLOC of code buried in it. It's a pretty darn powerful CPU, but, despite being a 32 bitter, is a microcontroller sporting only 32 KB of on-board flash. It maxes out on small applications.

Microchip Technology sells about a billion PIC-series processors a year now, along with a variety of other chips and products. That's something like 15% of all processors sold worldwide. Most PIC chips have a pretty limited address space; the smaller ones can only address a few hundred words of memory so even 10 KLOC is an impossible dream. That make's the survey results sound reasonable, though equating number of CPUs sold with number of development projects is perilous. But Microchip did sell 100k development systems last fiscal year, which averages one to every five firmware engineers worldwide. (Last year Microchip's revenue was about a billion dollars, suggesting the average selling 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 an alternate action switch costs more than momentary contacts plus an 8051 that remembers the selected state. Another outfit put a processor in sneakers to blink LEDs. Dedicated logic wasn't an option purely because marketing could never make up their mind what the blink pattern should be. Plenty of other companies distribute small controllers with smaller programs over a PCB to encapsulate access to I/O devices.

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