Use middle ouput (json file) from another recipe (another git repo) for a yocto build, is it possible? - yocto

Git repo A, requires the generated file (middle output of a json file m.json, doesn't require the full build of B) from another repo B.
A.bb:
DEPENDS="\
B \ #should B be added as a dependency here?
"
RDEPENDS_${PN} = " \
B \ # If I add B here, bitbake B will be run before bitbake A, is it right?
"
SRC_URI="git://git#A.git;name=A \
git://git#B.git;name=B \
"
SRCREV_A="${AUTOREV}
SRCREV_B="${AUTOREV}"
do_configure()
{
pushd ${S}/B
generated-middle-output-json-file.sh
popd
pushd ${S}/A
use-json.sh
popd
}
Is this the correct way to write this recipe?
Looking for any suggestions, I'm new to yocto build.
Thanks.

The correct thing to do would be to add a DEPENDS on B. In the B recipe you'd install the file into the sysroot as part of the do_install step and then you'd access if from the sysroot in A. The sysroot is used as a place to share output between recipes.

Related

How bitbake searches for recipe in build process?

I am trying to find out that how bitbake search for recipe in build process ?
For example,
I have a recipe something like below:
DESCRIPTION = "PetaLinux GSTREAMER supported packages"
inherit packagegroup
GSTREAMER_PACKAGES = " \
gstreamer1.0 \
gstreamer1.0-python \
gstreamer1.0-meta-base \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-rtsp-server \
gst-shark \
gstd \
gst-perf \
gst-interpipes \
"
GSTREAMER_PACKAGES_append_zynqmp = " gstreamer1.0-omx"
RDEPENDS_${PN} = "${GSTREAMER_PACKAGES}"
When I searched gstreamer1.0 related recipe in yocto layers, I found two recipe, one of them is gstreamer1.0_1.16.1.bb in meta layer, and the other is gstreamer1.0_%.bbappend in meta-petalinux layer.
Both of these layers was added to the BBLAYERS in bblayers.conf file and the priorities that spesified with BBFILE_PRIORITY_* in related layer's layer.conf file is same.
So,
Which recipe will be used in build process in that case ?
What is the recipe lookup rules in yocto ?
I changed somethings to understand the behaviour:
For example,
I entered the invalid github URL that spesified in gstreamer1.0_%.bbappend recipe. When I tried to build the linux system, I encountered with an error. Thats fine.
Then I corrected the github URL in this recipe and entered invalid source code address that spesified in gstreamer1.0_1.16.1.bb recipe. When I tried to build linux system, process finished successfully.
Then I increased the priority of meta layer. I supposed to encounter with an error in this case but again build process finished successfully.
Could you please help me to understand this behaviour ?
Thanks.
You have two different files: a .bb and a .bbappend.
A .bb is the base recipe of one (or multiple) packages. It generally describe how to fetch, configure, compile, install files in a package for your target.
A .bbappend file is an 'append' file. It allows a meta (here meta-petalinux) to modify an existing recipe in another meta without copying it. A .bbappend can modify any steps of the bb file: source fetch, configure, compile, install...
You can for example create your own bbappend of Gstreamer, to enable pango (disbaled by default on my Yocto). The bbappend filename is gstreamer1.0-plugins-base_%.bbappend and only contains PACKAGECONFIG_append = "pango"
The Yocto Manual can give you more information on bbappend files here.

Create a recipe for a QT5 application

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

About the wrong URI in tcf-agent_git.bb in Poky

I'm a new hand and try to build a xilinx by pocto.
As the guide, I cloned repositories (branch thud), source oe-... and change MACHINE="zedborad-zynq7", then bitbake petalinux-image-minimal, but I get following error:
ERROR: tcf-agent-1.7.0+gitAUTOINC+dad3a6f568-r0 do_fetch: Fetcher
failure: Fetch command ...
https://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git
refs/:refs/ failed with exit code 128, output: fatal: repository
'https://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git/' not
found ... ERROR: Task
(~/poky/meta/recipes-devtools/tcf-agent/tcf-agent_git.bb:do_fetch)
failed with exit code '1'
The issue is that the statement in tcf-agent_git.bb:
SRC_URI = "git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent \
It is NOT the wrong address, In fact, I can clone successfully with this address. On the other hand, any my modify on this variable will NOT work either.
I already grep -rn "eclipse.org", but only find this file.
Any recommendation will be welcome.
Thanks lot.
——————————————————————————
I can't resolve this issue finally.
I find that the builder does NOT fetch from the address the SRC_URL offer at all, instead, it fetches from a mirror given somewhere.
As a test, I edited the .bb file, add PREMIRRORS="" and MIRROS="", and add protocal=git statement for the SRC_URI. The statements are effective realy, the builder fetches from the SRC_URL address, but the protocol is still HTTPS, the function still fails.
My solution is cloning the source manually, and putting it to corresponding directory, in order to let the builder know this, I also touch a package_name.done and chmod 777 in the same directory, then I can continue.
I've run into the exact same issue using Xilinx Yocto stack (rel-v2018.3 branch). For me, the problem wasn't in the tcf-agent_git.bb recipe in core/meta/recipes-devtools/tcf-agent, but in the tcf-agent_%.bbappend file in meta-petalinux/recipes-devtools/tcf-agent. In there, I replaced
SRC_URI = " \
git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git;branch=master;protocol=https \
file://fix_ranlib.patch;striplevel=2 \
file://ldflags.patch \
file://tcf-agent.init \
file://tcf-agent.service \
"
with
SRC_URI = " \
git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git;branch=master \
file://fix_ranlib.patch;striplevel=2 \
file://ldflags.patch \
file://tcf-agent.init \
file://tcf-agent.service \
"
and it finishes building correctly.
The former used to work fine last time I built the image (a few months ago) but for some reason the protocol=https option makes it fail now.
Your SRC_URI seems wrong.
it should be
SRC_URI = "git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git \
This one is working perfect for me.
Note : The back slash () at the end means you have multiple line SRC_URI. correct it if you have only single line.
In December 2021, using branch rel-v2020.1, I needed to change the line into :
SRC_URI = "git://git.eclipse.org/r/tcf/org.eclipse.tcf.agent.git;protocol=https \

Yocto recipes not found

I'm learning Yocto and to try it I'm following a very detailed example.
When I try to build the image (qt5.image) it returns a couple of errors after parsing recipes:
$bitbake qt5-image
...
ERROR: No recipes available for:
/home/dev/yocto/poky/meta-raspberrypi/recipes-bsp/u-boot/u-boot_2019.07.bbappend
/home/dev/yocto/poky/meta-raspberrypi/recipes-multimedia/gstreamer/gstreamer1.0-omx_1.16%.bbappend
The error is pretty clear, but because those meta- are not mine, but downloaded from the official repository git://git.yoctoproject.org/meta-raspberrypi I'm not sure why this error may happen.
Is there something I can fix by myself?
UPDATE:
Here the content of bblayer.conf I've adjusted the paths but it's the same file of the example linked above:
$ cat conf/bblayers.conf
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
${HOME}/yocto/poky/meta \
${HOME}/yocto/poky/meta-poky \
${HOME}/yocto/poky/meta-openembedded/meta-oe \
${HOME}/yocto/poky/meta-openembedded/meta-multimedia \
${HOME}/yocto/poky/meta-openembedded/meta-networking \
${HOME}/yocto/poky/meta-openembedded/meta-perl \
${HOME}/yocto/poky/meta-openembedded/meta-python \
${HOME}/yocto/poky/meta-qt5 \
${HOME}/yocto/poky/meta-raspberrypi \
${HOME}/rpi/meta-rpi \
"
What the error message is telling you is that meta-raspberrypi layer is trying to modify recipes that it expects to exist in another layer. In this case the u-boot and gstreamer1.0-omx recipes come from "meta" (so the yocto/openembedded main layer).
You should check that your layers are all using the same branches (and are all up-to-date). I'm guessing that your meta layer (typically from poky git) is on some release branch and your meta-raspberrypi is using master. In that case the build would fail like yours does (e.g. gstreamer1.0-omx would be version 1.14.4 and the bbappend would look for another version).
I had the same issue, what I did is to checkout meta-raspberrypi with branch corresponding to the poky branch:
git clone -b warrior git://git.yoctoproject.org/poky
cd poky
git clone -b warrior git://git.yoctoproject.org/meta-raspberrypi
source oe-init-build-env
Add layer to conf/bblayers.conf
Change MACHINE in conf/local.conf
bitbake rpi-basic-image
Can you make sure 'meta-raspberrypi' is included in bblayers.conf file. You can check this layer included in
build-*/conf/bblayers.conf
If it is not included, add this layer into bbpath in bblayers.conf and rebuild it.
If it's still available could you please send the complete logs for the error?

Yocto: Install different config files based on MACHINE type or target image

I've got a couple of HW platforms (same cpu, etc.) that require different asound.conf files.
The way that I'm controlling the target platform is via the MACHINE variable and target image (i.e., MACHINE=machine_1 nice bitbake machine-1-bringup-image)
Normally, if just replacing the conf file I'd just create an alsa-state.bbappend and create a do_install_append function to replace it.
However since the different HW platforms require differ conf files I'm unsure how to handle it.
I've tried putting some logic into the append file do_install_append function but it's not working out. It's not always picking up the correct file (like it thinks that nothing has changed so that it uses the previous cached conf?)
Here's an example of one of the append files that I've tried:
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI += " \ file://asound_MACHINE1.conf \
file://asound_MACHINE2.conf \ "
do_install_append() {
echo " alsa-state.bbappend MACHINE: ${MACHINE}"
if [ "${MACHINE}" = "machine_1" ]; then
echo " machine_1"
echo " installing ${WORKDIR}/asound_MACHINE1.conf to ${D}${sysconfdir}/asound.conf"
install -m 644 ${WORKDIR}/asound_MACHINE1.conf {D}${sysconfdir}/asound.conf
else
echo " installing ${WORKDIR}/asound_MACHINE2.conf to ${D}${sysconfdir}/asound.conf"
install -m 644 ${WORKDIR}/asound_MACHINE2.conf ${D}${sysconfdir}/asound.conf
fi
}
I can see the correct echoes in the logs per the logic.
At any rate I don't think that the path I'm going down is the best way to deal with this.
Is there a 'standard' way to have different files installed based on either the target image or MACHINE variable?
do_install_append () {
// install common things here
}
do_install_append_machine-1 () {
// install machine-1 specific things here
}
do_install_append_machine-2 () {
// install machine-2 specific things here
}
The value of MACHINE is automatically added to OVERRIDES, which can be used at the end of a function append to have a MACHINE-specific addition to a function.
Maybe useful: https://www.yoctoproject.org/docs/2.4/mega-manual/mega-manual.html#var-OVERRIDES
You can have configuration files in machine specific directories in your particular case (just a specific configuration file for each machine). OpenEmbedded will fetch the most specific one. The directory structure in your recipe directory will look like:
files/<machine1>/asound.conf
files/<machine2>/asound.conf
And your alsa-state.bbappend will contain just one line (you don't need to change do_install because alsa-state.bb already installs asound.conf):
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
BTW: We are using that setup to have specific asound.state file per machine in our project.
Moreover, OpenEmbedded will detect that SRC_URI contains machine specific file and change the PACKAGE_ARCH accordingly, see: https://www.yoctoproject.org/docs/2.5/mega-manual/mega-manual.html#var-SRC_URI_OVERRIDES_PACKAGE_ARCH
Few more words on machine, distro or arch specific files: OE is trying to fetch the most specific file in file:// fetcher. It searches also in the directories named by distro (e.g files/<distro>/asound.conf) and architecture (e.g. armv7a, arm). It might be useful if you want to have file specific for some set of devices. More information: https://www.yoctoproject.org/docs/2.5/mega-manual/mega-manual.html#var-FILESOVERRIDES and also https://www.yoctoproject.org/docs/2.5/mega-manual/mega-manual.html#best-practices-to-follow-when-creating-layers (section "Place Machine-Specific Files in Machine-Specific Locations")
The above answer by clsulliv worked better than advertised. For future reference below is the append file I used:
FILESEXTRAPATHS_prepend:= "${THISDIR}/${PN}:"
SRC_URI += " \
file://machine1_asound.conf \
file://machine2_asound.conf \
"
do_install_append_machine1() {
echo " machine1"
echo " installing ${WORKDIR}/machine1_asound.conf to ${D}${sysconfdir}/asound.conf"
install -m 644 ${WORKDIR}/machine1_asound.conf ${D}${sysconfdir}/asound.conf
}
do_install_append_machine2() {
echo " machine2"
echo " installing ${WORKDIR}/machine2_asound.conf to ${D}${sysconfdir}/asound.conf"
install -m 644 ${WORKDIR}/machine2_asound.conf ${D}${sysconfdir}/asound.conf
}
Thanks for the help!