?? 00000000.htm
字號:
est, hook up the interrupt-driven serial port to the host development platfo <br />rm and run a serial communication program to communicate with your target (t <br />erminal device). <br />Bootloader <br />Although LILO (the Linux loader) should be available for your architecture, <br />it may be quicker to use your own bootloader to load the Linux kernel. [4] L <br />ILO passes some information to the kernel in a way similar to how an Intel P <br />C BIOS passes information to the kernel. LILO then calls the "kernel_entry" <br />function inside the kernel, giving up control to the kernel. If you're using <br /> your own bootloader, you need to pass parameters to the kernel by adding th <br />em to the "command_line" string, which is parsed by the kernel. In my case, <br />I had to add "root=/dev/ram" to the command_line string to tell the kernel t <br />hat I wanted the ramdisk to be mounted as the root file system. You could ad <br />d other kernel parameters to this string, if needed. Load the image at the s <br />pecified load address using your bootloader. Start executing from the addres <br />s of the "kernel_entry" symbol in the kernel image. <br />It will be easier to debug if the bootloader had its own "print" function, b <br />ecause the printk function inside the kernel buffers all the output to the c <br />onsole until the console is initialized (console_init() in $(TOPDIR)/init/ma <br />in.c). <br />If everything goes well, you should get something like the following message <br /> on your kernel debug terminal: <br />Detected 32MB of memory. <br />Loading R4000/MIPS32 MMU routines. <br />CPU revision is: 000028a0 <br />Primary instruction cache 32 kb, linesize 32 bytes <br />Primary data cache 32 kb, linesize 32 bytes <br />Linux version 2.2.12 (rpalani@rplinux) <br />(gcc version egcs-2.90.29 980515 (egcs-10)) <br />CPU frequency 200.00 MHz <br />Calibrating delay loop: 199.88 BogoMIPS <br />Memory: 14612k/16380k available <br />(472k kernel code, 908k data) <br />Checking for 鍂ait' instruction... available. <br />POSIX conformance testing by UNIFIX <br />Linux NET4.0 for Linux 2.2 <br />Based upon Swansea University Computer Society NET3.039 <br />Starting kswapd v1.1.1.1 <br />No keyboard driver installed <br />RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize <br />RAMDISK: Compressed image found at block 0 <br />VFS: Mounted root (ext2 filesystem) readonly. <br />Freeing unused kernel memory: 32k freed <br />The kernel tries to open a console and find and execute "init" from one of t <br />he following places in the root file system, in sequence: /sbin/init, /etc/i <br />nit, /bin/init. If all the above fail, it tries to create an interactive she <br />ll (/bin/sh as happens in my case). If even this fails, then the kernel "pan <br />ics," as would you. I hope that this does not happen in your case. If it doe <br />sn't a shell prompt will appear on the console. Applications can be run on t <br />he system by dropping them inside the ramdisk image and executing from there <br />. <br />Adding new drivers <br />New drivers for your target hardware can be added by picking up the driver t <br />hat matches most closely to your hardware (a vast number are available) and <br />modifying it. If you are dealing with a proprietary piece of hardware that i <br />s specific to your system, use the standard driver interfaces to implement a <br /> driver for the same. These drivers can be implemented as kernel modules in <br />order to load and unload them using insmod and rmmod. <br />Useful tips <br />Sprinkle printk() statements liberally throughout your code to aid debugging <br />. This may be an obvious suggestion, but it is worth mentioning. Remote GDB <br />[5] may also be useful for debugging, though in my experience printk's are m <br />ore than enough for debugging kernel code. In remote GDB, the host developme <br />nt system runs gdb and talks to the kernel running on the target platform vi <br />a a serial line. You need to setup CONFIG_REMOTE_DEBUG = Y in the kernel con <br />figuration. putDebugChar(char ch) and getDebugChar() are the two functions t <br />hat need to be implemented over the serial port for remote debugging using g <br />db. <br />If you are forced to use a common port for console and debug, the GDB output <br /> can be multiplexed with the debug output by setting the high bit in putDebu <br />gChar(). GDB forwards output without the high bit set to the user session. <br />To start with, implement only the basic minimum functions for the tty driver <br /> as specified in $(TOPDIR)/include/linux/tty_ldisc.h. <br />Real-time requirements <br />The subject of embedded systems is not complete without a mention of real-ti <br />me requirements. The standard Linux kernel provides soft real-time support. <br />There are currently two major approaches to achieve hard real-time with Linu <br />x. These are RTLinux and RTAI. Both approaches have their own real-time kern <br />el running Linux as the lowest priority task. When dealing with proprietary <br />hardware, as it often happens in embedded systems, the issue of proprietary <br />software crops up as well. In Linux, proprietary modules can be handled with <br /> the GNU Lesser General Public License, which permits linking with non-free <br />modules. It is compatible with the GNU General Public License, which is a fr <br />ee software license, and a copyleft license. [6] <br />With a good knowledge of the processor architecture and the hardware devices <br /> being used, porting Linux to an embedded system can be accomplished in a sh <br />ort time frame, which is of vital importance in the fast paced embedded syst <br />ems market. In my case, where I have been using UNIX for quite some time, it <br /> took me around two months to complete the port of the minimum kernel functi <br />onality to our platform. Porting Linux to a different platform should not ta <br />ke that long when doing it for a second time. <br />Rajesh Palani works as a senior software engineer at Philips Semiconductors. <br /> He has been designing and developing embedded software since 1993. He has w <br />orked on the design and development of software (ranging from firmware to ap <br />plications) for set-top boxes, digital still cameras, TVs (Teletext), and an <br />tilock braking systems. Contact him at <a href="mailto:rajesh.palani@philips.com.">rajesh.palani@philips.com.</a> <br />Endnotes <br />1. Stands for "GNU's Not Unix," a project launched in 1984 to develop a comp <br />lete Unix-like operating system which is free software: the GNU system. <br />Back <br />2. The topmost directory in the Linux source tree (/usr/src/linux, by defaul <br />t). <br />Back <br />3. Translation Lookaside Buffer-hardware used for virtual to physical addres <br />s mapping in a processor. <br />Back <br />4. The subject of developing a bootloader for your processor is outside the <br />scope of this article. <br />Back <br />5. GNU Debugger-helps you to start your program, make it stop on specified c <br />onditions, examine what has happened (when your program has stopped), and ch <br />ange things in your program. <br />Back <br />6. Copyleft says that anyone who redistributes the software, with or without <br /> changes, must pass along the freedom to further copy and change it. <br />Back <br />References <br />A Web site containing a wealth of information on Linux in general: <br />www.kernel.org/LDP <br />Web sites devoted to Linux on MIPS: <br />www.paralogos.com/mipslinux <br />www.linux-vr.org <br />www.linux.sgi.com <br />Web sites dealing with real-time Linux: <br />www.rtlinux.org <br />www.rtai.org <br />Beck, M. et al. Linux Kernel Internals. New York: Addison-Wesley, 1998. This <br /> book is a good source of information on the kernel internals. Rubini, Alesa <br />ndro. Linux Device Drivers. Sebastopol, CA: O Reilly & Associates, 1998. Thi <br />s book delves into kernel internals and talks in detail about all types of d <br />evice drivers under Linux. <br /> <br />【 在 dross (走人了) 的大作中提到: 】 <br />∶<i> 如果目標板不是使用i386結構的話呢 </i><br /> <br /> <br />-- <br /> 人有時候需要一點點刺激 <br /> 人有時候需要一點點打擊 <br /> 在那時侯不知道生命的意義就在超越自己 <br /> 爭取一種意義非凡的勝利 <br /> 我們都是和自己賽跑的人 <br /> 為了更好的明天拼命努力 <br /> <br /> <br />※ 來源:·BBS 水木清華站 smth.org·[FROM: 166.111.184.38] <br /><a href="00000000.htm">上一篇</a><a href="javascript:history.go(-1)">返回上一頁</a><a href="index.htm">回到目錄</a><a href="#top">回到頁首</a></center><center><h1>BBS 水木清華站∶精華區</h1></center></body></html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -