?? 00000000.htm
字號:
<?xml version="1.0" encoding="gb2312"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"/><title>在MIPS上移植linux doot </title></head><body><center><h1>BBS 水木清華站∶精華區</h1></center><a name="top"></a>發信人: BBF (棒棒頭~~冷酷到底), 信區: Embedded <br />標 題: Re: 移植一個Linux要修改那些部分涉及到哪些文件? <br />發信站: BBS 水木清華站 (Mon Apr 16 20:35:51 2001) <br /> <br />貼一篇權當灌水,寫的精彩,可惜是說MIPS porting的 <br />Linux Porting Guide <br />By Rajesh Palani <br />Embedded Systems Programming <br />(02/26/01, 07:50:40 PM EDT) <br />Why pay someone to port Linux for you? Here's oneLinux how-to no embedded pr <br />ogrammer should miss. <br />Linux is gaining in popularity in embedded systems. Many commercial vendors <br />specialize in porting Linux to embedded systems. This article explains the w <br />ork involved in porting Linux to a specific embedded system and how it was d <br />one for one embedded system in particular. <br />Until now, most embedded operating systems have been proprietary. If a new p <br />rocessor was designed and developed by a semiconductor company, they had to <br />depend on an operating system company to port their operating system to the <br />new processor. The other issue was with the development tools (compiler, deb <br />ugger, simulator, and so on) for the given processor. Usually the operating <br />system company also provided these tools. In addition, the peripherals aroun <br />d the processor required drivers that had to be developed for the specific o <br />perating system. With the introduction of Linux into the embedded sphere, it <br /> has become possible for the semiconductor company itself to port an operati <br />ng system to a new processor, since the source code for the Linux kernel is <br />available as open source. The GNU [1] project provides a wealth of developme <br />nt tools that support Linux and are also open source. In addition, many devi <br />ce drivers are available for Linux, which could be used directly or as a sta <br />rting point for your target devices. <br />Project specifics <br />In our example, the target platform (development board) to which we ported L <br />inux consisted of an ASIC (application-specific integrated circuit) for Wind <br />ows-based terminals (thin client) and Internet access terminals, a MIPS CPU, <br /> and a CPU interface (North Bridge). In addition, the development board also <br /> supported EDO DRAM, flash ROM, I2C RTC, I2C EEPROM, and I2C serial bus. The <br /> high-level system block diagram is shown in Figure 1. An architectural bloc <br />k diagram of the ASIC is shown in Figure 2. A ramdisk (explained later in th <br />e article) served as the root file system. A ramdisk was used initially in o <br />rder to speed up the porting process. Though this article is based on Linux <br />on MIPS, the overall approach is not very different for other processors (AR <br />M, 386, and so on). In addition, the article deals only with minimum kernel <br />functionality. <br />Figure 1 <br />Figure 2 <br />Cross-development tools were used for this project. The current development <br />was done on a PC running Red Hat Linux. The Linux VR Web site (see Reference <br />s) is a good starting point for cross-development tools and sources for Linu <br />x on MIPS. The following cross-development tools need to be downloaded and i <br />nstalled on the PC running Linux: cross-binutils-as, ld, and so on; C cross <br />compiler; and cross-development C libraries. The detailed steps for installa <br />tion are available along with the tools. <br />The kernel sources <br />The Linux kernel sources for MIPS can be downloaded from the Linux-VR site. <br />One of the most important steps in porting Linux to a new target platform is <br /> to have a very clear understanding of how the kernel sources are organized. <br /> The following directory structure is not complete and includes only parts t <br />hat are of interest to this article. The $(TOPDIR) [2] has the following sub <br />-directories: <br />arch-This subdirectory contains all of the architecture-specific code. For e <br />ach supported architecture (MIPS, ARM, 386, and so on), there is a subdirect <br />ory under "arch". Each supported architecture subdirectory has four major su <br />bdirectories: <br />kernel, which contains the architecture-specific kernel code <br />mm, which contains the architecture-specific memory management code <br />lib, which contains architecture specific library code (vsprintf and so on) <br />MY_PLATFORM (target platform directory), which contains platform-specific co <br />de. <br />Note that Linux ports to processors without memory management units (MMU) ar <br />e also available <br />documentation-This subdirectory contains the documentation for the kernel <br />drivers-This subdirectory contains code for the device drivers. Each type of <br /> device has further subdirectories, such as char, block, net, and so on <br />fs-This directory contains the file system code. This has further sub-direct <br />ories for each supported file system (ext2, proc, and so on) <br />include-The include subdirectory contains the include files for the kernel. <br />It has further subdirectories for common include files (for all architecture <br />s), one for every architecture supported, and a couple of other subdirectori <br />es <br />init-This directory contains the initialization code for the kernel <br />kernel-This directory contains the main kernel code <br />lib-This directory contains the library code of the kernel <br />mm-This directory contains the memory management code <br />Building the kernel image <br />The Makefile in the $(TOPDIR) has to have ARCH (architecture) properly defin <br />ed (MIPS in this case). The Makefile in $(TOPDIR)/arch/MY_ ARCH/boot has to <br />have CROSS_COMPILE (mipsel-linux, MIPS little-endian cross-compiler tool-set <br /> in this case) and LOADADDR (address at which the kernel image would be load <br />ed) defined as per the configuration. If additional configuration options ha <br />ve to be added, the $(TOPDIR)/arch/MY_ARCH/config.in file has to be modified <br />. You would need to have a config option for your platform (CONFIG_MYPLATFOR <br />M) to include code that is specific to your platform. The kernel has to be c <br />onfigured ("make config") to the barest minimum needs (serial driver, ramdis <br />k driver, ext2 file system). Then do a "make dep" to set up the dependencies <br /> and finally a "make vmlinux" to produce the kernel image. <br />Ramdisk <br />To begin with, a ramdisk can be mounted as the root file system. Ramdisk ima <br />ges and objects are also available readily for MIPS (Linux-VR site). A ramdi <br />sk image is a file that contains an image of an ext2 filesystem, while a ram <br />disk object is an elf object that encapsulates a ramdisk image and can be li <br />nked into the kernel. The ramdisk image is usually stored in compressed form <br />. CONFIG_BLK_DEV_RAM and CONFIG_BLK_DEV_INITRD need to be defined as Y in "m <br />ake config." The ramdisk image can be modified to include your applications, <br /> if required. Tools (scripts) are available at the Linux VR site for creatin <br />g a ramdisk object. The ramdisk.o file needs to be copied to $(TOPDIR)/ arch <br />/MY_ARCH/boot and linked into the kernel. There is a detailed document, $(TO <br />PDIR)/Documenta-tion/ramdisk.txt, on how to use the RAM disk block device wi <br />th Linux. <br />Processor-specific changes to the kernel code <br />If your processor is a standard (or popular) one, in most cases a Linux port <br /> to that processor would be available. If you are one of the unlucky few who <br /> has to deal with a specific implementation of a given processor core to whi <br />ch Linux has not yet been ported, you'll want to figure out which processor <br />in the list of ported ones is closest to yours and use that port as a starti <br />ng point for your specific processor implementation. For example, the MIPS c <br />ore is licensed to many silicon vendors who have their own implementations. <br />The number of TLB [3] (translation lookaside buffers) entries may be differe <br />nt for different implementations. Add a config option (CONFIG_MYCPU) to incl <br />ude code that is specific to your processor. Directories $(TOPDIR)/arch/MY_A <br />RCH/kernel and $(TOPDIR)/arch/MY_ARCH/mm contain the processor-specific code <br /> that require modifications if you are dealing with a new implementation. <br />Assembly file $(TOPDIR)/arch/MY_ARCH/kernel/head.S contains kernel_entry, th <br />e entry point for the kernel. This file also contains the exception handling <br /> code. Listing 1 shows the implementation of the kernel_entry routine in pse <br />udocode. <br />Listing 1: Kernel entry pseudocode <br />1. Set desired endian mode <br />2. Clear the BEV bit <br />3. Set the TLB bit <br />4. GOTO cpu_probe and return <br />5. Set up stack for kernel <br />6. Clear bss <br />7. GOTO prom_init and return <br />8. GOTO loadmmu and return <br />9. Disable coprocessors <br />10. GOTO start_kernel <br />11. GOTO 10 <br />The configuration register has to be set up correctly. The first thing to be <br /> done is to make sure that we are running in the desired endian mode. In our <br /> case, we run the system in little-endian mode. The bootstrap exception vect <br />or bit needs to be cleared to make sure that the normal exception vectors ar <br />e used henceforth. In addition, the TLB bit is set to make sure that TLB-bas <br />ed translation is used. <br />The next step is to probe for the cputype. Listing 2 is a very simple implem <br />
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -