Difference between revisions of "Porting"

From LinuxMIPS
Redirect page
Jump to: navigation, search
 
(7 intermediate revisions by 7 users not shown)
Line 1: Line 1:
This document reflects what I have learned through porting several MIPS machines and other related Linux work. Hopefully it will help beginners to get started and give the experienced a reference point.
+
#REDIRECT [[Linux/MIPS_Porting_Guide]]
 
+
This document goes through all the major steps to port Linux to a MIPS machine. The focus can perhaps be called "MIPS machine abstraction layer", i.e., the interface between machine-specific code and, mostly, MIPS common code. Another useful document focuses on "Linux hardware abstraction layer", i.e., the interface between Linux common code and architecture-specific code. The document is written by C Hanish Menon (www.hanishkvc.com).
+
 
+
== Prerequisites ==
+
 
+
* Know C programming.
+
* Have some knowledge of OS concepts, such as interrupt handling, system calls, memory management.
+
* Know how to configure and make Linux kernel. You can find many helps on this if you are not very comfortable.
+
* Have some knowledge of MIPS CPU. More than likely you will need to deal with CP0 registers, enable or disable interrupts, etc..
+
* You don't have to be an expert in MIPS assembly, but total ignorance of it might make you handicapped in some situations.
+
* Obviously, you need a MIPS hardware to play with.
+
* Finally but most importantly, you need a willing-to-learn heart and perhaps many restless debugging hours. :-)
+
 
+
It is also highly recommanded to read through the Linux MIPS HOWTO by Ralf Bächle, ralf@gnu.org. By the way, as part of the pre-requisite, you should also remember Ralf's name. :-)
+
 
+
== Kernel source trees ==
+
 
+
The common MIPS tree is the CVS tree at linux-mips.org. See the instructions in "Anonymous CVS servers" section in Linux/MIPS HOWTO. The current kernel version as of 2004/01/26 is 2.6.1. You can always check out earlier stable revisions by using "linux_2_4" or even "linux_2_2" branch tag.
+
 
+
== Kernel patches ==
+
 
+
For various reasons, a kernel tree may leave bugs there for a quite long time before a suitable fix is checked in. There are various places to get patches. Here are some of the more common ones:
+
 
+
    Jun Sun patches
+
    Linux/MIPS FTP archive
+
    Maciej W. Rozyki patches
+
    Brad LaRonde's patches
+
 
+
== Cross-compilation and toolchains ==
+
 
+
More than likely your MIPS box does not run Linux yet (why would you bother otherwise?). Therefore you will need another machine to build the kernel image. Once the image is built, you need to download this image to your MIPS machine and let it run your MIPS kernel. This is called cross-development. Your MIPS box is often called the target machine and the machine used to build the kernel image is called the host machine.
+
 
+
Cross-development is common for developing on embedded targets, because usually embedded targets do not have enough power or the peripherals to develop natively.
+
 
+
== The most common host machine is probably Linux on i386/PCs ==
+
 
+
You need to have cross-development tools setup on your host before you can start. Several years of experience have show that hile you can find instructions to build cross-compilation tools, your best bet is probably to get some ready-made ones.  Another reason is that a full [[toolchain]] build has become quite time consuming so you probably want to avoid it.
+
 
+
MontaVista used to offer for free Journeyman edition, which includes a full featured toolchain. Unfortunately, it does not offer that anymore. Instead you can download the preview kit, which includes a "slim" version of toolchain. You can get the kit from http://www.mvista.com/previewkit/index.html
+
 
+
Dan Kegel has a set of scripts that build cross-compiling tools. You can check it out here.
+
 
+
The following are links to pre-build toolchains, instructions to build your own toolchain and finally pre-compiled distributions for MIPS boards:
+
+
* Brad LaRonde's cross toolchain for Linux
+
* Steve Hill's toolchains for glibc and uClibc
+
* Toolchains from MIPS Technologies
+
* [[Distributions]] for MIPS
+
 
+
== Overall porting steps ==
+
 
+
Depending on your specific cases, some of the following steps can be skipped.
+
+
# [[Hello_World|Hello World!]] - Get board setup, serial porting working, and print out "Hello, world!" through the serial port.
+
# [[Add_Your_Own_Code|Add your own code]].
+
# Get [[Early_printk|early printk]] working - Make the first MIPS image and see the printk output from kernel.
+
# [[Serial Driver and Console]] - Get the real printk working with the serial console.
+
# [[KGDB]] can be enormously helpful in your development. It is highly recommended and it is not that difficult to set up.
+
# [[CPU_Support|CPU support]] - If your MIPS CPU is not currently supported, you need to add new code that supports it.
+
# Board specific support - Create your board-specific directory. Setup [[Linux_Interrupts|interrupt routing/handling]] and [[System_Time_and_Timer|kernel timer services]].
+
# [[PCI_Subsystem|PCI subsystem]] - If your machine has PCI, you need to get the PCI subsystem working before you can use PCI devices.
+
# Ethernet drivers - You should already have the serial port working before attempting this. Usually the next driver you want is the ethernet driver. With ethernet driver working, you can set up a NFS root file system which gives you a fully working Linux userland.
+
# ROMFS root file system - Alternatively you can create a userland file system as a ROMFS image stored in a ramdisk.
+
# Some words on [[Debugging]].
+
 
+
Next page: [[Hello World]]
+

Latest revision as of 02:55, 23 October 2005