Contentsxi1055.1.3BootstrapLoader.1065.1.4 Boot Messages..1095.2 InitializationFlowof Control.1115.2.1KernelEntryPoint:head.01135.2.2 Kernel Startup:main.c..1145..3Architecture Setup....1155.3KernelCommand-LineProcessing1165.3.1ThesetupMacro..1225.4 SubsystemInitialization...1225.4.1The*__initcallMacros.1255.5Theinit Thread.1265.5.1Initialization Via initcalls..1275.5.2initcall_debug...1275.5.3Final Boot Steps.1295.6Summary5.6.1Suggestions for Additional Reading.130.131Chapter6UserSpaceInitialization1326.1RootFileSystem.1336.1.1FHS:File System HierarchyStandard..1336.1.2File System Layout...1346.1.3Minimal File System..1366.1.4TheEmbedded RootFSChallenge..6.1.5Trial-and-Error Method..1376.1.6AutomatedFileSystemBuildTools.137
ptg Contents xi 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 . . 115 5.3.1 The _setup Macro . . 116 5.4 Subsystem Initialization . . 122 5.4.1 The *_initcall Macros . . 122 5.5 The init Thread . . 125 5.5.1 Initialization Via initcalls . . 126 5.5.2 initcall_debug . 127 5.5.3 Final Boot Steps . 127 5.6 Summary . . 129 5.6.1 Suggestions for Additional Reading . 130 Chapter 6 User Space Initialization .131 6.1 Root File System . . 132 6.1.1 FHS: File System Hierarchy Standard . 133 6.1.2 File System Layout . . 133 6.1.3 Minimal File System . 134 6.1.4 The Embedded Root FS Challenge . 136 6.1.5 Trial-and-Error Method . 137 6.1.6 Automated File System Build Tools . 137 Download at www.wowebook.com
xiiEmbedded Linux Primer, Second Edition6.2Kernel'sLastBoot Steps137..1396.2.1 First User Space Program..1396.2.2 Resolving Dependencies.6.2.3CustomizedInitialProcess.1406.3TheinitProcess..140...1436.3.1inittab..1456.3.2SampleWebServerStartupScript.1466.4Initial RAMDisk..1476.4.1 Booting with initrd..1486.4.2Bootloader Supportfor initrd....1506.4.3initrdMagic:linuxrc.1516.4.4 The initrd Plumbing.....1526.4.5 Building an initrd Imag......1536.5 Using initramfs.1546.5.1 Customizinginitramfs..1566.6Shutdown..1566.7 Summary..6.7.1 Suggestions forAdditional Reading.157Chapter7Bootloaders.159..1607.1 Role of a Bootloader...7.2Bootloader Challenges.1617.2.1 DRAM Controller161.1627.2.2 Flash Versus RAM...1627.2.3ImageComplexity.1657.2.4ExecutionContext
ptg xii Embedded Linux Primer, Second Edition 6.2 Kernel’s Last Boot Steps. . 137 6.2.1 First User Space Program . 139 6.2.2 Resolving Dependencies . 139 6.2.3 Customized Initial Process . . 140 6.3 The init Process . . 140 6.3.1 inittab . 143 6.3.2 Sample Web Server Startup Script . . 145 6.4 Initial RAM Disk . . 146 6.4.1 Booting with initrd . 147 6.4.2 Bootloader Support for initrd . 148 6.4.3 initrd Magic: linuxrc . 150 6.4.4 The initrd Plumbing . 151 6.4.5 Building an initrd Image . 152 6.5 Using initramfs . . 153 6.5.1 Customizing initramfs . . 154 6.6 Shutdown . 156 6.7 Summary . . 156 6.7.1 Suggestions for Additional Reading . . 157 Chapter 7 Bootloaders .159 7.1 Role of a Bootloader . 160 7.2 Bootloader Challenges . . 161 7.2.1 DRAM Controller . 161 7.2.2 Flash Versus RAM . 162 7.2.3 Image Complexity. . 162 7.2.4 Execution Context . 165 Download at www.wowebook.com
Contentsxili1667.3A Universal Bootloader: Das U-Boot..1667.3.1 ObtainingU-Boot..1677.3.2Configuring U-Boot..1697.3.3U-BootMonitorCommands.1707.3.4NetworkOperations..1737.3.5Storage Subsystems.....1747.3.6 Booting from Disk..1747.4Porting U-Boot..1757.4.1EP405U-Boot Port...1767.4.2U-Boot Makefile ConfigurationTarget1777.4.3EP405FirstBuild1787.4.4EP405ProcessorInitialization..1817.4.5Board-SpecificInitialization....1847.4.6Porting Summary1857.4.7U-Boot ImageFormat.7.5DeviceTreeBlob (Flat DeviceTree),.187.1897.5.1 Device Tree Source..1927.5.2Device Tree Compiler1937.5.3AlternativeKernel ImagesUsingDTB..1947.6OtherBootloaders.....1947.6.1Lilo1957.6.2GRUBStill MoreBootloaders.1977.6.3..1977.7Summary.1987.7.1Suggestions forAdditional Reading
ptg Contents xiii 7.3 A Universal Bootloader: Das U-Boot . . 166 7.3.1 Obtaining U-Boot . 166 7.3.2 Configuring U-Boot . 167 7.3.3 U-Boot Monitor Commands . 169 7.3.4 Network Operations . 170 7.3.5 Storage Subsystems . 173 7.3.6 Booting from Disk . 174 7.4 Porting U-Boot . . 174 7.4.1 EP405 U-Boot Port . 175 7.4.2 U-Boot Makefile Configuration Target . 176 7.4.3 EP405 First Build . 177 7.4.4 EP405 Processor Initialization. 178 7.4.5 Board-Specific Initialization . . 181 7.4.6 Porting Summary . . 184 7.4.7 U-Boot Image Format . 185 7.5 Device Tree Blob (Flat Device Tree) . . 187 7.5.1 Device Tree Source . 189 7.5.2 Device Tree Compiler . 192 7.5.3 Alternative Kernel Images Using DTB . 193 7.6 Other Bootloaders . . 194 7.6.1 Lilo . 194 7.6.2 GRUB . 195 7.6.3 Still More Bootloaders . . 197 7.7 Summary . . 197 7.7.1 Suggestions for Additional Reading . . 198 Download at www.wowebook.com
xivEmbedded Linux Primer, Second Edition201Chapter8DeviceDriverBasics..2028.1 DeviceDriverConcepts.2038.1.1 LoadableModules.2048.1.2DeviceDriverArchitecture.2048.1.3Minimal DeviceDriverExampleModule Build Infrastructure...2058.1.4.2098.1.5Installing a Device Driver8.1.6210Loading a Module8.1.7Module Parameters.2118.2Module Utilities.2128.2.1.212insmod2138.2.21smod8.2.3..213modprobe.8.2.4..214depmod.8.2.5215rmmod8.2.6.216modinfo..2178.3DriverMethods..2178.3.1DriverFileSystemOperations2208.3.2Allocation of DeviceNumbers8.3.3DeviceNodesandmknod..220.2228.4Bringing It All Together..2238.5Building Out-of-Tree Drivers..2248.6Device Drivers and the GPL.8.7..225Summary.2268.7.1Suggestions for Additional Reading
ptg xiv Embedded Linux Primer, Second Edition Chapter 8 Device Driver Basics .201 8.1 Device Driver Concepts . . 202 8.1.1 Loadable Modules . 203 8.1.2 Device Driver Architecture . 204 8.1.3 Minimal Device Driver Example . 204 8.1.4 Module Build Infrastructure . . 205 8.1.5 Installing a Device Driver . 209 8.1.6 Loading a Module . 210 8.1.7 Module Parameters . 211 8.2 Module Utilities . . 212 8.2.1 insmod . 212 8.2.2 lsmod . 213 8.2.3 modprobe . . 213 8.2.4 depmod . 214 8.2.5 rmmod . 215 8.2.6 modinfo . 216 8.3 Driver Methods . . 217 8.3.1 Driver File System Operations . . 217 8.3.2 Allocation of Device Numbers . 220 8.3.3 Device Nodes and mknod . 220 8.4 Bringing It All Together . . 222 8.5 Building Out-of-Tree Drivers . 223 8.6 Device Drivers and the GPL . . 224 8.7 Summary . 225 8.7.1 Suggestions for Additional Reading . . 226 Download at www.wowebook.com
ContentsXVChapter9FileSystems227.2289.1LinuxFileSystemConcepts2299.1.1Partitions2309.2ext22329.2.1MountingaFileSystem..2339.2.2Checking File System Integrity ...2359.3ext39.4ext42379.5ReiserFS...2389.6.239JFFS22409.6.1Building a JFFS2 Image.2429.7cramfs..2449.8NetworkFileSystem...2469.8.1Root File System on NFS.2489.9Pseudo File Systems...2499.9.1/proc File System.....2529.9.2sysfs.2559.10OtherFileSystems2569.11Building a Simple File System..2589.12Summary2599.12.1 Suggestions forAdditional Reading.261Chapter10MTDSubsystem....26210.1MTDOverview..26310.1.1EnablingMTDServices..26510.1.2MTDBasic10.1.3Configuring MTD on YourTarget267
ptg Contents xv Chapter 9 File Systems .227 9.1 Linux File System Concepts . . 228 9.1.1 Partitions . 229 9.2 ext2 . . 230 9.2.1 Mounting a File System . 232 9.2.2 Checking File System Integrity . . 233 9.3 ext3 . 235 9.4 ext4 . 237 9.5 ReiserFS . 238 9.6 JFFS2 . 239 9.6.1 Building a JFFS2 Image . 240 9.7 cramfs . . 242 9.8 Network File System . . 244 9.8.1 Root File System on NFS . 246 9.9 Pseudo File Systems . . 248 9.9.1 /proc File System . 249 9.9.2 sysfs . . 252 9.10 Other File Systems . . 255 9.11 Building a Simple File System . 256 9.12 Summary . 258 9.12.1 Suggestions for Additional Reading . . 259 Chapter 10 MTD Subsystem .261 10.1 MTD Overview . . 262 10.1.1 Enabling MTD Services . 263 10.1.2 MTD Basics . 265 10.1.3 Configuring MTD on Your Target . 267 Download at www.wowebook.com