Contentsxxi.465Chapter 17Linux and Real Time...46617.1 What Is Real Time?17.1.1 Soft Real Time..46617.1.2HardRealTime467.46717.1.3Linux Scheduling..46717.1.4Latency...46917.2 Kernel Preemption.46917.2.1Impediments toPreemption...47117.2.2Preemption Models....47217.2.3SMPKernel17.2.4.473SourcesofPreemptionLatency47317.3Real-TimeKernel Patch.17.3.1...475Real-Time Features..17.3.2.476O(1)Scheduler47717.3.3Creating a Real-Time Process.47817.4Real-TimeKernel PerformanceAnalysis.47817.4.1UsingFtraceforTracing..47917.4.2PreemptionOffLatencyMeasurement48117.4.3Wakeup LatencyMeasurement..48317.4.4Interrupt Off Timing....48417.4.5SoftLockupDetection..48517.5Summary48517.5.1SuggestionforAdditionalReading..487Chapter18 Universal Serial Bus.48818.1USBOverview48818.1.1USB Physical Topology.USB Logical Topology....49018.1.2
ptg Contents xxi Chapter 17 Linux and Real Time .465 17.1 What Is Real Time? . . 466 17.1.1 Soft Real Time . 466 17.1.2 Hard Real Time . 467 17.1.3 Linux Scheduling . 467 17.1.4 Latency . 467 17.2 Kernel Preemption . . 469 17.2.1 Impediments to Preemption. 469 17.2.2 Preemption Models . 471 17.2.3 SMP Kernel . 472 17.2.4 Sources of Preemption Latency . 473 17.3 Real-Time Kernel Patch. . 473 17.3.1 Real-Time Features . 475 17.3.2 O(1) Scheduler . 476 17.3.3 Creating a Real-Time Process . 477 17.4 Real-Time Kernel Performance Analysis . . 478 17.4.1 Using Ftrace for Tracing . . 478 17.4.2 Preemption Off Latency Measurement . 479 17.4.3 Wakeup Latency Measurement . . 481 17.4.4 Interrupt Off Timing . 483 17.4.5 Soft Lockup Detection . 484 17.5 Summary . . 485 17.5.1 Suggestion for Additional Reading . . 485 Chapter 18 Universal Serial Bus .487 18.1 USB Overview . . 488 18.1.1 USB Physical Topology . . 488 18.1.2 USB Logical Topology . . 490 Download at www.wowebook.com
xxii Embedded Linux Primer, Second Edition49118.1.3USBRevision.49218.1.4USBConnectors..49418.1.5USBCableAssemblies49418.1.6USBModes.49518.2Configuring USB..49718.2.1USBInitialization..50018.3sysfsandUSBDeviceNaming50218.4Useful USBTools..50218.4.1USBFileSystem..50418.4.2Using usbview.18.4.3.507USB Utils (lsusb)..50818.5CommonUSB Subsystems...50818.5.1USBMass StorageClas.....51118.5.2USBHIDClass51218.5.3USBCDCClassDrivers51518.5.4USBNetworkSupport...51618.6USBDebug.....51718.6.1usbmon18.6.2UsefulUSBMiscellanea518.51918.7Summary51918.7.1 Suggestions forAdditional Reading.Chapter19.521udev.52219.1What Is udev?.19.2DeviceDiscovery.52352519.3DefaultudevBehavior
ptg xxii Embedded Linux Primer, Second Edition 18.1.3 USB Revisions . 491 18.1.4 USB Connectors . 492 18.1.5 USB Cable Assemblies . 494 18.1.6 USB Modes . 494 18.2 Configuring USB . . 495 18.2.1 USB Initialization . 497 18.3 sysfs and USB Device Naming . 500 18.4 Useful USB Tools . . 502 18.4.1 USB File System . 502 18.4.2 Using usbview . 504 18.4.3 USB Utils (lsusb) . 507 18.5 Common USB Subsystems . . 508 18.5.1 USB Mass Storage Class . 508 18.5.2 USB HID Class . 511 18.5.3 USB CDC Class Drivers . 512 18.5.4 USB Network Support . . 515 18.6 USB Debug . . 516 18.6.1 usbmon . 517 18.6.2 Useful USB Miscellanea . . 518 18.7 Summary . . 519 18.7.1 Suggestions for Additional Reading . . 519 Chapter 19 udev .521 19.1 What Is udev? . 522 19.2 Device Discovery . 523 19.3 Default udev Behavior . 525 Download at www.wowebook.com
Contentsxxili52719.4Understanding udev Rules...53019.4.1Modalias19.4.2Typical udevRules Configuration...53353519.4.3InitialSystemSetupforudev.53819.5LoadingPlatformDeviceDrivers..54019.6Customizing udev Behavior..54019.6.1udevCustomizationExample:USBAutomounting19.7541Persistent Device Naming...54219.7.1udev Helper Utilities....54519.8Using udev with busybox.54519.8.1busyboxmdev.54719.8.2Configuringmdev...54819.9Summary54819.9.1SuggestionsforAdditionalReading..549Appendix AGNU Public License.550Preamble..551TermsandConditionsforCopying,Distribution,and Modification.No Warranty.555AppendixBU-Boot Configurable Commands.557561AppendixC BusyBoxCommands..571AppendixDSDRAMInterfaceConsiderations....572D.1SDRAMBasics.573D.1.1SDRAMRefresh.574D.2Clocking
ptg Contents xxiii 19.4 Understanding udev Rules . . 527 19.4.1 Modalias . . 530 19.4.2 Typical udev Rules Configuration . . 533 19.4.3 Initial System Setup for udev . . 535 19.5 Loading Platform Device Drivers . 538 19.6 Customizing udev Behavior . . 540 19.6.1 udev Customization Example: USB Automounting . . 540 19.7 Persistent Device Naming . . 541 19.7.1 udev Helper Utilities . . 542 19.8 Using udev with busybox . . 545 19.8.1 busybox mdev . . 545 19.8.2 Configuring mdev . . 547 19.9 Summary . . 548 19.9.1 Suggestions for Additional Reading . . 548 Appendix A GNU Public License .549 Preamble . 550 Terms and Conditions for Copying, Distribution, and Modification . . 551 No Warranty . . 555 Appendix B U-Boot Configurable Commands .557 Appendix C BusyBox Commands .561 Appendix D SDRAM Interface Considerations . 571 D.1 SDRAM Basics . . 572 D.1.1 SDRAM Refresh . . 573 D.2 Clocking . 574 Download at www.wowebook.com
xxiv Embedded Linux Primer, Second EditionD.3SDRAMSetup575.580D.4Summary580D.4.1Suggestions forAdditional ReadingAppendixEOpen SourceResources.581..582Source Repositories and Developer Information....582Mailing Lists..583LinuxNewsandDevelopments.583Open Source Legal Insight and Discussion585AppendixFSampleBDI-2000ConfigurationFileIndex593
ptg xxiv Embedded Linux Primer, Second Edition D.3 SDRAM Setup . 575 D.4 Summary . . 580 D.4.1 Suggestions for Additional Reading . . 580 Appendix E Open Source Resources .581 Source Repositories and Developer Information . 582 Mailing Lists . 582 Linux News and Developments . 583 Open Source Legal Insight and Discussion . 583 Appendix F Sample BDI-2000 Configuration File .585 Index .593 Download at www.wowebook.com
Foreword for the First EditionComputersareeverywhereThisfact,ofcourse,is no surpriseto anyone who hasn'tbeen living in a cave during thepast 25 years or so. And you probably know that computers aren't just on our desktops, inour kitchens, and, increasingly, in our living rooms, holding our music collections. They'realso in our microwave ovens, our regular ovens, our cell phones, and our portable digitalmusicplayers.And if you're holding this book, you probably know a lot, or are interested in learningmore about, these embedded computer systems.Until not too long ago, embedded systems were not very powerful, and they ran special-purpose,proprietaryoperating systems that were very differentfrom industry-standardones. (Plus,they were much harder to develop for.)Today, embedded computers are aspowerful as, if not more powerful than, a modern home computer. (Consider the high-endgaming consoles,for example.)Along with this power comes the capability to run a full-fledged operating system suchas Linux. Using a system such as Linux for an embedded product makes a lot of sense. Alarge community of developers are making this possible.Thedevelopment environmentandthedeployment environment can be surprisingly similar,whichmakesyourlifeasadeveloper much easier. And you have both the security of a protected address space that avirtual memory-based system gives you and the power and fexibility of a multiuser, multi-process system.That's agood deal all around.For this reason, companies all over theworld areusing Linux on many devices such asPDAs, home entertainment systems, and even, believe it or not, cell phones!I'm excited about this book. It provides an excellent"guide up the learning curve" for thedeveloper who wants to use Linux for his or her embedded system. It's clear, well-written,and well-organized; Chris's knowledge and understanding show through at every turn. It'snot only informative and helpful; it's also enjoyable to read.I hope you learn something and have fun at the same time. I know I did.Arnold RobbinsSeries Editorxxv
ptg xxv Foreword for the First Edition Computers are everywhere. This fact, of course, is no surprise to anyone who hasn’t been living in a cave during the past 25 years or so. And you probably know that computers aren’t just on our desktops, in our kitchens, and, increasingly, in our living rooms, holding our music collections. They’re also in our microwave ovens, our regular ovens, our cell phones, and our portable digital music players. And if you’re holding this book, you probably know a lot, or are interested in learning more about, these embedded computer systems. Until not too long ago, embedded systems were not very powerful, and they ran special-purpose, proprietary operating systems that were very different from industry-standard ones. (Plus, they were much harder to develop for.) Today, embedded computers are as powerful as, if not more powerful than, a modern home computer. (Consider the high-end gaming consoles, for example.) Along with this power comes the capability to run a full-fledged operating system such as Linux. Using a system such as Linux for an embedded product makes a lot of sense. A large community of developers are making this possible. The development environment and the deployment environment can be surprisingly similar, which makes your life as a developer much easier. And you have both the security of a protected address space that a virtual memory-based system gives you and the power and flexibility of a multiuser, multiprocess system. That’s a good deal all around. For this reason, companies all over the world are using Linux on many devices such as PDAs, home entertainment systems, and even, believe it or not, cell phones! I’m excited about this book. It provides an excellent “guide up the learning curve” for the developer who wants to use Linux for his or her embedded system. It’s clear, well-written, and well-organized; Chris’s knowledge and understanding show through at every turn. It’s not only informative and helpful; it’s also enjoyable to read. I hope you learn something and have fun at the same time. I know I did. Arnold Robbins Series Editor Download at www.wowebook.com