During the past few years, residential gateway devices were built on proprietary real-time operating systems (RTOS) or equivalent 'home-grown' code developed by in-house engineering teams. But, with price pressures increasing in the sector, systems based on proprietary OSes are at a disadvantage, requiring designers to closely re-evaluate their position with regards to using Linux in a residential gateway design.
The Linux community is also making the decision a little easier. Unlike a few years back, a wealth of Linux resources, including freely available device drivers, networking, middleware, development tools and application components, helps developers bring their products to market faster by eliminating investments in internal technology development and by letting manufacturers concentrate on their particular value-added technology. Additionally, Linux has been readily ported to some of the most popular embedded processor architectures including PowerQUICC, PowerPC, MIPS, ARM, and StrongArm, making Linux even more compelling.
But to be truly successful, designers need an out-of-the box Linux solution that effectively uses the valuable resources provided by residential gateway hardware designs. In this article, we'll show how Linux is providing the out-of-the box networking capabilities needed in a residential gateway design. We'll also show how designers can improve resource utilization and ease code downloads in Linux architectures.
Networking Out of the Box
More and more software is becoming available for Linuxnot just open-source software, but third-party application programs, development tools, debuggers, compilers and protocol stacks. Linux has a number of cross compilation tools allowing developers to generate machine code for a target platform even if their host development platform uses a different CPU. This helps overcome problems obtaining native tools and hardware support during system development. The number of device drivers available for Linux is also large and growing, and the source code for Linux device drivers is almost always free. Run-times of Linux are also royalty-free.
The main advantage of using a Linux kernel is that many of these protocols are freely available and easily configurable "out of the box." For example, Linux can easily install and configure a DHCP or DNS server (which can automatically configure any device connecting into the residential gateway, such as a laptop or printer) through a few simple entries, as shown in Figure 1.

Figure 1: Example dhcpd.conf, configuration file.
Support for PPPoE, PPPoA, PPP, and multi-link PPP in the Linux kernel (Version 2.4.20+) is configured in a similar manner by enabling kernel support and configuring the appropriate ".conf" file. The provision of these protocols within the kernel allows immediate low-level xDSL support within the end gateway product.
In today's society, security is also a prime concern, and in residential gateways the Linux kernel supports a number of useful features. Using Linux IP masquerading and firewalls, the very existence of the complete residential network can be hidden behind a single IP address. If the firewall is configured to support network address translation (NAT), then all internal addresses are translated to public IP addresses when leaving the internal network, thus concealing their original identity. The firewall's main role is to deny, accept or reject matching packets it receives based on a user-defined set of rules. This is extremely powerful in restricting access to and from the gateway, e.g. parental child locks on particular websites or addresses.
Although many of the residential protocols are contained within the Linux kernel, a significant tradeoff exists between the system cost and a feature-rich residential gateway. Unfortunately, the desire for multi-use services, such as VoIP, data over cable, and emerging protocols (IPv6 or multi-casting) creates a significant challenge in trying to squeeze these packages into a small embedded memory footprint.
Reducing the Resource Burden
We have discussed some of the key features that Linux provides. But one of the challenges that the Linux community has to deal with is memory utilization. Since residential gateway developers are, by their nature, embedded systems, they are restricted in terms of cost and resources. Thus, any OS used in a residential gateway must cautiously use the memory resources provided.
Since memory is such a precious commodity in embedded systems, the Linux OS must carefully manage it to ensure that applications run without being starved of memory resources. A number of different memory management techniques can be adopted.
The most efficient use of memory is to have programs reside in memory pages only when they are needed by the operating system. This 'load-on-demand' technique allows unused programs to be quickly discarded (or overwritten) by the Linux kernel, e.g. initialization code used once at boot time, then never used again. At the heart of this operation is a type of least recently used (LRU) algorithm that measures the frequency of physical page usage. Memory pages that are referenced the most are less likely to be discarded when memory becomes scarce.
Residential gateway products that rely on physically mapped memory operating systems restrict the developer into running only as many applications as the memory can physically hold. Systems developed with processors and operating systems (such as Linux) that allow MMU support offer the developer a distinct advantage. An MMU allows virtual memory support and gives the appearance of more available system memory, which can handle larger and more complex applications than on a physical mapped system (Figure 2).

Figure 2: Memory Paging between virtual and physical memory.
The developer can use a number of other techniques to minimize the memory 'footprint' of the Linux kernel. Since the kernel is modular, the easiest way to reduce the memory footprint is to remove any unused kernel features during the initial kernel configuration stage. During the kernel build stage, dynamic linking can be used to share common library functions among many executables to reduce footprint size. Similarly, once the kernel is ready to be downloaded to the target hardware, compression tools such as 'GZIP' can be used to shrink the kernel further and to compress entire file-systems or any subsequent file contained therein.
Kernel Downloading Made Easy
With the Linux kernel continually being updated and enhanced, kernel downloads are another key ingredient when evaluating Linux for a residential gateway design. A number of options are available to the developer to download the successfully compiled kernel onto a residential gateway development target.
Many freeware boot-loaders, such as U-Boot, can be installed in a boot-ROM or Flash and can be used to test the development hardware or download and run application code for a variety of different processor types. U-Boot also contains a number of built-in drivers (USB, I2C, SPI, PCI) and board support packages (BSPs) for a wide range of commercially available development platforms. These BSPs provide developers with useful reference code and are easily configurable to suit different kernel configurations and embedded systems.
Traditional embedded systems make use of network disks and on-board file systems to store the required system applications and files. This approach dramatically increases the required memory footprint. A key requirement for an embedded system is therefore to provide some form of diskless operation. The Linux kernel provides Trivial File Transport Protocol (TFTP) support or Network File Services (NFS) servers, which can be used for booting and transferring files to and from a remote machine. This offers a substantial amount of flexibility during the initial development stages as new files or features can be added to a kernel and quickly tested without requiring continual flash programming.
Using remote file server partitions allows extensions to the available pool of applications that can be run. The embedded system simply retrieves what it needs on demand. In the context of a residential gateway, this allows a degree of future proofing since new applications could be stored onto a connected PC or laptop and downloaded via an NFS partition to the residential gateway during system boot.
Several commercial companies also offer a complete, end-to-end embedded Linux development solution, including tools, operating system, middleware and software stacks. Software vendors in this market are delivering complete, Linux OS-based solutions that include the operating system, BSP tools for specific boards, and a complete set of integrated components needed to rapidly construct new residential gateway products. This allows developers to concentrate their efforts on creating custom applications, instead of dwelling on hardware, OS, and development board issues.
Wrap Up
Linux has made serious inroads into the embedded market and is expected to become the dominant OS in this area. Linux has proven to be a scalable platform suitable for embedding into many sizes of projects ranging from very small to extremely large.
Linux is already penetrating the residential gateway market that has, until just recently, been the domain of proprietary operating systems. It has excelled in this market because of its exceptional stability, scalability, suitability to task, access to source code, and overall value.
Despite the myriad benefits of Linux, some developers of residential gateways are reluctant to port their applications to Linux because they lack confidence in the maturity of Linux as a commercial platform. Embedded Linux OS providers can address these developer concerns and provide Linux components for new products more quickly and effectively, freeing product development teams to focus on the addition of new features. Due to the scalability of Linux, it is easier than ever to incorporate components, applications, protocols and middleware into new residential gateway products. Moreover, residential gateway applications can be created on widely available development platforms, and then migrated to the target device.
With the growing availability of components, source code, tools, programmers, services and knowledge base, Linux is a strong contender and poised for continued growth in the residential gateway market.
About the Authors
Bert Wilhelm is a product manager for gateway solutions at Metrowerks, a Motorola company. Bert holds a bachelors degree from the University of North Texas and can be reached at bwilhelm@metrowerks.com.
Nigel Dick is a senior staff applications engineer working in Motorola's Networking & Communication System Division in East Kilbride Scotland. He has a Bachelors of Engineering degree in Electronic and Electrical Engineering from Strathclyde University, Glasgow, and a Masters of Science in Data Communication Systems from Brunel University, London. Nigel can be reached at nigel.dick@motorola.com.