Foreword p. xix Preface p. xxi Acknowledgments p. xxvii About the Author p. xxix Introduction p. 1 Why Linux? p. 2 Embedded Linux Today p. 3 Open Source and the GPL p. 3 Free Versus Freedom p. 4 Standards and Relevant Bodies p. 5 Linux Standard Base p. 5 Open Source Development Labs p. 5 Chapter Summary p. 7 Suggestions for Additional Reading p. 7 Your First Embedded Experience p. 9 Embedded or Not? p. 10 BIOS Versus Bootloader p. 11 Anatomy of an Embedded System p. 12 Typical Embedded Linux Setup p. 14 Starting the Target Board p. 15 Booting the Kernel p. 16 Kernel Initialization: Overview p. 17 First User Space Process: init p. 19 Storage Considerations p. 19 Flash Memory p. 20 NAND Flash p. 22 Flash Usage p. 23 Flash File Systems p. 24 Memory Space p. 25 Execution Contexts p. 26 Process Virtual Memory p. 28 Cross-Development Environment p. 30 Embedded Linux Distributions p. 32 Commercial Linux Distributions p. 33 Do-It-Yourself Linux Distributions p. 34 Chapter Summary p. 34 Suggestions for Additional Reading p. 35 Processor Basics p. 37 Stand-alone Processors p. 38 IBM 970FX p. 39 Intel Pentium M p. 39
Freescale MPC7448 p. 40 Companion Chipsets p. 41 Integrated Processors: Systems on Chip p. 43 PowerPC p. 44 AMCC PowerPC p. 44 Freescale PowerPC p. 47 MIPS p. 52 Broadcom MIPS p. 53 AMD MIPS p. 55 Other MIPS p. 56 ARM p. 56 TI ARM p. 56 Freescale ARM p. 58 Intel ARM XScale p. 59 Other ARM p. 60 Other Architectures p. 60 Hardware Platforms p. 61 CompactPCI p. 61 ATCA p. 61 Chapter Summary p. 62 Suggestions For Additional Reading p. 63 The Linux Kernel-A Different Perspective p. 65 Background p. 66 Kernel Versions p. 67 Kernel Source Repositories p. 69 Linux Kernel Construction p. 70 Top-Level Source Directory p. 70 Compiling the Kernel p. 71 The Kernel Proper: vmlinux p. 73 Kernel Image Components p. 75 Subdirectory Layout p. 79 Kernel Build System p. 79 The Dot-Config p. 80 Configuration Editor(s) p. 82 Makefile Targets p. 85 Kernel Configuration p. 88 Custom Configuration Options p. 90 Kernel Makefiles p. 94 Kernel Documentation p. 95 Obtaining a Linux Kernel p. 96 What Else Do I Need? p. 96
Chapter Summary p. 97 Suggestions for Additional Reading p. 98 Kernel Initialization p. 99 Composite Kernel Image: Piggy and Friends p. 100 The Image Object p. 103 Architecture Objects p. 104 Bootstrap Loader p. 105 Boot Messages p. 106 Initialization Flow of Control p. 109 Kernel Entry Point: head.o p. 111 Kernel Startup: main.c p. 113 Architecture Setup p. 114 Kernel Command Line Processing p. 114 The_setup Macro p. 116 Subsystem Initialization p. 121 The*_initcall Macros p. 122 The init Thread p. 123 Initialization via initcalls p. 125 Final Boot Steps p. 126 Chapter Summary p. 128 Suggestions for Additional Reading p. 128 System Initialization p. 129 Root File System p. 130 FHS: File System Hierarchy Standard p. 131 File System Layout p. 131 Minimal File System p. 132 The Root FS Challenge p. 134 Trial-and-Error Method p. 135 Automated File System Build Tools p. 135 Kernel's Last Boot Steps p. 136 First User Space Program p. 137 Resolving Dependencies p. 138 Customized Initial Process p. 138 The Init Process p. 139 inittab p. 142 Example Web Server Startup Script p. 144 Initial RAM Disk p. 145 Initial RAM Disk Purpose p. 146 Booting with initrd p. 146 Bootloader Support for initrd p. 147 initrd Magic: linuxrc p. 149
The initrd Plumbing p. 150 Building an initrd Image p. 151 Using initramfs p. 152 Shutdown p. 153 Chapter Summary p. 154 Suggestions for Additional Reading p. 155 Bootloaders p. 157 Role of a Bootloader p. 158 Bootloader Challenges p. 159 DRAM Controller p. 159 Flash Versus RAM p. 160 Image Complexity p. 160 Execution Context p. 163 A Universal Bootloader: Das U-Boot p. 164 System Configuration: U-Boot p. 164 U-Boot Command Sets p. 167 Network Operations p. 167 Storage Subsystems p. 170 Booting from Disk: U-Boot p. 171 Porting U-Boot p. 172 EP405 U-Boot Port p. 172 U-Boot Makefile Configuration Target p. 174 EP405 Processor Initialization p. 174 Board-Specific Initialization p. 177 Porting Summary p. 180 U-Boot Image Format p. 181 Other Bootloaders p. 183 Lilo p. 183 GRUB p. 184 Still More Bootloaders p. 186 Chapter Summary p. 186 Suggestions for Additional Reading p. 187 Device Driver Basics p. 189 Device Driver Concepts p. 190 Loadable Modules p. 191 Device Driver Architecture p. 192 Minimal Device Driver Example p. 192 Module Build Infrastructure p. 193 Installing Your Device Driver p. 197 Loading Your Module p. 198 Module Utilities p. 199
insmod p. 199 Module Parameters p. 199 lsmod p. 201 modprobe p. 201 depmod p. 203 rmmod p. 203 modinfo p. 204 Driver Methods p. 205 Driver File System Operations p. 205 Device Nodes and mknod p. 208 Bringing It All Together p. 209 Device Drivers and the GPL p. 211 Chapter Summary p. 211 Suggestions for Additional Reading p. 212 File Systems p. 213 Linux File System Concepts p. 214 Partitions p. 214 ext2 p. 216 Mounting a File System p. 218 Checking File System Integrity p. 219 ext3 p. 221 ReiserFS p. 224 JFFS2 p. 225 cramfs p. 228 Network File System p. 230 Root File System on NFS p. 232 Pseudo File Systems p. 234 Proc File System p. 234 sysfs p. 238 Other File Systems p. 240 Building a Simple File System p. 242 Chapter Summary p. 243 Suggestions for Additional Reading p. 244 MTD Subsystem p. 247 Enabling MTD Services p. 248 Building MTD p. 250 MTD Basics p. 251 Configuring MTD p. 253 MTD Partitions p. 253 Redboot Partition Table Partitioning p. 255 Kernel Command Line Partitioning p. 259
Mapping Driver p. 260 Flash Chip Drivers p. 262 Board-Specific Initialization p. 263 MTD Utilities p. 265 JFFS2 Root File System p. 268 Chapter Summary p. 270 Suggestions for Additional Reading p. 271 BusyBox p. 273 Introduction to BusyBox p. 274 BusyBox is Easy p. 275 BusyBox Configuration p. 275 Cross-Compiling BusyBox p. 277 BusyBox Operation p. 278 BusyBox Init p. 281 Example rcs Initialization Script p. 283 BusyBox Target Installation p. 284 BusyBox Commands p. 286 Chapter Summary p. 288 Suggestions for Additional Reading p. 288 Embedded Development Environment p. 289 Cross-Development Environment p. 290 "Hello World"-Embedded p. 291 Host System Requirements p. 295 Hardware Debug Probe p. 296 Hosting Target Boards p. 296 TFTP Server p. 296 BOOTP/DHCP Server p. 298 NFS Server p. 300 Target NFS Root Mount p. 302 U-Boot NFS Root Mount Example p. 304 Chapter Summary p. 306 Suggestions for Additional Reading p. 307 Development Tools p. 309 GNU Debugger (GDB) p. 310 Debugging a Core Dump p. 311 Invoking GDB p. 313 Debug Session in GDB p. 315 Data Display Debugger p. 317 cbrowser/cscope p. 319 Tracing and Profiling Tools p. 321 strace p. 321
strace Variations p. 325 ltrace p. 327 ps p. 328 top p. 330 mtrace p. 332 dmalloc p. 334 Kernel Oops p. 337 Binary Utilities p. 340 readelf p. 340 Examining Debug Info Using readelf p. 342 objdump p. 344 objcopy p. 345 Miscellaneous Binary Utilities p. 346 strip p. 346 addr2line p. 346 strings p. 347 ldd p. 347 nm p. 348 prelink p. 349 Chapter Summary p. 349 Suggestions for Additional Reading p. 350 Kernel Debugging Techniques p. 351 Challenges to Kernel Debugging p. 352 Using KGDB for Kernel Debugging p. 353 KGDB Kernel Configuration p. 355 Target Boot with KGDB Support p. 355 Useful Kernel Breakpoints p. 358 Debugging the Linux Kernel p. 360 gdb Remote Serial Protocol p. 361 Debugging Optimized Kernel Code p. 364 gdb User-Defined Commands p. 369 Useful Kernel gdb Macros p. 370 Debugging Loadable Modules p. 378 printk Debugging p. 383 Magic SysReq Key p. 384 Hardware-Assisted Debugging p. 385 Programming Flash Using a JTAG Probe p. 387 Debugging with a JTAG Probe p. 389 When It Doesn't Boot p. 392 Early Serial Debug Output p. 393 Dumping the printk Log Buffer p. 394
KGDB on Panic p. 396 Chapter Summary p. 397 Suggestions for Additional Reading p. 398 Debugging Embedded Linux Applications p. 399 Target Debugging p. 400 Remote (Cross) Debugging p. 400 gdbserver p. 403 Debugging with Shared Libraries p. 405 Shared Library Events in GDB p. 407 Debugging Multiple Tasks p. 411 Debugging Multiple Processes p. 411 Debugging Multithreaded Applications p. 414 Debugging Bootloader/Flash Code p. 417 Additional Remote Debug Options p. 417 Debugging via Serial Port p. 418 Attaching to a Running Process p. 418 Chapter Summary p. 419 Suggestions for Additional Reading p. 419 Porting Linux p. 421 Linux Source Organization p. 422 The Architecture Branch p. 422 Custom Linux for Your Board p. 424 Prerequisites and Assumptions p. 426 Customizing Kernel Initialization p. 427 Static Kernel Command Line p. 429 Platform Initialization p. 431 Early Variable Access p. 435 Board Information Structure p. 436 Machine-Dependent Calls p. 438 Putting It All Together p. 439 Other Architectures p. 442 Chapter Summary p. 442 Suggestions for Additional Reading p. 443 Linux and Real Time p. 445 What Is Real Time? p. 446 Soft Real Time p. 446 Hard Real Time p. 446 Linux Scheduling p. 447 Latency p. 447 Kernel Preemption p. 449 Impediments to Preemption p. 449
Preemption Models p. 451 SMP Kernel p. 452 Sources of Preemption Latency p. 453 Real-Time Kernel Patch p. 453 Real-Time Features p. 455 O(1) Scheduler p. 458 Creating a Real-Time Process p. 458 Critical Section Management p. 459 Debugging the Real-Time Kernel p. 460 Soft Lockup Detection p. 460 Preemption Debugging p. 461 Debug Wakeup Timing p. 461 Wakeup Latency History p. 462 Interrupt Off Timing p. 462 Interrupt Off History p. 462 Latency Tracing p. 464 Debugging Deadlock Conditions p. 466 Runtime Control of Locking Mode p. 467 Chapter Summary p. 467 Suggestions for Additional Reading p. 467 GNU Public License p. 469 U-Boot Configurable Commands p. 479 BusyBox Commands p. 483 SDRAM Interface Considerations p. 491 SDRAM Basics p. 492 SDRAM Refresh p. 493 Clocking p. 494 SDRAM Setup p. 495 Summary p. 500 Suggestions for Additional Reading p. 500 Open Source Resources p. 501 Sample BDI-2000 Configuration File p. 505 Index p. 513 Table of Contents provided by Blackwell's Book Services and R.R. Bowker. Used with permission.