Custom-Porting-Guide.pdf

(59 KB) Pobierz
Custom Linux: A Porting Guide
Custom Linux: A Porting Guide
Porting LinuxPPC to a Custom SBC
Shie Erlich
Rafi Yanai − my partner in the porting process
Avi Rubenbach − without whom this wouldn't be possible
Revision History
Revision 2.1
2003−03−08
Revised by: gjf
Modified code example per author
Revision 2.0
2002−06−13
Revised by: tab
Added GFDL per author
Revision 1.0
2002−05−13
Revised by: SE
Initial release
43085575.002.png
Custom Linux: A Porting Guide
Table of Contents
Chapter 1. Introduction. .....................................................................................................................................1
1.1. Who needs to read this ?. ..................................................................................................................1
1.2. What do I need to know (why so much) ?. .......................................................................................1
1.3. The tools. ..........................................................................................................................................1
1.4. The hardware. ...................................................................................................................................2
1.5. Copyright & License. ........................................................................................................................2
Chapter 2. Bootcamp: How To Begin ?. ...........................................................................................................3
2.1. Creating a development environment. ..............................................................................................3
2.2. Compiling the first kernel. ................................................................................................................3
2.3. Booting the machine. ........................................................................................................................4
Chapter 3. Booting In The Dark. .......................................................................................................................5
3.1. Debugging with print_str(). ..............................................................................................................5
3.2. Modifying code using compiler flags. ..............................................................................................5
3.3. Getting the console to work. .............................................................................................................6
3.3.1. Forcing the kernel to boot our−way. .......................................................................................6
3.3.2. Non−standard hardware − just say no!. ...................................................................................6
3.3.3. Let there be light: calculating baud rate. .................................................................................6
Chapter 4. Linux Still Isn't Booting. .................................................................................................................8
4.1. Memory probing, RTC and decrementors. .......................................................................................8
4.2. Big−little endian (we should have known). ......................................................................................8
4.2.1. Probing the CPC700. ...............................................................................................................8
4.2.2. Making CPC700 speak little−endian. ......................................................................................8
4.3. Ethernet: our first PCI device. ..........................................................................................................9
4.4. Some Miscellaneous Issues. ............................................................................................................10
Chapter 5. Linux Is Booting ... What Now ?. .................................................................................................11
5.1. The 64 bit barrier. ...........................................................................................................................11
5.2. Booting from flash. .........................................................................................................................12
Appendix A. GNU Free Documentation License. ..........................................................................................13
A.1. PREAMBLE. .................................................................................................................................13
A.2. APPLICABILITY AND DEFINITIONS. .....................................................................................13
A.3. VERBATIM COPYING. ...............................................................................................................14
A.4. COPYING IN QUANTITY. ..........................................................................................................14
A.5. MODIFICATIONS. .......................................................................................................................15
A.6. COMBINING DOCUMENTS. ......................................................................................................16
A.7. COLLECTIONS OF DOCUMENTS. ...........................................................................................16
A.8. AGGREGATION WITH INDEPENDENT WORKS. ..................................................................17
A.9. TRANSLATION. ...........................................................................................................................17
A.10. TERMINATION. .........................................................................................................................17
A.11. FUTURE REVISIONS OF THIS LICENSE. ..............................................................................17
A.12. How to use this License for your documents. ..............................................................................18
i
43085575.003.png
Custom Linux: A Porting Guide
Table of Contents
Appendix B. Trademarks. ................................................................................................................................19
ii
 
Chapter 1. Introduction
1.1. Who needs to read this ?
This guide describes a work in progress, to port Linux to a custom PowerPC−based board. This means making
the operating system work on unfamiliar hardware. Anyone who is on the same track might benefit from
reading this paper, as it highlights the pitfalls and problematic points along the way.
1.2. What do I need to know (why so much) ?
Before attempting to port Linux, know at least the following: (whenever possible, a link to a proper
information source is attached)
·
Hardware: know what hardware you've got, how it works (if it works), and how is it initialized. Get
all the hardware manuals you can − you'll probably need them. Also, never assume the hardware
works the way it supposed to ! Hardware people do the darnest things :−(
·
Basic understanding of drivers and how they work in Linux. Programming knowledge of simple
drivers is an advantage − but not a must. http://www.tldp.org/HOWTO/Module−HOWTO/index.html
·
How to work with Vision−ICE, how configure it and use it to load a binary kernel into the target
RAM. Also, at the beginning, you'll need to know how to use ICE to debug in assembly.
How to compile and configure a Linux kernel. http://www.tldp.org/HOWTO/Kernel−HOWTO.html
· Working knowledge of C programming is a must. Some assembly is sure to help. Also, it is best to get
to know Makefiles. They tend to raise their ugly head once in a while.
·
·
The Internet is your friend. All the information you need is probably on the net. You just have to
know how to find it. Google is a good way to start; mailing lists and news groups usually keep the
real gold.
·
How to install Linux, configure it, administrate it and basically take care of everything it needs. This
guide does not cover anything regarding system administration, setting up a server etc.
1.3. The tools
This section describes the tools we used during the process. Most are trivial to install and use. When
neccesary, consult the appropriate url or manual.
·
HardHat Linux : First and foremost, HHLinux, now known as MontaVista Linux, is the distribution
we started with. The distribution contains LSPs (same as BSPs) for PowerPC in a number of board
configurations. For porting to our board, we took the LSP which is closest in hardware to our Artysyn
PMPPC board, and started from there.
·
LXR : This is THE killer tool, which allowed us to port Linux in a very short time. LXR is a cross
referencer, which means it reads a piece of code (the Linux kernel, for example), and then allows
browsing the code, searching through it and much more. I cannot emphasize enough how important
this tool is. To see what the end result looks like, look a t http://lxr.linux.no/source . LXR itself can be
downloaded at http://lxr.sf.net
·
VisionICE : A hardware debugger, which has the ability to stop, run and add breakpoint straight in the
CPU. VisionIce is very usuful when no operating system is running, and allows to step in the kernel
during boot process. The application can also be used to take a binary image of a kernel, load it into
the target's RAM memory and run it − useful when you've got no boot loader.
Chapter 1. Introduction
1
43085575.004.png
Custom Linux: A Porting Guide
·
CVS : A version control system, allows you to keep multiple versions of the code. Other than backing
up the code, it allows diffing between different version, and reverting to older version, when needed.
·
A terminal program, like HyperTerminal or ProCOMM for Windows", or minicom for Linux.
1.4. The hardware
The board is based on PPC750 (PowerPC) processor. It is 6U VME64 standard. The board is designed to host
two PCI Mezzanine cards (CCPMC) − Mezzanine cards that comply with Std CCPMC1386 can be attached.
· 1 MB of L2 cache.
COP connector.
· CPC700 system controller.
· 128 MB SDRAM with ECC.
· Flash memory, divided to boot flash and user flash.
· NVRAM memory.
· I/O discretes.
· RS232 channels.
· General purpose registers.
· PCI 2.1 local bus.
· 10/100 BaseT ethernet channel.
· VME64 system bus.
·
1.5. Copyright & License
Copyright (c) 2002 Shie Elrich
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free
Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no
Invariant Sections, no Front−Cover Texts, and no Back−Cover Texts. A copy of the license is included in
Chapter 1. Introduction
2
43085575.001.png
Zgłoś jeśli naruszono regulamin