Foreword for the First Edition |
|
xxv | |
Foreword for the Second Edition |
|
xxvi | |
Preface |
|
xxvii | |
Acknowledgments for the First Edition |
|
xxxiii | |
Acknowledgments for the Second Edition |
|
xxxv | |
About the Author |
|
xxxvi | |
Chapter 1 Introduction |
|
1 | (8) |
|
|
2 | (1) |
|
|
3 | (1) |
|
1.3 Open Source and the GPL |
|
|
3 | (2) |
|
1.3.1 Free Versus Freedom |
|
|
4 | (1) |
|
1.4 Standards and Relevant Bodies |
|
|
5 | (3) |
|
1.4.1 Linux Standard Base |
|
|
5 | (1) |
|
|
6 | (1) |
|
1.4.3 Carrier-Grade Linux |
|
|
6 | (1) |
|
1.4.4 Mobile Linux Initiative: Moblin |
|
|
7 | (1) |
|
1.4.5 Service Availability Forum |
|
|
7 | (1) |
|
|
8 | (1) |
|
1.5.1 Suggestions for Additional Reading |
|
|
8 | (1) |
Chapter 2 The Big Picture |
|
9 | (28) |
|
|
10 | (2) |
|
2.1.1 BIOS Versus Bootloader |
|
|
11 | (1) |
|
2.2 Anatomy of an Embedded System |
|
|
12 | (8) |
|
2.2.1 Typical Embedded Linux Setup |
|
|
13 | (1) |
|
2.2.2 Starting the Target Board |
|
|
14 | (2) |
|
|
16 | (2) |
|
2.2.4 Kernel Initialization: Overview |
|
|
18 | (1) |
|
2.2.5 First User Space Process: init |
|
|
19 | (1) |
|
2.3 Storage Considerations |
|
|
20 | (12) |
|
|
20 | (2) |
|
|
22 | (1) |
|
|
23 | (1) |
|
|
24 | (1) |
|
|
25 | (1) |
|
|
26 | (2) |
|
2.3.7 Process Virtual Memory |
|
|
28 | (2) |
|
2.3.8 Cross-Development Environment |
|
|
30 | (2) |
|
2.4 Embedded Linux Distributions |
|
|
32 | (2) |
|
2.4.1 Commercial Linux Distributions |
|
|
33 | (1) |
|
2.4.2 Do-It-Yourself Linux Distributions |
|
|
33 | (1) |
|
|
34 | (3) |
|
2.5.1 Suggestions for Additional Reading |
|
|
35 | (2) |
Chapter 3 Processor Basics |
|
37 | (26) |
|
3.1 Stand-Alone Processors |
|
|
38 | (5) |
|
|
39 | (1) |
|
|
39 | (1) |
|
|
40 | (1) |
|
|
40 | (1) |
|
|
41 | (2) |
|
3.2 Integrated Processors: Systems on Chip |
|
|
43 | (16) |
|
|
44 | (1) |
|
3.2.2 Freescale Power Architecture |
|
|
44 | (1) |
|
3.2.3 Freescale PowerQUICC I |
|
|
45 | (1) |
|
3.2.4 Freescale PowerQUICC II |
|
|
46 | (1) |
|
|
47 | (1) |
|
3.2.6 Freescale PowerQUICC III |
|
|
48 | (1) |
|
|
48 | (2) |
|
3.2.8 AMCC Power Architecture |
|
|
50 | (3) |
|
|
53 | (1) |
|
|
54 | (1) |
|
|
55 | (1) |
|
|
55 | (1) |
|
|
56 | (2) |
|
|
58 | (1) |
|
3.2.15 Other ARM Processors |
|
|
59 | (1) |
|
|
59 | (1) |
|
|
60 | (1) |
|
|
60 | (1) |
|
|
60 | (1) |
|
|
61 | (2) |
|
3.5.1 Suggestions for Additional Reading |
|
|
62 | (1) |
Chapter 4 The Linux Kernel: A Different Perspective |
|
63 | (36) |
|
|
64 | (4) |
|
|
65 | (2) |
|
4.1.2 Kernel Source Repositories |
|
|
67 | (1) |
|
4.1.3 Using git to Download a Kernel |
|
|
68 | (1) |
|
4.2 Linux Kernel Construction |
|
|
68 | (10) |
|
4.2.1 Top-Level Source Directory |
|
|
69 | (1) |
|
4.2.2 Compiling the Kernel |
|
|
69 | (3) |
|
4.2.3 The Kernel Proper: vmlinux |
|
|
72 | (1) |
|
4.2.4 Kernel Image Components |
|
|
73 | (4) |
|
4.2.5 Subdirectory Layout |
|
|
77 | (1) |
|
|
78 | (11) |
|
|
78 | (2) |
|
4.3.2 Configuration Editor(s) |
|
|
80 | (3) |
|
|
83 | (6) |
|
|
89 | (7) |
|
4.4.1 Custom Configuration Options |
|
|
91 | (4) |
|
|
95 | (1) |
|
|
96 | (1) |
|
4.6 Obtaining a Custom Linux Kernel |
|
|
96 | (1) |
|
4.6.1 What Else Do I Need? |
|
|
97 | (1) |
|
|
97 | (2) |
|
4.7.1 Suggestions for Additional Reading |
|
|
98 | (1) |
Chapter 5 Kernel Initialization |
|
99 | (32) |
|
5.1 Composite Kernel Image: Piggy and Friends |
|
|
100 | (9) |
|
|
103 | (1) |
|
5.1.2 Architecture Objects |
|
|
104 | (1) |
|
|
105 | (1) |
|
|
106 | (3) |
|
5.2 Initialization Flow of Control |
|
|
109 | (6) |
|
5.2.1 Kernel Entry Point: head.o |
|
|
111 | (2) |
|
5.2.2 Kernel Startup: main.c |
|
|
113 | (1) |
|
|
114 | (1) |
|
5.3 Kernel Command-Line Processing |
|
|
115 | (7) |
|
|
116 | (6) |
|
5.4 Subsystem Initialization |
|
|
122 | (3) |
|
5.4.1 The *_initcall Macros |
|
|
122 | (3) |
|
|
125 | (4) |
|
5.5.1 Initialization Via init calls |
|
|
126 | (1) |
|
|
127 | (1) |
|
|
127 | (2) |
|
|
129 | (2) |
|
5.6.1 Suggestions for Additional Reading |
|
|
130 | (1) |
Chapter 6 User Space Initialization |
|
131 | (28) |
|
|
132 | (5) |
|
6.1.1 FHS: File System Hierarchy Standard |
|
|
133 | (1) |
|
|
133 | (1) |
|
6.1.3 Minimal File System |
|
|
134 | (2) |
|
6.1.4 The Embedded Root FS Challenge |
|
|
136 | (1) |
|
6.1.5 Trial-and-Error Method |
|
|
137 | (1) |
|
6.1.6 Automated File System Build Tools |
|
|
137 | (1) |
|
6.2 Kernel's Last Boot Steps |
|
|
137 | (3) |
|
6.2.1 First User Space Program |
|
|
139 | (1) |
|
6.2.2 Resolving Dependencies |
|
|
139 | (1) |
|
6.2.3 Customized Initial Process |
|
|
140 | (1) |
|
|
140 | (6) |
|
|
143 | (2) |
|
6.3.2 Sample Web Server Startup Script |
|
|
145 | (1) |
|
|
146 | (7) |
|
6.4.1 Booting with initrd |
|
|
147 | (1) |
|
6.4.2 Bootloader Support for initrd |
|
|
148 | (2) |
|
6.4.3 initrd Magic: linuxrc |
|
|
150 | (1) |
|
6.4.4 The initrd Plumbing |
|
|
151 | (1) |
|
6.4.5 Building an initrd Image |
|
|
152 | (1) |
|
|
153 | (3) |
|
6.5.1 Customizing initramfs |
|
|
154 | (2) |
|
|
156 | (1) |
|
|
156 | (3) |
|
6.7.1 Suggestions for Additional Reading |
|
|
157 | (2) |
Chapter 7 Bootloaders |
|
159 | (42) |
|
|
160 | (1) |
|
7.2 Bootloader Challenges |
|
|
161 | (5) |
|
|
161 | (1) |
|
|
162 | (1) |
|
|
162 | (3) |
|
|
165 | (1) |
|
7.3 A Universal Bootloader: Das U-Boot |
|
|
166 | (8) |
|
|
166 | (1) |
|
|
167 | (2) |
|
7.3.3 U-Boot Monitor Commands |
|
|
169 | (1) |
|
|
170 | (3) |
|
|
173 | (1) |
|
|
174 | (1) |
|
|
174 | (13) |
|
|
175 | (1) |
|
7.4.2 U-Boot Makefile Configuration Target |
|
|
176 | (1) |
|
|
177 | (1) |
|
7.4.4 EP405 Processor Initialization |
|
|
178 | (3) |
|
7.4.5 Board-Specific Initialization |
|
|
181 | (3) |
|
|
184 | (1) |
|
7.4.7 U-Boot Image Format |
|
|
185 | (2) |
|
7.5 Device Tree Blob (Flat Device Tree) |
|
|
187 | (7) |
|
|
189 | (3) |
|
7.5.2 Device Tree Compiler |
|
|
192 | (1) |
|
7.5.3 Alternative Kernel Images Using DTB |
|
|
193 | (1) |
|
|
194 | (3) |
|
|
194 | (1) |
|
|
195 | (2) |
|
7.6.3 Still More Bootloaders |
|
|
197 | (1) |
|
|
197 | (4) |
|
7.7.1 Suggestions for Additional Reading |
|
|
198 | (3) |
Chapter 8 Device Driver Basics |
|
201 | (26) |
|
8.1 Device Driver Concepts |
|
|
202 | (10) |
|
|
203 | (1) |
|
8.1.2 Device Driver Architecture |
|
|
204 | (1) |
|
8.1.3 Minimal Device Driver Example |
|
|
204 | (1) |
|
8.1.4 Module Build Infrastructure |
|
|
205 | (4) |
|
8.1.5 Installing a Device Driver |
|
|
209 | (1) |
|
|
210 | (1) |
|
|
211 | (1) |
|
|
212 | (5) |
|
|
212 | (1) |
|
|
213 | (1) |
|
|
213 | (1) |
|
|
214 | (1) |
|
|
215 | (1) |
|
|
216 | (1) |
|
|
217 | (5) |
|
8.3.1 Driver File System Operations |
|
|
217 | (3) |
|
8.3.2 Allocation of Device Numbers |
|
|
220 | (1) |
|
8.3.3 Device Nodes and mknod |
|
|
220 | (2) |
|
8.4 Bringing It All Together |
|
|
222 | (1) |
|
8.5 Building Out-of-Tree Drivers |
|
|
223 | (1) |
|
8.6 Device Drivers and the GPL |
|
|
224 | (1) |
|
|
225 | (2) |
|
8.7.1 Suggestions for Additional Reading |
|
|
226 | (1) |
Chapter 9 File Systems |
|
227 | (34) |
|
9.1 Linux File System Concepts |
|
|
228 | (2) |
|
|
229 | (1) |
|
|
230 | (5) |
|
9.2.1 Mounting a File System |
|
|
232 | (1) |
|
9.2.2 Checking File System Integrity |
|
|
233 | (2) |
|
|
235 | (2) |
|
|
237 | (1) |
|
|
238 | (1) |
|
|
239 | (3) |
|
9.6.1 Building a JFFS2 Image |
|
|
240 | (2) |
|
|
242 | (2) |
|
|
244 | (4) |
|
9.8.1 Root File System on NFS |
|
|
246 | (2) |
|
|
248 | (7) |
|
|
249 | (3) |
|
|
252 | (3) |
|
|
255 | (1) |
|
9.11 Building a Simple File System |
|
|
256 | (2) |
|
|
258 | (3) |
|
9.12.1 Suggestions for Additional Reading |
|
|
259 | (2) |
Chapter 10 MTD Subsystem |
|
261 | (28) |
|
|
262 | (5) |
|
10.1.1 Enabling MTD Services |
|
|
263 | (2) |
|
|
265 | (2) |
|
10.1.3 Configuring MTD on Your Target |
|
|
267 | (1) |
|
|
267 | (12) |
|
10.2.1 Redboot Partition Table Partitioning |
|
|
269 | (4) |
|
10.2.2 Kernel Command-Line Partitioning |
|
|
273 | (1) |
|
|
274 | (2) |
|
10.2.4 Flash Chip Drivers |
|
|
276 | (1) |
|
10.2.5 Board-Specific Initialization |
|
|
276 | (3) |
|
|
279 | (5) |
|
10.3.1 JFFS2 Root File System |
|
|
281 | (3) |
|
|
284 | (3) |
|
10.4.1 Configuring for UBIFS |
|
|
284 | (1) |
|
10.4.2 Building a UBIFS Image |
|
|
284 | (3) |
|
10.4.3 Using UBIFS as the Root File System |
|
|
287 | (1) |
|
|
287 | (2) |
|
10.5.1 Suggestions for Additional Reading |
|
|
288 | (1) |
Chapter 11 BusyBox |
|
289 | (16) |
|
11.1 Introduction to BusyBox |
|
|
290 | (1) |
|
|
291 | (1) |
|
11.2 BusyBox Configuration |
|
|
291 | (2) |
|
11.2.1 Cross-Compiling BusyBox |
|
|
293 | (1) |
|
|
293 | (10) |
|
|
297 | (2) |
|
11.3.2 Sample rcS Initialization Script |
|
|
299 | (1) |
|
11.3.3 BusyBox Target Installation |
|
|
300 | (2) |
|
|
302 | (1) |
|
|
303 | (2) |
|
11.4.1 Suggestions for Additional Reading |
|
|
304 | (1) |
Chapter 12 Embedded Development Environment |
|
305 | (20) |
|
12.1 Cross-Development Environment |
|
|
306 | (5) |
|
12.1.1 "Hello World" Embedded |
|
|
307 | (4) |
|
12.2 Host System Requirements |
|
|
311 | (1) |
|
12.2.1 Hardware Debug Probe |
|
|
311 | (1) |
|
12.3 Hosting Target Boards |
|
|
312 | (10) |
|
|
312 | (1) |
|
|
313 | (3) |
|
|
316 | (2) |
|
12.3.4 Target NFS Root Mount |
|
|
318 | (2) |
|
12.3.5 U-Boot NFS Root Mount Example |
|
|
320 | (2) |
|
|
322 | (3) |
|
12.4.1 Suggestions for Additional Reading |
|
|
323 | (2) |
Chapter 13 Development Tools |
|
325 | (42) |
|
|
326 | (7) |
|
13.1.1 Debugging a Core Dump |
|
|
327 | (2) |
|
|
329 | (2) |
|
13.1.3 Debug Session in GDB |
|
|
331 | (2) |
|
13.2 Data Display Debugger |
|
|
333 | (2) |
|
|
335 | (2) |
|
13.4 Tracing and Profiling Tools |
|
|
337 | (18) |
|
|
337 | (4) |
|
|
341 | (2) |
|
|
343 | (1) |
|
|
344 | (2) |
|
|
346 | (2) |
|
|
348 | (2) |
|
|
350 | (3) |
|
|
353 | (2) |
|
|
355 | (6) |
|
|
355 | (2) |
|
13.5.2 Examining Debug Information Using readelf |
|
|
357 | (2) |
|
|
359 | (1) |
|
|
360 | (1) |
|
13.6 Miscellaneous Binary Utilities |
|
|
361 | (3) |
|
|
361 | (1) |
|
|
361 | (1) |
|
|
362 | (1) |
|
|
362 | (1) |
|
|
363 | (1) |
|
|
364 | (1) |
|
|
364 | (3) |
|
13.7.1 Suggestions for Additional Reading |
|
|
365 | (2) |
Chapter 14 Kernel Debugging Techniques |
|
367 | (56) |
|
14.1 Challenges to Kernel Debugging |
|
|
368 | (1) |
|
14.2 Using KGDB for Kernel Debugging |
|
|
369 | (12) |
|
14.2.1 KGDB Kernel Configuration |
|
|
371 | (1) |
|
14.2.2 Target Boot with KGDB Support |
|
|
372 | (4) |
|
14.2.3 Useful Kernel Breakpoints |
|
|
376 | (1) |
|
14.2.4 Sharing a Console Serial Port with KGDB |
|
|
377 | (2) |
|
14.2.5 Debugging Very Early Kernel Code |
|
|
379 | (1) |
|
14.2.6 KGDB Support in the Mainline Kernel |
|
|
380 | (1) |
|
14.3 Kernel Debugging Techniques |
|
|
381 | (29) |
|
14.3.1 gdb Remote Serial Protocol |
|
|
382 | (3) |
|
14.3.2 Debugging Optimized Kernel Code |
|
|
385 | (7) |
|
14.3.3 GDB User-Defined Commands |
|
|
392 | (1) |
|
14.3.4 Useful Kernel GDB Macros |
|
|
393 | (9) |
|
14.3.5 Debugging Loadable Modules |
|
|
402 | (5) |
|
|
407 | (2) |
|
|
409 | (1) |
|
14.4 Hardware-Assisted Debugging |
|
|
410 | (7) |
|
14.4.1 Programming Flash Using a JTAG Probe |
|
|
411 | (2) |
|
14.4.2 Debugging with a JTAG Probe |
|
|
413 | (4) |
|
14.5 When It Doesn't Boot |
|
|
417 | (4) |
|
14.5.1 Early Serial Debug Output |
|
|
417 | (1) |
|
14.5.2 Dumping the printk Log Buffer |
|
|
417 | (3) |
|
|
420 | (1) |
|
|
421 | (2) |
|
14.6.1 Suggestions for Additional Reading |
|
|
422 | (1) |
Chapter 15 Debugging Embedded Linux Applications |
|
423 | (22) |
|
|
424 | (1) |
|
15.2 Remote (Cross) Debugging |
|
|
424 | (5) |
|
|
427 | (2) |
|
15.3 Debugging with Shared Libraries |
|
|
429 | (6) |
|
15.3.1 Shared Library Events in GDB |
|
|
431 | (4) |
|
15.4 Debugging Multiple Tasks |
|
|
435 | (7) |
|
15.4.1 Debugging Multiple Processes |
|
|
435 | (3) |
|
15.4.2 Debugging Multithreaded Applications |
|
|
438 | (3) |
|
15.4.3 Debugging Bootloader/Flash Code |
|
|
441 | (1) |
|
15.5 Additional Remote Debug Options |
|
|
442 | (1) |
|
15.5.1 Debugging Using a Serial Port |
|
|
442 | (1) |
|
15.5.2 Attaching to a Running Process |
|
|
442 | (1) |
|
|
443 | (2) |
|
15.6.1 Suggestions for Additional Reading |
|
|
444 | (1) |
Chapter 16 Open Source Build Systems |
|
445 | (20) |
|
16.1 Why Use a Build System? |
|
|
446 | (1) |
|
|
447 | (4) |
|
16.2.1 Installing Scratchbox |
|
|
447 | (1) |
|
16.2.2 Creating a Cross-Compilation Target |
|
|
448 | (3) |
|
|
451 | (3) |
|
16.3.1 Buildroot Installation |
|
|
451 | (1) |
|
16.3.2 Buildroot Configuration |
|
|
451 | (1) |
|
|
452 | (2) |
|
|
454 | (10) |
|
16.4.1 OpenEmbedded Composition |
|
|
455 | (1) |
|
|
456 | (1) |
|
|
456 | (4) |
|
|
460 | (1) |
|
|
461 | (1) |
|
16.4.6 Configuring OpenEmbedded |
|
|
462 | (1) |
|
|
463 | (1) |
|
|
464 | (1) |
|
16.5.1 Suggestions for Additional Reading |
|
|
464 | (1) |
Chapter 17 Linux and Real Time |
|
465 | (22) |
|
|
466 | (3) |
|
|
466 | (1) |
|
|
467 | (1) |
|
|
467 | (1) |
|
|
467 | (2) |
|
|
469 | (4) |
|
17.2.1 Impediments to Preemption |
|
|
469 | (2) |
|
|
471 | (1) |
|
|
472 | (1) |
|
17.2.4 Sources of Preemption Latency |
|
|
473 | (1) |
|
17.3 Real-Time Kernel Patch |
|
|
473 | (5) |
|
17.3.1 Real-Time Features |
|
|
475 | (1) |
|
|
476 | (1) |
|
17.3.3 Creating a Real-Time Process |
|
|
477 | (1) |
|
17.4 Real-Time Kernel Performance Analysis |
|
|
478 | (7) |
|
17.4.1 Using Ftrace for Tracing |
|
|
478 | (1) |
|
17.4.2 Preemption Off Latency Measurement |
|
|
479 | (2) |
|
17.4.3 Wakeup Latency Measurement |
|
|
481 | (2) |
|
17.4.4 Interrupt Off Timing |
|
|
483 | (1) |
|
17.4.5 Soft Lockup Detection |
|
|
484 | (1) |
|
|
485 | (2) |
|
17.5.1 Suggestion for Additional Reading |
|
|
485 | (2) |
Chapter 18 Universal Serial Bus |
|
487 | (34) |
|
|
488 | (7) |
|
18.1.1 USB Physical Topology |
|
|
488 | (2) |
|
18.1.2 USB Logical Topology |
|
|
490 | (1) |
|
|
491 | (1) |
|
|
492 | (2) |
|
18.1.5 USB Cable Assemblies |
|
|
494 | (1) |
|
|
494 | (1) |
|
|
495 | (5) |
|
18.2.1 USB Initialization |
|
|
497 | (3) |
|
18.3 sysfs and USB Device Naming |
|
|
500 | (2) |
|
|
502 | (6) |
|
|
502 | (2) |
|
|
504 | (3) |
|
|
507 | (1) |
|
18.5 Common USB Subsystems |
|
|
508 | (8) |
|
18.5.1 USB Mass Storage Class |
|
|
508 | (3) |
|
|
511 | (1) |
|
18.5.3 USB CDC Class Drivers |
|
|
512 | (3) |
|
18.5.4 USB Network Support |
|
|
515 | (1) |
|
|
516 | (3) |
|
|
517 | (1) |
|
18.6.2 Useful USB Miscellanea |
|
|
518 | (1) |
|
|
519 | (2) |
|
18.7.1 Suggestions for Additional Reading |
|
|
519 | (2) |
Chapter 19 udev |
|
521 | (28) |
|
|
522 | (1) |
|
|
523 | (2) |
|
19.3 Default udev Behavior |
|
|
525 | (2) |
|
19.4 Understanding udev Rules |
|
|
527 | (11) |
|
|
530 | (3) |
|
19.4.2 Typical udev Rules Configuration |
|
|
533 | (2) |
|
19.4.3 Initial System Setup for udev |
|
|
535 | (3) |
|
19.5 Loading Platform Device Drivers |
|
|
538 | (2) |
|
19.6 Customizing udev Behavior |
|
|
540 | (1) |
|
19.6.1 udev Customization Example: USB Automounting |
|
|
540 | (1) |
|
19.7 Persistent Device Naming |
|
|
541 | (4) |
|
19.7.1 udev Helper Utilities |
|
|
542 | (3) |
|
19.8 Using udev with busybox |
|
|
545 | (3) |
|
|
545 | (2) |
|
|
547 | (1) |
|
|
548 | (1) |
|
19.9.1 Suggestions for Additional Reading |
|
|
548 | (1) |
Appendix A GNU Public License |
|
549 | (8) |
|
|
550 | (1) |
|
Terms and Conditions for Copying, Distribution, and Modification |
|
|
551 | (4) |
|
|
555 | (2) |
Appendix B U-Boot Configurable Commands |
|
557 | (4) |
Appendix C BusyBox Commands |
|
561 | (10) |
Appendix D SDRAM Interface Considerations |
|
571 | (10) |
|
|
572 | (2) |
|
|
573 | (1) |
|
|
574 | (1) |
|
|
575 | (5) |
|
|
580 | (1) |
|
D.4.1 Suggestions for Additional Reading |
|
|
580 | (1) |
Appendix E Open Source Resources |
|
581 | (4) |
|
Source Repositories and Developer Information |
|
|
582 | (1) |
|
|
582 | (1) |
|
Linux News and Developments |
|
|
583 | (1) |
|
Open Source Legal Insight and Discussion |
|
|
583 | (2) |
Appendix F Sample BDI-2000 Configuration File |
|
585 | (8) |
Index |
|
593 | |