發表文章

目前顯示的是 2月, 2018的文章

yocto recipe : (1) 撰寫 recipe

此篇文章介紹如何透過 yocto 的 utilities 來產生 recipe. 而完成的 recipe 又如何加入到 image. yocto 相關工具介紹 有三個適用於 layer 與 recipe 相關的 utilities. bitbake-layers: 負責 (1) 建立 layer. (2) 修改 bblayers.conf. (3) 查看 layer 底下的 recipes recipetool: 用於建立一個 recipe 和新增/修改 recipe. 這邊 recipe 在 yocto 即是 xx.bb 或 xx.bbappend 檔案 devtool: 定位在開發測試上. devtool 會建立一個獨立的 workspace layer. 讓開發者於此建立/修改 recipe 與 patch source code. 在不修改原有設定下與現有 layers 進行整合測試. 完畢之後可以再透過 devtool 新增或更新到 layer 裡 利用 utilities 撰寫 recipe 的時候. 要確保所屬的 layer 是存在於 bblayer.conf. 不然執行 bitbake [recipe basename] 會找不到相關的 recipe. yocto 事前準備 以 core-image-miniaml recipe 為例子. core-image-miniaml 會產生系統所需的 image 相關檔案. 接著利用 bitbake-layers 建立自己的 layer 於 build 目錄底下. 再透過 bitbake-layers 把 layer 加入到 bblayers.conf 設定檔. [ yijyun@localhost poky ] $ . oe-init-build-env [ yijyun@localhost build ] $ bitbake core-image-minimal [ yijyun@localhost build ] $ bitbake-layers create-layer meta-layer [ yijyun@localhost build ] $ bitbake-layers add-

yocto 概念

圖片
這篇文章紀錄我對於 yocto 的概念. 以下用的版本為 2.4 (rocko). 一開始介紹幾個用詞. 接著述說架構的運作流程. 最後再介紹 bitbake 指令用法. 名詞定義 [2]摘錄比較常看到的名詞定義 BitBake: The task executor and scheduler used by the OpenEmbedded build system to build images. For more information on BitBake, see the BitBake User Manual. Task: A unit of execution for BitBake (e.g. do_compile, do_fetch, do_patch, and so forth). Recipe: A set of instructions for building packages. A recipe describes where you get source code, which patches to apply, how to configure the source, how to compile it and so on. Recipes also describe dependencies for libraries or for other recipes. Recipes represent the logical unit of execution , the software to build, the images to build, and use the .bb file extension. P.S recipe 在 yocto 用 .bb 檔案表示. 而 .bbappend 用於修改 .bb 的設定 Metadata: The files that BitBake parses when building an image. In general, Metadata includes recipes, classes, and configuration files. In the context of t

script 嵌入 binary 檔案

下載的一些工具安裝檔案, 有時候是一個檔案頗大的 shell script. 這麼大的原因是 script 有塞入 binary file 的關係. 而這樣的好處應該就是可以把檔案集中成一個. 之外我覺得就是省去記檔案名稱吧 XDD. 此文章紀錄如何實作封裝與安裝的 script. 實作 這邊分兩個部分, 一個是負責封裝 install template script 與 binary 檔案的 pack script. 另一個則是 install template script. 這的 binary file 以 tar 檔案為例子. Pack script pack script 的流程主要是以 install template script 為樣板, 產生一個 install script. 接著在後面加入類似標籤的字串. 並在”下一行“塞入 tar 檔案. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #!/bin/sh read -p "Input a tar file path: " file # is file exsted > if [ ! -f ${ file } ] then echo "no such file" exit 1 fi # check file extension extension = $( basename ${ file } | tr "[:upper:]" "[:lower:]" | tr '.' '\n' | tail -n 1 ) if [ ${ extension } ! = "tar" ] then echo "only support tar file" exit 1 fi # append install.sh first echo "packing...." cat install_