I am new to Yocto and doing some starter projects. I have added my own layer called meta-tutorial .
I have the following recipe file inside my layer at meta-tutorial/recipe-example/hello/hello_1.0.bb
DESCRIPTION = "Simple helloworld application"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://hello.c"
S = "${WORKDIR}"
do_compile() {
${CC} hello.c ${LDFLAGS} -o hello
}
do_install() {
install -d ${D}${bindir}
install -m 0755 hello ${D}${bindir}
}
The hello.c source file is located at meta-tutorial/recipe-example/hello/files/hello.c
When I source the oe-init-build-env script , and try to build my recipe as follows bitbake hello_1.0.bb, I encounter the following issues :
WARNING: No bb files in default matched BBFILE_PATTERN_meta-tutorial '^/home/Yocto-test/poky/meta-tutorial/'
ERROR: Nothing PROVIDES 'hello_1.0.bb'
What is the problem here exactly, it's not clear?
A Yocto layer have a configuration file that describes where to look for recipes .bb and recipes append files .bbappend:
meta-tutorial/conf/layer.conf:
...
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"
^
|
(Look closely)-----------------
...
so, your mistake is that you put your recipe under the path:
meta-tutorial/recipe-example/hello
^
|
(The mistake)-------
So, your recipe should be under:
meta-tutorial/recipes-example/hello
^
|
(Correction)---------
Related
I am trying to modify /etc/inittab file to add a restart function. To check whether I can add a line in inittab, I created a demo. I created a .bb file under proect-spec/meta-user/recipes-apps:
#
# This is the GPIO-DEMO apllication recipe
#
#
SUMMARY = "automatic-restart application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://* \
"
S = "${WORKDIR}"
FILESEXTAPATHS_preprend := "${THISDIR}/files:"
#inherit update-rc.d
INITSCRIPT_NAME = "hello"
INITSCRIPT_PARAMS = "start 98 5 ."
do_install() {
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${S}/hello ${D}${sysconfdir}/init.d/hello
install -d ${D}/opt/hello
cp ${S}/hello.elf ${D}/opt/hello/
}
do_install_append(){
echo "adding a line" >> ${D}${sysconfdir}/inittab
}
FILES_${PN} += "${sysconfdir}/*"
FILES_${PN} += "/opt/hello/"
By the way, this file is used firsly put an .elf file under /etc/init.d and it worked.
However, when I was adding these below code block to check whether I can modify "inittab" :
do_install_append(){
echo "adding a line" >> ${D}${sysconfdir}/inittab
}
then building the petalinux project, I encountered with this error:
"file /etc/inittab conflicts between attempted installs of hello-1.0-r0.cortexa9hf_neon and sysvinit-inittab-2.88dsf-r10.plnx_zynq7"
This is a well known issue in Yocto which is you cannot ship two packages(recipes) that are installing the same file in the final rootfs.
So, either you remove one of hello or sysvinit-inittab from the image, or use update-alternatives class as mentioned in this question.
I have been struggling for too long, so I need help :)
I made a big QT5.8 application and usually when I want to compile it with my PC I just have to run the following command: qmake -qt=5.9 -spec linux-arm-gnueabihf-g++ -config configuration_name.
With this command, I can cross compile my source code for the armhf architecture using linux-arm-gnueabihf-g++ toolchain.
But now, as can easily create a yocto image for my target (Raspberry pi), I want to make a recipe in order to compile my qt software and put it into my image.
For now, I achieved to perform these following task in my recipe without errors:
do_fetch -> Yocto fetch the source from git repo (OK)
do_unpack -> OK
After that I want to perform a qmake command in order to generate my makefile, but here is my problem :/
First, I included the qmake5 class in my recipe using
require recipes-qt/qt5/qt5.inc
Then I tried a lot of things..
writing "qmake" into the do_configure task doesn't work. Last thing I tried was: '${OE_QMAKE_QMAKE} ${S}/my_software.pro -config my_config' but still the same error:
Could not find qmake spec 'linux-oe-g++'
I don't know what to do and I can't find any recipe exemple doing the things that I want to do.
If somebody already experienced this issue or have experience compiling qt5 software with a yocto recipe I would like your help :)
my recipe:
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = " "
USERNAME = "****"
PASSWORD = "*****"
S = "${WORKDIR}/git"
require recipes-qt/qt5/qt5.inc
do_fetch(){
git clone http://${USERNAME}:${PASSWORD}#gitlab.....
}
do_configure () {
${OE_QMAKE_QMAKE} ${S}/my_software.pro -config my_config
}
Thanks
Short answer
Add "inherit qmake5" and let Yocto take care of it :)
Long answer
Here's an example of how I added a QT project. It is not using git, it is using local files. However for getting one step further I suggest:
Use my way as a test. Copy the QT project to /yocto/local_sources/Myproject/
and make this known to Yocto by using FILESEXTRAPATHS_prepend_ (as shown below).
If this works on your environment, adapt it to your needs (e.g. build from git instead of local_source, which is better off course.)
This way is tested and works also well for later remote-debugging with qt-creator and the yocto SDK by the way. Stick to Yocto, it's worth it in the end.
Here's my .bb file:
#
# Build QT xyz application
#
SUMMARY = "..."
SECTION = "Mysection"
LICENSE = "CLOSED"
#Add whatever you need here
DEPENDS += "qtbase qtmultimedia qtsvg"
#Add here your .pro and all other relevant files (if you use git later this step will be less tedious ...)
SRC_URI += "file://Myproject.pro"
SRC_URI += "file://*.h"
SRC_URI += "file://*.cpp"
SRC_URI += "file://subdir1/*.h"
SRC_URI += "file://subdir1/*.cpp"
SRC_URI += "file://subdir2/*.h"
SRC_URI += "file://subdir2/*.cpp"
SRC_URI += "file://subdir2/subdir3/*.h"
SRC_URI += "file://subdir2/subdir3/*.cpp"
#If you need autostart:
#SRC_URI += "file://myproject.service"
#Register for root file system aggregation
FILES_${PN} += "${bindir}/Myproject"
#RBE todo: both needed ?
FILESEXTRAPATHS_prepend_${PN} := "/yocto/local_sources/Myproject/Src:"
FILESEXTRAPATHS_prepend := "/yocto/local_sources/Myproject/Src:"
S = "${WORKDIR}"
#If you want to auto-start this add:
#SYSTEMD_SERVICE_${PN} = "Myproject.service"
FILES_${PN} = "${datadir} ${bindir} ${systemd_unitdir}"
FILES_${PN}-dbg = "${datadir}/${PN}/.debug"
FILES_${PN}-dev = "/usr/src"
#Check what's needed in your case ...
RDEPENDS_${PN} += "\
qtmultimedia-qmlplugins \
qtvirtualkeyboard \
qtquickcontrols2-qmlplugins \
gstreamer1.0-libav \
gstreamer1.0-plugins-base-audioconvert \
gstreamer1.0-plugins-base-audioresample \
gstreamer1.0-plugins-base-playback \
gstreamer1.0-plugins-base-typefindfunctions \
gstreamer1.0-plugins-base-videoconvert \
gstreamer1.0-plugins-base-videoscale \
gstreamer1.0-plugins-base-volume \
gstreamer1.0-plugins-base-vorbis \
gstreamer1.0-plugins-good-autodetect \
gstreamer1.0-plugins-good-matroska \
gstreamer1.0-plugins-good-ossaudio \
gstreamer1.0-plugins-good-videofilter \
"
do_install_append () {
# Install application
install -d ${D}${bindir}
install -m 0755 Myproject ${D}${bindir}/
# Uncomment if you want to autostart this application as a service
#install -Dm 0644 ${WORKDIR}/myproject.service ${D}${systemd_system_unitdir}/myproject.service
# Install resource files (example)
#install -d ${D}${datadir}/${PN}/Images
#for f in ${S}/Images/*; do \
# install -Dm 0644 $f ${D}${datadir}/${PN}/Images/
#done
}
#Also inherit "systemd" if you need autostart
inherit qmake5
My program depends on the poco recipes, which provides both the header files and shared libraries. However, I cannot make use of the header files from poco in my recipe, which leads to the error Poco/Delegate.h: No such file for directory.
How do I make the header available at build time for my software package?
Here is an example recipe:
SUMMARY = ""
DESCRIPTION = ""
AUTHOR = ""
LICENSE = "CLOSED"
LIC_FILES_CHKSUM = ""
HOMEPAGE = ""
BUGTRACKER = ""
S = "${WORKDIR}"
SRC_URI = " file://foo.cpp \
file://CMakeLists.txt \
"
inherit pkgconfig cmake
DEPENDS_foo = "poco"
RDEPENDS_foo = "poco"
do_install() {
install -d ${D}/${bindir}
install -m 755 ${S}/foo ${D}/${bindir}
}
FILES_${PN} = "${bindir}/foo"
We can use provider and user to illustrate this case, the package (recipe) provides a header file to be used by another package (recipe) is the provider, the package (recipe) use a header file from another package (recipe) is the user.
First we change the provider's recipe (myprovider.bb) to export the header file -- myapi.h,
...
do_install() {
install -d ${D}/${bindir}
install -m 755 ${B}/hello_provider ${D}/${bindir}
install -d ${D}${libdir}/lib_myprovider/
install -m 0755 ${WORKDIR}/myapi.h ${STAGING_DIR_TARGET}${libdir}/lib_myprovider/
}
...
Secondly we change the user's recipe (myuser.bb) to refer the header file -- myapi.h
...
do_compile () {
${CC} ${WORKDIR}/main.c -o hello_user ${CFLAGS} ${LDFLAGS} -I${STAGING_DIR_TARGET}/${libdir}/lib_myprovider/
}
# file dependency declaration
FILES_${PN} = "${libdir}/lib_myprovider"
# package dependency declaration
DEPENDS += "myprovider"
...
At last, rebuild myprovider.bb and myuser.bb recipes, it should work.
Manual recommends:
Recipes should never populate the sysroot directly:
Recommended way is (poco recipe should do something similar):
Files should be installed into standard locations:
...
do_install() {
...
install -d ${D}${includedir}
install -m 0755 ${S}/myapi.h ${D}${includedir}/
...
}
...
Than, include poco recipe as a build dependency of foo.bb :
DEPENDS += "poco"
And compile normally.
You could use DEPENDS to have dependency with "poco" recipe and it would build and populate "poco" recipe's headers and libs into your recipe's sysroot.
Similar way you have to mention the export paths in the provider's recipe with FILES_*( * - package type)
I'm looking for a template recipe for enabling a systemd recipe in yocto. The executable is already installed by a recipe provided by yocto. The goal of this recipe is to provide make /usr/bin/btattach be run at startup.
As a start I created the following structure in my layer in the appropriate recipe directory:
btattach-systemd/
|-- files
| `-- btattach.service
`-- btattach-systemd.bb
The content of the recipe
SUMMARY = "Writes patterns to the fb device"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
inherit systemd
REQUIRED_DISTRO_FEATURES= "systemd"
SRC_URI = "file://btattach.service"
S = "${WORKDIR}"
do_install () {
install -m 0644 ${WORKDIR}/btattach.service.service ${D}${sysconfdir}/systemd/system
}
SYSTEMD_SERVICE_${PN} = "btattach.service"
Besides that, the IMAGE_INSTALL in the image recipe has been correctly extended with btattach-systemd.
bitbake btattach-systemd runns ok but when trying to build the complete image the at do_rootfs step for the whole image. with the error:
* opkg_solver_install: Cannot install package btattach-systemd.
Ideas on where the bug is?
I think the recipe should look like this (leaving out summary, license, license checksum, and assuming that the binary package is called "btattach"):
SRC_URI = "file://btattach.service"
SYSTEMD_SERVICE_${PN} = "btattach.service"
inherit systemd
do_install_append() {
install -d ${D}${systemd_unitdir}/system
for service in ${SYSTEMD_SERVICE_${PN}}; do
install -m 0644 ${WORKDIR}/${service} ${D}${systemd_unitdir}/system/
sed -i -e 's,#BINDIR#,${bindir},g' ${D}${systemd_unitdir}/system/${service}
done
}
RDEPENDS_${PN} = "btattach"
I am sorry for not commenting your question as I have no reputation for that. Also, LetoThe2nd answer is more complete than mine, but here follows a possible quick fix:
It seems to me you are installing 'btattach.service.service' instead of 'btattach.service'.
Assuming that the .service file is correct, my take on the Yocto recipe and why it might be failing is because that the btattach.service file isn't included with the installation which is what the final line does below.
Have you ensured that you do a bitbake btattach.systemd -c cleanall and bitbake btattach.systemd -c cleanstate beforehand as well, as I noticed you had a typo in the Yocto recipe as btattach.service.service.
SUMMARY = "Writes patterns to the fb device"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
inherit systemd
REQUIRED_DISTRO_FEATURES= "systemd"
SRC_URI = "file://btattach.service"
S = "${WORKDIR}"
do_install () {
install -m 0644 ${WORKDIR}/btattach.service ${D}${sysconfdir}/systemd/system
}
SYSTEMD_SERVICE_${PN} = "btattach.service"
FILES_${PN} += "/lib/systemd/system/btattach.service"
I need to install a native script, call it foo, in one recipe (foo-native) and then use it in the do_compile step of another (target) recipe - call it bar.
My (minimal) native recipe
SRC_URI = "file://foo"
LICENSE = "CLOSED"
inherit native
BBCLASSEXTEND = "native"
S = "${WORKDIR}"
do_compile() {
:
}
do_install() {
install -d ${D}/usr/bin
install ${WORKDIR}/foo ${D}/usr/bin
}
The script, foo, exists in a directory called files which resides next to the recipe. i.e.
foo/
├── files
│ └── foo
└── foo.bb
My target recipe for bar
SRC_URI = ""
LICENSE = "CLOSED"
DEPENDS = "foo-native"
do_fetch[noexec] = "1"
do_configure[noexec] = "1"
do_compile() {
foo >myfile.json
}
do_install() {
install -d ${D}/etc
install ${WORKDIR}/myfile.json ${D}/etc
}
The error I get is in the do_compile task of bar, and it simply says that foo can not be found (i.e. has not been installed into a directory on the path).
First, you don't need the line
inherit native
in foo.bb. It's taken care of for you by BBCLASSEXTEND = "native".
Secondly, change your do_install to:
do_install() {
install -d ${D}${bindir}
install ${WORKDIR}/foo ${D}${bindir}
}
Note: use ${bindir} instead of /usr/bin. ${bindir} is determined using ${prefix}, which in turn is changed e.g. when building a -native version of a recipe.