嵌入式LINUX开发(英文版)

嵌入式LINUX开发(英文版)
作 者: Christopher Hallinan
出版社: 人民邮电出版社
丛编项: 典藏原版书苑
版权说明: 本书为公共版权或经版权方授权,请支持正版图书
标 签: 嵌入式系统
ISBN 出版时间 包装 开本 页数 字数
未知 暂无 暂无 未知 0 暂无

作者简介

  Christopher Hallinan是MontaVista公司的FAE(现场应用工程师),拥有25年以上的网络和通信行业经验,做过多种产品的开发工作,在软件接口方面的深厚的开发背景。加盟MontaVista之前,Chris是一位Linux顾问,拥有4年Linux系统移植、设备驱动和bootloader开发经验,在U-Boot(一个流行的bootloader)项目中做出了杰出的贡献。

内容简介

本书是一部全面易懂的嵌入式Linux开发实用指南。主要内容包括:处理器基础、Linux内核、内核初始化、系统初始化、Bootloader、设备驱动基础、文件系统、MTD子系统、BusyBox、嵌入式开发环境、开发工具、内核调试技术、调试嵌入式Linux应用程序、Linux与实时等。 本书适合有一定的C语言编程基础,对本地局域网和互连网有基本了解的嵌入式开发人员和工程师阅读。

图书目录

Chapter 1 Introduction 1

1.1 Why Linux? 2

1.2 Embedded Linux Today 3

1.3 Open Source and the GPL 3

1.3.1 Free Versus Freedom 4

1.4 Standards and Relevant Bodies 5

1.4.1 Linux Standard Base 5

1.4.2 Open Source Development Labs 5

1.5 Chapter Summary 7

1.5.1 Suggestions for Additional Reading 7

Chapter 2 Your First Embedded Experience 9

2.1 Embedded or Not? 10

2.1.1 BIOS Versus Bootloader 11

2.2 Anatomy of an Embedded System 12

2.2.1 Typical Embedded Linux Setup 14

2.2.2 Starting the Target Board 15

2.2.3 Booting the Kernel 16

2.2.4 Kernel Initialization: Overview 17

2.2.5 First User Space Process: init 19

2.3 Storage Considerations 19

2.3.1 Flash Memory 20

2.3.2 NAND Flash 22

2.3.3 Flash Usage 23

2.3.4 Flash File Systems 24

2.3.5 Memory Space 25

2.3.6 Execution Contexts 26

2.3.7 Process Virtual Memory 28

2.3.8 Cross-Development Environment 30

2.4 Embedded Linux Distributions 32

2.4.1 Commercial Linux Distributions 33

2.4.2 Do-It-Yourself Linux Distributions 34

2.5 Chapter Summary 34

2.5.1 Suggestions for Additional Reading 35

Chapter 3 Processor Basics 37

3.1 Stand-alone Processors 38

3.1.1 IBM 970FX 39

3.1.2 Intel Pentium M 39

3.1.3 Freescale MPC7448 40

3.1.4 Companion Chipsets 41

3.2 Integrated Processors: Systems on Chip 43

3.2.1 PowerPC 44

3.2.2 AMCC PowerPC 44

3.2.3 Freescale PowerPC 47

3.2.4 MIPS 52

3.2.5 Broadcom MIPS 53

3.2.6 AMD MIPS 55

3.2.7 Other MIPS 56

3.2.8 ARM 56

3.2.9 TI ARM 56

3.2.10 Freescale ARM 58

3.2.11 Intel ARM XScale 59

3.2.12 Other ARM 60

3.2.13 Other Architectures 60

3.3 Hardware Platforms 61

3.3.1 CompactPCI 61

3.3.2 ATCA 61

3.4 Chapter Summary 62

3.4.1 Suggestions For Additional Reading 63

Chapter 4 The Linux Kernel——A Different Perspective 65

4.1 Background 66

4.1.1 Kernel Versions 67

4.1.2 Kernel Source Repositories 69

4.2 Linux Kernel Construction 70

4.2.1 Top-Level Source Directory 70

4.2.2 Compiling the Kernel 71

4.2.3 The Kernel Proper: vmlinux 73

4.2.4 Kernel Image Components 75

4.2.5 Subdirectory Layout 79

4.3 Kernel Build System 79

4.3.1 The Dot-Config 80

4.3.2 Configuration Editor(s) 82

4.3.3 Makefile Targets 85

4.3.4 Kernel Configuration 88

4.3.5 Custom Configuration Options 90

4.3.6 Kernel Makefiles 94

4.3.7 Kernel Documentation 95

4.4 Obtaining a Linux Kernel 96

4.4.1 What Else Do I Need? 96

4.5 Chapter Summary 97

4.5.1 Suggestions for Additional Reading 98

Chapter 5 Kernel Initialization 99

5.1 Composite Kernel Image: Piggy and Friends 100

5.1.1 The Image Object 103

5.1.2 Architecture Objects 104

5.1.3 Bootstrap Loader 105

5.1.4 Boot Messages 106

5.2 Initialization Flow of Control 109

5.2.1 Kernel Entry Point: head.o 111

5.2.2 Kernel Startup: main.c 113

5.2.3 Architecture Setup 114

5.3 Kernel Command Line Processing 114

5.3.1 The __setup Macro 116

5.4 Subsystem Initialization 121

5.4.1 The *__initcall Macros 122

5.5 The init Thread 123

5.5.1 Initialization via initcalls 125

5.5.2 Final Boot Steps 126

5.6 Chapter Summary 128

5.6.1 Suggestions for Additional Reading 128

Chapter 6 System Initialization 129

6.1 Root File System 130

6.1.1 FHS: File System Hierarchy Standard 131

6.1.2 File System Layout 131

6.1.3 Minimal File System 132

6.1.4 The Root FS Challenge 134

6.1.5 Trial-and-Error Method 135

6.1.6 Automated File System Build Tools 135

6.2 Kernel’s Last Boot Steps 136

6.2.1 First User Space Program 137

6.2.2 Resolving Dependencies 138

6.2.3 Customized Initial Process 138

6.3 The Init Process 139

6.3.1 inittab 142

6.3.2 Example Web Server Startup Script 144

6.4 Initial RAM Disk 145

6.4.1 Initial RAM Disk Purpose 146

6.4.2 Booting with initrd 146

6.4.3 Bootloader Support for initrd 147

6.4.4 initrd Magic: linuxrc 149

6.4.5 The initrd Plumbing 150

6.4.6 Building an initrd Image 151

6.5 Using initramfs 152

6.6 Shutdown 153

6.7 Chapter Summary 154

6.7.1 Suggestions for Additional Reading 155

Chapter 7 Bootloaders 157

7.1 Role of a Bootloader 158

7.2 Bootloader Challenges 159

7.2.1 DRAM Controller 159

7.2.2 Flash Versus RAM 160

7.2.3 Image Complexity 160

7.2.4 Execution Context 163

7.3 A Universal Bootloader: Das U-Boot 164

7.3.1 System Configuration: U-Boot 164

7.3.2 U-Boot Command Sets 167

7.3.3 Network Operations 167

7.3.4 Storage Subsystems 170

7.3.5 Booting from Disk: U-Boot 171

7.4 Porting U-Boot 172

7.4.1 EP405 U-Boot Port 172

7.4.2 U-Boot Makefile Configuration Target 174

7.4.3 EP405 Processor Initialization 174

7.4.4 Board-Specific Initialization 177

7.4.5 Porting Summary 180

7.4.6 U-Boot Image Format 181

7.5 Other Bootloaders 183

7.5.1 Lilo 183

7.5.2 GRUB 184

7.5.3 Still More Bootloaders 186

7.6 Chapter Summary 186

7.6.1 Suggestions for Additional Reading 187

Chapter 8 Device Driver Basics 189

8.1 Device Driver Concepts 190

8.1.1 Loadable Modules 191

8.1.2 Device Driver Architecture 192

8.1.3 Minimal Device Driver Example 192

8.1.4 Module Build Infrastructure 193

8.1.5 Installing Your Device Driver 197

8.1.6 Loading Your Module 198

8.2 Module Utilities 199

8.2.1 insmod 199

8.2.2 Module Parameters 199

8.2.3 lsmod 201

8.2.4 modprobe 201

8.2.5 depmod 203

8.2.6 rmmod 203

8.2.7 modinfo 204

8.3 Driver Methods 205

8.3.1 Driver File System Operations 205

8.3.2 Device Nodes and mknod 208

8.4 Bringing It All Together 209

8.5 Device Drivers and the GPL 211

8.6 Chapter Summary 211

8.6.1 Suggestions for Additional Reading 212

Chapter 9 File Systems 213

9.1 Linux File System Concepts 214

9.1.1 Partitions 214

9.2 ext2 216

9.2.1 Mounting a File System 218

9.2.2 Checking File System Integrity 219

9.3 ext3 221

9.4 ReiserFS 224

9.5 JFFS2 225

9.6 cramfs 228

9.7 Network File System 230

9.7.1 Root File System on NFS 232

9.8 Pseudo File Systems 234

9.8.1 Proc File System 234

9.8.2 sysfs 238

9.9 Other File Systems 240

9.10 Building a Simple File System 242

9.11 Chapter Summary 243

9.11.1 Suggestions for Additional Reading 244

Chapter 10 MTD Subsystem 247

10.1 Enabling MTD Services 248

10.1.1 Building MTD 250

10.2 MTD Basics 251

10.2.1 Configuring MTD 253

10.3 MTD Partitions 253

10.3.1 Redboot Partition Table Partitioning  255

10.3.2 Kernel Command Line Partitioning 259

10.3.3 Mapping Driver 260

10.3.4 Flash Chip Drivers 262

10.3.5 Board-Specific Initialization 263

10.4 MTD Utilities 265

10.4.1 JFFS2 Root File System 268

10.5 Chapter Summary 270

10.5.1 Suggestions for Additional Reading 271

Chapter 11 BusyBox 273

11.1 Introduction to BusyBox 274

11.1.1 BusyBox is Easy 275

11.2 BusyBox Configuration 275

11.2.1 Cross-Compiling BusyBox 277

11.3 BusyBox Operation 278

11.3.1 BusyBox Init 281

11.3.2 Example rcS Initialization Script 283

11.3.3 BusyBox Target Installation 284

11.3.4 BusyBox Commands 286

11.4 Chapter Summary 288

11.4.1 Suggestions for Additional Reading 288

Chapter 12 Embedded Development Environment 289

12.1 Cross-Development Environment 290

12.1.1 “Hello World”——Embedded 291

12.2 Host System Requirements 295

12.2.1 Hardware Debug Probe 296

12.3 Hosting Target Boards 296

12.3.1 TFTP Server 296

12.3.2 BOOTP/DHCP Server 298

12.3.3 NFS Server 300

12.3.4 Target NFS Root Mount 302

12.3.5 U-Boot NFS Root Mount Example 304

12.4 Chapter Summary 306

12.4.1 Suggestions for Additional Reading 307

Chapter 13 Development Tools 309

13.1 GNU Debugger (GDB) 310

13.1.1 Debugging a Core Dump 311

13.1.2 Invoking GDB 313

13.1.3 Debug Session in GDB 315

13.2 Data Display Debugger 317

13.3 cbrowser/cscope 319

13.4 Tracing and Profiling Tools 321

13.4.1 strace 321

13.4.2 strace Variations 325

13.4.3 ltrace 327

13.4.4 ps 328

13.4.5 top 330

13.4.6 mtrace 332

13.4.7 dmalloc 334

13.4.8 Kernel Oops 337

13.5 Binary Utilities 340

13.5.1 readelf 340

13.5.2 Examining Debug Info Using readelf 342

13.5.3 objdump 344

13.5.4 objcopy 345

13.6 Miscellaneous Binary Utilities 346

13.6.1 strip 346

13.6.2 addr2line 346

13.6.3 strings 347

13.6.4 ldd 347

13.6.5 nm 348

13.6.6 prelink 349

13.7 Chapter Summary 349

13.7.1 Suggestions for Additional Reading 350

Chapter 14 Kernel Debugging Techniques 351

14.1 Challenges to Kernel Debugging 352

14.2 Using KGDB for Kernel Debugging 353

14.2.1 KGDB Kernel Configuration 355

14.2.2 Target Boot with KGDB Support 355

14.2.3 Useful Kernel Breakpoints 358

14.3 Debugging the Linux Kernel 360

14.3.1 gdb Remote Serial Protocol 361

14.3.2 Debugging Optimized Kernel Code 364

14.3.3 gdb User-Defined Commands 369

14.3.4 Useful Kernel gdb Macros 370

14.3.5 Debugging Loadable Modules 378

14.3.6 printk Debugging 383

14.3.7 Magic SysReq Key 384

14.4 Hardware-Assisted Debugging 385

14.4.1 Programming Flash Using a JTAG Probe 387

14.4.2 Debugging with a JTAG Probe 389

14.5 When It Doesn’t Boot 392

14.5.1 Early Serial Debug Output 393

14.5.2 Dumping the printk Log Buffer 394

14.5.3 KGDB on Panic 396

14.6 Chapter Summary 397

14.6.1 Suggestions for Additional Reading 398

Chapter 15 Debugging Embedded Linux Applications 399

15.1 Target Debugging 400

15.2 Remote (Cross) Debugging 400

15.2.1 gdbserver 403

15.3 Debugging with Shared Libraries 405

15.3.1 Shared Library Events in GDB 407

15.4 Debugging Multiple Tasks 411

15.4.1 Debugging Multiple Processes 411

15.4.2 Debugging Multithreaded Applications 414

15.4.3 Debugging Bootloader/Flash Code 417

15.5 Additional Remote Debug Options 417

15.5.1 Debugging via Serial Port 418

15.5.2 Attaching to a Running Process 418

15.6 Chapter Summary 419

15.6.1 Suggestions for Additional Reading 419

Chapter 16 Porting Linux 421

16.1 Linux Source Organization 422

16.1.1 The Architecture Branch 422

16.2 Custom Linux for Your Board 424

16.2.1 Prerequisites and Assumptions 426

16.2.2 Customizing Kernel Initialization 427

16.2.3 Static Kernel Command Line 429

16.3 Platform Initialization 431

16.3.1 Early Variable Access 435

16.3.2 Board Information Structure 436

16.3.3 Machine-Dependent Calls 438

16.4 Putting It All Together 439

16.4.1 Other Architectures 442

16.5 Chapter Summary 442

16.5.1 Suggestions for Additional Reading 443

Chapter 17 Linux and Real Time 445

17.1 What Is Real Time? 446

17.1.1 Soft Real Time 446

17.1.2 Hard Real Time 446

17.1.3 Linux Scheduling 447

17.1.4 Latency 447

17.2 Kernel Preemption 449

17.2.1 Impediments to Preemption 449

17.2.2 Preemption Models 451

17.2.3 SMP Kernel 452

17.2.4 Sources of Preemption Latency 453

17.3 Real-Time Kernel Patch 453

17.3.1 Real-Time Features 455

17.3.2 O(1) Scheduler 458

17.3.3 Creating a Real-Time Process 458

17.3.4 Critical Section Management 459

17.4 Debugging the Real-Time Kernel 460

17.4.1 Soft Lockup Detection 460

17.4.2 Preemption Debugging 461

17.4.3 Debug Wakeup Timing 461

17.4.4 Wakeup Latency History 462

17.4.5 Interrupt Off Timing 462

17.4.6 Interrupt Off History 462

17.4.7 Latency Tracing 464

17.4.8 Debugging Deadlock Conditions 466

17.4.9 Runtime Control of Locking Mode 467

17.5 Chapter Summary 467

17.5.1 Suggestions for Additional Reading 467

Appendix A: GNU Public License 469

Appendix B: U-Boot Configurable Commands 479

Appendix C: BusyBox Commands 483

Appendix D: SDRAM Interface Considerations 491

D.1 SDRAM Basics 492

D.1.1 SDRAM Refresh 493

D.2 Clocking 494

D.3 SDRAM Setup 495

D.4 Summary 500

D.4.1 Suggestions for Additional Reading 500

Appendix E: Open Source Resources 501

Appendix F: Sample BDI-2000 Configuration File 505

Index 513