




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
i.MXCAS Rev.6, JohnLi(NXA08200)GSM現(xiàn)場支持工程師lvds/dsilvds/dsi8DX/支持\imx-yocto-L5.4.24_2.1.0\i.MX_Yocto_Project_User's_Guide.pdf,此文檔的查缺補(bǔ)漏,并專注于bringup相關(guān)軟件定制,與產(chǎn)品化定制。MX_Porting_Guide.pdf為的portingguide,中關(guān)于linux/dts通用部分還沒有完全修改過方文檔的替代,請一切以文檔為準(zhǔn)。章支持/DDR修創(chuàng)建i.MX8QXPLinux5.4.24板級開發(fā)包編譯環(huán) 1.1板級開發(fā) Device 2.1的deviceTree結(jié) deviceTree的由來(no deviceTree的基礎(chǔ)與語法(no deviceTree的代碼分析(no i.MX8XBSP包文 i.MX8XBSP的編譯(no 如何為目標(biāo)文件及順 kernel BSP的內(nèi)核初始化過程(no BSP的內(nèi)核定制Error!Bookmarknot Error!BookmarknotIO管腳配置與Pinctrl驅(qū)動Error!Bookmarknot Error!Bookmarknot Error!BookmarknotuSDHC設(shè)備定制(eMMCflash,SDcard,SDIOcard)Error!BookmarknotLVDSLCD驅(qū)動定制Error!BookmarknotLVDSLDBSerDas驅(qū)動支持Error!BookmarknotMiPiDSISerDas驅(qū)動支持Error!BookmarknotV4L2框架汽車級頭/橋驅(qū)動:數(shù)字/模擬Error!BookmarknotGPIO_Key驅(qū)動定制Error!BookmarknotGPIO_LED驅(qū)動定制Error!BookmarknotFusenvram驅(qū) Error!BookmarknotSPI與SPISlave驅(qū)動Error!BookmarknotUSB3.0TypeCUSB3.0TypeA(未驗(yàn)證)Error!Bookmarknot汽車級以太網(wǎng)驅(qū)動定制Error!Bookmarknoti.MX8DXMEK支持Error!Bookmarknoti.MX8MEK支持Error!BookmarknotNANDFlash支持與燒錄Error!Bookmarknoti.MX8QXPLinux板級開發(fā)Linux5.4.24板級開發(fā)包地址如下>i.MX8Processors->i.MX8X->Tools&Software->EmbeddedLinuxfori.MXApplicationsPorcessorsLinuxCurrentReleaseReleaseand Linuxi.MXLinuxReleasei.MXLinuxUser’si.MXLinuxReferencei.MXPortingi.MXYoctoProjectUser’si.MXVPUAPIReferencei.MXGraphicsUser’sBuildSeeREADMEoninstructionsforeachSCFWPortingAACPlusVerisilicon tforms/BinaryDemoi.MX8MNanoi.MX8MMinii.MX8MQuadi.MX8DualXi.MX8Qualus(C0)i.MX8Qualus(B0)i.MX8QuadMaxi.MX7ULP7Duali.MX6UltraLite,i.MX6ULL,i.MX7Duali.MX6SLLi.MX6QuadPlus,i.MX6Quad,i.MX6DualLite,i.MX6SoloXLinuxL5.4.24_2.1.0ationSCFWPortingi.MX8QXPMEKLinuxDemo鏡像也可以Ubuntu18.04sudoapt-getsudoapt-getinstallgawkwgetgit-corediffstatunziptexinfogcc-multilibbuild-essentialchrpathsocatlibsdl1.2-sudosudoapt-getinstalllibsdl1.2-devxtermsedcvssubversioncoreutilstexi2htmldocbook-utilspython-2makegccg++desktop-file-utilslibgl1-mesa-devlibglu1-mesa-devmercurialautoconfautomakegroffcurllzopsudoapt-getinstallu-boot-gitconfig--globalusernamegitgitconfig--globalgitconfigimx-yocto-L5.4.24_2.1.0\i.MX_Yocto_Project_User's_Guide.pdf創(chuàng)建yocto編譯環(huán)境陸地區(qū)無法從的git服務(wù)器repo工具,可以改成如下的git服務(wù)器mkdircd /git/git-repo-ooda+xexportmkdirimx-yocto-bspcdimx-yocto-bspreporepoinit--bimx-linux-zeus-mimx-5.4.24- repoDISTRO=<distroname>MACHINE=imx8qxpc0meksourceimx-setup-release.sh-bimx8qxpc0mek_”distroDistronamefsl-imx-wayland-Waylandwestonfsl-imx-xwayland-WaylandgraphicsandX11.X11applicationsusingEGLarenotDISTRO=fsl-imx-xwaylandMACHINE=imx8qxpc0meksourceimx-setup-release.sh-bBitbakeimage與編譯配置,以及建議使用功能,編譯結(jié)果輸出,燒寫命令,SDK編譯與安裝AnFSLCommunityi.MXcoreimagewithconsoleenvironment-noGUIBuildsani.MXimagewithaGUIwithoutanyQtcontentBuildsanopensourceQt5imagewithMachineLearningfeatures.Theseimagesareonlysupportedfori.MXSoCwithhardwarebylayerTboxCluster&surroundview之類的不需要復(fù)雜GUI支持的GUIQTDISTRO=fsl-imx-waylandMACHINE=imx8qxpc0meksourceimx-setup-release.sh-bimx8qxpc0mek_waylandsourceimx-setup--bbitbakefsl-image-machine-bitbakeimx-image-bitbakeimx-image--imx8qxpc0mek.sdcard.bz2-fsl-image-machine-test-(sdcard鏡像,解壓后可以直接燒寫)fsl-image-machine-test-imx8qxpc0mek.tar.bz2->fsl-image-machine-test-imx8qxpc0mek(rootfs壓縮包)u-boot-sd-2020.04-r0.bin(uboot)->mx8qx-mek-scfw-tcm.bin(scbl31-imx8qx.bin(ATF)-imx8qxpc0mek.sdcard.bz2--(編譯時間)(sdcard鏡像,解壓后可以直接燒寫)-imx8qxpc0mek.tar.bz2--(編譯時間rootfs.tar.bz2(rootfs壓縮包)u-boot-sd-2020.04-r0.bin(uboot)->mx8qx-mek-scfw-tcm.bin(scbl31-imx8qx.bin(ATF)-imx8qxpc0mek.sdcard.bz2->imx-image-full-imx8qxpc0mek-(編譯時間)imx-image--imx8qxpc0mek.tar.bz2-imx-image-full--(編譯時間rootfs.tar.bz2(rootfs壓縮包)u-boot-sd-2020.04-r0.bin(uboot)->mx8qx-mek-scfw-tcm.bin(scbl31-imx8qx.bin(ATF)(secoHABcontainer僅有鏡像(secoHABcontainer僅有鏡像(secoHABcontainer僅有鏡像)bunzip2-dk-fsl-image-machine--sudoddif=fsl-image-machine-of=/dev/sd<partition>bs=1Mbunzip2-dk--sudoddif=imx-image-of=/dev/sd<partition>bs=1Mbunzip2-dk-fimx-image-sudoddif=imx-image-fullof=/dev/sd<partition>bs=1Mbitbakefsl-image-machine--cbitbakeimx-image--cbitbakeimx-image--cmkdirsdk到SDK輸 YouareabouttoinstalltheSDKtomkdirsdk到SDK輸 ./fsl-imx-wayland-YouareabouttoinstalltheSDKtomkdirsdk到SDK輸出 ./fsl-imx-wayland-Proceed[Y/n]?YProceed[Y/n]?YYouareabouttoinstalltheSDKtoimx8qxpc0mekwayland/sdk".Proceed[Y/n]?Ysourcesetup-environment<build-以上yoctoInte(R)Core(TMi7-8650UCPU@1.90GHZ2.11GHZRAM8.00GBSystem:64Windows:Windows10SSD硬盤,實(shí)現(xiàn)中發(fā)現(xiàn)使用SSDyocto虛擬機(jī)工具,版本,設(shè)置與ubuntuVMware?Workstation15yer15.5.1內(nèi)存:4GB處理器45.4.24BSPpython3支持,所以需要用ubuntu18.04(16.0414.04python3),uname-Linuxubuntu5.3.0-40-generic#32~18.04.1-ubuntuSMPMonFeb314:05:58UTC2020x86_64x86_64不支持python3ubuntu180418.04iso本次編譯主機(jī)使用了服務(wù)器,編譯過程中出現(xiàn)MLlayer相關(guān)的do_fetch包失敗,請多試幾次bitbake,最終可以成功。包失敗,請多試幾次bitbakeimx-gpu-viv-6.4.0.p2.4-aarch64.bindo_fetch失敗,wgeth /lgfiles/NMG/MAD/YOCTO/<packagefilename>:imx-gpu-viv-6.4.0.p2.4-aarch64.bin:i.MXGraphicslibrariesfori.MX8.wget 就可以快速下gpu安裝包git服務(wù)器的情況而定,一般是從幾個小時到 編譯SCfirmwaretarxzvfimx-scfw-porting-kit- (untarscfwtools |->imx-scfw-porting-kit-ododa+x./imx-scfw-porting-kit-./imx-scfw-porting-kit-1.5.0.bin(runthebinfiletoinstallscfwtoolscdimx-scfw-porting-kit-tarxzvftarxzvfscfw_export_mx8qx_b0.tar.gz(untarsource /open-source/gnu-toolchain/gnu-rm/downloads(E.g.Linux64-bitFile:gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2(95.90MB))注意驗(yàn)證過的工具鏈版本是2017-q2,不建議使用的工具鏈mkdirtoolchainmvgcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2toolchain/cdtoolchaintarjxvfgcc-arm-none-eabi-6-2017-q2-update- exportTOOLS=../../toolchain/makeqxB=mekR=B0(如果需要看串口調(diào)試信息就增加M=1參數(shù),U=2表示使用SCU本身串口,注意重新編譯之前要makeclean-qx一下)makeqxB=mekR=B0M=1Generating Generating tform/board/mx8qxmek/dcd/dcd.hfrom Generating Generating tform/board/mx8qx_mek/dcd/dcd_retentionhfromCompiling tform/drivers/pmic/fslpmic.cCompiling Compiling Compiling Compiling tform/board/boardcommon.cAssembling Compiling Linkingbuild_mx8qx_b0/scfw_tcm.elfObjcopybuild_mx8qx_b0/scfw_tcm.bin 編譯uboot:gitgitcduboot-gittag|grepgitcheckoutrel_imx_5.4.24_2.1.0gitstatusHEADdetachedatrel_imx_5.4.24_2.1.0nothingtocommit,workingdirectorycleanlsconfigs|grep…source~/imx-yocto-bsp/imx8qxpc0mek_wayland/sdk/environment-setup-aarch64-poky-linux(sdk安裝地址makeimx8qxp_mek_defconfig…WARNING'./ahab-container.img'notfound,resultingbinaryisnot-functionalmake[1]:Nothingtobedonefor'SPL'.OBJCOPYu-OBJCOPYu-boot-start=$(aarch64-poky-linux-nmu-boot|grep rel_dyn_start|cut-f1-d'');end=$(aarch64-poky-linux-nmu-boot|grep rel_dyn_end|cut-f1-d'');tools/relocate-relau-boot-nodtb.bin0x $start$end u- u-MKIMAGEu- u-MKIMAGEu-boot- u-CFGCHKu-u-編譯Linuxgitgitcdlinux-gittag|grepgitcheckoutrel_imx_5.4.24_2.1.0gitstatusHEADdetachedatsource~/imx-yocto-bsp/imx8qxpc0mek_wayland/sdk/environment-setup-aarch64-poky-linuxmakeimx_v8_defconfigmakedtbsmakedtbs//justmake gitgitcdimx-gittag|grepgitcheckoutrel_imx_5.4.24_2.1.0gitstatusHEADdetachedatLDFLAGS=""LDFLAGS=""make 編譯log… Builtbuild/imx8qx/release/bl31.bingitgitcdimx-mkimagegittag|grep5.4.gitcheckoutrel_imx_5.4.24_2.1.0gitstatusHEADdetachedatimx-mkimage需要調(diào)用hostPCGCC工具,所以需要退出之前的terminal。重新進(jìn)入,從而退出之前source的交叉編譯變量。將mx8qxc0-ahab-container.img,scfirmwarebin,atf和uboot拷貝至對應(yīng) cp../../imx-yocto-bsp/imx8qxpc0mek_wayland/tmp/deploy/images/imx8qxpc0mek/imx-boot-tools/mx8qxc0-ahab-container.img./iMX8QX/
cp../imx-atf/build/imx8qx/release/bl31.bin./iMX8QX/cp../uboot-imx/u-boot.bin./iMX8QX/ls imx8qx_ddr3_dcd_1066MHz_ecc.cfg imx8dx_ddr3_dcd_16bit_1066MHz.cfgimx8qx_ddr3_dcd_800MHz.cfg imx8dx_ddr3_dcd_16bit_933MHz.cfgimx8qx_ddr3_dcd_800MHz_ecc.cfgmx8qxc0-ahab-container.img imx8qx_ddr3_dcd_933MHz_ecc.cfgscriptsmakeSOC=iMX8QXflash_b0REV=C0//REV=C0表示編譯C0版本的i.MX8X,REV=B0表示編譯B0版本i.MX8Xincludemisc.makincludem4makincludeandroid.makincludetest.makincludeautobuildmakincluderev_amakincludealias.mak./../mkimage_imx8-socQX-revB0-appendmx8qxc0-ahab-container.img-c-scfwscfw_tcm.bin-apu-boot-atf.bina350x -outflash.binSOC:QXREVISION:B0NewContainer:0SCFW:scfw_tcm.bin u-boot-atf.bincore:a35addr:0x Output:flash.binCONTAINERFUSEVERSION:0x00CONTAINERSWVERSION:0x0000 i.MX8QXP containerimageoffset(aligned):11800flags:0x10Hashoftheimages=SCFWfile_offset=0x11800size=0x2a000Hashoftheimages=sha384APfile_offset=0x3b800size=0xe0c00CST:CONTAINER0offset:0x400CST:CONTAINER0:SignatureBlock:offsetisat0x590Note:Pleasecopyimagetooffset:IVT_OFFSET+注意:根據(jù)文檔《i.MX_Linux_Release_Notes.pdfwgetwget odod+ximx-seco-3.6.3.bin&&./imx-seco-3.6.3.bin--auto-位于更新鏡像到已經(jīng)燒寫了*.sdcardsdcardvmuser@ubuntu:~$cat/proc/partitionsmajorminor#blocksname 32768 sudoddif=flash.binof=/dev/sdcbs=1kseek=32kernelandcpImagetoBootcpimx8qxp-mek.dtbtoBootimx8qxcpimx8dx-mek.dtbtoBootimx8qxDevice2.1的deviceTree結(jié)DeviceTree imx8-ss-dc0.dtsi;imx8qxp-ss-dc.dtsiimx8-ss-adma.dtsi;imx8qxp-ss-adma.dtsiimx8-ss-conn.dtsi;imx8qxp-ss-conn.dtsimx8-ss-lsio.dtsi;imx8qxp-ss-lsio.dtsiimx8-ss-hsio.dtsi;imx8qxp-ss-hsio.dtsiimx8-ss-img.dtsi;imx8qxp-ss-img.dtsiimx8-ss-gpu0.dtsi";imx8qxp-ss-gpu.dtsi imx8x-dt-bindings/clock/imx8-clockhdt-bindings/firmware/imx/rsrchdt-bindings/gpio/gpiohdt-bindings/interrupt-controller/arm-gichdt-bindings/input/inputhdt-bindings/thermal/thermalh-dual-imx8qxp-mek-s以下為i.MX8X的SOC的DTSI,以i.MX8QXP為基礎(chǔ),i.MX8 /DX為i.MX8QXP的部imx8-ss-dc0.dtsi;imx8qxp-ss-dc.dtsiimx8-ss-adma.dtsi;imx8qxp-ss-adma.dtsiimx8-ss-conn.dtsi;imx8qxp-ss-conn.dtsimx8-ss-lsio.dtsi;imx8qxp-ss-lsio.dtsiimx8-ss-hsio.dtsi;imx8qxp-ss-hsio.dtsiimx8-ss-img.dtsi;imx8qxp-ss-img.dtsiimx8-ss-gpu0.dtsi";imx8qxp-ss-gpu.dtsiimx8.dtsi:SOC中將i.MX8QXP部分去掉cpu2/3及相應(yīng)thermalmapimx8dx.dtsi:SOC中將 imx8x-mek.dtsi:MEK板級主要文件,包括所有外設(shè)驅(qū)動部分。由于客戶主要是定制板級驅(qū)imx8qxp-mek.dtsi.MX8QXPMEKDTBimx8qxp-mek-dsi-rm67191.dtsMEKrm67191MiPiDSI接口屏的DTSimx8qxp-mek-enet2.dts/imx8qxp-enet2-tja1100.dtsi/imx8qxp-mek-enet2-i.MX8QXPMEK板支持通過enet2NXPtja1100100Mhz汽車級以太網(wǎng)PHYimx8qxp-mek-ov5640.dts:i.MX8QXPMEKMiPiCSIOV5649Cameraimx8qxp-mek-rpmsg.dts:i.MX8QXPMEKA35M4rpmsgimx8qxp-mek-dsp.dts:MEK板支持HiFiDSPcodecDTB文件imx8qxp-mek-it6263-lvds0/1-dual-channel.dtsMEKLVDS0LVDS1dualchannel模式來連接LVDSto橋,來連接顯示器(默認(rèn)的imx8qxp-mek.dts是使用singlechannel模式來連接的。)imx8qxp-mek-jdi-wuxga-lvds0/1-panel.dts:MEK板支持通過LVDS0LVDS1dualchannel模式來連接jdi_tx26d202vm0bwadualchannelLVDS屏imx8qxp-mek-sof-cs42888.dts:Enablesyback/recordusingSoundOpenFirmwareforHiFi4DSPwithcs42888codec.imx8qxp-mek-sof-wm8960.dts:Enablesyback/recordusingSoundOpenFirmwareforHiFi4DSPwithWM8960codec.imx8qxp-mek-dsi-rm67191.dtsMEKrm67191MiPiDSI接口屏的DTBimx8dx-mek.dtsi.MX8DXMEKDTBimx8dx-mek-rpmsg.dts:i.MX8DXMEKA35M4rpmsg默認(rèn)uboot根據(jù)M4是否運(yùn)行決定使用fdt_file=imx8qxp-mek.dtb或者imx8qxp-mek-rpmsg.dtb。默認(rèn)uboot根據(jù)M4是否運(yùn)行決定使用fdt_file=imx8dx-mek.dtb或者imx8dx-mek-rpmsg.dtb。使用M4,需要手動修改為包括imx8qxp-mek.dts//#include"imx8qxp-mek-rpmsg.dts"#include"imx8qxp-mek.dts"deviceTree的由來(no“每次正式的linuxkernelrelease之后都會有兩周的mergewindow,在這個窗口期間,kernel各個部分的者都會提交各自的patch,將自己測試穩(wěn)定的代碼請求并入kernelmainline。每到這個時候,Linus就會比較繁忙,他需要從各個內(nèi)核者的分支上取得 代碼并merge到自己的kernelsourcetree中。TonyLindgren,內(nèi)核OMAPdevelopmenttree的 給Linus,請求提交OMAP平臺代碼修改,并給出了一些細(xì)節(jié)描述:2、關(guān)于如何解決mergeconfictsgitmergetool就可以處理,不能處理的,給出了詳細(xì)介紹一切都很平常,也給出了足夠的信息,然而,正是這個pullrequest了一場針對ARMlinux的內(nèi)核代碼的爭論。我相信LinusARM相關(guān)的代碼早就不爽了,ARMmerge工作量較大倒在其次,主要是他認(rèn)為ARM很多的代碼都是,代碼里面有若干愚蠢的table,而多個人在這個table,從而導(dǎo)致了。因此,在處理完OMAP的pullrequest之后(Linus并非針對OMAP平臺,只是TonyLindgren撞在槍口上了),他發(fā)出了怒吼:Gaah.Gaah.Guys,thiswholeARMthingisaf*ckingpaininthe負(fù)責(zé)ARMlinux開發(fā)的RussellKing臉上掛不住,進(jìn)行了反駁:事情沒有那么嚴(yán)重,這次的mergeconfictsOMAP和IMX/MXCARMlinux團(tuán)隊(duì)的努我們已經(jīng)有一些思考,正在進(jìn)行中……一時間,討論的氣氛有些,但總體是坦誠和友好的。1、內(nèi)核者(CPU體系結(jié)構(gòu)無關(guān)的代碼2、ARM系統(tǒng)結(jié)構(gòu)代碼的3、ARMsubarchitecture的人(來自各個ARMSOCARMsubarchitecture的人并沒有使命感,作為公司的一員,他們最大的目標(biāo)是以最快的速度支持自己公司的SOC,盡快的占領(lǐng)市場。這些人的軟件功力未必強(qiáng),對linuxkernel的一長串的CPUlist,每個CPU多多少少有些不同,這時候#ifdef就充斥了各個源代碼中,讓ARMmach-和t- 作為ARM體系結(jié)構(gòu)的人,其能力不容置疑。以RussellKing為首的team很好的了ARM體系結(jié)構(gòu)的代碼?;旧?,除了mach-和t- 的。作為ARMlinux的者,一個不斷有新的SOC加入的CPUarchitecturecode的確是一個。在In X86的架構(gòu)一統(tǒng)天下的時候,任何想正面In 倒巨人(或者說想要和巨人并存)必須另辟蹊徑。ARM的策略有兩個,一個是focus在嵌入式應(yīng) 采用licenseIP的方式,讓的廠商加入ARM建立的生態(tài)系統(tǒng)。,ARM公司是成功的,但是這種模式也給ARMlinux的者帶來了噩夢。越來越多的廠商加入ARM陣營,越來越多的ARMtform相關(guān)的代碼被加入到內(nèi)核,不同廠商的周邊HWblock設(shè)計(jì)又各不相題,發(fā)現(xiàn)問題。Linus注意到每次mergewindow中,ARM的代碼變化大約占整個ARCH 率的確很夸張,因?yàn)閡nicore32是在2.6.39mergewindow中第一次全新提交,它的代碼是全新的,但是其代碼變化大約占整個ARCH 的9.6%(需要提及的是unicore32是一個中國芯。有些維ARMkernelimage來支持。1、ARMlinux缺少tform(各個ARMsubarchitecture,或者說各個SOC)之間的協(xié)調(diào),導(dǎo)致armlinux的代碼有重復(fù)。值得一提的是在本次爭論之前,ARM者已經(jīng)進(jìn)行了不少相關(guān)的工作(例如PM和clocktree)來抽象相同的功能模塊。2、ARMlinux中大量的boardspecific的源代碼應(yīng)該踢出kernel,否則這些代碼和table會影響linuxkernel的長期目標(biāo)。3、各個subarchitecture的者直接提交給Linux并入主線的機(jī)制缺乏層次。architectureARMVendor)的資源。因此,內(nèi)核社區(qū)成立了一個ARMsubarchitectureteam,該team主ARM廠商的代碼(notARMcorepart),RussellKingARMcorepart的代碼。此外,建立一個ARMtformconsolidationtree。ARMsubarchitectureteam負(fù)責(zé)review各個subarchitecture者提交的代碼,并在ARMtformconsolidationtree上。在下一個mergewindow到來的時候,將patch發(fā)送給Linus。針對重復(fù)的代碼問題,如果不同的SC使用相同的Pboc(例如I2Controle,那么這個rvr的ode要從各個rh/r/ah-xx中獨(dú)立出來,變成一個通用的模塊供各個SCspfc的模塊使用。移動到哪個 呢?對于2C或者USBOG而言,這些HWblk的驅(qū)動當(dāng)然應(yīng)該移動到krnldrives 是-hip也是off-hip的,但是對于軟件而言,它們是沒有差別的(或者說好的軟件抽象應(yīng)該掩蓋底層硬件的不同)。對于那些sysmvl的code呢?例如oknrontrruptotrol其實(shí)些也是AM-pefi,應(yīng)該屬于nuxkrellnux/kernl or-inux-krnlfrmwors。當(dāng)然對于AM平臺,也需要保存一些和fraeork交互的od,這些ode叫做AMSoCrerhieturecd。OK,總結(jié)一下:1、ARM的代碼仍然保存在 2、ARMSoCcorearchitecturecode保存在arch/arm 3、ARMSOC的周邊外設(shè)模塊的驅(qū)動保存在drivers 4、ARMSOC的特定代碼在arch/arm/mach-xxx 5、ARMSOCboardspecific的代碼被移除,由DeviceTree機(jī)制來負(fù)責(zé)傳遞硬件拓?fù)浜陀布Y源信OKDeviceTree了。本質(zhì)上,DeviceTreehardcodeHW配置信息嵌入到內(nèi)核代碼的方法,改用bootloader傳遞一個DB的形式。對于基于ARMCPU的嵌入式系統(tǒng),我們習(xí)慣于針對每一個tform進(jìn)行內(nèi)核的編譯。但是隨著ARM在消費(fèi)類電子上的廣泛應(yīng)用(甚至桌面系統(tǒng)、服務(wù)器系統(tǒng))ARMX86那樣用一個kernelimage來支持多個tform。在這種情況下,如果我們認(rèn)為kernel是一個blackbox,那么其輸入?yún)?shù)應(yīng)該2、runtime對于嵌入式系統(tǒng),在系統(tǒng)啟動階段,bootloader會加載內(nèi)核并將控制權(quán)轉(zhuǎn)交給內(nèi)核,此外,還需要把上述的三個參數(shù)信息傳遞給kernelkernellinuxkernel中,DeviceTree的設(shè)計(jì)目標(biāo)就是如此?!癲eviceTree的基礎(chǔ)與語法(no簡單的說,如果要使用DeviceTree,首先用戶要了解自己的硬件配置和系統(tǒng)運(yùn)行參數(shù),并把這些信息組織成DeviceTreesourcefileDTC(DeviceTreeCompiler),可以將這些適合人DeviceTreesourcefileDeviceTreebinaryfile(有一個更好聽的名字,DTB,devicetreeblob)。在系統(tǒng)啟動的時候,bootprogram(例如:firmware、bootloader)flashDTBcopy到內(nèi)存(bootloaderDTBfirmware可以探測到deviceDTB保存在內(nèi)存中,并把DTB的起始地址傳遞給program(例如OSkernel,bootloader或者其他特殊功能的程一般是bootloader->OS。DeviceTree在描述DeviceTree的結(jié)構(gòu)之前,我們先問一個基礎(chǔ)問題:是否DeviceTree要描述系統(tǒng)中的所有硬件信息?答案是否定的。基本上,那些可以動態(tài)探測到的設(shè)備是不需要描述的,例如USBdeviceSOC上的usbhostcontrollerdevicetree中描述。同樣的道理,在computersystem中,PCIdevice可以態(tài)探測到,不需要在devicetree中描述,但是PCIbridge如果不能被探測,那么就需要描述之。需要描述的內(nèi)容一般包括PeripheralInterruptGPIOClockDevicetreeDTSDeviceTreeSourcearch/arm/boot/dtsDTB:DeviceTreeeBlob:DTSarch/arm/boot/dts下,DTC:DeviceTreeCompiler:script/dtc/dtc,makeARCH=armimx6q-/ //rootnodenode1{//childnodes“node1”,” a-string-property="Astring";// a-string-list-property="firststring","secondstring a-byte-data-property=[0x010x230x340x56];//BYTE數(shù)據(jù)型屬性,由[] child-node1{//childrennodesofnode1:"child-node1"and"child- second-child-property= a-string-property a-string-property= o, child-node2 node2 a-cell-property=<1234>;/*eachnumber(cell)isauint32*///u32數(shù)據(jù)型屬性,由<> child-node1 從上圖中可以看出,devicetree的基本單元是node。系統(tǒng)中的每個設(shè)備用一個node來描述,中只能有一個rootnode。每個node中包含了若干的property/value來描述該node的一些特性。每個node用節(jié)點(diǎn)名字(nodename)標(biāo)識,節(jié)點(diǎn)名字的格式是[label:]node-name[@unit-address]nodereg屬性(property),那么該節(jié)點(diǎn)名字中必須不能包括@unit-address。unit-addressbus上cpuunit-address0開始編址,以此加一。而具體的設(shè)備,例如以太網(wǎng)控制器,其unit-address就是寄存器地址。rootnode的nodename是確定的,必須是“/”。node-nameunit-address:此設(shè)備的主地址,必須唯一,必須和此節(jié)點(diǎn)的reg屬性的開始地址一rootnode,CPUcpumemory節(jié)點(diǎn)/ model="NXPi.MX6QuadSABRESmartDevice compatible="fsl,imx6q-sabresd","fsl,imx6q";cpus{ #address-cells= #size-cells= cpu0:cpu@0… cpu@1… cpu@2… cpu@3… soc… memory reg= }aliases節(jié)點(diǎn)定義了一些別名。為何要定義這個node呢?因?yàn)镈evicetree是樹狀結(jié)構(gòu),當(dāng)要引用一個node的時候要指明相對于rootnode的fullpath,例如/node1/child-node1。如果多次,每aliasesfullpath*Giventhealiasmxcfb0,itwilllookupaliasesnodesforthefulldevicealiasesserial0="/simple-ethernet0="/simple-}DescribesCPUsorcoresintheStandardpropertiesinclude:reg,clock-frequency,reservation-granule-size,cpus
TLB,L1cache,aswellasmultilevelandsharedcachescanbe #address-cells= #size-cells= cpu0:cpu@0 compatible="arm,cortex- device_type= reg= next-level-cache= operating-points= /* uV 396000 fsl,soc-operating-points= /*ARMkHzSOC-PUuV clock-latency=<61036>;/*twoCLK32periods clocks=<&clks <&clks <&clks <&clks <&clks <&clks <&clks <&clksIMX6QDL_PLL1_BYPASS_SRC> clock-names="arm","pll2_pfd2_396m", "pll1_sw","pll1_sys","pll1_bypass","pll1", arm-supply= pu-supply= soc-supply= cpu@1 compatible="arm,cortex- device_type= reg= next-level-cache= cpu@2 compatible="arm,cortex- device_type= reg= next-level-cache= cpu@3 compatible="arm,cortex- device_type= reg= next-level-cache= memorydevicenode是所有設(shè)備樹文件的必備節(jié)點(diǎn),它定義了系統(tǒng)物理內(nèi)存的layout。必須等于memory。reg屬性定義了該devicenode的地址信息,該屬性的值被解析成任意長度的(address,size)數(shù)組,具體用多長的數(shù)據(jù)來表示address和size是在其parentnode中定義(#address-cells和#size-cells)devicenode,reg描述了memory-mappedIOregisterlength。對于memorynodememoryRAM:startingaddress0x0,length #address-cells=1anda#size-cells=1:memory{ device_type= reg= RAM:startingaddress0x0,length RAM:startingaddress ,length memory@0devicetype="memory";reg=<0x memory@0devicetype=reg= device_type=reg= chosennode主要用來描述由系統(tǒng)firmware指定的runtimeparameter。如果存在chosen這個nodeparentnode必須是名字是“/”taglist傳遞的一些linuxkernel的運(yùn)行DeviceTree傳遞。例如commandline可以通過bootargs這個property這個屬性傳遞;initrdlinux,initrd-startproperty這個屬性傳遞。在實(shí)際中,建議增加一個bootargs的屬性,例如:chosen bootargs= 我們知道,devicetree用于HWtform識別,runtimeparameter傳遞以及硬件設(shè)備描述chosenruntimeparameter了解了基本的devicetree的結(jié)構(gòu)后,我們總要把這些結(jié)構(gòu)體現(xiàn)在devicetreesourcecode上來。linuxkerneldts的文件就是描述硬件信息的devicetreesourcefiledts文件中,一個node被定義成:[label:][label:]node-name[@unit-{[propertiesdefinitions][childnodes]}“[]”表示option,因此可以定義一個只有nodename的空節(jié)點(diǎn)。label方便在dts文件中,具體后面會描述。childnode的格式和node是完全一樣的,因此,一個dts文件中就是若干嵌套組成的node,property以及childnote、childnoteproperty描述。C++中的從基類到頂層的派生類)逐個進(jìn)行分析。 //#address-cells=#size-cells=<1>;chosen{};aliases{};memory{devicetype="memory";reg=<00>;devicetree顧名思義是一個樹狀的結(jié)構(gòu),既然是樹,必然有根?!?”是根節(jié)點(diǎn)的nodename。“{”和“}”之間的內(nèi)容是該節(jié)點(diǎn)的具體的定義,其內(nèi)容包括各種屬性的定義以及childnode的定義。chosen、aliasesmemorysubnode,subnoderootnode是完全一樣的,因此,subnodesubnodedevicetree。屬性的定義采用property=value的形式。例如#address-cells和#size-cellsproperty,而<1>value。value屬性值是空<empty>Valueisempty—usedforconveyingtrue-false屬性值是32bitunsignedintegers,用尖括號表示。例如#size-cells=<1>,<u32>A32-bitintegerinbig-endianformat.Example:the32-bitvalue0x wouldberepresentedinmemoryas: interrupts=<1764bitunsignedintegers,用尖括號表示。<u64>A64-bitintegerinbig-endianformat,wouldberepresentedastwo<u32>cellsclock-frequency= <phandle>--specifiesanumericalidentifierforanodethatisuniquewithinthedevicebinarydata,用方括號表示。例如binary-property[0x010x230x450x67]--eachbyterepresentedbytwohexadecimallocal-mac-address=[0000123456orlocal-mac-address=textstring,device_typememory"<string>--StringsareprintableandNULL-terminatedstringlist,用雙引號表示。<stringlist>--Alistofstring>valuesconcatenated在描述compatible屬性之前要先描述model屬性。model屬性指明了該設(shè)備屬于哪個設(shè)備生產(chǎn)商的哪一個model。一般而言,我們會給model賦值“manufacturer,model”。例如model="fsl,imx6q-sabresd"。fsl是生產(chǎn)商,imx6q-sabresd是model類型,指明了具體的是哪一個系列的SOC。OKcompatiblestringlistmodle(每個string是一個model)。這些字符串列表作系統(tǒng)用來選擇用哪一個driver來驅(qū)動該設(shè)備。假設(shè)定義該屬性:compatible=“aaaaaa”,“bbbbb"。那么操作操作系統(tǒng)可能首先使用aaaaaa來匹配適合的driver,如果沒有匹配到,那么使用字符串bbbbb來繼續(xù)尋找適合的driver,對于本例,compatible="fsl,imx6q-sabresd","fsl,imx6q";listrootnode,compatiblemachinetype的(devicetree代碼分析文章中會給出更細(xì)致的描述)。對于普通的HWblock的節(jié)點(diǎn),例如interrupt-controller,compatible屬性是用來匹配適合的driver的。A<u32>valuespecifiesanumericalidentifierforanodethatisuniquewithinthedevicetree.Usedbyothernodesthatneedtorefertothenodeassociatedwiththeproperty.{phandle=<1>;*Aphandlevalueof1isdefined.Anotherdevicenodecouldreferencethepicnodewithaphandlevalueof1:interrupt-parent=TheDTCtoolautomaticallyinsertsthephandlepropertieswhentheDTSiscompiledintothebinaryDTBformatwhennoexplicitphandleproperties.Definesahumanreadablestringdescribingadevice[label:]node-name[@unit-address][label:]property-name=value;[label:]property-name;Labelsmayalsoappearbeforeorafteranycomponentofapropertyvalue,orbetweencellsofacellarray,orbetweenbytesofabytestring.
reg=reglabel:<0sizelabel:0x prop=[abcdefbyte4:00fffe];str=start:"stringvalue"end:Thelabel'intc:’labelisusedtoassignaphandletotheinterrupt-parentpropertyintherootReferences&followedbyanode’slabelina<>errupt-parent=<&intc>;ortheymaybe&followedbyanode’sfullpathininterrupt-parent=<&{/soc/interrupt-controller@00a01000}Outsideacellarray,areferencetoanothernodewillbeexpandedtothatnode’sfullpath.ethernet0=&EMAC0;&cpu0expandstodevicenode中包含了有尋址需求(regproperty)subnode(后文也許會用childnodesubnode是一樣的意思),那么就必須要定義這兩個屬性?!?”number的意思,#address-cellssubnodereg屬性的地址域特性的,也就是說需要用多少u32cell來描述該地址域。同理可以推斷#size-cellsreg的描述中會給出更詳#address-cellsdefinesthenumberof<u32>cellsusedtoencodetheaddressfieldinachildnode’sregpropertydefinesthenumberof<u32>cellsusedtoencodethesizefieldinachildnode’sregproperty.
Alistoftuplesinthereg=<address1length1[address2length2][address3length3]...Theregpropertyisinterpretedbyitsparentnode’s#address-cellsand#size-
assuming#address-cellsand#size-cellsareboth1,reg=<0x30000x200xFE000x100>;
willbedecodedas2memoryblocksof0x3000…0x3020andcpusareassignedaddresses0and1andnosizetheaddressesformare<000>,<100>,<200>.Itrepresent<chipselectnumber,offset,Theroot-directchildrendescribetheCPU'sviewoftheaddressspace(memorymappedRoot-indirectchildrenusethe definedbytheirParentnodes todefinewhateveraddressingschememakessensefortheRoot-indirectchildrenneedbetranslatedtoaroot RangesisalistofaddressEachentryintherangestableisatupleintheformof(child-bus-address,parent-bus-address,length).Thesizeofeachfieldisdeterminedbytakingthechild's#address-cellsvalue,theparent's#address-cellsvalue,andthechild's#size-cellsvalue.Taketherangeentry<00 0x10000>for“00”ischild ”isparentaddress“0x10000”isthechildaddresslength示例2:RangesisIfit’sdefinedwithan<empty>value,itspecifiesthattheparentandchildaddressspaceisidentical,andnoaddresstranslationiserrupt-controller-Anemptypropertydeclaringanodeasadevicethatreceivesinterrupt#interrupt-cells-apropertyoftheinterruptcontrollernode.Itstateshowmanycellsareininterruptspecifierforthisinterruptcontroller(Similarto#address-cellsand#size-interrupt-parent-specifyaphandletotheinterruptcontrollerthatitisattached*Nodesthatdonothaveaninterrupt-parentpropertycanalsoinheritthepropertyfromtheirparentinterrupts-Apropertyofadevicenodecontainingalistofinterruptspecifiers,oneforeachinterruptoutputsignalonthedevice.HWblock的interruptsource是如何物理的連接到interruptcontroller的呢?在dts文件中是用interrupt-parentinterrupt-parentrootnode,難道rootnode會產(chǎn)生中斷到interruptcontroller嗎?當(dāng)然不會,只不過如果一個能夠產(chǎn)生中斷的devicenode沒有定義interrupt-parent的話,其interrupt-parent屬性就是跟隨parentnode。因此,與其在所有的下游設(shè)備中定義interrupt-parent,不如統(tǒng)一在rootnode中定義了。intclable,標(biāo)識了一個devicenode(在本例中是標(biāo)識了intc:interrupt-controller@00a01000這nodeTree的范圍內(nèi)唯一識別了一個devicenode,也就是phandle),不過,在dts文件,可以使用cLabelsandReferenceslablenode或者property,后續(xù)可以使用&來這個lable。DTC會將lable轉(zhuǎn)換成u32的整數(shù)值放入到DTB中,用戶層面就interruptDeviceTreeinterrupttree,也就Powr_ePAPR_APPROVD_v1.1:系統(tǒng)中有一個interrrupttree的根節(jié)點(diǎn),device1、device2以及PCIhostbridge的interruptline都rootinterruptcontroller的。PCIhostbridge設(shè)備中有一些下游的設(shè)備,也會產(chǎn)生中斷,但PCIhostbridgeinterruptcontroller(interruptnexus),然rootinterruptcontrollerinterrupt,interruptsource(interruptspecifierinterruptsource的信息)都是限定在其所屬的interrupt中。interrupttree的關(guān)鍵屬性。它指明了設(shè)備樹中的各個devicenodeinterrupteventinterruptcontroller也是可以級聯(lián)的,上圖中沒有表示出來。那么在這種情況下interrupttreerootinterrupt-parentinterruptcontrollerroot。 intc:interrupt-controller@00a01000 compatible="arm,cortex-a9- #interrupt-cells= #address-cells= #size-cells= reg=<0x00a01000 <0x00a00100 Property:Valuetype:Description:--indicatestheoperationalstatusofa可以使用okay和disabled來打開和注掉某一個驅(qū)動的設(shè)備Abinding swhataparticularcompatiblevaluemeans,whatpropertiesitshouldhave,whatchildnodesitmighthave,andwhatdeviceitrepresentsLocated Eachbindingpagespecifiesthepropertiesandchildnodesthatareexpectedand/orallowedforthebindinggroupedintocategoriestomakethemeasytofindanPleasereadthebindingdocforeachmoduleunder beforeyoucreatetheDTSfileforthefirsttime*NXPIMX6QIOMUXPleaserefertofsl,imx-pinctrl.txtinthisdirectoryforcommonbindingpartandusage.Requiredcompatible:"fsl,imx6q-fsl,pins:twointegersarray,representsagroupofpinsmuxandsetting.Theformatisfsl,pins=<PINFUNCIDCONFIG>,PINFUNC_IDispinworkingonaspecificfunction,CONFIGisthepadsettingvaluepull-upforthispin.Pleaserefertoimx6qdatasheetforthevalidconfigCONFIGbitsPADCTL (1<< (0<< (1<< (2<<14)PADCTLPUS22K (3<<(1(1<<(2<<(3<<PADCTLSPEED(1<<(1<<(1<<PADCTLPUEPADCTLDSE (0<<PADCTLDSE48ohm(1<<(2<<(3<<(4<<(5<<(6<<(7<< (1<< (0<<Refertoimx6q-pinfunchindevicetreesourcefolderforallavailableimx6qPIN_FUNC_ID.#defineMX6QDL_PAD_SD2_DAT1SD2_DATA1 0x04c0x3600x0000x00x0#defineMX6QDL_PAD_SD2_DAT1ECSPI5_SS0 0x04c0x3600x8340x10x0#defineMX6QDL_PAD_SD2_DAT1EIM_CS2_B 0x04c0x3600x0000x20x0#defineMX6QDLPADSD2DAT1AUD4TXFS 0x04c0x3600x7c80x30x0#defineMX6QDLPADSD2DAT1KEYCOL7 0x04c0x3600x8f00x40x0#defineMX6QDL_PAD_SD2_DAT1GPIO1_IO14 0x04c0x3600x0000x50x0dtctoollocatesatscripts/dtc/,itisbuiltoutbyrulehostprogs-yindtbtarges:arch/arm/boot/dts/Makefiledefineswhich.dtbtargetswillbebuiltoutbuildscripts/dtc/dtc-Idts-Odtb-o/path/to/my-tree.dtb/path/to/my-./
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- GB/T 45859-2025耐磨鑄鐵分類
- 廢鋼船買賣合同協(xié)議
- 2025年工業(yè)水處理工(高級)職業(yè)技能認(rèn)定考試題庫(附答案)
- 2025年保密知識測試題題庫附有答案
- 2025年安全培訓(xùn)試題及答案
- 重難點(diǎn)2 閱讀理解詞義猜測題-2024年高考英語復(fù)習(xí)專練(新高考專用)原卷版
- 浙江省寧波市七校聯(lián)考2023-2024學(xué)年八年級上學(xué)期12月月考數(shù)學(xué)試卷(含解析)
- 內(nèi)陸?zhàn)B殖產(chǎn)業(yè)鏈上下游企業(yè)調(diào)研考核試卷
- 圓錐曲線大題綜合五個方程型(原卷版)
- 家禽養(yǎng)殖信息化對農(nóng)業(yè)勞動力技能需求的變化分析考核試卷
- 高速公路施工標(biāo)準(zhǔn)化技術(shù)指南
- 6、上海-建筑工程交通設(shè)計(jì)及停車庫(場)設(shè)置標(biāo)準(zhǔn)
- 茶樹斜紋夜蛾的特征習(xí)性、暴發(fā)原因及防治措施
- 航海英語聽力與會話第四版答案
- 氯化銨安全技術(shù)說明書MSDS
- DB33∕T 1189-2020 裝配式建筑結(jié)構(gòu)構(gòu)件編碼標(biāo)準(zhǔn)
- 上海市醫(yī)藥采購服務(wù)與監(jiān)管信息系統(tǒng)
- 寶鋼產(chǎn)品質(zhì)量證明書模板
- 三相三線兩元件電能表48種接線功率對3
- 環(huán)境工程原理課程設(shè)計(jì)-丙酮吸收填料塔要點(diǎn)
- 鄱陽湖底泥中重金屬污染現(xiàn)狀評價(jià)
評論
0/150
提交評論