BY MOHIT ARORA AND VARUN JAIN • FREESCALE SEMICONDUCTORBOOT-UP, <strong>THE</strong> SEQUENCE<strong>OF</strong> STEPS THAT A SYSTEMPERFORMS BETWEEN WHEN YOUSWITCH ON POWER AND LOADAPPLICATIONS, IS SIMPLEIN <strong>THE</strong>ORY BUT <strong>OF</strong>TEN COMPLEXIN REALITY. <strong>THE</strong> MAIN JOB<strong>OF</strong> A BOOT LOADER IS TO LOAD<strong>THE</strong> OPERATING SYSTEM,BUT S<strong>OF</strong>TWARE AND HARDWARE<strong>ENGINEER</strong>S VIEW THIS PROCESSIN DIFFERENT WAYS.UNDERSTANDINGEMBEDDED-SYSTEM-BOOT TECHNIQUESTo load a program into memory, you mustfirst load a program into memory. The bootupprocess, often a complex multistep sequenceinvolving numerous substeps, solvesthis problem. Any boot-up process, includingbooting up Windows, Linux, or an embeddedRTOS (real-time operating system),begins with the application of power to thesystem and the subsequent removal of systemreset. During POR (power-on-reset) assertion, you may have toreconfigure hardware peripherals if operational values differ fromthose of default settings. Embedded microcontrollers, for example,often offer various hardware-reset-configuration schemes.Over the last several decades, bootingup has evolved from a simple DOSbasedstep to more complicated multiple-operating-systemchoices or evenperipheral-based boot-up techniques.A USB (Universal Serial Bus) interface,for example, allows you to boot upa disk image from an external storagedevice; this approach is increasinglypopular in industrial- and embeddedsystemapplications because it providesabundant flexibility. In the case of softwarecorruption, for example, in whicha system requires the reloading of newfirmware, the USB technique allowsa service engineer to simply copy newsoftware onto a flash drive and bootfrom it. The service department thereforesaves the thousands of dollars inexpenses that it would otherwise incurin transporting the equipment to themanufacturer for repair.To enable system-boot flexibilityboth from USB, PCIe (PeripheralComponent Interconnect Express),and SDHC (secure-digital-high-capacity)interfaces and from conventionalmemory devices requires in-depth hardwareand software capabilities. Opensourcefirmware—specifically, the U-Boot (Universal Boot Loader) utility,which finds wide use in embedded-systemplatforms—may also be of value.The Linux-based boot loader can automaticallyboot up the operating system;alternatively, it allows a user to manuallyrun explicit commands to start theoperating system, and it supports bootingfrom a variety of interfaces (seesidebar “The U-Boot”).WINDOWS XP SYSTEM BOOTA simple x86 boot sequence is fairlyself-explanatory (Figure 1). WindowsXP follows comparable steps, albeitPOWER ICON: ZEFFSS1/ISTOCKPHOTO.COM; BUTTON AND BACKGROUND: DSGPRO/ISTOCKPHOTO.COM18 EDN | FEBRUARY 3, 2011
with more sophistication. The boot sequencebegins with the application ofsystem power; the processor remains inreset. When all voltages and currentlevels are acceptable, the power supplysends a power-good signal to the processor.The next step, POR negation,takes place when the availability of thegood-power signal negates the processorreset to allow the CPU to begin operation.The CPU points to the ROMboot address and begins executingthe BIOS (basic-input/output-system)code. The ROM BIOS then performsPOST (power-on self-test), a basic testof core hardware to verify basic performance.The boot-up process then reportsany errors that occur at this point usingbeep codes because the video subsystemhas not yet initialized.The next step is video-card initialization,during which the BIOS searchesfor a video-card adapter by scanningmemory addresses C000:0000 throughC780:0000 to find a video ROM. Thevideo test initializes and tests any discoveredvideo adapter, potentiallyalong with its video memory, and displaysconfiguration information. If a“cold” start is taking place, the ROMBIOS executes a full POST. If it is a“warm” start, the boot-up process skipsthe memory-test portion of the POST.The CMOS now reads from theBIOS. During this step, the BIOS locatesand reads configuration informationstored in the CMOS. A small coinbattery cell on the motherboard typicallymaintains the CMOS, a small—typically, 64-byte area of memory—onthe motherboard. The CMOS memorystores information such as date,time, and peripheral-boot order. If thefirst bootable disk is a fixed disk, theBIOS examines its first sector for anMBR (master boot record). The MBRcomprises a partition table, which describesthe layout of the fixed disk, anda partition-loader code, which includesinstructions for continuing the bootprocess. The boot, or partition, loaderthen examines the partition table foran active partition. The partition loadersearches the first sector of that partitionfor a boot record. The boot processthan checks the active partition’sboot record for a valid boot signature. Ifit finds one, it executes the boot-sectorcode as a program.The NTLDR (New Technology Load -AT A GLANCE↘ The system-boot process,although potentially simple in concept,becomes complex when youconsider various implementationoptions.↘ Windows XP provides a popularcase study of a classic bootsequence.↘ Numerous hardware and softwaretechniques provide differentmeans of getting postreset-configurationdata to the processor.↘ Primary and secondary bootoptions comprehend different startupand kernel-code sizes, read- andwrite-performance expectations,and other variables.↘ U-Boot (Universal Boot Loader)is a powerful open-source tool thatdeserves consideration in Linuxbaseddesigns.er) for Windows, a hidden system filethat resides in the root directory of thesystem partition, controls the loadingof Windows XP. During NTLDR’s initialphase, it moves the processor fromreal mode to protected mode, enabling32-bit memory accesses and turning onmemory paging. It then loads the appropriateminidrivers to allow NTLDRto load files from a partition formattedwith any of the file systems that WindowsXP supports, including FAT (fileallocationtable)-16, FAT-32, and NTFS(New Technology File System).STEPS BEFORE <strong>THE</strong> BOOTSEQUENCE1 POWER ON2 RESET TO PROCESSOR UNTILGOOD POWER SUPPLY IS AVAILABLE3 RESET NEGATED, PROCESSOR-READY, POINTS TO ROM ADDRESSBOOT SEQUENCE1 POWER ON SELF-TEST2 LOOKS FOR VIDEO CARD,RUNS BUILD IN BIOS PROGRAM3 SYSTEM BIOS LOOKS FOR O<strong>THE</strong>RPERIPHERAL BIOS, EXECUTESO<strong>THE</strong>R BIOSIf the boot-initialization file residesin the root directory, NTLDR reads itscontents into memory. If the file containsentries for more than one operatingsystem, NTLDR suspends the bootsequence, displays a menu of choices,and waits for the user to make a selection.NTLDR then continues theboot-up process by locating and loadingthe DOS-based New Technologyexecutable file to perform hardwaredetection. After selecting a hardwareconfiguration, NTLDR begins loadingthe Windows XP New Technologykernel file. During this process, thescreen clears, and a series of white rectanglessubsequently progresses acrossit. NTLDR now loads device driversthat are marked as boot devices. Beforeperforming this load, NTLDR relinquishescontrol of the computer.At this point, the system displays agraphics screen with a status bar indicatingthe load status. During later initializationphases, the system cannotaccept device interrupts. The I/O manageralso begins to load the remainderof the system drivers, picking up whereNTLDR left off. The last task for thisinitialization phase is to launch thesession-manager subsystem, which isresponsible for creating the user-modeenvironment. The session-managersubsystem then loads the Windowsdevice driver, which implements thegraphics subsystem. Windows XP bootis not complete until a user has successfullylogged onto the system. The Windowslog-in file begins the log-in proc-4 BIOS DISPLAYS START-UP SCREEN5 MEMORY-COUNT TEST,HARD-DISK-DRIVE-PARAMETER SETTING6 BIOS LOOKS FOR COM AND LTP PORTS7 BIOS LOOKS FORBOOT-SEQUENCE SETTING8 LOADS OPERATING SYSTEM9 BIOS COPIES FILES TO MEMORY,OPERATING SYSTEM TAKES OVER BOOT-UP10 OPERATING SYSTEM CHECKS SYSTEMMEMORY, LOADS DRIVERS,AND STARTS APPLICATIONFigure 1 Microsoft’s Windows XP moves through a suite of steps as it boots a system.FEBRUARY 3, 2011 | EDN 19