Responsive image
博碩士論文 etd-0208106-031349 詳細資訊
Title page for etd-0208106-031349
論文名稱
Title
Linux核心程式之移植與除錯
On the Porting and Debugging of Linux Kernel
系所名稱
Department
畢業學年期
Year, semester
語文別
Language
學位類別
Degree
頁數
Number of pages
85
研究生
Author
指導教授
Advisor
召集委員
Convenor
口試委員
Advisory Committee
口試日期
Date of Exam
2006-01-13
繳交日期
Date of Submission
2006-02-08
關鍵字
Keywords
除錯、嵌入式作業系統、移植
debugging with ICE, embedded linux, access register, /proc, porting
統計
Statistics
本論文已被瀏覽 5614 次,被下載 0
The thesis/dissertation has been browsed 5614 times, has been downloaded 0 times.
中文摘要
近年來,由於Linux結合了可靠性高,效能佳,有良好的工具,具有
遷移性,組態自由度高等優點,已經有愈來愈多廠商採用Linux做為
電子產品內部的作業系統。然而因為Linux核心程式非常複雜,加上
各種產品可能皆有各自不同的平台。因此Linux常常需要被移植到不
同的平台上。

在本篇論文中,我們詳述如何將Linux 移植到一個類似舊有,但目前
核心沒有支援的新平台。此外,我們提出二種除錯技巧來解決我們在
本篇論文中所遇到的問題。其中一種能讓我們更容易地利用ICE來
追蹤模組;另一種則能讓我們能透過/proc檔案系統來存取處理器的
內部暫存器,而不用每次都為了除錯去寫程式來存取內部暫存器
的資料。

透過這二種除錯技巧,我們能夠有效地降低系統開發
與除錯的時間。
Abstract
In recent years, more and more vendors adopt Linux to be the embedded operating
system for their electronic products because of its combination of reliability, performance,
good tool chains, portability, and configurability. However, Linux kernel is complex, and
different electronic products may use different platforms. For this reason, it often requires
that Linux be ported to different platforms.

In this thesis, we describe the details of how we port Linux to a new platform which is
similar to but not exactly the same as another platform and thus is not currently supported by
the kernel. Moreover, we propose two robust debugging techniques to solve the problems we
had encountered in this thesis. One is to make it easier to trace a module with ICE; the other is
to allow us to access the internal registers of the processor through the /proc filesystem rather
than write a program every time we need to access those internal registers for the purpose of,
say, debugging.

By using these techniques, we show that the time required to port and debug a Linux
kernel can be definitely reduced.
目次 Table of Contents
Contents
Acknowledgments iv
List of Tables iii
List of Figures iv
List of Listings v

Chapter 1 Introduction 1
1.1 Embedded Linux System . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Motivations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Organization of the Thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

Chapter 2 Platform 4
2.1 Evaluation Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Linux Kernel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Toolchain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Chapter 3 Porting Linux 8
3.1 Boot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.1 head.s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.1.2 Boot Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2 Machine Registration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.3 Serial Console . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.4 GPIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.5 Root Filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.6 Device Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.7 Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.8 NFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.8.1 Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Chapter 4 A Tiny Tool for Simplifying Tracing Modules with ICE 31
4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.2 Design and Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.2.1 Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.2.2 The Inline Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.2.3 Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

Chapter 5 Controlling Machine State via the /proc Filesystem 38
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.2 Design and Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2.1 The /proc Filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2.2 The ioremap() Function . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2.3 Read/Write on the /proc Filesystem . . . . . . . . . . . . . . . . . . 40
5.2.4 Multi-registers Access . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.2.5 Verification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

Chapter 6 Conclusion and Future Works 51

Appendix A Building A Root Filesystem from Scratch 56
Appendix B Complete Source Code for the Tool Described in Chapter 4 62
Appendix C Complete Source Code for the Module Described in Chapter 5 65

List of Tables
A.1 Programs for the target platform . . . . . . . . . . . . . . . . . . . . . . . . 58
A.2 Libraries for the target platform . . . . . . . . . . . . . . . . . . . . . . . . 61

List of Figures
1.1 Embedded Linux architecture . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.1 Block diagram of Creator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Block diagram of the CPU board . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1 Files modified . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 Linker will insert head-s3c2410 into the head.o . . . . . . . . . . . . . . . . 11
3.3 PORT-H control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.4 Network filesystem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.1 Disable interrupt then trace module with ICE . . . . . . . . . . . . . . . . . 32
4.2 Program status register format . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.3 Snapshot of ICE debug mode . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.1 Diagram of MMU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2 IO REG2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.3 Diagram showing our mechanism . . . . . . . . . . . . . . . . . . . . . . . 44
參考文獻 References
[1] Create ARM920T-S3C2410 User’s Guide (1.2 ed.), Microtime Computer Inc., 2005.
[2] K. Yaghmour, Building Embedded Linux Systems, O’Reilly, 2003.
[3] Microtime Computer Inc., Embedded Linux3ARM9 S3C2410 (PreSOCes)î@®,
Chwa Taiwan Inc., 2005.
[4] Microtime Computer Inc., ARM9 S3C2410¶áPSOC@®, Chwa Taiwan Inc., 2005.
[5] S. Welsh and P. Knaggs, ARM Assembly Language Programming, BSc (Hons) Computing,
2003.
[6] J. Corbet, A. Rubini, and G. Kroah-Hartman, Linux Device Drivers, 3rd ed., O’Reilly,
2005.
[7] Danel P. Bovet and Marco Cesati, Understanding the Linux Kernel, O’Reilly, 2001.
[8] Andrew Morton, Linux Kernel Development, Novell, 2005.
[9] Brain W. Kernighan and Dennis M. Ritchie, The C programming Language, Prentice
Hall, 1988.
[10] Wookey and Tak-Shing, Porting the Linux Kernel to a New ARM Platform,
http://www.aleph1.co.uk, 2002.
[11] F. Vahid and T. Givargis, Embedded System Design: A Unified Hardware/Software Introduction,
New York, Wiley, 2002.
[12] Janos Sztipanovits, Gautam Biswas, Ken Frampton, Aniruddha Gokhale, Larry Howard,
Gabor Karsai, T. John Koo, Xenofon Koutsoukos, and Douglas C. Schmidt, Introducing
Embedded Software and Systems Education and Advanced Learning Technology
in an Engineering Curriculum, ACM Transactions on Embedded Computing Systems
(TECS), ACM, 2005.
[13] Norman Ramsey, Embedding an Interpreted Language Using Higher-order Functions
and Types, Proceedings of the 2003 workshop on Interpreters, virtual machines and
emulators, ACM, 2003.
[14] Ann Gordon-Ross, Susan Cotterell, and Frank Vahid, Tiny Instruction Caches for
Low Power Embedded Systems, ACM Transactions on Embedded Computing Systems
(TECS), ACM, 2003.
[15] Brain Ward, The Book of Vmware, No Starch Press, 2003.
[16] Ashfaq A. Khan, Practical Linux Programming: Device Drivers, Embedded systems,
and the Internet, Delmar Thomson Learning, 2002.
[17] Michael Beck, Harald Bohme, Mirko Dziadzka, Ulrich Kunitz, Robert Magnus, Dirk
Verworner, and Claus Schroter, Linux Kernel Programming, 3rd ed., Addison-Wesley
Professional, 2002.
[18] Ori Pomerantz, Linux Kernel Module Programming Guide, Iuniverse Inc., 2000.
[19] Wrox, Professional Linux Kernel Programming, Wrox Press Ltd., 2002.
[20] M. Tim Jones, GNU/Linux Application Programming (Programming Series), Charles
River Media, 2005.
[21] Richard Stones, Neil Matthew, and Alan Cox, Beginning Linux Programming, Wrox,
2000.
[22] Christopher Negus and Thomas Weeks, Linux Troubleshooting Bible, John Wiley &
Sons, 2004.
[23] Sivarama P. Dandamudi, Guide to Assembly Language Programming in Linux, Springer,
2005.
[24] Doug Abbott, Linux for Embedded and Real-Time Applications, Newnes, 2002.
[25] Tammy Noergaard, Embedded Systems Architecture: A Comprehensive Guide for Engineers
and Programmers, Newnes, 2005.
電子全文 Fulltext
本電子全文僅授權使用者為學術研究之目的,進行個人非營利性質之檢索、閱讀、列印。請遵守中華民國著作權法之相關規定,切勿任意重製、散佈、改作、轉貼、播送,以免觸法。
論文使用權限 Thesis access permission:校內校外均不公開 not available
開放時間 Available:
校內 Campus:永不公開 not available
校外 Off-campus:永不公開 not available

您的 IP(校外) 位址是 3.135.190.101
論文開放下載的時間是 校外不公開

Your IP address is 3.135.190.101
This thesis will be available to you on Indicate off-campus access is not available.

紙本論文 Printed copies
紙本論文的公開資訊在102學年度以後相對較為完整。如果需要查詢101學年度以前的紙本論文公開資訊,請聯繫圖資處紙本論文服務櫃台。如有不便之處敬請見諒。
開放時間 available 已公開 available

QR Code