| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung |
| software:linux:yocto:recipes [2022-09-27 12:58] – Urs Graf | software:linux:yocto:recipes [2023-06-13 10:19] (aktuell) – Urs Graf |
|---|
| | package_qa | do_package_qa | perform sanity checks on package | | | package_qa | do_package_qa | perform sanity checks on package | |
| |
| *: it seems that ''do_fetch'' and ''do_unpack'' can not be modified/overridden in a recipe, more about overriding see below. | *: it seems that ''do_fetch'' and ''do_unpack'' can not be modified/overridden in a recipe. More about overriding see below. |
| |
| Each of the listed functions is called when building the package, or can explicitly be invoked using | Each of the listed functions is called when building the package, or can explicitly be invoked using |
| ===== Anatomy of a Recipe ===== | ===== Anatomy of a Recipe ===== |
| |
| In essence, a recipe needs provide 4 things: | In essence, a recipe needs to provide 4 things: |
| |
| * where is source (code) | * where is the source (code) |
| * how to build it | * how to build it |
| * how/where to install it (in the image) | * how/where to install it (in the image) |
| Almost all recipes need some source code or other source from which to build the software. | Almost all recipes need some source code or other source from which to build the software. |
| In bitbake this step is called ''fetch''. | In bitbake this step is called ''fetch''. |
| Sources are specified by setting the ''SRC_URI'' variable and be fetched from a variety of sources. | Sources are specified by setting the ''SRC_URI'' variable and can be fetched from a variety of sources. |
| |
| For example, setting ''SRC_URI'' as shown below will fetch 2 local files ''heloworld.c'' and ''Makefile''. | For example, setting ''SRC_URI'' as shown below will fetch 2 local files ''heloworld.c'' and ''Makefile''. |
| |
| There is a variety of fetchers available for downloading files from the internet or cloning git repositories and more. | There is a variety of fetchers available for downloading files from the internet or cloning git repositories and more. |
| Each has their own requirements and options, which can be found [[ https://www.yoctoproject.org/docs/1.6/bitbake-user-manual/bitbake-user-manual.html#bb-fetchers | here ]]. | Each has their own requirements and options, which can be found [[ https://www.yoctoproject.org/docs/1.6/bitbake-user-manual/bitbake-user-manual.html#bb-fetchers | here]]. |
| |
| <code> | <code> |
| </code> | </code> |
| |
| For makefile based projects, see [[ https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#new-recipe-makefile-based-package | here]]. | For makefile based projects, see [[ https://docs.yoctoproject.org/dev-manual/new-recipe.html?highlight=makefile#building-a-makefile-based-package | Building a Makefile-Based Package]]. |
| |
| ==== Appending a Function ==== | ==== Appending a Function ==== |
| |
| Manual creation of recipes may be required when [[ .:devtool | devtool ]] fails to automatically create one. | Manual creation of recipes may be required when [[ .:devtool | devtool ]] fails to automatically create one. |
| |
| ==== <deprecated> ==== | |
| |
| === Adding a Recipe to the Layer === | === Adding a Recipe to the Layer === |
| |
| As configured above, ''bitbake'' will look for recipes in any sub directory | ''bitbake'' will look for recipes in any sub directory of ''recipes-ost'', **but not in ''recipes-ost'' itself!** Create a folder inside ''recipes-ost'' called ''helloworld'' and inside that create a file called ''helloworld_1_0.bb'' with the following content: |
| 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: | |
| |
| <code> | <code> |
| DESCRIPTION = "Example Hello World" | DESCRIPTION = "Example Hello World" |
| SECTION = "ntb" | SECTION = "ost" |
| DEPENDS = "" | DEPENDS = "" |
| |
| </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. Also note that ''inherit autotools'' is only necessary because the hello world uses autotools. | ''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. Also note that ''inherit autotools'' is only necessary because the hello world uses autotools. |
| |
| To add the new recipe to the build edit ''oe-core/build/conf/local.conf'' and append ''IMAGE_INSTALL_append = " helloworld"'' (make sure to include the space before ''helloworld''). | To add the new recipe to the build edit ''oe-core/build/conf/local.conf'' and append ''IMAGE_INSTALL_append = " helloworld"'' (make sure to include the space before ''helloworld''). |
| ==== Adding a kernel module ==== | ==== Adding a kernel module ==== |
| |
| This part is an extension of the previous and assumes the ''meta-ntb'' layer exists and was added to ''bblayers.conf'' as described above. This part uses the [[ https://github.com/zechenturm/fpga_loader | fpga_loader ]] kernel module to demonstrate how to add an out-of-tree kernel module to yocto. | This part is an extension of the previous and assumes the ''meta-ost'' layer exists and was added to ''bblayers.conf'' as described above. This part uses the [[ https://github.com/zechenturm/fpga_loader | fpga_loader ]] kernel module to demonstrate how to add an out-of-tree kernel module to yocto. |
| |
| Create a new directory ''recipes-kernel'' under ''meta-ntb'' and in that create another folder inside that called ''fpga-loader''. Create a file called ''fpga-loader_1.0.bb'' in ''fpga-loader'' and add the following content: | Create a new directory ''recipes-kernel'' under ''meta-ost'' and in that create another folder inside that called ''fpga-loader''. Create a file called ''fpga-loader_1.0.bb'' in ''fpga-loader'' and add the following content: |
| <code> | <code> |
| DESCRIPTION = "FPGA Loader Kernel Module" | DESCRIPTION = "FPGA Loader Kernel Module" |
| SECTION = "ntb" | SECTION = "ost" |
| DEPENDS = "" | DEPENDS = "" |
| |