Archive for the ‘Uncategorized’ Category

Embedded History Month

Tuesday, April 8th, 2008 Michael Barr

This seems to be the month for celebrating the history of embedded systems.

Twenty-five year old compiler vendor IAR, which just launched a nicely redesigned website, has published an interesting history of the company and its founder, Anders Rundgren.

And next week I’ll be out at the Embedded Systems Conference, which is celebrating twenty consecutive years of bringing the community together with a backward-facing keynote led by Jack Ganssle.

USB On-The-Go

Thursday, January 31st, 2008 Michael Barr

Last fall, Netrino was asked by a prospective client to assist with the design of a product to be controlled by a smartphone. At first, the requirement was stated as a Bluetooth connection between the smartphone and the product. Later, however, Bluetooth was deemed by the client too complex a connection for their customers to manage. Thus the connection requirement was changed to a USB link via physical cable.

Unfortunately, and quite to our client’s surprise, this was easier stated as a requirement than implemented. USB is not a bi-directional protocol. According to the standard, each USB endpoint is either a “host” or a “device”. A PC running Windows is an obvious USB host. Printers and mice are obvious USB devices. But what about a smartphone, particularly a smartphone running Windows Mobile? Should a smartphone be a USB host or a device? The answer turns out to reveal a design oversight the original USB specification.

For historical reasons, USB was stuck with this host vs. device design issue and smartphones were all treated as USB devices only. (Smartphones make sense as devices when considered in relation to the host PCs they sync with.) So what would happen if you wanted to use a smartphone like our client as a USB host, with a device like a printer attached directly?

As we would learn in our research, this shortcoming of the original USB standard was recognized over a decade ago and a new standard called USB On-The-Go (OTG) was defined to allow products like smartphones to change roles from USB host to USB device on the fly. Unfortunately, this requires dedicated hardware at the USB interface–as well as different cabling.

For one reason or another, USB OTG technology never made its way into smartphones. There is certainly historical evidence of chip supplier attempts to integrate OTG. But perhaps the emergence of Bluetooth as an alternate host or device technology in that product space about the same time led to OTG being excluded from or disabled at the smartphone design level.

Unfortunately, that left our client between a rock and a hard place. Control via USB would be possible only with a USB host implementation in their product and a custom interface between that and the smartphone. The didn’t want to use Bluetooth and couldn’t use USB.

How have you solved this problem?

Firmware Code of Ethics

Friday, September 15th, 2006 Michael Barr

WE THE MEMBERS OF THE EMBEDDED SOFTWARE COMMUNITY, in order to protect our customers (and their customers) from the risks inherent in our products, extend product lifetimes, lower long-term maintenance costs, promote the general welfare of society, and advance the integrity and reputation of our profession, do hereby ordain and establish the following code of ethical conduct.

Check return codes. If a function can return an error code, it will almost certainly return one eventually. How will our software recover if it doesn’t even know an error has occurred? We will, therefore, always check all return codes. When an error is detected, we will take whatever action is required to recover safely.

Document reasoning. We make dozens of design and implementation decisions each week; we forget the reasoning behind others at a similar pace. We will, therefore, document all of our reasoning in the code itself. Furthermore, we will update these comments if our reasoning changes.

Use version control. Even when done carefully and with discipline, making backup copies of source directories, commenting out code that might be needed again, and tracking changes in comments is insufficient. The use of a good configuration management tool is a must. Furthermore, we agree to always perform a diff and provide a good description of the explanation for all changes each time a file is checked in.

Enforce coding standards. No matter how proud we may be of our abilities, we do not “own” the code we produce. Our employers and clients own it; we and others are hired to develop and maintain it. The true owners have the right to enforce a coding standard upon our work. If they do not choose to exercise this right, we will self-enforce a standard in line with generally accepted programming practices.

Run lint regularly. Compilers are more concerned with generating code than the correctness of your syntax. Only a static analysis tool like lint can watch over our shoulders to ensure we’re not straying into dangerous or non-portable programming constructs. We will, therefore, include lint in our development process. If we don’t remove all code with warnings, we will at least understand why each and every warning remains.

Perform code inspections. Automated tools are helpful, but nothing is better than a peer review for finding logic errors. Code inspections have been shown to be many times more efficient than any other single debugging tool. We will always review our code as a group at least once before each release.

Assign one tester to every developer. Programmers make lousy testers, especially when it’s their own code they’re testing. For best results, one independent tester should be hired for every developer. And the testing team must maintain and rerun regression tests regularly, to certify that a new release is at least as good as the previous one.

Measure performance. Of course, there are some kinds of tests that are best performed by the engineers themselves. In real-time systems, we shall directly measure interrupt latency and the time it takes each of our critical subroutines to complete. An oscilloscope and a spare I/O pin are quite handy in this regard.

These best practices are easy things to do, and all are inexpensive to implement. A one or two person design team can as easily follow these rules as a 50-person engineering department. If you aren’t following these rules today, there are no excuses for tomorrow.

Electronic Voting

Sunday, January 5th, 2003 Michael Barr

Many people take the position that electronic voting is less trustworthy than paper-based balloting. Without dismissing their concerns, I think we should also consider some of the positives that electronic voting may bring. Having moved this fall, I had the unlikely experience of using a shiny new touch screen electronic voting machine during the primary, then going back to a paper ballot during the general election. Traveling backward in technology like this gave me lots to think about.

Some of the really nice things about the touch-screen system are the ease with which a voter can change his mind or correct a mistake, and the virtual certainty that you’ve cast all the votes you are allowed and that they’ve been properly read. Misvotes, undervotes, and overvotes are all possible with optical scanners and other paper-based systems, since the ballot readers don’t give the voter any feedback. However, electronic touchscreen voting eliminates these issues.

First, Do No Harm

Monday, September 17th, 2001 Michael Barr

Many of the folks I hang around with own digital watches. I have one myself. In addition to keeping fairly accurate time, mine features a stopwatch, a countdown timer, and a set of five alarms. A friend has a different watch from the same company—one that features a digital compass. To take a compass reading, you stand still, hold the watch level, press the “Compass” button, and read a cardinal point (N, NNE, NE, ENE, E, etc.) and angle in degrees. The reading tells you where the top of the watch is currently pointing.

Multi-function devices like these aren’t unique. Lots of products have multiple features. Today’s buzzword for this phenomenon is “convergence.” Staying only with the watch theme for a minute, there are GPS watches, watches with digital cameras, calculator watches, and full-featured PDAs for your wrist. There are also watches that double as heart rate monitors, pagers, cell phones, and TVs. There’s even one watch that runs Linux—X-Windows and all. It seems the wrist is pretty valuable real estate.

No matter which of these devices you might choose to wear on your favored wrist, the device is still primarily your watch. No one in their right mind would wear a multi-function watch on one wrist and a backup timekeeping device on the other. It’s reasonable to expect that, no matter what goes wrong with the extra features of the watch, you’d at least be able to get the time from the thing. Or is it?

My friend learned the hard way that the failure of a watch extra can interfere with it’s implied ability to keep the time. On a recent trip to Alaska, my friend managed to confuse the digital compass in his watch twice. This happened first on the airplane, several miles above the Earth. The second time it happened he was hiking north of Anchorage. Each time, he attempted to take a compass reading only to have the watch reboot itself. Apparently, the strength of the Earth’s magnetic field isn’t within a useful range in those locations.

The designers of this particular watch must have decided that bad sensor readings were more likely than useless magnetic field values. And they deemed rebooting a good way to “fix” a bad sensor. This might have made sense in a lab environment, where the only bad readings were manufactured. However, in the real world, there are places where compasses—even those of the analog sort—aren’t useful. In the process of rebooting the watch, the current time was lost—a far more costly problem for the wearer than an out of range compass reading.

The lesson here is not exclusive to watch designers. All of us who are designing multi-function devices should consider the functions separate. A problem with one function should never be the cause of problems with another.

NOTE: this article was originally published on 7/13/01.