Porting Linux to a PowerPC Board

An experiment and experience in using Linux in an embedded application.

We believe Linux is going to play a significant role in embedded applications. It is compliant with POSIX 1003.1 and supports the POSIX soft real-time extension. Theoretically, it is capable of supporting a wide range of embedded applications which require only soft real-time performance such as Internet routing. Easy customization makes it even more attractive. To investigate the possibilities of using Linux as a platform for embedded systems, we conducted an experiment in which we ported the kernel to a PowerPC-based board. The porting took a few weeks. Our result is a Linux port, called elinux here, based on the Linux kernel 2.1.132 which was the latest version at the time we began the experiment. elinux runs dozens of commands and programs, including bash and vi on the console via a serial port. Porting Linux is actually a very enjoyable experience. Besides, all the work is based on open-source software exclusively.

Introduction

Linux is portable. We have already seen many Linux ports on various processors. However, few documents describe how to port Linux. The information is scattered in various documents and source code. Porting is not an easy job for any operating system. Even a minor change in the kernel code to suit a particular piece of hardware needs a considerable effort. Fortunately for Linux, all major components of the kernel are already designed to be architecture-independent. This makes the work relatively much easier.

It is harder to port Linux to a board with a new processor than with a processor Linux has already supported. In the latter case, we can reuse board-independent code; for example, the code for memory management. Only a relatively small portion of the kernel code is board-dependent. When we considered implementing elinux, we tried to avoid reinventing the wheel. We kept most of the necessary changes limited to board-dependent parts. Our experiment was done on a PowerPC-based board. Linux already has ports for PowerPC-based machines such as Power Macintosh and a few PowerPC-based embedded boards. However, due to diverse board architectures, configurations and booting methods, modifications are required when we consider a new board.

In our case, some changes in the kernel and a few small new programs were created to support elinux. In the following article, we emphasize our experience with the issues of most concern in our work rather than implementation details. These include setting up the cross-development platform, designing the booting sequence, modifying the kernel, creating the executable image and root file system image and debugging.

Experimental Hardware

Our goal is not to port Linux to a particular kind of hardware. Instead, we are interested in approaches to porting the Linux kernel to potential embedded systems. Thus, it doesn't matter what kind of board we choose as long as it presents a typical situation. The board we actually used in our experiments is a PowerPC-based board built on a PCI bus. It has a PowerPC 603e processor, an MPC 106 as the memory controller and the PCI bridge, 32MB DRAM memory, a PC16552 DUART chip for two serial ports, a memory-mapped real-time clock in non-volatile memory and a simple but customized interrupt controller. It also has two flash memory slots and an Intel 82558 LAN controller to provide three LAN ports.

The board has its own bootstrap code in ROM. This code does hardware initialization and also provides a simple native file system and the TFTP support. Although we used these two services to boot elinux, our approach can support booting completely from ROM.

Cross-Development Platform

Simply installing binaries from any Linux distribution does not guarantee a working cross-development platform. Some people experienced difficulties in setting up a complete cross-development environment. Our experience shows that this is not only possible, but also brings us a fair amount of convenience, as we can use some of the most popular software packages. Our lessons are proper distributions, proper configurations and recompiling.

Here are our actual steps in setting up the cross-development platform for PowerPC on Pentium machines:

  • Install Red Hat 5.2 on a Dell OptiPlex Pentium II 400 MHz PC with 256MB RAM and 8GB SCSI hard disk.

  • Get the source code of the latest stable Linux kernel, 2.0.36 when our work began.

  • Recompile the kernel from the kernel source to make sure support for loopback devices, RAM disks and other necessary items is included.

  • Use the newly recompiled image to boot the development platform.

After the base development system is ready, we install cross-development support as follows:

  • First, install the source code of the binary utilities binutils-2.9.1.0.15 which includes cross-assembler, cross-loader and other cross-utilities.

  • Recompile and install the cross-utilities for PowerPC with Linux.

  • Install the source code of the compiler gcc 2.8.1.

  • Recompile and install for the cross-compiler.

After this, the environment is ready to develop elinux on the Pentium machine. As for the standard C library glibc, we don't need it at this time. If we wanted to do general programming for elinux, we could cross-compile the glibc. For convenience in testing small programs, we actually used glibc binaries for PowerPC from the Red Hat distribution.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Re: Porting Linux to a PowerPC Board

Anonymous's picture

can you give the exact files that will be executed incourse of booting the kernel for PowerPC, if we are booting the target through NFS support?

about porting commands...

Anup's picture

Hi,

well you have explained variou porting steps clearly, though I need some guidance about porting the more than one application in to one powerpc board...

Means...can I make one makefile and proceed ahead to create the compressed image and download in the board or any other method...

Please guide me .

Thank You,
Anup.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix