Member Contributed Articles
2003a: Embedded Linux
(by Dennis Kenney; January 2003)
By Dennis Kenney
Free as in Free Sex
"Software is like sex: it's better when it's free." -Linus
This quotation appears in "Just for Fun", David Diamond's biography of Linus Torvalds written with Linus. Linus, a socially-challenged geek, married the first woman to ask him for a date. Of course the invitation was by email. How else?
Linus believes Linux should be everywhere, from supercomputers to embedded systems. Linux supercomputers are being made from thousands of commodity microprocessors. Writing in "Just for Fun" in the context of the appeal Microsoft and Linux has for the masses, Linus says: "Linux doesn't have just one niche." "And at the same time you'll find Linux in embedded devices, everything from anti-lock brakes to watches. Watch it flow."
Linus' acceptance of a position at Transmeta caused as much consternation as the news that his wife Tove was expecting. Transmeta produces software that makes their simple and less power-hungry CPU perform like larger and more power-demanding CPUs. Linus wrote the original Transmeta x86 (x86 designates a clone of the Intel CISC family of processors) interpreter. Metadata is hoping that the shipping of their second generation chip will make Metadata profitable.
Embedded OSs have different requirements than general purpose OSs. As Microsoft and Embedded Linux RTOS vendors have already found out, one size doesn't fit all.
Valley of the Sun
Arizona is a land of dust devils, scorpions, road runners, and Goldwater Republicans. Tempe, Arizona is the home of Arizona State University, Honeywell Commercial Aircraft Systems and Rob Wehrli live in Phoenix. The restaurant at Pinnacle Peak with its animal by-products kicking band and Rawhide are near Scotsdale. We'll throw in Motorola and Luke Air Force Base just to show you the diversity of the greater Phoenix area. And of the greatest importance, Phoenix has pretensions of becoming the Embedded Systems Capitol of the world. Phoenix could be considered a Refried Beantown.
Rob, a consultant at Arizona Cooperative Power, is at the October Boston Linux and Unix User Group to show us how to program embedded systems with GNU tools. Rob found the Java User Group that I went to in Phoenix when I worked on Honeywell's Flight Management System--a critical real-time embedded system that is installed in practically all of the new Airbus and Boeing airline jets. Rob gets the group on the same page right up front. What are embedded systems?
Personal computers and workstations aren't considered to be embedded systems even though they contain numerous embedded microprocessors and microcomputers (central processing units (CPUs)) in their video adaptor cards, microdiskette and hard disk controllers, sound boards, and network interface cards (NICs).
The main chip in your PC is a microprocessor. It could be an Intel Pentium II or an IBM PowerPC. A microcomputer can operate without peripheral or helper chips such as random access memory (RAM). Its program will be small since its program size and data are restricted to on-chip memory. A microcontroller is a specialized microcomputer that outputs control signals to a bus or serial port. A microcontroller is usually smaller than a microprocessor and may not have an operating system that can be distinguished from the application software. Your PC is likely to have a digital signal processor (DSP) or two in its modem and wireless interface chips. A DSP has an instruction set that is designed for signal processing, of which some of the instructions are unique to digital signal processors. Finally, a special-purpose device, the video processor, that's a cross between a CPU and a DSP, drives the monitor. Any hybrid of these basic units is possible depending on the design challenge. Systems-on-a-chip (SoCs), programmable logic, and application specific integrated circuits (ASICs) are beyond the scope of this article.
Embedded systems are all those little computers that we usually don't notice, such as digital watches, cellular phones, electronic toys, the brains in set-top boxes and game computers, Navstar Global Positioning System (GPS) receivers and modems, and the controllers in our automotive air bags, brakes, fuel, and ignition systems. Sometimes they are described as real-world systems because they sense and talk to things outside of themselves. The outside world could be a LAN, a WAN, a display system, or storage devices. Embedded systems spend a lot of time socializing since complex systems can have scores, hundreds, or thousands of embedded systems, thus the term distributed systems.
These systems all have time constraints that determine if their performance is fast enough. Systems that have small time constraints that must have guaranteed task performance are described as being real-time. Their behavior must be deterministic - guaranteed to occur under all circumstances. Basically, all embedded systems are real-time, the term real-time being reserved to describe those with critical time constraints. Linux is described as being almost real-time, and is good enough for many embedded systems.
Operating systems that have large kernels can't be made real-time but are good enough for many applications. The marketers describe these systems as being time-sensitive, pointing out that as CPUs continue to get faster more applications will move into the good-enough region.
Inertial reference systems, the next-generation replacement for the older iron-wheel inertial navigation systems, have laser gyros to sense angular displacements. A laser beam is split so that the resulting beams interfere with each other in the cavity of the ring gyro. Angular displacement and direction are determined by counting the number of lines in the diffraction pattern that moves pass a photo detector. It is "critical" in such real-time systems that the number of blips in each accurately measured time period be computed during each and every cycle to maintain the correct values for angles, velocities, and displacements (position). The real-time operating systems (RTOSs) used in such systems are proprietary at the present time.
Critical Real-Time Systems
Protection in the time and space domains means respectively that one task will not prevent another task from meeting its time constraints by tying up the CPU and a process will not write to another process's allocated memory space, corrupting its code or data. Further levels of "protection" can be defined concerned with security and failure/recovery modes.
Grand Rapids, Michigan, home of Smiths Aerospace's American division, has more Mexican restaurants than Boston. Smiths has made inroads into Honeywell's Flight Management Systems monopoly in commercial avionics by installations in Boeing's new improved B737s, the B767 Tanker Transport, and Boeing's Lockheed's C-130 Avionics Modernization Program (AMP).
Avionics are those electrical systems in airplanes that navigate, communicate, control flight path and the engines, record flight data and display situational information to the flight crew. Ada, the programming language named after the Countess of Lovelace, is the preferred language for critical systems. The Ada environment is required to coexist with C and C++, proof of the dominance of C in real-time applications. DO-178B is the FAA standard that critical avionic systems are certified to. The unified modeling language (UML) is used in the process-driven real-time systems development as well as in commercial business applications. State diagrams are especially important.
Specifications for avionic equipment are maintained by the Aeronautical, Inc. corporation (ARINC). ARINC 653 is a specification for an avionics computer that can be partitioned into applications of varying criticality. The operating system has to be certified to a level as high as any of the applications it is controlling, usually Level A, the highest level. Green Hills' AE653 operating system is certified to Level A, giving avionic manufacturers using the RTOS a jumpstart on certifying a DO-178B, Level A, system based on ARINC 653.
This is the domain of heavyweight process (the Software Engineering Institute's Capabilities Maturity Model (SEI's CMM)). I do like two-member team programming and the write-test-first(or during)-coding techniques of Agile Programming but Extreme Programming hasn't penetrated into critical real-time systems.
Reference and Commercial Off-the-Shelf (COTS) Systems
The PC/104 standard platform was designed single-handed by Ampro. A complete x86 (Intel-compatible) computer can be placed on the small single board computer (SBC) with standard "legacy" connectors for serial, parallel and keyboard connections. New-style connections for the universal serial bus (USB) and LCD-drivers have to be added with non-standard connectors. SBCs with the newer, larger CPUs, standards-based connectors for the newer interfaces, and more real estate enable more complex designs. Motorola emphasized real-time applications before Intel by designing chips for adverse environments. The lower power required by RISC chips is another advantage that the PowerPC has over Intel's CISC family of CPUs.
Newer "transition" reference platforms have non-standard connectors - translate that into expensive proprietary cables. A cottage industry has grown up to supply hobbyists with "cheap" copies of these connectors and/or cables.
All reference platforms should be designed as components that can be extended by simple cable connections to other "component" boards. Costly unique designs should be avoided for prototypes or the majority of small-volume applications.
Hitachi reference platforms
Rob uses Hitachi SuperH reduced instruction set computer (RISC) processors extensively in what would be considered to be outside the real-time domain. His applications have functions similar to those that occur in your PC - video, memory, network, and CPU-intensive.
Hitachi has a broad range of SuperH RISC chips with various combinations of RAM, DSPs, and on-chip peripherals. Rob uses a chip that has an integrated liquid crystal (flat panel) display (LCD)-driving DSP, since most of his designs incorporate LCD displays.
The high-end proprietary integrated development environments (IDEs) emulate, simulate, and interact with the target computer in a typical configuration on a board. Rob prefers to use the Hitachi H8S-2148AF Reference Platform and the H8S-2674R uClinux Board.
Free Software Tools for Embedded Systems
The GNU C/C++ Compiler (GCC) has been ported to just about every computer I can think of, including the microcontrollers and microcomputers of embedded systems. GCC, renamed GNU compiler collection tools, now commonly refers to the complete tool chain for software development including editors, compilers for numerous languages, linkers, and debuggers.
Desktop Development Hosts and Cross-Compilers
The ideal is to use whatever development computer (host or development platform) you choose, cross-compiling to whatever target computer you choose. The versatility of the GCC Cross Compiler & Tools have made them the starting point for several modern proprietary environments.
Professor Gerald Sussman was relating how he hired RMS (mundane name, Richard Stallman) away from Harvard into the MIT AI Laboratory. I had one of those 60s' flashbacks consisting of an image of Dr. Frankenstein juicing his creation into life with lightening. RMS quit his MIT job because of the viral effect of MIT employment contracts - MIT could have intellectual property rights to the free software that RMS was writing.
I was saying that the new Linux development was being done on network fabrics and multiple CPUs - all the way up to supercomputers. Embedded system developers are sticking with older mature builds that they will probably use as a baseline for further development.
Forking the code as occurred in Unix--the divergence caused by different vendors adding new proprietary features to their Unix operating system is a religious taboo with the priests of the Free Software Foundation. I use the terms fork and fragmentation almost as synonyms.
Dr. Sussman found strong exception to this idea of developing a branch for real-time OSs and told me he would email me some links about some new embedded development projects. I'm not sure if this was the old Free Software Foundation fear of the infamous Unix fork occurring in GNU/Linux or something else. Unix dialects going on divergent paths driven by proprietary features, can be compared to the browser wars on the Windows desktops. This is generally considered to be bad. When litigation between AT&T and UC Berkeley tied up Unix development, Linus blissfully developed his Unix clone. And here we are.
Formation of the Embedded Linux Consortium has raised hopes that a "standard" embedded Linux will evolve.
Getting eMbed with Microsoft
Microsoft's embedded OSs, Windows compact edition (CE), CE's successor CE .NET, and XP Embedded are in a dead-heat with embedded Linux, both having about 34% of the embedded market. Microsoft `s eMbedded Visual C++ 3.0 is designed to program Windows CE applications. Embedded VC++ is now a separate environment (free download) whereas it formerly was a plug-in to Visual Studio.C and C++ are the programming languages of choice, but I would expect C# to be brought down from the .NET environment to the eMbedded one.
The iPAQ OS, formerly known as WinCE
IPAQs come pre-installed with Microsoft's Windows for PocketPC, which was formerly known as Windows CE. Compaq is locked in to selling a Microsoft OS with the iPAQ. On the positive side, Compaq sponsors and hosts handhelds.org which has detailed instructions for installing Linux on the iPAQ as well as other activities of interest to users and developers.
Embedded Linux is likely to hang on to its market vs. Microsoft and capture a portion of the embedded hand-held operating equipment (EHOE) market as well. "All predictions are difficult, especially about the future."
Phoenix Version of Russian Roulette
Rob had a plethora of goodies to be raffled, including 4 books from O'Reilly. Rob said we could decide which prizes we wanted to try to get, something that seemed reasonable to Ben, the mathematician, and me.
ROB displayed the first item, collected a few raffle tickets in his cap, drew a ticket, and we had a happy winner. Rob then displayed item number 2, gathered some more tickets into the hat with the old collection of tickets, drew a ticket, and we had a second happy winner. Now my ma didn't raise any idiots. On the 4th iteration of the loop both the mathematician and I were in the hat (along with most of the remaining blu.orgers). Or is it bloggers? Finally it was Cambridge (micro)Brewery time.
O'Reilly Publishing update
I spent most of Tuesday at ESC 2002 Boston in Michael Barr's "Embedded Programming 101" classes. Michaels' "Programming Embedded Systems with C and C++", O'Reilly's standard embedded systems book, features a tick on the cover. (You know, the vector for Lyme disease.) Michael said he didn't have any problem with the choice of image since he actually had some input in the usually very secretive process of selecting a cover for one of the "animal" books.
Michael's book is being joined at O'Reilly's Publishing this year by John Catsoulis' "Designing Embedded Hardware". John wasn't speaking at ESC Boston but I downloaded the free chapter of Michael's book from oreilly.com. Rob demonstrated a minimal reference board that toggles a light-emitting diode, similar to the example application that John designs with an ATMEL ATtiny15 in the free chapter of "Designing Embedded Hardware". A poster for MIT's Spring Independent Activities Period (IAP) is plugging a course in which the students will build a similar device using a living cell (using florescence).
O'Reilly's "Programming with GNU Software" and its bundled CD will be indispensable for GNU developers even though it doesn't seem to have the binaries for Linux. It's difficult to even mention all of the O'Reilly books that a developer might find pertinent for developing embedded systems.
Bookmark these sites!
blu.org - The Boston Linux & Unix User Group's website
embedded-linux.org - The Embedded Linux Consortium website
microsoftembedded.com - Microsoft's website for its embedded system products
oreilly.com - O'Reilly Publishing's website
The Linux Journal Readers' Choice for 2002 listed Montavista Linux numero uno for embedded Linux, followed by Qtopia and Lineo. And then there's the Boston Public Library: "Free for All".
How am I driving? email@example.com
Copyright © 2003 Dennis Kenney