Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
Nächste ÜberarbeitungBeide Seiten der Revision
software:linux:toradex:toradex-build [2019-10-16 12:14] mlammerichsoftware:linux:toradex:toradex-build [2021-03-01 09:43] Moritz Lammerich
Zeile 1: Zeile 1:
 ====== Building a New Image ====== ====== Building a New Image ======
  
-Images are built using bitbake and yocto.+Images are built using [[ :software/linux/yocto/start | the yocto project]].
  
 The build process is based on [[ https://developer.toradex.com/knowledge-base/board-support-package/openembedded-%28core%29#update-to-a-specific-version-by-using-its-tag | this toradex guide ]]. The build process is based on [[ https://developer.toradex.com/knowledge-base/board-support-package/openembedded-%28core%29#update-to-a-specific-version-by-using-its-tag | this toradex guide ]].
  
-===== Customising the Toradex image =====+===== Setting up the build environment =====
  
-Note that everything in this section assumes a build environment that is set up accoring to the guide above.+The following was taken from [[ https://developer.toradex.com/knowledge-base/board-support-package/openembedded-%28core%29#update-to-a-specific-version-by-using-its-tag | the toradex guide ]].
  
-==== Adding a custom application ====+First, make sure that the ''repo'' tool is available:
  
-A custom application can be added to yocto build by means of a new recipes and a new layer.+<code> 
 +mkdir ~/bin 
 +export PATH=~/bin:$PATH 
 +curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo 
 +chmod a+x ~/bin/repo 
 +</code>
  
-There are various ways to source application to be added to a build. This guide describes how to add [[ https://github.com/DynamicDevices/bbexample | this hello world application from github ]] into the toradex image. If you want to build your own hello world applicationcheck out [[ https://blog.mbedded.ninja/programming/embedded-linux/yocto-project/adding-a-custom-app-to-a-yocto-build/ | this guide ]] on how to do that.+Nextmake sure ''git'' is installed and configured:
  
-=== On layers and recipes ===+<code> 
 +sudo apt install git 
 +git config --global user.name "John Doe" 
 +git config --global user.email johndoe@example.com 
 +</code>
  
-Recipes could be considered the fundamental building block of yocto. A recipe describes how to build the thing you want to build (i.e an application, kernel module, ...), its dependencies and more. +Now fetch the toradex layers using ''repo'':
  
-Groups of recipes that belong together are grouped into layers. For example ''meta-toradex-nxp'' is the layer that contains all the things needed to support the hardware specific to Toradex's modules that use NXP based processors+<code> 
- +mkdir ${HOME}/oe-core 
-=== Creating a custom layer ===+cd ${HOME}/oe-core 
 +repo init -u https://git.toradex.com/toradex-manifest.git -b refs/tags/5.1.0 -m tdxref/default.xml 
 +repo sync 
 +</code>
  
-To create a new layercreate a new directory in the ''oe-core/layers'' directory(''oe-core'' is the folder the build environment was set up in above). Since this is the NTB wiki, this guide will use ''oe-core/layers/meta-ntb''. The directory name can be anything, but it should start with ''meta-''. Now change into that directory and create another folder called ''conf''. In ''conf'', create a file named ''layer.conf'' with the following content:+Finallysource the setup script:
  
 <code> <code>
-BBPATH := "${BBPATH}:${LAYERDIR}"+. export 
 +</code>
  
-BBFILES :"${BBFILES} ${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bappend"+==== Adding the NTB layers ====
  
-BBFILE_COLLECTIONS += "ntb"+The NTB specific recipes are maintained in the [[ software:linux:yocto:meta-ntb | meta-ntb]] layer.
  
-BBFILE_PATTERN_ntb := "^${LAYERDIR}/" +change into the ''layers'' directory
-BBFILE_PRIORITY_ntb := "5"+ 
 +<code> 
 +cd ../layers
 </code> </code>
  
-This file configures the layer and where to look for recipesIn this case it will look for file in ''meta-ntb/recipes-<some name>/<some other name>/<file name>.bb''. ''.bb'' is the file extension used by ''bitbake'' the build system used by yocto. Finally, create a folder named ''recipes-ntb'' inside ''meta-ntb''. This folder will store all the recipes for this layer. The directory structure should now look like this:+clone the [[ https://github.com/zechenturm/meta-ntb meta-ntb ]] repository:
  
-  * oe-core +<code> 
-    ... +git clone https://github.com/zechenturm/meta-ntb 
-    * meta-ntb +</code>
-      * conf +
-        * layer.conf +
-      * recipes-ntb+
  
-=== Adding a Recipe to the Layer ===+change back to the ''build'' directory and add the layers to ''conf/bblayers.conf'':
  
-As configured above, ''bitbake'' will look for recipes in any sub directory  +<code> 
-of ''recipes-ntb'', **but not in ''recipes-ntb'' itself!** Create a folder inside ''recipes-ntb'' called ''helloworld'' and inside that create a file called ''helloworld_1_0.bb'' with the following content:+cd ../build 
 +nano conf/bblayers.conf 
 +</code>
  
 <code> <code>
-DESCRIPTION = "Example Hello World" +BBLAYERS ?= " \ 
-SECTION = "ntb" +... 
-DEPENDS = ""+${TOPDIR}/../layers/meta-ntb/meta-ntb \ 
 +${TOPDIR}/../layers/meta-ntb/meta-ntb-toradex \ 
 +" 
 +</code>
  
-LICENSE "MIT" +==== local.conf =====
-LIC_FILES_CHKSUM "file://LICENSE;md5=96af5705d6f64a88e035781ef00e98a8"+
  
-FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"+Add the following to ''conf/local.conf''
  
-SRCREV = "b9fb7785e9e1f357f29bef63dce8f1d91adb6170" +<code> 
-SRC_URI = "git://github.com/DynamicDevices/bbexample.git" +MACHINE = "cb20"
- +
-S = "${WORKDIR}/git" +
- +
-inherit autotools+
 </code> </code>
  
-''bitbake'' is very particular about licenses to ensure no closed source software ends up in a project that only wants open source software. Hence the recipe needs to specify the license used (MIT in this case) and a checksum for the license file to ensure it has not been altered. All this is handled by the ''LIC_FILES_CHKSUM'' field. THe other two interesting fields are ''SRC_URI'' and ''SRC_REV''. ''SRC_URI'' specifies where the source for the application/module/... for this recipe is. In this case ''git:%%//%%'' lets ''bitbake'' know the source lives in a git repository. Note that ''https:%%//%%'' will not work.+==== build ====
  
-Now running ''bitbake console-tdx-image'' should run without errors and the image should include a ''hello'' executable that prints ''Hello World'' when executed.+Production Image:
  
-== Additional Information ==+<code> 
 +bitbake ntb-image 
 +</code>
  
-[[ https://blog.mbedded.ninja/programming/embedded-linux/yocto-project/adding-a-custom-app-to-a-yocto-build/ ]]+Development Image:
  
-[[ https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles ]]+To create a development image, add the following to ''local.conf''.
  
-===== Building the SDK =====+<code> 
 +NTB_DEVBUILD "1" 
 +</code>
  
-To build the SDK for an image append '' -c populate_sdk'' to the bitbake build command.+Then build the image:
  
-For example, to build the SDK for the standard toradex image ''console-tdx-image'' run ''bitbake console-tdx-image -c populate_sdk''+<code> 
 +bitbake ntb-image 
 +</code>
  
-For more information check the [[ https://developer.toradex.com/knowledge-base/linux-sdks | Toradex guide ]].