Porting Linux to a PowerPC Board
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.
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.
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.
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-220.127.116.11.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.
- March 2015 Issue of Linux Journal: System Administration
- High-Availability Storage with HA-LVM
- DNSMasq, the Pint-Sized Super Dæmon!
- Localhost DNS Cache
- Real-Time Rogue Wireless Access Point Detection with the Raspberry Pi
- Days Between Dates: the Counting
- You're the Boss with UBOS
- The Usability of GNOME
- Multitenant Sites
- Linux for Astronomers