EmbeddedLinux®:Hardware,Software,and
Interfacing
ByCraigHollabaughPh.D.
Publisher :AddisonWesley
PubDate :March07,2002
ISBN :0-672-32226-9
Pages :432
Slots :1.0
EmbeddedLinuxcoversthedevelopmentand
implementationofinterfacingapplicationsonanembedded
Linuxplatform.Itincludesacomprehensivediscussionof
platformselection,crosscompilation,kernelcompilation,
rootfilesystemcreation,booting,remotedebugging,realworldinterfacing,applicationcontrol,datacollection,
Tableof archiving,andpresentation.
•
Contents
Thisbookincludesserial,parallel,memoryI/O,USB,and
•
interrupt-drivenhardwaredesignsusingx86-,
StrongARM®-,andPowerPC®-basedtargetboards.In
addition,youwillfindsimpledevicedrivermodulecode
thatconnectsexternaldevicestothekernel,andnetwork
integrationcodethatconnectsembeddedLinuxfield
devicestoacentralizedcontrolcenter.Examplesteach
hardwaredevelopershowtostoreandactivatefieldbitsand
deliverprocessinformationusingopensourcesoftware.If
youareahardwaredeveloper,softwaredeveloper,system
integrator,orproductmanagerwho'sbegunexploring
embeddedLinuxforinterfacingapplications,thisbookis
foryou.
EmbeddedLinux®:Hardware,Software,and
Interfacing
ByCraigHollabaughPh.D.
Publisher :AddisonWesley
PubDate :March07,2002
ISBN :0-672-32226-9
Pages :432
•
Tableof
Contents
•
Slots :1.0
Copyright
Foreword
AbouttheAuthor
Acknowledgments
Introduction
BenefitsofThisBook
WhatThisBookCovers
WhoThisBookIsFor
ConventionsUsedinThisBook
PartI:
GettingStarted
Chapter1.
IntroducingEmbeddedLinux
WhyLinux,WhyNow?
WhatIsanEmbeddedSystem?
WhatDoesReal-TimeMean?
ImplicationsofOpenSource
Summary
AdditionalReading
Chapter2.
SystemArchitecture
IntroducingProjectTrailblazer
TheSilverjackResortLayout
ProjectTrailblazerRequirements
TheProjectTrailblazerSystemArchitecture
Summary
Chapter3.
SelectingaPlatformandInstallingToolSets
SourcesofInformation
TheProjectTrailblazerStrategicDirection
Buildingtbdev1,theEmbeddedLinuxDevelopment
Workstation
Summary
AdditionalReading
Chapter4.
BootingLinux
TheTargetPBRs
TheLinuxBootProcess
TheLinuxrootFilesystem
CreatingtherootFilesystem
InstallingtheTFTPServer
Installingminicom
BootingtheEmbeddedPlanetRPX-CLLF
BootingtheBrightstarEngineeringMediaEngine
BootingtheTri-MMZ104andtheCOTSPCwithaFlashIDE
Drive
BootComparison
Summary
AdditionalReading
Chapter5.
Debugging
Introducinggdb
LocalDebugging
RemoteDebugging
Network-MountingtherootFilesystem
Summary
AdditionalReading
PartII:
Interfacing
Chapter6.
AsynchronousSerialCommunicationInterfacing
TheProjectTrailblazerAsynchronousSerialHardware
DevelopmentEnvironment
LinuxSerialCommunications
Summary
AdditionalReading
Chapter7.
ParallelPortInterfacing
ControlUsingtheParallelPort
StandardParallelPortControlwithPortI/O
StandardParallelPortControlUsingppdev
DevelopingaCustomDeviceDriver
StandardParallelPortControlUsingtheCustomDeviceDriver
liftmon_snowcon
Summary
AdditionalReading
Chapter8.
USBInterfacing
LearningAboutUSB
ProjectTrailblazerUSBHardware
Summary
AdditionalReading
Chapter9.
MemoryI/OInterfacing
TheHardwareDesignProcess
DevelopingLiftMonitoringandSnow-MakingControlforthe
MediaEngine
DevelopingLiftMonitoringandSnow-MakingControlforthe
RPX-CLLF
Summary
AdditionalReading
Chapter10.
SynchronousSerialCommunicationInterfacing
TemperatureSensingandDisplay
SPICommunicationandtheLM70
I2CCommunicationwiththePhilipsSemiconductorSAA1064
Summary
AdditionalReading
Chapter11.
UsingInterruptsForTiming
LinuxTimingSources
MeasuringInterruptLatency
ImplementingtheRaceTimer
Summary
AdditionalReading
Chapter12.
SystemIntegration
IntegrationOverview
InstallingtheSystemIntegrationApplications
CreatingandTestingtheProjectTrailblazerDatabase
DevelopingtheTargetandCGIIntegrationScripts
Summary
AdditionalReading
Chapter13.
FinalThoughts
GUIDevelopment
Real-timeCapabilities
TheEmbeddedLinuxVendorOfferings
ProjectTrailblazerHardware
Summary
AdditionalReading
Top
Copyright
Manyofthedesignationsusedbymanufacturersandsellerstodistinguishtheir
productsareclaimedastrademarks.Wherethosedesignationsappearinthis
book,andAddison-Wesleywereawareofatrademarkclaim,thedesignations
havebeenprintedininitialcapitallettersorinallcapitals.
Theauthorandpublisherhavetakencareinthepreparationofthisbook,but
makenoexpressedorimpliedwarrantyofanykindandassumeno
responsibilityforerrorsoromissions.Noliabilityisassumedforincidentalor
consequentialdamagesinconnectionwithorarisingoutoftheuseofthe
informationorprogramscontainedherein.
Thepublisheroffersdiscountsonthisbookwhenorderedinquantityforspecial
sales.
Formoreinformation,pleasecontact:
PearsonEducationCorporateSalesDivision201W.103rdStreet
Indianapolis,IN46290
(800)428-5331
VisitAWontheWeb:www.awl.com/cseng/
Copyright©2002byPearsonEducation
Allrightsreserved.Nopartofthispublicationmaybereproduced,storedina
retrievalsystem,ortransmitted,inanyformorbyanymeans,electronic,
mechanical,photocopying,recording,orother-wise,withoutthepriorconsent
ofthepublisher.PrintedintheUnitedStatesofAmerica.Published
simultaneouslyinCanada.
LibraryofCongressCatalogCardNumber2001089582
Textprintedonrecycledpaper
12345678910—CRS—05040302
Firstprinting,March2002
Credits
AssociatePublisherJeffKoch
AcquisitionsEditorKatiePurdum
DevelopmentEditorMarkCierzniak
ManagingEditorMattPurcell
ProjectEditorAndrewBeaster
CopyEditor
KittyWilsonJarrett
Indexer
KenJohnson
Proofreader
JuliCook
TechnicalEditorRobSavoye
TeamCoordinatorDenniBannister
InteriorDesignerAnneJones
CoverDesignerArenHowell
PageLayout
MarkWalchle
AyannaLacey
MichelleMitchell
Dedication
Formysupportstaff,theSpuds:KathyandChrisAnderson,CaelaandSteve
Bova,MelanieandScottClemmons,PamandRobertCort,TinaDittmar,
JonathanFulford,TanyaandKevinHansel,MargaretHollabaugh,Maureenand
SteveJett,ScottKidner,BrianKopp,TeresaLoconte,MichelleandBrad
Lohrding,DarlaandAlfredLorber,VenitaandCraigLujan,JeanandJohn
McLennan,MarceMiller,LisaandJimOlwine,KatiePurdum,AnnaandMike
Sadler,JenniferandFritzSiegrist,KarenandJohnTotten,KarynYoung,and
especiallyMelanieKline.
Top
Foreword
Embeddedsystems,theonce-sleepybackwaterofinformationtechnology,are
nowemergingasamultibillion-dollarindustrythatisalreadypervadingour
everydayexistencesandchangingourlives.Aroundtheworld,"smartdevices"
areinsinuatingthemselvesintoeveryone'sdailyroutine:Youdrivetoworkin
yourelectronicallycontrolledcarorrideadigitallyguidedcommutertrain,take
acallonyourmobilephone,makecopiesattheoffice,sitinonadigital
conferencecall,andthengohomeandwatchamoviefromyourcableboxor
DVDplayer.Ifyoulookaroundyou,you'llrealizethat50to100embedded
computerstouchyourlifeeveryday.
Linuxistakingthisworldofembeddedandpervasivecomputingbystorm.
Oncedominatedbyproprietaryandobscureoperatingsystems,tools,and
applications,embeddeddesignstodaybenefitfromthetransparencyand
functionalityofopen-sourcesoftware,especiallyLinux.Evenconservative
estimatesshowembeddedLinuxgarneringuptohalfofallnewembedded
designsbytheendof2002.
InmyroleatMontaVistaSoftware,Ihavethepleasureoftalkingtothousands
ofembeddeddevelopersandofsneakingglimpsesintotheirvariedprojects.In
thiscontextIfirstmetDr.CraigHollabaughatLinuxWorldinNewYorkin
2001.Inthecourseofhiswritingthisbook,Ihadthepleasureofhiscompany
severalmoretimesandnumerouschatsbyphone.
IfindCraig'sapproachbothsensibleandcomprehensive.Hischoiceofan
applicationtorunthefabledSilverjackwinterresortbothrecallsthe"meatand
potatoes"oftheembeddedapplicationsspace(controlandinstrumentation)and
launchesintotoday'shotnewareasofpervasivecomputing(embeddedWeb
interfacing,multimedia,andmessaging).Hissurveyofavailableembedded
hardwareandkeyinterfacetechnologiesandhisstep-by-stepaccountofthe
embeddedLinuxdevelopmentprocessprovideinvaluablesignpostsforaspiring
systemdesigners.
Craig'steamoftrailblazingengineersconfrontedthedauntingtaskofacquiring
andusingembeddedLinuxdevelopmenttoolsanddeploymentcomponents.
TheSilverjackscenarioandthedetailsoftheengineeringeffortmirrorthe
experiencesofmanydevelopersfacingtheirfirstembeddedLinuxproject.The
slopeissteep,buttherewardsareverygreat.BookslikeEmbeddedLinux;
organizationsliketheEmbeddedLinuxConsortium,EMBLIX,and
LinuxDevices;andtheeffortsofembeddedLinuxplatformvendorsclearapath
tosuccessfuldevelopmentanddeploymentofthenextgenerationofsmart,
Linux-baseddevices.
WilliamWeinberg
DirectorofStrategicMarketing/EmbeddedLinuxEvangelist
MontaVistaSoftware
SanJose,CA
January2002
Top
AbouttheAuthor
CraigHollabaughhasbeenfascinatedbyelectronicssinceheboughtanAM
radioinelementaryschool.HewasfirstexposedtoUnixduringacross-country
talksessionin1985.Later,headministerednetworkedSunandDEC
workstationswhilepursuingadoctoraldegreeinelectricalengineeringat
GeorgiaInstituteofTechnology.
Craig'sfirstembeddedSCADA(supervisorycontrolanddataacquisition)
design,thePacMeister,remotelymonitoredthegasolineadditiveinjection
processandearnedhimaU.S.patent.Hisnextembeddeddesign,theTitan
PAC-3,basedonIntelx86architecture,controlledthisinjectionprocess,usinga
home-growthmultitaskingoperatingsystemwritteninC++,completewithboot
code,communicationsability,andfield-downloadableapplicationcode.
In1995Craigco-foundedWirelessScientific,wherehedeveloped20spreadspectrum900MHzISMindustrialtelemetryproducts.Craigworkedwithmore
than200developers,systemsintegrators,andequipmentmanufacturersto
incorporatewirelesstelemetrywithintheirSCADAapplicationsorproduct
lines.In1996WirelessScientific'sGlobalDataManagementprojectusedLinux
asadevelopmentplatformtoremotelymonitorandcontroladditivetanklevels.
In1997LanierCorporationchargedCraigwitharchitectingitsnext-generation
VoiceWriter,amedicaldigitaldictationandtranscriptionsystemwithrevenues
beyond$100million.Hisresponsibilitiesincludedensuringthatproduct
developmentfollowedcurrent/futuretechnologicaltrends,adheredto
technical/medicalinformationstandards,andincorporatedLanier'slegacy
products.
CraigconsultsfromhishomeinOuray,Colorado.Hedevelopedthefirmware
forAntec'sflagshipcabledistributionproduct,theProteusScalableNode.At
Clifton,WeissandAssociates,Craigisamemberofacarrier-class
telecommunicationsnetworkdesignteam.Hiscurrentresponsibilitiesinvolve
designingandanalyzingwiredandwirelessvoiceanddatanetworksforDallas
AreaRapidTransit,MetroNorthRailroad,NewYorkCityTransit,and
PittsburghAreaTransit.He'salsodesigningFM,MP3,andBluetoothheadset
electronicsforArriva.
TheOuraycommunitybenefitsthroughCraig'ssystemadministrationsupport
ofOuraynetandhisadulteducationclassesinelectronicsandprogramming.
Mostrecently,Craigco-foundedTheSilverjackBakingCompany,wherehe
willbakeandsellscrumptiousdelightsfromahorse-drawnbakerywagonon
Ouray'sMainStreetduringthesummermonths.Ifthere'ssnowflying,you'll
mostlikelyfindhimsnowboardingatTelluride.
Top
Acknowledgments
Theenthusiasmtowardthisbookhasbeensimplyphenomenal.EveryoneI
mentionittohassupportedmyeffortsinsomeway.I'dliketostartbythanking
afewpeoplewhohelpedmetoseemygreatness:KatiePurdum,Angelo
d'Amelio,RogerSmith,GerriSpina,EvaMontibello,andTeresaLoconte.
Theseday-to-daysupportersthentookoverandcontinuedthepush:Melanie
Kline,JoshKline,MouseandHarryDurgin,PaulVallejos,BenBlouse,Scott
Kidner,BrianKopp,andmylittlebabysister,KarenTotten.Iattributethe
book'sreadabilitytomyeditingteam:JohnHollabaugh,RobSavoye,Kitty
Jarrett,andMarkCierzniak.AspecialthankstoRickLehrbaum,forhis
comprehensiveembeddedLinuxWebsite,linuxdevices.com.Iwanttothank
theseindividualsatcompaniesthatofferedtheirproductsandtechnicalsupport
forthebook'sexamples:DougSteadatTri-MSystems,StuartAdamsat
BrightstarEngineering,KenApplebaum,JohnHavre,andMattHooverat
EmbeddedPlanet,EugeneFengatSiliconStorageTechnology,JuanVazquezat
ESPTech,TomBarnumatVersaLogic,andBillWeinburgatMontaVista
Software.Theworkoftheseindividualsalsocontributedtotheexamples:
ThomasOehser,ErikMouw,OriPomerantz,AlessandroRubini,Jonathan
Corbet,TimWaugh,JanAxelson,CraigPeacock,RikuSaikkonen,JensGecius,
DetlefFliegl,BradHards,MarkPilon,DanielSmolik,MarkusSchlup,Michael
Hipp,DavidBeal,WolfgangDenk,MarkHatle,DanMalek,LarryDoolittle,
andJimReady.Theseopen-sourcedevelopersdeserveatremendous
acknowledgementfortheiractivities:allthekernelprogrammers,Debian,
ApacheSoftwareFoundation,MySQL,andGNU.Thisbookexistsbecauseof
yourcontributions,support,andencouragement.Ithankyou.
Top
Introduction
Thisisanexcitingtime.TheproliferationofInternettechnologyhas
transformedourconceptofinformation.24hoursperday,peoplerelyon
networkdevicesforbusinessandpersonaluse.Overtime,thisdependencewill
growfurther.Today'snetworkdevices,suchasservers,routers,anddesktop
computers,formtheInternet'sinfrastructure.Tomorrow'sdeviceswillcontrol
yourhome'stemperature,maintaininventorylevelsatyourbusiness,and
monitorautomobiletrafficpatterns.Onlyahandfulofthebillionsofprocessors
producedeachyeargointodesktoporservercomputers.Theremaining
processorsmonitorandcontrolotherfacetsoftheworld.
Individualsandbusinesseswantsmart,network-connected,devicestoimprove
theirlives,theirefficiency,andtheirbottomdollar.Thesedevicesmustbe
simpletooperate,reliable,andinexpensive.ThisiswhereLinuxcomesin.
AdvancesintechnologyaccompaniedbycompetitivepricingallowLinuxto
movefromthedesktopandserverenvironmenttoembeddeddevices.Linux
offersreliability,features,open-sourcecode,andaproventrackrecord;these
featuresmakeitperfectlysuitedforembeddedsystemdesigns.Inthisbook,you
willfindinformationtocreateanembeddedLinuxfoundation.Youcanthen
extendthisfoundationinyourowndesigns.
Top
BenefitsofThisBook
WhenIfirststartedresearchingmaterialforthisbook,Iassumedthatonline
embeddedLinuxinformationwaslikeotherLinuxinformation—plentifuland
welldocumented.Iquicklydiscoveredthatmyassumptionwaswrong.Ifound
embeddedLinuxdocumentationtobesparse,scattered,incomplete,and
sometimesdated.Thiswasdiscouragingandinvigoratingatthesametime.
AlthoughIworriedaboutbeingabletofindadequateinformation,Iwasfurther
convincedoftheneedforthisbook.Peoplearedesigningembeddedproducts
withLinux,sotheinformationandknowledgeareoutthere;itjusthasn'tall
beeninoneplaceuntilnow.
Asaninstructor,Ihavedeterminedthatstudentsbestunderstandandretain
theoreticalconceptsandideaswhenaccompaniedbyexamples.Whenstudents
seeaconceptinaction—whetheritisaroboticarmmovement,avoltmeter
reading,oranoscilloscopewaveform—they'remostlikelytolaterapplythat
concepttosolvetheirownproblems.That'swhythisbookisfullofstep-by-step
examples.Youwilllearnthroughtheexampleandbeabletoapplythat
knowledgetoyourowndesigns.
Top
WhatThisBookCovers
Thisbookincludesacompleteseriesofreal-worldinterfacingexamples
designedtointroduceembeddedLinuxfromhardwareandsoftware
perspectives.AfteryoucreateanembeddedLinuxdevelopmentenvironment,
youwillstepthroughhardwareandsoftwareinterfacingexamples,using
asynchronousserialcommunication,thePCparallelport,USB,memoryI/O,
synchronousserialcommunication,andinterrupts.Allinterfacingexamplesare
thentiedtogetherusingsystemintegration.Allthismaterialispresentedby
usingawinterresortautomationprojectcalledProjectTrailblazer.Youcanfind
thebook'ssourcecodeandscriptsatwww.embeddedlinuxinterfacing.com.
Thefollowingtextbrieflysummarizeseachchapter.
Chapter1,"IntroducingEmbeddedLinux,"describesthebriefhistoryofLinux
asanembeddedoperatingsystemandtheimplicationsofusingopen-source
softwareinproductdesign.
Chapter2,"SystemArchitecture,"introducesawinterresortautomationproject
calledProjectTrailblazeranddevelopsaseriesofprojectrequirements.Project
Trailblazeranditsrequirementsformthebasisforthebook'sinterfacing
examples.
Chapter3,"SelectingaPlatformandInstallingToolSets,"describestheprocess
ofplatformselection.Fourtargetboards—whichusex86,StrongARM,and
PowerPCprocessors—areselectedforProjectTrailblazer.Thischapterthen
describesthecreationofanembeddedLinuxdevelopmentworkstationcalled
tbdev1.Allthedevelopmenttoolsareeitherinstalledorcompiled,includingthe
cross-compiledtoolchainfortheStrongARMandPowerPCprocessors.
Chapter4,"BootingLinux,"describestheLinuxbootprocess,frompower-on
tothebashprompt.Usingaminimumrootfilesystem,eachtargetboardis
bootedusingLinuxversion2.4.
Chapter5,"Debugging,"configuresgdbandgdbserverfortargetboard
debuggingovertheEthernetnetwork.Across-compiledversionofhelloworld
isremotelyexecutedanddebugged.
Chapter6,"AsynchronousSerialCommunicationInterfacing,"describesthe
Linuxserialportdevicedriverforcontrolofportsignalsandbuffers.AnRFID
tagreader,anLCDdisplay,andcontrolcircuitryareinterfacedtotheLinux
serialport.
Chapter7,"ParallelPortInterfacing,"describesinterfacingACcircuitstoan
x86targetboard'sparallelprinterport.Acustomdevicedrivercalled
helloworld_proc_modulethatusesa/procdirectoryentryisintroduced.
Chapter8,"USBInterfacing,"describesconnectingacameraandspeakersfor
visualinputandaudiooutputtoatargetboard'sUSBport.
Chapter9,"MemoryI/OInterfacing,"describesinterfacingACcircuitstothe
StrongARMandPowerPCtargetboards'CPUbuses.
Chapter10,"SynchronousSerialCommunicationInterfacing,"describesSPI
andI2Cconnectionsandcommunications.Alow-costSPItemperaturesensor
andI2CLEDdisplaydriverareinterfacedtothetargetboards.
Chapter11,"UsingInterruptsforTiming,"describesLinuxtimingsourcesand
themeasurementofeachtargetboard'saverageinterruptlatency.Aneventtimer
with1msaccuracyisdevelopedtomeasureracetimes.
Chapter12,"SystemIntegration,"describesthecreationoftheProject
Trailblazerdatabase.Targetandserverbashscriptsaredeveloped,usingthis
databaseforcollectionanddistributionoftemperature,image,and
authenticationdata.
Chapter13,"FinalThoughts,"summarizestheinterfacingprojectsand
discussesembeddedLinuxtopicsthatarenotaddressedelsewhereinthebook.
Top
WhoThisBookIsFor
Ifyouareahardwareengineer,softwaredeveloper,systemintegrator,or
productmanagerwho'sbegunexploringembeddedLinuxforinterfacing
applications,thenthisbookisforyou.Thebook'scomprehensiveinterfacing
examplesaresimple,requiringonlyabasicunderstandingofdigitallogic
design,Candbashprogramming,andLinuxsystemadministration.
Top
ConventionsUsedinThisBook
ThisbookusesseveralcommonconventionstohelpteachembeddedLinux.
Thetypographicalconventionsusedinthisbookincludethefollowing:
Commandsandcomputeroutputappearinamonospacedcomputerfont.
Commandsyoutypeappearinaboldfacedcomputerfont.
Italicsareusedtointroduceyoutonewterms.
Inadditiontotypographicalconventions,thisbookincludestips,whichlook
likethis:
TIP
Informationthatoffersshortcutsandsolutionstocommonproblemsis
highlightedasatip.
Top
PartI:GettingStarted
INTHISPART
1IntroducingEmbeddedLinux
2SystemArchitecture
3SelectingaPlatformandInstallingToolSets
4BootingLinux
5Debugging
Top
Chapter1.IntroducingEmbeddedLinux
INTHISCHAPTER
WhyLinux,WhyNow?
WhatIsanEmbeddedSystem?
WhatDoesReal-TimeMean?
ImplicationsofOpenSource
AdditionalReading
SoyouwanttouseLinuxinyournextembeddedsystemdesign?Great!You're
notalone:Thousandsofdevelopersworldwidearedoingthesamething.Like
you,theywanttotakeadvantageofcountlesshoursofcodecreationtomake
theirproductsreliable,featurepacked,robust,andquicktomarket.Embedded
Linux—usingLinuxasanoperatingsysteminembeddeddevices—isnow
commonplace.In1999notmanydevelopersconsideredLinuxanoptionfor
embeddeddesigns.Today,however,Linuxiswellpoisedtobecomethemarket
leaderforembeddedoperatingsystems.
Inacoupleyears,it'slikelythatafairpercentageofthebillionsofprocessors
producedeveryyearwillrunLinux.ThemassiveInternetadoptionofLinux,
combinedwithtechnologyadvancesandpricereductionsinhardware(CPUs)
andmemory(bothflashandRAM),finallymakeembeddingLinuxaviable
option.Since1999useofembeddedLinuxhasgonefromzeroadoptionto
takingsecondplace,intermsofmarketshare,behindWindRiver.1Experts
estimatethatembeddedLinuxwilltakeoverthenumber-onemarketshare
positionbytheendof20021.Thisisveryinteresting,consideringthatLinux
actuallystartedasstudentprojectsomanyyearsago.Linuxcanbecomenumber
one,throughtheadoptionofembeddedLinuxfordesignsthatbecomeproducts.
Top