在yocto中使用devtool工具來修改源碼 / using devtool to modify source code under yocto


https://wiki.phytec.com/pages/viewpage.action?pageId=127338558

 

准備工作

參考資料:

devtool是yocto中的一個工具,我們使用該工具主要用於修改BSP中各個軟件包的源碼,在修改后將提交加入到指定的layer中。

它的工作流程為:

 

   
Use ctrl + scroll to zoom the graph
Open readonly"
devtool flow

 

其中,如果你不想用git的方式來做提交,那可以一直使用devtool生成的源碼目錄,當然這樣不利於對更改的管理。

常用的軟件包名稱:

軟件包
名稱
barebox bootloader barebox
u-boot bootloader u-boot
i.MX6 內核 linux-mainine
AM335x 內核

Vendor:linux-ti

Mainline: linux-mainline

i.MX6ul 內核

Vendor:linux-imx

Mainline: linux-mainline

i.MX7 內核 linux-phytec-fsl
AM57x 內核 linux-phytec-ti

以下以barebox為例,首先執行modify指令,該指令將源碼解壓縮后放在build/workspace中,然后再根據recipe打上補丁:

% devtool modify barebox
NOTE: Creating workspace layer  in  /mnt/work/home/bob/bsp/BSP-Yocto-HTML5-phyBOARD-Mira-v1 .0 /build/workspace
NOTE: Enabling workspace layer  in  bblayers.conf
Parsing recipes.. done .
NOTE: Fetching barebox...
NOTE: Unpacking...
NOTE: Patching...
NOTE: Source tree extracted to  /mnt/work/home/bob/bsp/BSP-Yocto-HTML5-phyBOARD-Mira-v1 .0 /build/workspace/sources/barebox
NOTE: Recipe barebox now  set  up to build from  /mnt/work/home/bob/bsp/BSP-Yocto-HTML5-phyBOARD-Mira-v1 .0 /build/workspace/sources/barebox

然后就可以在workspace/sources/barebox/ 中修改代碼,此時任何做出的任何修改,yocto都會根據修改的類型來進行重新編譯。

編譯

如在修改barebox源碼后執行(注意bitbake必須在build目錄下執行,且已經source環境):

% bitbake barebox

就會重新編譯barebox,並更新deploy中的barebox.bin文件。

如果執行:

% bitbake phytec-qt5demo-image

則會在重新編譯barebox的基礎上,將新的barebox增加到img,如.sdcard文件中。

在鏡像生成后,進行測試,測試滿意時,可以用git將本次修改的內容提交

% git add file_name_edited
% git commit

接着繼續調試下一個需求。

出錯時的復位方法

如果此時workspace中代碼已改亂,或者其他問題,可以通過:

% devtool reset barebox

然后刪除源碼目錄,注意備份之前的修改:

rm  -rf workspace /sources/barebox

重新再次用modify修改軟件包。

將更改增加到layer

注意這個功能的前提是之前對源碼的修改已經提交到git,未提交到git的源碼修改無法通過這個方式增加。

如果還沒有建立layer,請把當前目錄移動到sources文件夾,然后:

% yocto-layer create example
Please enter the layer priority you'd like to use  for  the layer: [default: 6]
Would you like to have an example recipe created? (y /n ) [default: n]
Would you like to have an example bbappend  file  created? (y /n ) [default: n]
 
New layer created  in  meta-example.
 
Don't forget to add it to your BBLAYERS ( for  details see meta-example /README ).

並修改build/conf/bblayers.conf,增加meta-example layer,

然后使用下面這個命令來生成bbappend文件以及補丁:

% devtool finish barebox meta-example

此時就會在meta-example中自動生成所作的修改。

bob@Z220 ~ /bsp/sources/meta-example/recipes-bsp
  % tree
.
└── barebox
     ├── barebox
     │   └── 0001-example.patch
     └── barebox_%.bbappend

注意patch文件一般是有順序的,而之前介紹的流程並不會自動使用在workspace commit時的順序,需要在bb文件中再檢查一下。

執行了devtool finish barebox meta-example操作之后, workspace中barebox的源碼就會實效了, 需要先把workspace中的barebox目錄刪除, 下次如果要修改barebox的源碼, 可以使用devtool modify barebox重新創建barebox的源碼.

    • 無標簽
    •  

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM