Linux设备树用户手册

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Thispagewalksthroughhowtowriteadevicetreeforanewmachine.Itisintendedtoprovideanoverviewofdevicetreeconceptsandhowtheyareusedtodescribeamachine.本文将介绍如何为一个新机器编写设备树。我们准备提供一个有关设备树概念的概述和如何使用这些设备树来描述一个机器。Forafulltechnicaldescriptionofdevicetreedataformat,refertotheePAPRspecification.TheePAPRspecificationcoversalotmoredetailthanthebasictopicscoveredonthispage,pleaserefertoitformoreadvancedusagethatisn'tcoveredbythispage.完整的设备树数据格式的技术说明书请参考ePAPR规范。ePAPR规范涵盖了比本文基本主题更丰富的细节,要查阅本文没有涉及到的高级用法请参考该规范。-----------------------------------------Thedevicetreeisasimpletreestructureofnodesandproperties.Propertiesarekey-valuepairs,andnodemaycontainbothpropertiesandchildnodes.Forexample,thefollowingisasimpletreeinthe.dtsformat:设备树是一个包含节点和属性的简单树状结构。属性就是键-值对,而节点可以同时包含属性和子节点。例如,以下就是一个.dts格式的简单树:这棵树显然是没什么用的,因为它并没有描述任何东西,但它确实体现了节点的一些属性:■asinglerootnode:/一个单独的根节点:“/”■acoupleofchildnodes:node1andnode2两个子节点:“node1”和“node2”■acoupleofchildrenfornode1:child-node1andchild-node2两个node1的子节点:“child-node1”和“child-node2”■abunchofpropertiesscatteredthroughthetree.一堆分散在树里的属性。Propertiesaresimplekey-valuepairswherethevaluecaneitherbeemptyorcontainanarbitrarybytestream.Whiledatatypesarenotencodedintothedatastructure,thereareafewfundamentaldatarepresentationsthatcanbeexpressedinadevicetreesourcefile.DeviceTreeUsagechinaunix.net属性是简单的键-值对,它的值可以为空或者包含一个任意字节流。虽然数据类型并没有编码进数据结构,但在设备树源文件中任有几个基本的数据表示形式。■Textstrings(nullterminated)arerepresentedwithdoublequotes:文本字符串(无结束符)可以用双引号表示:1.string-property=astring■'Cells'are32bitunsignedintegersdelimitedbyanglebrackets:‘Cells’是32位无符号整数,用尖括号限定:1.cell-property=0xbeef1230xabcd1234■binarydataisdelimitedwithsquarebrackets:二进制数据用方括号限定:1.binary-property=[0x010x230x450x67];■Dataofdifferingrepresentationscanbeconcatenatedtogetherusingacomma:不同表示形式的数据可以使用逗号连在一起:1.mixed-property=astring,[0x010x230x450x67],0x12345678;■Commasarealsousedtocreatelistsofstrings:逗号也可用于创建字符串列表:1.string-list=redfish,bluefish;BasicConcepts基本概念-----------------------------------------Tounderstandhowthedevicetreeisused,wewillstartwithasimplemachineandbuildupadevicetreetodescribeitstepbystep.我们将以一个简单机开始,然后通过一步步的建立一个描述这个简单机的设备树,来了解如何使用设备树。SampleMachine模型机Considerthefollowingimaginarymachine(looselybasedonARMVersatile),manufacturedbyAcmeandnamedCoyote'sRevenge:考虑下面这个假想的机器(大致基于ARMVersatile),制造商为“Acme”,并命名为“Coyote'sRevenge”:■One32bitARMCPU一个32位ARMCPU■processorlocalbusattachedtomemorymappedserialport,spibuscontroller,i2ccontroller,interruptcontroller,andexternalbusbridge■256MBofSDRAMbasedat0256MBSDRAM起始地址为0■2Serialportsbasedat0x101F1000and0x101F2000两个串口起始地址:0x101F1000和0x101F2000■GPIOcontrollerbasedat0x101F3000GPIO控制器起始地址:0x101F3000■SPIcontrollerbasedat0x10170000withfollowingdevices带有以下设备的SPI控制器起始地址:0x10170000■MMCslotwithSSpinattachedtoGPIO#1MMC插槽的SS管脚连接至GPIO#1■Externalbusbridgewithfollowingdevices外部总线桥挂载以下设备■SMCSMC91111Ethernetdeviceattachedtoexternalbusbasedat0x10100000SMCSMC91111以太网设备连接到外部总线,起始地址:0x10100000■i2ccontrollerbasedat0x10160000withfollowingdevicesi2c控制器起始地址:0x10160000,并挂载以下设备■MaximDS1338realtimeclock.Respondstoslaveaddress1101000(0x58)MaximDS1338实时时钟。响应至从地址1101000(0x58)■64MBofNORflashbasedat0x30000000Initialstructure初始结构Thefirststepistolaydownaskeletonstructureforthemachine.Thisisthebareminimumstructurerequiredforavaliddevicetree.Atthisstageyouwanttouniquelyidentifythemachine.1./{2.compatible=acme,coyotes-revenge;3.};compatiblespecifiesthenameofthesystem.Itcontainsastringintheform,.Itisimportanttospecifytheexactdevice,andtoincludethemanufacturernametoavoidnamespacecollisions.Sincetheoperatingsystemwillusethecompatiblevaluetomakedecisionsabouthowtorunonthemachine,itisveryimportanttoputcorrectdataintothisproperty.compatible指定了系统的名称。它包含了一个“制造商,型号”形式的字符串。重要的是要指定一个确切的设备,并且包括制造商的名子,以避免命名空间冲突。由于操作系统会使用compatible的值来决定如何在机器上运行,所以正确的设置这个属性变得非常重要。Theoretically,compatibleisallthedataanOSneedstouniquelyidentifyamachine.Ifallthemachinedetailsarehardcoded,thentheOScouldlookspecificallyforacme,coyotes-revengeinthetoplevelcompatibleproperty.CPUs中央处理器NextstepistodescribeforeachoftheCPUs.AcontainernodenamedcpusisaddedwithachildnodeforeachCPU.Inthiscasethesystemisadual-coreCortexA9systemfromARM.•/{•compatible=acme,coyotes-revenge;cpus{•cpu@0{•compatible=arm,cortex-a9;•};•cpu@1{•compatible=arm,cortex-a9;•};•};•};Thecompatiblepropertyineachcpunodeisastringthatspecifiestheexactcpumodelintheform,,justlikethecompatiblepropertyatthetoplevel.每个cpu节点的compatible属性是一个“制造商,型号”形式的字符串,并指定了确切的cpu,就像顶层的compatible属性一样。Morepropertieswillbeaddedtothecpunodeslater,butwefirstneedtotalkaboutmoreofthebasicconcepts.NodeNames节点名称Itisworthtakingamomenttotalkaboutnamingconventions.Everynodemusthaveanameintheform[@].现在应该花点时间来讨论命名约定了。每个节点必须有一个“名称[@设备地址]”形式的名字。isasimpleasciistringandcanbeupto31charactersinlength.Ingeneral,nodesarenamedaccordingtowhatkindofdeviceitrepresents.ie.Anodefora3comEthernetadapterwouldbeusethenameethernet,not3com509.名称就是一个不超过31位的简单ascii字符串。通常,节点的命名应该根据它所体现的是什么样的设备。比如一个3com以太网适配器的节点就应该命名为ethernet,而不应该是3com509。Theunit-addressisincludedifthenodedescribesadevice

1 / 24
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功