Bitbake fails on do_package_qa error? - embedded-linux

I am trying to write my own custom recipe. I am using Yocto Project with Bitbake.
The following package when given bitbake apriltags commands does the following and throws error at do_package
It successfully does the following tasks:
do_fetch
unpack
do_compile
and then fails at do_package
In my /yocto/build/tmp/work/armv7a-vfp-neon-poky-linux-gnueabi/apriltags/0.1-r4/git/build/lib there is a pkgconfig.pc and libapriltags.a which is causing the error.
My package recipe:
DESCRIPTION = "Apriltags application"
SECTION = "examples"
LICENSE = "CLOSED"
PR = "r3"
DEPENDS = "opencv"
SRC_URI = "git://github.com/zafrullahsyed/apriltags.git;protocol=https;tag=v0.1"
S = "${WORKDIR}/git"
inherit pkgconfig autotools
do_install() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/git/build/bin/apriltags_demo ${D}${bindir}
}
My error as follows:
ERROR: QA Issue: package apriltags contains bad RPATH /home/zaif/yocto/build/tmp/work/armv7a-vfp-neon-poky-linux-gnueabi/apriltags/0.1-r3/git/build/lib in file /home/zaif/yocto/build/tmp/work/armv7a-vfp-neon-poky-linux-gnueabi/apriltags/0.1-r3/packages-split/apriltags/usr/bin/apriltags_demo
ERROR: QA run found fatal errors. Please consider fixing them.
ERROR: Function failed: do_package_qa
ERROR: Logfile of failure stored in: /home/zaif/yocto/build/tmp/work/armv7a-vfp-neon-poky-linux-gnueabi/apriltags/0.1-r3/temp/log.do_package.21621
ERROR: Task 10 (/home/zaif/yocto/poky/meta-bebot/recipes-bebot/apriltags/apriltags_0.1.bb, do_package) failed with exit code '1'

The Apriltags has dependencies which need to be modified according to the machine you are working on.
You need to have the values of the requires, Libs and Cflags accordingly. Also verify whether you need the python pod packages or not.

My package Apriltags has bad dependencies that are according to PC in AprilTags/cmake/pods.cmake such as Eigen3(default), whereas for OE eigen3 package is libeigen. Hard coded the requires, Libs and Cflags and also removed python pod packages which are not required.
pods.cmake:
"Name: ${pc_name}\n"
"Description: ${pc_description}\n"
"Requires: ${libeigen}\n"
# "Version: ${pc_version}\n"
"Libs: -L\${bindir} ${pc_libs}\n"
"Cflags: -I\${bindir} ${pc_cflags}\n")
My recipe is as follows:
DESCRIPTION = "Apriltags application"
SECTION = "examples"
LICENSE = "CLOSED"
PR = "r5"
DEPENDS = "opencv"
SRC_URI = "git://github.com/zafrullahsyed/apriltags.git;protocol=https;tag=v0.3"
S = "${WORKDIR}/git"
inherit pkgconfig autotools
do_install() {
install -d ${D}${bindir}
install -m 0755 ${WORKDIR}/git/build/bin/apriltags_demo ${D}${bindir}
}

Related

Linker script fails in Yocto build

I am trying to use Bitbake tool for the cross-compilation of a Git project from x86 architecture to aarm64 architecture, but I am getting ld errors during the do_compile stage. I already checked d/tmp/work/aarch64-xilinx-linux/commandlinetool/1.0+gitAUTOINC+ce84868f3c-r0/recipe-sysroot/ and those missing files are actually exist! I don't know why bitbake complains about missing files. I also tried to add related paths to my custom recipe using FILES_${PN} = "" but this didn't help.
Also, I have glibc as a dependency in my recipe but this doesn't help:
# dependencies DEPENDS += "glibc" RDEPENDS_${PN} = "glibc"
Errors I am getting are as the following:
| ~/bin/build/tmp/work/aarch64-xilinx-linux/commandlinetool/1.0+gitAUTOINC+ce84868f3c-r0/recipe-sysroot-native/usr/bin/aarch64-xilinx-linux/../../libexec/aarch64-xilinx-linux/gcc/aarch64-xilinx-linux/9.2.0/ld: cannot find /lib/libc.so.6
| ~/bin/build/tmp/work/aarch64-xilinx-linux/commandlinetool/1.0+gitAUTOINC+ce84868f3c-r0/recipe-sysroot-native/usr/bin/aarch64-xilinx-linux/../../libexec/aarch64-xilinx-linux/gcc/aarch64-xilinx-linux/9.2.0/ld: cannot find /usr/lib/libc_nonshared.a
| ~/bin/build/tmp/work/aarch64-xilinx-linux/commandlinetool/1.0+gitAUTOINC+ce84868f3c-r0/recipe-sysroot-native/usr/bin/aarch64-xilinx-linux/../../libexec/aarch64-xilinx-linux/gcc/aarch64-xilinx-linux/9.2.0/ld: cannot find /lib/ld-linux-aarch64.so.1
Edit: Here is the recipe I am using. It depends on another Git project named "deviceaccess" (which my recipe for that project cross-compiled successfully):
LICENSE = "GPLv3 & Unknown"
LIC_FILES_CHKSUM = "file://LICENSE;md5=84dcc94da3adb52b53ae4fa38fe49e5d \
file://cmake/debian_package_templates/copyright;md5=0630bd8af87d19e6a57f9d1f9c5cf11f"
SRC_URI = "git://github.com/ChimeraTK/CommandLineTools.git;protocol=https"
# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "ce84868f3c86f3f0790772a31fb5202a14f38fb8"
S = "${WORKDIR}/git"
# dependencies
DEPENDS += "glibc deviceaccess"
RDEPENDS_${PN} = "glibc deviceaccess"
# cmake
inherit pkgconfig cmake
FILES_${PN} = ""
# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
EXTRA_OEMAKE = ""

How do you properly build gpiod applications from Yocto?

I am trying to incorporate a CPLD programming utility on Github available at https://github.com/kontron/altera-stapl into my Yocto build but am getting undefined references to gpiod functions. I have that it depends on libgpiod in my recipe. Am I specifying the dependency correctly?
Here is my recipe:
SUMMARY = "CPLD STAPL Programming"
DESCRIPTION = "A userspace port of the Altera Jam STAPL Bytecode Player."
MAINTAINER = "Michael Walle <michael.walle#kontron.com>"
HOMEPAGE = "https://github.com/kontron/altera-stapl"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=4641e94ec96f98fabc56ff9cc48be14b"
SRC_URI = "git://github.com/kontron/altera-stapl.git"
SRCREV = "71540fb3dccf57ea0e43cef77d628244de402152"
SRC_URI[sha256sum] = "DCF8A052CD7908F484EAEE8A1924809056611E68EA28652E17C021BE836FAA6C"
DEPENDS = "libgpiod"
S="${WORKDIR}/git"
do_install () {
install -d ${D}${bindir}
install -m 0755 altera-stapl ${D}${bindir}
}
These are the linker errors I am getting (there are a lot of them, not just this one, I can post the whole log if needed)
gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/ld: altera-gpio.c:(.text+0x3f4): undefined reference to `gpiod_line_request_output'
/home/gen-ccm-root/workdir/tools/poky/build-dev/tmp/work/armv7at2hf-neon-poky-linux-gnueabi/altera-stapl/1.0-r0/recipe-sysroot-native/usr/bin/arm-poky-linux-gnueabi/../../libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/9.2.0/ld: altera-gpio.o: in function `close_jtag_hardware':
altera-gpio.c:(.text+0x4da): undefined reference to `gpiod_line_release'
collect2: error: ld returned 1 exit status
Makefile:31: recipe for target 'altera-stapl' failed
What is the correct way to set the dependency?
Update: I am running Yocto Zeus on Ubuntu 18.04 (my GCC is 7.4.0).
Turns out this issue was in the Makefile that was part of the GitHub project, and was actually fixed in a recent version. In case anyone else ever wants to use this project, the final recipe is as follows (just update the SRCREV if newer versions are release):
SUMMARY = "CPLD STAPL Programming"
DESCRIPTION = "A userspace port of the Altera Jam STAPL Bytecode Player."
HOMEPAGE = "https://github.com/kontron/altera-stapl"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=4641e94ec96f98fabc56ff9cc48be14b"
SRC_URI = "git://github.com/kontron/altera-stapl.git"
SRCREV = "852ff9d13cc06fef7d207abe12cc19ea5b67a16b"
DEPENDS = "libgpiod"
S="${WORKDIR}/git"
do_install () {
install -d ${D}${bindir}
install -m 0755 altera-stapl ${D}${bindir}
}

How to bitbake copy a prebuilt static library into the sdk

Scenario:
I am working with yocto linux recipes. I am trying to make a recipe which simply copies a prebuilt MyLibrary.a and its headers available on the built linux image. So, I have a libMyLibrary.a which I want to copy to /usr/lib. And MyLibrary's headers files MyLibrary.h and MyLibrary.hpp into /usr/include. Note that MyLibrary is already built and I just want to copy the binary and headers into desired locations of the built linux image.
So following is the recipe:
SUMMARY = "Script to make a static library available in yocto linux image"
LICENSE = "CLOSED"
FILES_${PN} += "${libdir}"
SRC_URI = "file://libMyLibrary.a \
file://MyLibrary..hpp \
file://MyLibrary..h \
"
S = "${WORKDIR}"
do_install () {
install -d ${D}${libdir}
install -d ${D}${includedir}
install -m 0644 ${WORKDIR}/libMyLibrary.a ${D}${libdir}/
install -m 0644 ${WORKDIR}/MyLibrary.h ${D}${includedir}/
install -m 0644 ${WORKDIR}/MyLibrary.hpp ${D}${includedir}/
}
Initially I started with getting some errors in the do_install step. I resolved them but now the do_rootfs step is complaining about my bb file that is mylibrary_1.0.bb. I am pretty sure that the parent recipe that calls my recipe has no errors since it builds a lot of other recipes and mine is just additional to it. Also, the errors started to appear after I wrote the do_install step.
Question
Can someone point out what is wrong with my recipe above?
Or is there a simple example recipe which copies a .a and its headers into the desired location i.e. /usr/lib and /usr/include like I am doing above?
Explaining what the errors are would be useful. Note that because your recipe only ships a static library and headers it won't generate a mylibrary package, which is probably what the errors are about.

"File format not recognized" when building Petalinux app

I am using Petalinux 2017.2 and the included tools to build a Linux image for a Zynq ZC702 board. I am trying to add a pre-compiled executable to my rootfs with a bitbake recipe.
SUMMARY = "Demo on ARM-Linux"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = " \
file://Demo1.out \
"
FILES_${PN} = " \
/home/root/Demo/ \
/home/root/Demo/Demo1.out \
"
S = "${WORKDIR}"
do_install() {
install -d ${D}/home/root/Demo
install -m 0755 ${S}/Demo1.out ${D}/home/root/Demo
}
When I attempt to build the rootfs with my app included I get this error:
ERROR: demo-1.0-r0 do_package: objcopy failed with exit code 1 (cmd was 'arm-xilinx-linux-gnueabi-objcopy' --only-keep-debug '/home/common/peta_proj_2017.2_secure/build/tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/demo/1.0-r0/package/home/root/Demo/Demo1.out' '/home/common/peta_proj_2017.2_secure/build/tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/demo/1.0-r0/package/home/root/Demo/.debug/Demo1.out'):
arm-xilinx-linux-gnueabi-objcopy:/home/common/peta_proj_2017.2_secure/build/tmp/work/cortexa9hf-neon-xilinx-linux-gnueabi/demo/1.0-r0/package/home/root/Demo/Demo1.out: File format not recognized
ERROR: demo-1.0-r0 do_package: Function failed: split_and_strip_files
I assume objcopy has an issue with my file having been compiled for arm-linux-gnueabihf, but I already know it works since I've tried copying it to the rootfs manually after Linux is booted and tested it. I would try to recompile it with the arm-xilinx-linux-gnueabi toolchain but it's missing some of the libraries I need. I don't know why objcopy is being called for this operation anyway. All I want is for it to move the file to the rootfs, but for some reason it's doing all this extra work on it. Is there a way I can make bitbake ignore the file's format?
looks like the problem is that objcopy is trying to strip symbols, and as you said, the toolchain used is not the same as the one it was used to build it.
You can try to setting:
INHIBIT_PACKAGE_STRIP="1"
somewhere (perhaps in your local.conf).
It should skip the step on which the build system tries to strip debug symbols from binaries hence will probably not invoke objcopy.
1 [https://www.yoctoproject.org/docs/current/mega-manual/mega-manual.html#var-INHIBIT_PACKAGE_STRIP]1

Configure fails on `PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.12.3)'

I am attempting to create a fairly simple BitBake recipe that uses autotools, which you can see here:
SUMMARY = "an example autotools recipe"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
inherit autotools
SRC_URI = "file://${TOPDIR}/piu/geo_utilities"
S = "${TOPDIR}/piu/geo_utilities"
After starting a BitBake build with this recipe's default package included, do_configure fails with the following:
configure: line 12851: syntax error near unexpected token `GLIB,'
configure: line 12851: `PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.12.3)'
When I run ldd --version, I get this: ldd (GNU libc) 2.17.
I've found several sites like this Google Groups post and this GitHub issue which suggest that the problem can be solved by updating pkg-config. I'm running Red Hat, so I've run sudo yum install pkgconfig which returns that pkgconfig-0.27.1-4.el7.x86_64 already installed and latest version.
(this question followed after this question was solved by the answerer)
The proper fix is to inherit pkgconfig. Specifically you need pkgconfig-native built.
I believe that this error was due to the do_configure step of my custom recipe being ran before the glib for my target machine was generated. I was able to resolve this error by adding this line to the recipe:
DEPENDS += " glib-2.0 pkgconfig "

Resources