Cramming For Linux

Texas Instruments - Telogy Networks

Overview
Telogy Networks is a Texas Instruments Company specializing in silicon and solutions for ADSL customer premise equipment (CPE). Their chipset solutions enable original equipment manufacturers (OEMs) to develop ADSL products quickly, easily and cost-effectively.

Telogy's newest solution is based on Texas Instruments' next-generation CPE DSL silicon, the AR7 Single-Chip Router. The AR7 is a high peformance networking engine that features an integrated MIPS-based 32-bit RISC processor, a DSP-based digital transceiver, and an ADSL analog front end (AFE). This single chip can be used to implement designs ranging from a single bridge/router to an integrated access device (IAD) to a small office/home office (SOHO) gateway. When combined with 802.11g technology, the AR7 can also form the basis of a complete WiFi ADSL router.

Along with the AR7 hardware reference design, the Telogy Networks DSL solution also includes a Linux-based router software stack called the Network Support Package (NSP). This software package includes all of the functionality needed to implement a variety of full-featured DSL modem designs. It provides all of the network protocols, bridging, gateway, routing and management features. It is designed in such a way as to allow OEMs to easily add their own intellectual property.

Challenge
In this highly competitive market space, it was critical for Telogy Networks to provide a solution that maximized performance, incorporated the newest funtionality, while minimizing the unit cost. On the AR7 platform, this was achieved by leveraging Linux on a device that was populated with only 2MB of Flash and 8MB of RAM.

The problem was how to add the new AR7 features to a system that had no more room in flash and was already consuming all of the available RAM.

Solution
Telogy Networks turned to the team of embedded Linux experts at The PTR Group to help with their resource problem. They asked us to squeeze as much free flash and as much free memory as we could from the system. Without these savings, they would not be able to support the new AR7 platform.

The first thing we did was to reduce the size of their flash filesystem. We accomplished this by converting their filesystem from CRAMFS to SquashFS. SquashFS is another compressed filesystem that has a better compression ratio than CRAMFS.

The next area we targeted was the Linux kernel. Utilizing our experience in kernel internals and applying our embedded systems expertise, we were able to reduce the size of the kernel image in flash and the amount of runtime memory used by the kernel.

Another step we took to reduce the size of the kernel image was to replace the gzip compression and decompression of the kernel image with a more efficient algorithm. The algorithm of choice was the brand new 7z algorithm that is currently under development as part of the 7-zip application. Using the 7z compression algorithm we were able to achieve almost a 30% reduction in the size of the compressed kernel image.

During our system analysis, we found that the Linux kernel was making system calls to the AR7 custom bootloader to perform low-level I/O to the flash configuration parameters. This was forcing Linux to preserve all of the bootloader's runtime memory to support these few system calls. The PTR Group redesigned this interface so that the kernel was no longer dependent on the bootloader's runtime memory. The net result was that a significant amount of runtime memory was made available for the Linux kernel.

Our system analysis also uncovered another inefficiency related to the flash. The NSP was using separate MTD partitions to store the various groups of configuration information and parameter data. However, since each MTD partition was aligned on a flash sector size of 64kB, some of the partitions were being underutilized. To increase the flash utilization, The PTR Group created a special MTD-based device driver that allowed the various data groups to share the same MTD partition.

In addition to the detailed analysis of the Linux kernel, we also focused our attention of the binary images on the target filesystem. This included both the applications and the dynamic libraries.

To help reduce the applications flash and memory usage, we ported Montavista's Library Optimizer Tool to the uClibc/Busybox environment. Once the tools were ported to our environment we were able to run the optimizer against several of the larger dynamic libraries on the system. The optimizer works by taking apart the library and rebuilding it with only those object modules required by the binaries on the target filesystem. This reduced the runtime memory usage as well as the size flash filesystem.

After all was said and done, The PTR Group had saved enough flash memory and runtime memory that all of the new AR7 features and functionality were able to fit on the reference platform.

The PTR Group also assisted in the debug and analysis of bugs and issues that were discovered during system test.