L1nux

Alex Lentnon explains the whys and hows of fitting a quart into a pint pot-with room to spare

t's hard to escape hearing about Liiiux these for networking. This includes a large nurnber of days, while sightiiigs of the. mascot, drivers for network interface adaptors, and a a slightly overweight penguin, are complete implementation ofTCP/IP networking. Ibecoming commonplace. If you're a There are also drivers available for USB devices, systems softw-are buff tlie excitement can seem PCMClA cards, multimedia devices and many natural enough, but for everyone else, curious other types of hardware. bewilderment is the more likely sentiment. So The typical Liiiux distribution comprises a what exactly is Linux, and why is it so wealth of software resources. In addition to the important? kernel, it will include a basic Linux file system, Linux is an open-source Unix-like kernel, that a desktop GUI, development and debugging can be freely distributed under the ternis of the tools and a myriad of other open-source GNU General Public Liccnse. (See the Links (distributed under the GPL) amlications and section for details of the GNU project and the utilities Such is the enthusiasm of the Linux Open Source Initiative). It was developed initially fraternity that, whatever your requirements, by the Finnish student LinusTorvalds, and had its there 15 likely to he a group working on a first official release a surprisingly long time ago project which will be useful to you-XM in October 199 1.Right from the beginning, as is Java, wireless networking, Bluetooth, netwo tlie case today, distributions of the Linux kernel protocols, IPv6, home automatLon, remote have been accompanied by GNU-developed data acquisition and many iiiore utility prograins to form a complete . Strictly speaking, the correct name for The whys of embedded Linux such distributions is GNU/Linux, although tlie Historically, Linux wa5 GNU prefix is generally dropped in the interests speufically as an opei-ahng system for the of brevity. Sirice its initial release the desktop/ environment. More communications infrastructure provided by [he recently, there has been a growing Internet has enabled large numbers of developers interest in tailoring Linux to the very 1 to enhance and extend Liimx, to the point where different hardware and software 1 it can now be seen as a mature alternative to needs of the embedded applicauons operating environments such as Windows and environment. Unix. In hardware terms, the mimmum I Linux is a multi-tasking, multi-user, multi- requirements of desktop Linux 7 processor operating system supporting a wide compare favourably with operating range of hardware platfornis, such as , Alpha, systems such as Windows and Solaris Sparc, MIPS, SuperH, PowerPC and ARM. Where , a Linux distributor, suggests hardwarc support is provided, the kernel makes niinirnuni installation of an Intel 386 or use of protected-mode memory management, above for the CPU, a 1620 Mbyte hard disk increasing system reliability as one failing for a server, or 450 Mbytes for a workstanon, application is unlikely to cause the kernel, or arid 16 Mbytes of RAM A hardwar other applications, to fail. One of the great footprint of this order is entirely strengths of the operating system is the support reasonable for a desktop PC,

IEE REVIEW MAY 2001 .33 edded operating system must display a ree of robustness well beyond the requirements of the desktop domain. A Linux server, or even a desktop

1 machine, expects a specific power- down sequence to occur before the power supply is removed from the system. If the power fails unexpectedly a system can become corrupt. Power cycling and power failures (often user generated) are inore likely in embedded environments and the system is required to handle these without user intervention. Established embedded operating systems, such as QNX, pSOS, and VxWorks, have been designed from the ground up to conform to the constraints inherent in an embedded environment. Similarly, the demands for real-time performance were addressed during the initial design phase. As a result, commercial non-Linux embedded operating systems have tended to he more scalable at the low end and have better real-time performance. The real- time performance issue can he important in the embedded operating system market, and embedded Linux vendors are working hard to match the real-time capabilities of established products. Given the availability of highly capable existing embedded operating systems, and the substantial hardware and software challenges id inherent in adapting Linux to the embedded world, the obvious question to ask is: why t bother? In practice, the considerations that make preient Linux attractive in the embedded domain insuperable closely mirror its strengths in the desktop 1 Arcom’s Elanl04-NC obstacles to current embedded systems environment. Embedded Linux hardware-at least in terms of CPU and RAM Development Kit, incorporating an Elan- requirements No licensing fee is needed-For high-volume, low- 104NC single board Space for the file $ystem is, however, quite cost items such as Internet appliances, a zero computer [featuring a another matter If we are able to use rotating licensing fee can’t be beaten. 100 MHz media, as with the Arcom Elan-l04NC single 486-compatible processor, with board computer (Fig l), incorporating Open source-The kernel and support 16 Mbytes of RAM and 16 Mbytes of RAM, a 100 MHz 486, and a applications are open-source, implying direct 8 Mbytes of flash 4 Gbyte attached hard disc, then it’s possible to access to the source code. Developers can thus memory), a power run a standard installation of Linux (albeit see exactly how individual parts of the supply unit and all connectors needed to slowly) In practice, most embedded systems operating system work, can customise run embedded Linux run from ROM or , and a more behaviour, and optimise performance in time- ‘out of the box’ typical footprint would be a 386/486/586 or critical sections of code-an impossibility equivalent processor, 8-1 6 Mbytes of‘hard disc’, with rival commercial operating systems. implemented as flash memory, and 16 Mbytes Similarly. in the medical and defence arenas, it or more of RAM The high per-byte cost of flash is often necessary to certify an entire body of memory means that a pared down keriiel and code running within an . minimal file system are mandatory for any This is only possible where the complete practical implementation of embedded Linux operating system source is available for Aside from footprint constraints, an inspection.

34 IEE REVIEW MAY 2001 Reliability-Linux has an enviahle reputation for robustness. Up-time is measured in weeks or years and systems rarely, if ever, require rebooting.

Scalability-With the advent of Linux 2.4, the kernel has become significantly more modular and scalable. This is a distinct advantage when using Linux in resource- constraiped environments.

Large programmer base-Linnx is developed by a large number of pcople primarily communicating through the Internet. The current maturity of Linux, and the extended feature set, is a reflection of the multitude of individual programmers who enjoy working m the Linux environment (often in their spare time.).

Support-Getting up to speed with a new operating system can be problematic. In the case of Linux, extensive documentation is available from the Internet, and companies such as Red Hat provide support, traiiiiiig seminars and courses. Literature and training can be very effective, but a particularly effective way of progressing with Linux development is to subscribe to one of the Internet-based, Linux-oriented mailing lists. Questions can be asked as problems arise and, given the question has not been answered too many times before, somebody is bound to come to your assistance. systems for which a iiiininiuin set of Standards-The distributed nature of the Linux components must be carcfully defined. development process has encouraged a high proportion of the components of the Liiiux The initial program loader (IPL) environment to be written to open Before the Linux kernel can start running it specifications and standards. obviously needs to he loaded into memory. When running froin staridard devices, e.g. a Portability-It is relatively straightforward to hard disc drive, standard IPLs, such ab LILO and develop/debug an application on a hmt GRUB, are readily available. However, when system running Linux and then transfer to the running from ROM or from flash EPROM-the target, helping to ensure a shortened likely set up in an embedded context-a debugging cycle. hardware-specific loader will bc required.

All these features combine to produce an The kernel embedded operating system that is attractive This Is the heart of the Linux operating system. froin a licensing perspective, while supporting Linux has a ‘monolithic’ kernel, meaning rapid application development with a reduced that the whole operating system-process time to market. management, memory management, file system and drivers-is contained within one binary How is embedded Linux implemented? image. Given the open-source, modular, nature Standard Linux distributions tend to install a of Linux a user can recompile the kernel to great deal of software to a target system on the obtain the functionality set required. A compiled basis that the user may find it useful. This kernel is generally stored in a compressed form, approach does not serve well for cinbedded and is then uriconipressed when it has been

IEE REVIEW MAY 2001 35 s

of devices, libraries, utilities, configuration files and scripts to get the system up and running. The majority of the file system footprint is taken up by system utilities and their associated shared library files. There are at least two open-source projects that are useful when considering which applications and utilities to place on the file system: ‘BusyBox’ which encapsulates around 125 of the inat common Linux commands in one binary executable, and ‘TinyLogin’ which supports nine of the commonly required login and authentication commands. Both of these projects are designed to be highly modular to allow minimal footprints. Linux applications are usually linked to shared lihraries. These, just as their name implies, are libraries of functions that are shared between applications and utilities. The most frequently 2 Screen capture of an loaded into Inemor): A compressed kernel is required shared library is the C runtime library X-Windows based thin typically in the range 400-740 kbytes, (GLIBC) -around 4 Mbytes! Luckily, libraries client running on Arcom’s SEC-GXm depending on the degree of functionality can often be reduced in size by removing all single board computer supported. debugging information. Running the ‘strip’ (featuring a- a 233 MHz A benefit of the kernel architecture is support command on the C runtime library brings the Pentium-class for ‘loadable modules’, facilitating the extension size down to a mere I Mbyte or so. However, if processor, supporting up to 128 Mbytes of of the kernel by linking additional code at this is still too large for your embedded system, RAM and 16 Mbytes of runtime. Suppose, for example, that we need to it is possible to turn to slightly less standardised flash-memory support two different Ethernet controllers, an embedded libraries, for example uClibc and RTL8139 controller on platform A, and an nen-lih. NE2000-compatible controller on platform B. Again, depending upon application We can generate module files for each of these requirements for a build of embedded Linux, devices and install the relevant file on each additional file system components will be platform. Having booted our small generic needed. For Java support we may need to add a kernel, the ‘insmod’ command can then be used JVM such as Kaffe or IBM’s J9, For a headed to link-in the appropriate module, and the system we may wish to have a GUI based correct Ethernet controller is then supported. around X-Windows (Fig. 2) or one of the Loadable modules allow the user to add support smaller footprint alternatives such as FLTK, to the kernel for additional devices at any time. QT/Embedded or Microwindows. They are also extremely useful during developinent as they can be loaded and The file system - high uvailability unloaded on the fly An embedded Linux file system, unlike desktop Application-specific requirements may or server implementations, must offer user- necessitate the modification or ‘patching’ of the independent support for recovery in the event of kernel. Real-time support would be a prime power failures. Also, power consumption, size example of an instance where kernel and failure rate considerations mean that the modification would be required, and there are a file system is likely to be running from some L number of open-source and commercial variant of flash or read-only memory, rather L solutions available (see Links secton for than a hard disc or other rotating media. letails). There are a number of alternatives when using flash-based storage media. Some flash The file system - components devices connect to the standard hard drive The Linux kernel mounts a ‘root’ file connector (IDE port) and emulate a hard disc system when booted. Depending on the drive. These are extremely easy to use-requiring required configuration, this may be no changes to the Linux kernel-but are located on a floppy or hard disc drive, generally susceptible to corruption. An a ROM or flash memory, or on a share alternative is to use a ‘smart’flash device such as of a drive accessed over a network. the DiscOiiChip from M-Systems. The Linux The file system must contain a minimal set kernel must be rebuilt to support this device,

36 IEE REVIEW MAY 2001 but, again, depending on the file system used, Links corruption can occur. Another option is to make Most of the links given below can be found at the use of on-board flash memory. As with Linux Devices portal. (www.linuxdevices.com) DiscOnChip devices, drivers must he added to GNU project and Free Software Foundation the Linux kernel-but there is the option of www.gnu.org using the Journalling Flash File-System (JFFS) , currently under development within the open- Open Source Initiative source community. w.opensource.org The 2.4 series of Linux kernels currently Non-commercial distributions include support for the JFFS. This is a ‘log- LinuxRouter- www.linuxrouter.org structured’ file system, which means that old pLinux -http://sunsite.dWmulinux/ data is not lost when new data is written to Embedded Debian Project- http://www.emdebian.org/ flash. Periodically this old information is garbage collected from the flash, but a write Commercia/ distributions interruption will not cause the file system to Embedix- http://www.lineo.com/ MontaVista Hard Hat - http://www.mvista.com/ become corrupt. Work is also underway to LynuxWorks- http://www.bluecat.com/ implement a compressed JFFS for embedded Red Hat E.D.K.- http://www.redhat.com/embedded devices. /developer/ Arcom has ported the JFFS to its Elan- 104NC Open-source embedded Linux projects and SBC-GXm based embedded Linux BusyBox- http://busybox.lineo.com/ development kits. TinyLogin - http://tinylogin.lineo.com/ Newlib- http://sources.redhat.com/newlib/ So, how do I get hold of embedded Linux? uClibc- http://www.uclinux.org/ There are three basic choices. First, there’s the JournallingNog-structuredfile systems self-sufficient approach-select a suitable Ext3-ftp://ftp.uk.iinux.org/pub/linux/scVfs/jfs/ distribution aiid do the port yourself. The ReiserFS - http://www.namesys.coni/ choice of distributions is fairly wide, with J FS - http://oss.software.ibm .com/developer/ opensource/jfs/ commercial offerings from the likes of Lineo, J FFS - http://developer.axis.com/software/jffs/ Lynuxworks and Montavista, and non- commercial variants such as FLinux and the Java Linux Router project. Individual distributions, Kaffe- http://www.transvirtuai.com/kaffe.htm Japhar- http://www.japhar.org/ particularly commercial distributions, tend to J9 JVM - httD://www.embedded.oti.com/ add value through enhancing development tools and/or support for additional software Real time components such as embedded GUIs, real-time ELAX- http://sources.redhat.com/elix/ RT Linux- http://sources.redhat.com/elix/ operation, embedded Java virtual machines and RTAl - htto://www.aero.aolimi.iVoroiects/rtai/,, data communications stacks e.g. Bluetooth. The non-commercial distributions are usually who supports an embedded Linux ‘out of the targeted at a specific application area-e.g. an box’ Arcom Control Systems, for example, embedded Internet router. This is no easy provide5 an embedded Linux variant ported L option. You may find that the support provided both 486 and 586 equivalent platforms. This by a given distribution is not complete enough allows a user to concentrate 011 adding value for your application. You will almost certainly through application development rather than find that there is a non-trivial aniount of devoting time and energy to the intricacies 1 development work required to port a generic of system software distribution to your hardware platform of Whatever approach is choice. embedded Linux has now evolved to the Secondly, you can employ an embedded Linux point where it can address, at low or, vendor to port their distribution to your chosen zero cost, all but the most demanding o hardware platform. Vendors such as Red Hat, embedded applications. Its future looks Montavista and Lynuxworks will all port their bright-the penguin has come of age. products to your platforms. This work may include, for example, hardware drivers and/or Arcom Control Systems: 200 1 A footprint minimisation. There can he a high initial cost, although this can then he amortised Alex Lemon IS an Embedded Software Manager at over ongoing product sales given the lack of a Arcom Coiitrol Systems, Clifton Road. Cambri licensing fee. CBI 4WH (tel+44 (())I223 41 1200, fax +44 Finally, you can select hardware from a vendor (0)01223 410457; ajlennon@arcom couk)

IEE REVIEW MAY 2001 37