Registered User |
Registered User mNo edit summary Tag: 2017 source edit |
||
(5 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{ApplicableFor | |||
|MPUs list=STM32MP13x, STM32MP15x | |MPUs list=STM32MP13x, STM32MP15x, STM32MP21x, STM32MP23x, STM32MP25x | ||
|MPUs checklist=STM32MP13x,STM32MP15x | |MPUs checklist=STM32MP13x, STM32MP15x, STM32MP21x, STM32MP23x, STM32MP25x | ||
}}</noinclude> | }} | ||
<noinclude></noinclude> | |||
==Article purpose== | ==Article purpose== | ||
The main purpose of this article is to give main steps on how to add a customer application or an already existing application inside the Yocto build process ( | The main purpose of this article is to give main steps on how to add a customer application or an already existing application inside the Yocto build process (by using the [[STM32MPU Distribution Package]]). | ||
==Pre- | ==Pre-requisite== | ||
You are already familiar with the Yocto build process and the OpenSTLinux distribution. | You are already familiar with the Yocto build process and the OpenSTLinux distribution. | ||
Line 17: | Line 18: | ||
You may want to add an application which is already present in layers, for example '''OpenCV'''. You can search for it. | You may want to add an application which is already present in layers, for example '''OpenCV'''. You can search for it. | ||
{{PC$}} bitbake -s|grep opencv | {{PC$}}bitbake -s|grep opencv | ||
If nothing is displayed, it can be because this recipe is not included in your layers. You can try to search for it. | If nothing is displayed, it can be because this recipe is not included in your layers. You can try to search for it. | ||
{{PC$}} | {{PC$}}find . -type f -iname "opencv*.bb" | ||
./layers/meta-openembedded/meta-oe/recipes-support/opencv/ | ./layers/meta-openembedded/meta-oe/recipes-support/opencv/opencv_4.7.0.bb | ||
If the find command displays a recipe, then [[How_to_create_a_new_open_embedded_layer#Add_the_new_layer_to_your_configuration|add the layer to your configuration]] | If the find command displays a recipe, then [[How_to_create_a_new_open_embedded_layer#Add_the_new_layer_to_your_configuration|add the layer to your configuration]] | ||
To check that this application can be built, compile it with the bitbake command: | To check that this application can be built, compile it with the bitbake command: | ||
{{PC$}} bitbake opencv | {{PC$}}bitbake opencv | ||
You can now add it to an image. | You can now add it to an image. | ||
Line 36: | Line 37: | ||
* Copy the new recipe inside the customer layer | * Copy the new recipe inside the customer layer | ||
{{PC$}} mkdir ../meta-my-custo-layer/recipes-custom/mymodule | {{PC$}}mkdir ../meta-my-custo-layer/recipes-custom/mymodule | ||
{{PC$}} cp workspace/recipes/mymodule/mymodule.bb ../meta-my-custo-layer/recipes-custom/mymodule | {{PC$}}cp workspace/recipes/mymodule/mymodule.bb ../meta-my-custo-layer/recipes-custom/mymodule | ||
* Copy the source code files, the Makefile inside the customer layer | * Copy the source code files, the Makefile inside the customer layer | ||
{{PC$}} mkdir ../meta-my-custo-layer/recipes-custom/mymodule/mymodule | {{PC$}}mkdir ../meta-my-custo-layer/recipes-custom/mymodule/mymodule | ||
{{PC$}} cp kernel_module_example/Makefile ../meta-my-custo-layer/recipes-custom/mymodule/mymodule | {{PC$}}cp kernel_module_example/Makefile ../meta-my-custo-layer/recipes-custom/mymodule/mymodule | ||
{{PC$}} cp kernel_module_example/kernel_module_example.c ../meta-my-custo-layer/recipes-custom/mymodule/mymodule | {{PC$}}cp kernel_module_example/kernel_module_example.c ../meta-my-custo-layer/recipes-custom/mymodule/mymodule | ||
{{PC$}} devtool reset mymodule | {{PC$}}devtool reset mymodule | ||
* Some fields of new recipes must be also completed, at least '''LICENSE''', '''LIC_FILES_CHKSUM''', and '''SRC_URI''' | * Some fields of new recipes must be also completed, at least '''LICENSE''', '''LIC_FILES_CHKSUM''', and '''SRC_URI''' | ||
:*Details on the license are explained in {{DocSource | domain=Yocto Project | path=dev-manual/ | :*Details on the license are explained in {{DocSource | domain=Yocto Project | path=dev-manual/new-recipe.html#licensing | text=Yocto Project Documentation Writing a New Recipe/Licensing}} | ||
:*Details on SRC_URI are explained in {{DocSource | domain=Yocto Project | path=dev-manual/ | :*Details on SRC_URI are explained in {{DocSource | domain=Yocto Project | path=dev-manual/new-recipe.html#fetching-code | text=Yocto Project Documentation Writing a New Recipe/Fetching Code}} | ||
{{Warning|The recipe update must be done now directly in ../meta-my-custo-layer/recipes-custom/mymodule/mymodule.bb}} | {{Warning|The recipe update must be done now directly in ../meta-my-custo-layer/recipes-custom/mymodule/mymodule.bb}} | ||
<syntaxhighlight lang="c" line highlight="5-6,9"> | <syntaxhighlight lang="c" line highlight="5-6,9"> | ||
Line 81: | Line 82: | ||
To check that your updates of new recipe have not broken the compilation, compile it with the bitbake command: | To check that your updates of new recipe have not broken the compilation, compile it with the bitbake command: | ||
{{PC$}} bitbake mymodule | {{PC$}}bitbake mymodule | ||
You can now add it to an image. | You can now add it to an image. | ||
==Quickly add the recipe to an image== | ==Quickly add the recipe to an image== | ||
* For a quick check you can add this new recipe (mymodule.bb) inside st-image-weston, recompile this image, flash/boot the board and check the module is well | * For a quick check you can add this new recipe (mymodule.bb) inside st-image-weston, recompile this image, flash/boot the board and check the module is well functional | ||
{{PC$}} cd .../meta-st-openstlinux/recipes-st/images/ | {{PC$}}cd .../meta-st-openstlinux/recipes-st/images/ | ||
Open st-image-weston.bb and add this line : '''CORE_IMAGE_EXTRA_INSTALL += " mymodule "''' | Open st-image-weston.bb and add this line : '''CORE_IMAGE_EXTRA_INSTALL += " mymodule "''' | ||
{{PC$}} bitbake st-image-weston | {{PC$}}bitbake st-image-weston | ||
After flashing and booting the board, Insert the kernel module example into the Linux kernel | After flashing and booting the board, Insert the kernel module example into the Linux kernel | ||
{{Board$}} modprobe kernel_module_example | {{Board$}}modprobe kernel_module_example | ||
[18167.821725] {{Highlight|Kernel module example}}: hello world from STMicroelectronics | [18167.821725] {{Highlight|Kernel module example}}: hello world from STMicroelectronics | ||
Remove the kernel module example from the Linux kernel | Remove the kernel module example from the Linux kernel | ||
{{Board$}} rmmod kernel_module_example | {{Board$}}rmmod kernel_module_example | ||
[18180.086722] {{Highlight|Kernel module example}}: goodbye from STMicroelectronics | [18180.086722] {{Highlight|Kernel module example}}: goodbye from STMicroelectronics | ||
Line 104: | Line 105: | ||
* This new recipe (mymodule.bb) must be added inside the custom image you compile | * This new recipe (mymodule.bb) must be added inside the custom image you compile | ||
{{PC$}} cd .../meta-my-custo-layer/recipes-samples/images/ | {{PC$}}cd .../meta-my-custo-layer/recipes-samples/images/ | ||
Open my-custom-image.bb and add this line : '''IMAGE_INSTALL += "mymodule"'''<br> | Open my-custom-image.bb and add this line : '''IMAGE_INSTALL += "mymodule"'''<br> | ||
{{PC$}} bitbake my-custom-image | {{PC$}}bitbake my-custom-image | ||
<noinclude> | <noinclude> |
Latest revision as of 11:36, 5 November 2024
1. Article purpose[edit | edit source]
The main purpose of this article is to give main steps on how to add a customer application or an already existing application inside the Yocto build process (by using the STM32MPU Distribution Package).
2. Pre-requisite[edit | edit source]
You are already familiar with the Yocto build process and the OpenSTLinux distribution.
You have already created a customer layer (How to create a new open embedded layer) or want to add an already existing application to update, for your own needs, the OpenSTLinux distribution.
You have already created in your environment either an external out of tree kernel module, or an "hello world" user space example.
3. Adding an application[edit | edit source]
3.1. Adding an application already present in layers[edit | edit source]
You may want to add an application which is already present in layers, for example OpenCV. You can search for it.
bitbake -s|grep opencv
If nothing is displayed, it can be because this recipe is not included in your layers. You can try to search for it.
find . -type f -iname "opencv*.bb"
./layers/meta-openembedded/meta-oe/recipes-support/opencv/opencv_4.7.0.bb
If the find command displays a recipe, then add the layer to your configuration
To check that this application can be built, compile it with the bitbake command:
bitbake opencv
You can now add it to an image.
3.2. Adding a customer application (integrated in a customer layer)[edit | edit source]
Once mymodule or myhelloworld recipes have been created with devtool commands, to add it in the Yocto build process, some additional commands below must be used.
They concern the external out-of-tree Linux kernel module (mymodule).
Similar commands shall be executed for the "hello world" user space example (myhelloworld).
- Copy the new recipe inside the customer layer
mkdir ../meta-my-custo-layer/recipes-custom/mymodule
cp workspace/recipes/mymodule/mymodule.bb ../meta-my-custo-layer/recipes-custom/mymodule
- Copy the source code files, the Makefile inside the customer layer
mkdir ../meta-my-custo-layer/recipes-custom/mymodule/mymodule
cp kernel_module_example/Makefile ../meta-my-custo-layer/recipes-custom/mymodule/mymodule
cp kernel_module_example/kernel_module_example.c ../meta-my-custo-layer/recipes-custom/mymodule/mymodule
devtool reset mymodule
- Some fields of new recipes must be also completed, at least LICENSE, LIC_FILES_CHKSUM, and SRC_URI
- Details on the license are explained in Yocto Project Documentation Writing a New Recipe/Licensing
- Details on SRC_URI are explained in Yocto Project Documentation Writing a New Recipe/Fetching Code
# NOTE: LICENSE is set to "CLOSED" to allow you to at least start building - if
# this is not accurate with respect to the licensing of the software being built (in most cases, it
# is not) you must specify the correct value, before using this
# recipe for anything other than the initial testing/development!
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
# No information for SRC_URI yet (only an external source tree is specified)
SRC_URI = ""
For instance for Linux kernel module:
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe"
SRC_URI = "file://Makefile \
file://kernel_module_example.c \
"
Or for user space application:
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
SRC_URI = "file://hello_world_example.c \
"
To check that your updates of new recipe have not broken the compilation, compile it with the bitbake command:
bitbake mymodule
You can now add it to an image.
4. Quickly add the recipe to an image[edit | edit source]
- For a quick check you can add this new recipe (mymodule.bb) inside st-image-weston, recompile this image, flash/boot the board and check the module is well functional
cd .../meta-st-openstlinux/recipes-st/images/
Open st-image-weston.bb and add this line : CORE_IMAGE_EXTRA_INSTALL += " mymodule "
bitbake st-image-weston
After flashing and booting the board, Insert the kernel module example into the Linux kernel
Kernel module example: hello world from STMicroelectronicsmodprobe kernel_module_example [18167.821725]
Remove the kernel module example from the Linux kernel
Kernel module example: goodbye from STMicroelectronicsrmmod kernel_module_example [18180.086722]
Once this quick check is done, please remove the addon in st-image-weston
- Create your custom image my-custom-image by following the recommendation made in How to create your own image#Customizing images. It can inherit of st-image-weston image.
- This new recipe (mymodule.bb) must be added inside the custom image you compile
cd .../meta-my-custo-layer/recipes-samples/images/
Open my-custom-image.bb and add this line : IMAGE_INSTALL += "mymodule"
bitbake my-custom-image