Installing library into yocto rootfs - yocto

I am working on yocto i have compiled a library using yocto, which installed library inside
/tmp/work/corei7-64-poky-linux/lib-ad/git-r0/package/usr/lib/libad.a
Now inside my recipe i have included
FILES_${PN} += " \
libad.a \
"
Now this is adding this file into build-corei7-64/tmp/sysroots/corei7-64/usr/lib/libad.a
but not into final rootfs, I assume FILES_${PN} will copy my files into rootfs.
but this is not happening.
Any help is appreciated, Thank You

Well, up to now you managed to build and package your code correctly.
I guess you mean with rootfs the image that you build. To add a package to an image you can set IMAGE_INSTALL_append = "lib-ad" within your local conf

Related

How to install tar.gz package to Yocto by adding new layer?

I new to Yocto so there are probably some mistakes and misunderstanding that I've had, I appreciate if you can help.
So, I want to add a new package (tar file) to my custom image.
I have followed steps and steps in manual and some online instructions. While running: "bitbake mylayer", the layer is built fine but I got this error while building the image, here is the log file:
DEBUG: Executing python function rootfs_deb_bad_recommendations
DEBUG: Python function rootfs_deb_bad_recommendations finished
DEBUG: Executing python function extend_recipe_sysroot
NOTE: Installed into sysroot: []
NOTE: Skipping as already exists in sysroot: ['depmodwrapper-cross', 'apt-native', 'dpkg-native', 'pseudo-native', 'update-rc.d-native', 'prelink-native', 'makedevs-native', 'ldconfig-native', 'opkg-util$
DEBUG: Python function extend_recipe_sysroot finished
DEBUG: Executing python function do_rootfs
NOTE: ###### Generate rootfs #######
NOTE: Installing the following packages: apt busybox copy-uefiimg-to-sda coreutils dpkg e2fsprogs-resize2fs libfontconfig1 libfreetype6 libglib-2.0-0 gptfdisk libjemalloc2 kernel-module-axi-dma-sensor ku$
ERROR: Unable to install packages.
Reading package lists...
Building dependency tree...
Reading state information...
Package mypackage is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'mylayer' has no installation candidate
DEBUG: Python function do_rootfs finished
ERROR: Function failed: do_rootfs
And here is mylayer.bb:
SUMMARY = ""
LICENSE = "CLOSE"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += "file://mypackage.tar"
Also, I have included the package in conf/local.conf:
IMAGE_INSTALL_append += " mylayer"
So beside trying to figure out how to solve this problem, I also have some questions:
I have read some example of .bb, and they mentioned about LIC_FILES_CHKSUM. The mypackage.tar.gz is a package to install a platform for the device and I don't know much about the source code, so I don't know if it is necessary to include the license? Or how to know that this package need license to install?
In some answer I found online, there is one saying that I need to include PACKAGE_CLASSES ?= "package_deb" (they want to install the .deb file), so probably in my case I will need PACKAGE_CLASSES ?= "package.tar" right? I have tried to change variable, but it still not successful.
The mypackage.tar includes some deb files. If I could not install mypackage.tar, can I instead install these .deb files? Can I put it all in mylayer.bb?
Thank you in advanced, I have tried to study much documents as I could but I get so confused and there is huge amount of information to digest.
First, before answering your questions
Let me mention some best practices advice for you:
Rename the recipe to some significant name related to you compressed package.
Naming the recipe to mylayer confuses Yocto users, because there is the term layer also.
Regarding you recipe:
There is no need for FILESEXTRAPATHS because the recipe path is added automatically to Yocto paths.
FILESEXTRAPATHS it is required for .bbappend files.
You need to override the do_install task function, it does nothing by default.
do_install is the first essential task to make sure that your sources are included in the final image.
Beside that, when specifying a compressed source file into SRC_URI, yocto automatically decompresses it.
This is mentioned here.
So, here what your recipe should look like:
SUMMARY = ""
LICENSE = "CLOSED"
# Prevent Yocto from decompressing the file
SRC_URI = "file://mypackage.tar;unpack=0"
do_install(){
# Create the opt folder into the final image, ${D} is ${WORKDIR}/image
install -d ${D}/opt
# Copy the compressed file there; You can change permissions as you want
install -m 0755 ${WORKDIR}/mypackage.tar ${D}/opt
}
# Very important to specify what you installed in (do_install)
FILES_${PN} = "/opt/*"
Now, when you run IMAGE_INSTALL_append += " mylayer" your file will be installed.
Regarding your questions:
You mentioned that your compressed file contains .deb files, I assume that no license checksum is needed. Also, I understand that you may wanted to point to SRC_URI[md5sum] or other checksums for the full package. That is also not needed for local files, it is used to check for the integrity of online sources.
PACKAGE_CLASSES as mentioned here, is used by the system to know in what type the data should be packaged. By the data I mean the data that you installed with do_install. That data get packaged for according to your PACKAGE_CLASSES variable, for example, to deb file. And that is used, along side with all other recipes packages, to build the final rootfs.
Yes, if you are installing the tar file into the image and then unpack it to install all deb files, for example, with dpkg. You can use the bin_package class to do that, now the recipe must be changed for that reason:
Decompress the tar file and provide the deb files in the local files folder.
Add all deb files to SRC_URI
Inherit the bin_package class
Specify the files to be packaged.
Your recipe should look like this:
SUMMARY = ""
LICENSE = "CLOSED"
SRC_URI = "file://deb_file1.deb \
file://deb_file2.deb"
# No need to `do_install` , it is invoked by the (bin_package) class
FILES_${PN} = ""
Important:
About FILES_${PN}, you need to add all what the deb installed into the image folder
Example, if your deb file installs this:
/usr/bin/hello
/etc/hello.cfg
Specify them:
FILES_${PN} = "/usr/bin/*"
FILES_${PN} += "/etc/*"
Use * so if other deb files install files into the same folder as others it will include all.

Adding a lib to yocto rootfs

I am using this recipe, which by default doesn't copy the resulting .a lib (it expects header only usage I think)
I am trying to get the resultant libspdlog.a into my sysroot, but I can't seem to make that happen. I coppied the recipe to my layer (had to anyway because my project refereces an older version of meta-oe)
So far i've tried:
FILES_${PN} += "${libdir}/libspdlog.a"
FILES_${PN}-dev += "${libdir}/libspdlog.a"
FILES_${PN}-staticdev += "${libdir}/libspdlog.a"
and
do_install() {
install -d ${D}${libdir}
install -m 0644 libspdlog.a ${D}${libdir}
}
I'm pretty sure do_install is not getting called.
I had to add to my IMAGE_INSTALL spd-dev so maybe this has something to do with it
Thanks
do_install is right and for now just have FILES_${PN} += "${libdir}/libspdlog.a".
If you have kept the same name of the recipe when you copied over you will need to add the following IMAGE_INSTALL_append = " spdlog" (in either local.conf or an image recipe if you have one) to put into image.
To verify do_install is working ok:
Inside your build folder (where you issue bitbake from) there will be tmp/work (if you haven't changed this in your local.conf)
Find the location of your recipe folder <recipe_name>/<recipe_version> (eg. spdlog/1.8.0-r0/)
Inside here there will be a packages-split/spdlog folder
Inside this you should see your structure usr/lib/libspdlog.a

How to include irdadump into Yocto (Poky) irda-utils 0.9.18 package

Please excuse my lack of knowledge and incorrect use of terminology. I
am looking to include irdadump in my build image within Yocto.
I modified the
/poky/meta/recipes-connectivity/irda-utils/irda-utils_0.9.18.bb file to
include irdadump in the list of targets to be built.
INITSCRIPT_NAME = "irattach"
INITSCRIPT_PARAMS = "defaults 20"
TARGETS ??= "irattach irdaping irdadump"
do_compile () {
for t in ${TARGETS}; do
oe_runmake -C $t
done
}
However the bitbake process fails which comes down to the dependency of
pkg-config and glib 2.0 required for idradump.
I did a quick search online and noticed that there was a separate .bb
file for irdadump:
http://cgit.openembedded.org/openembedded/plain/recipes/irda-utils/
I tried to replicate this however was still faced with compiling issues.
Could anyone give me a helping hand on including irdadump to my
irda-utils package?
Thank you
To add irda-utils to your build image, just add IMAGE_INSTALL_append in your conf/local.conf file.Next time when you will run Bitbake,it will include irda-utlis package in your build image.
IMAGE_INSTALL_append = " irda-utils"

Adding new recipe to Yocto fails during generate root fs

I have been using Yocto to create Linux builds for an ARM board.
I had been cross compiling add on applications manually. Now we are in a place where we would like a nice integrated build so I started adding custom recipes to yocto.
I have been struggling with the ARM build (a x86 build with the same code seems fine).
Even a basic 'hello world' pretty much cut and paste from the development manual does not work (http://www.yoctoproject.org/docs/current/dev-manual/dev-manual.html#new-recipe-writing-a-new-recipe)
Here is the recipe:
SUMMARY = "Simple helloworld application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
RPROVIDES_${PN} = "helloworld"
FILES_${PN} += "${bindir}"
SRC_URI = "file://helloworld.c"
S = "${WORKDIR}"
do_compile() {
${CC} helloworld.c -o helloworld ${LDFLAGS}
}
do_install() {
install -d ${D}${bindir}
install -m 0755 helloworld ${D}${bindir}
}
Here is the error:
ERROR: helloworld not found in the base feeds (smarc_samx6i cortexa9t2hf-vfp-neon-mx6qdl cortexa9hf-vfp-neon-mx6qdl cortexa9t2hf-vfp-neon cortexa9t2hf-vfp cortexa9hf-vfp-neon cortexa9hf-vfp armv7at2hf-vfp-neon armv7ahf-vfp-neon armv7at2hf-vfp armv7ahf-vfp armv6thf-vfp armv6hf-vfp armv5tehf-vfp armv5ehf-vfp armv5thf-vfp armv5hf-vfp noarch any all).
ERROR: Function failed: do_rootfs
Any suggestions as to what would be causing this error?
The package does build properly; the problem seems to be isolated to finding it for the rootfs.
Thanks!
EDIT:
I have a solution that seems to work, although it is not ideal long term.
Changing the package name under IMAGE_INSTALL from helloworld to helloworld-0.0.1 resolves the issue. Obviously I would rather not hard code the version of each package in the top level recipe and other packages do not require this, so hopefully there is another solution.
EDIT 2:
Renaming the recipe and removing the version string also resolves the issue. Once again, this does not seem ideal long term.
OK, after some further testing I discovered this was a naming issue with the recipe.
It was named helloworld-0.0.1.bb (the same format with the other recipes I had put together driving me to try this simple test).
If anyone else encounters this simply replacing the '-' with a '_' resolves this.
1.Rename your recipe name e.g hello-0.1.bb to hello_0.1.bb
2.Add below line at last only:
FILES_${PN} = "${bindir}/*"
Abvoe line helps you copy your binary to rootfs.

Compile rygel for yocto with plugins

I'm using bitbake to compile rygel for yocto from the meta-openembedded layer, with the plugins mpris and gst-launch.
As per the PACKAGECONFIG docs, I created a bbappend file and added the following:
EXTRA_OECONF = "--disable-introspection \
--disable-tracker-plugin \
--with-media-engine=gstreamer \
--enable-mpris-plugin \
--enable-gst-launch-plugin"
PR = "r1"
It compiles and installs, but has no plugins.
The append shows up when I run bitbake-layers show-appends, so at least bitbake is finding it. After running bitbake the directory tmp/work/core2-64-poky-linux/rygel/0.26.1-r1/image/usr/lib/rygel-2.6/plugins/ is populated. Then when I run the image /usr/lib/rygel-2.6/ contains an engines dir and nothing else.
Any idea where I'm going wrong?
I don't think your read all the way down to "If you want to change an existing PACKAGECONFIG block, you can do so one of two ways:".
From a bbappend, just do
PACKAGECONFIG_append = " mpris gst-launch"
In the recipe do_install, they remove some of the engines and plugins files. This might be the reason you do not see them in your image.
do_install_append() {
# Remove .la files for loadable modules
rm -f ${D}/${libdir}/rygel-${LIBV}/engines/*.la
rm -f ${D}/${libdir}/rygel-${LIBV}/plugins/*.la
}
your compiling plugins successfully and not able to see in board(rootfs)? if yes please add below line in your .bbappend file. '
FILES_${PN} += "${libdir}/*"
this will add all your compiled plugins to your rootfs image.