Bitbake LibSocketCAN - embedded

I am trying to build libsocketcan into my image. To add libsocketcan In my main application recipe I added IMAGE_INSTALL_append += " libsocketcan ". When debugging my application with Eclipse this works perfectly. When I attempt to bitbake my application I am told
fatal error: libsocketcan.h: No such file or directory
I am not sure where I am missing my dependency.
Makefile.am
AUTOMAKE_OPTIONS = foreign subdir-objects
bin_PROGRAMS = MAIN_Application
MAIN_Application_LDADD = -lsocketcan -lpthread
AM_CPPFLAGS = \
-I$(srcdir)/include \
-I$(srcdir)/include/utilities \
-I$(srcdir)/include/comms
MAIN_Application_SOURCES = \
src/main.c \
src/scheduler.c \
src/utilities/time_conversions.c \
src/utilities/ring_buffer.c \
src/utilities/logger.c \
src/comms/can.c
I believe this is the only file that would make a difference. Has anyone else ever faced this? What else do I need to do to allow my bitbake to find the include?
Edit: recipe as requestes
LICENSE = "MIT"
IMAGE_LINGUAS = " "
# Base image Install
IMAGE_INSTALL = " packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"
# Configure image base size
IMAGE_ROOTFS_SIZE ?= "4096"
IMAGE_ROOTFS_EXTRA_SPACE_append = "${#bb.utils.contains("DISTRO_FEATURES", "systemd", " + 2048", "", d)}"
# User preferences
inherit core-image
inherit extrausers
# Change root password (note the capital -P)
EXTRA_USERS_PARAMS = "\
usermod -P toor root; \
useradd -P michael -G sudo michael; \
"
# uncomment the line %sudo ALL=(ALL) ALL in /etc/sudoers
modify_sudoers() {
sed 's/# %sudo/%sudo/' < ${IMAGE_ROOTFS}${sysconfdir}/sudoers > ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp
mv ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp ${IMAGE_ROOTFS}${sysconfdir}/sudoers
}
ROOTFS_POSTPROCESS_COMMAND_append = " modify_sudoers;"
# Dependencies
DEPENDS = " libsocketcan "
# Install necessary libraries
IMAGE_INSTALL_append += " packagegroup-core-ssh-openssh "
IMAGE_INSTALL_append += " can-utils "
IMAGE_INSTALL_append += " libsocketcan"
IMAGE_INSTALL_append += " sudo "
IMAGE_INSTALL_append += " iw wireless-tools wpa-supplicant "
# Install SMG applications
IMAGE_INSTALL_append += " udevrules "
IMAGE_INSTALL_append += " mainapplication "
# Apply kernel customizations
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://kernel_customization.cfg"
# Remove image features
IMAGE_INSTALL_remove += " packagegroup-fsl-optee-imx"
BAD_RECOMMENDATIONS = " udev-hwdb"
#MKUBIFS_ARGS="--leb-size 126976 --min-io-size 2048 --max-leb-cnt 3600"
#UBINIZE_ARGS="--peb-size 128KiB --min-io-size 2048 --sub-page-size 2048"
#IMAGE_FSTYPES += " ubi ubifs"
Edit 2: main application recipe
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "\
file://MAIN_Application \
file://services \
"
inherit autotools systemd
S = "${WORKDIR}/MAIN_Application"
SYSTEMD_SERVICE_${PN} = "MAINapplication.service"
do_install_append () {
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/services/MAINapplication.service ${D}${systemd_system_unitdir}
sed -i -e 's,#BINDIR#,${bindir},g' ${D}${systemd_system_unitdir}/MAINapplication.service
}

libsocketcan provides these packages:
tmp/work/aarch64-poky-linux/libsocketcan/0.0.11-r0/image
└── usr
├── include
│   ├── can_netlink.h
│   └── libsocketcan.h
├── lib
│   ├── libsocketcan.so -> libsocketcan.so.2.3.0
│   ├── libsocketcan.so.2 -> libsocketcan.so.2.3.0
│   ├── libsocketcan.so.2.3.0
│   └── pkgconfig
│   └── libsocketcan.pc
Adding DEPENDS += "libsocketcan" will cause all those files to be populated into your custom layer's working directory.
NOTE
Your recipe seems to do not install your MAIN_Application output binary file. So your recipe should look like:
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "\
file://MAIN_Application \
file://services \
"
inherit autotools systemd
S = "${WORKDIR}/MAIN_Application"
DEPENDS += "libsocketcan"
SYSTEMD_SERVICE_${PN} = "MAINapplication.service"
do_install_append () {
install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/services/MAINapplication.service ${D}${systemd_system_unitdir}
sed -i -e 's,#BINDIR#,${bindir},g' ${D}${systemd_system_unitdir}/MAINapplication.service
install -m 0644 ${S}/MAIN_Application ${D}${bindir}
}
Just make sure that MAIN_Application is the right binary name.

IMAGE_INSTALL_append adds package to image.
It has not much to do with build-time dependencies of your application.
What you should add to you app.bb is:
DEPENDS = "libsocketcan"

This is an answer just to help you fix some issues related to your image recipe:
Here are some important comment:
IMAGE_INSTALL
IMAGE_INSTALL = " packagegroup-core-boot ${CORE_IMAGE_EXTRA_INSTALL}"
...
inherit core-image
Never and never override IMAGE_INSTALL before core-image, because IMAGE_INSTALL of core-image will not take effect.
Variable assignement
IMAGE_INSTALL_append += " packagegroup-core-ssh-openssh "
IMAGE_INSTALL_append += " can-utils "
IMAGE_INSTALL_append += " libsocketcan"
IMAGE_INSTALL_append += " sudo "
IMAGE_INSTALL_append += " iw wireless-tools wpa-supplicant "
Do not use append with += , use one of them only.
DEPENDS ??
Image recipes are just dedicated to collect recipes and create image rootfs and final image type (wic, ...)
You do not need DEPENDS.
SRC_URI ??
This is also a non-image recipe variable, did it even took effect ?
Move the kernel configuration fragment to your custom virtual/kernel package recipe.
I recommend your image recipe to look like:
LICENSE = "MIT"
IMAGE_LINGUAS = " "
# Configure image base size
IMAGE_ROOTFS_SIZE ?= "4096"
IMAGE_ROOTFS_EXTRA_SPACE_append = "${#bb.utils.contains("DISTRO_FEATURES", "systemd", " + 2048", "", d)}"
# User preferences
inherit core-image extrausers
# Change root password (note the capital -P)
EXTRA_USERS_PARAMS = "\
usermod -P toor root; \
useradd -P michael -G sudo michael; \
"
# uncomment the line %sudo ALL=(ALL) ALL in /etc/sudoers
modify_sudoers() {
sed 's/# %sudo/%sudo/' < ${IMAGE_ROOTFS}${sysconfdir}/sudoers > ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp
mv ${IMAGE_ROOTFS}${sysconfdir}/sudoers.tmp ${IMAGE_ROOTFS}${sysconfdir}/sudoers
}
ROOTFS_POSTPROCESS_COMMAND_append = " modify_sudoers;"
# Install necessary libraries
IMAGE_INSTALL_append = " packagegroup-core-ssh-openssh \
can-utils \
libsocketcan \
sudo \
iw wireless-tools wpa-supplicant"
# Install SMG applications
IMAGE_INSTALL_append = " udevrules \
mainapplication"
# Remove image features
IMAGE_INSTALL_remove += " packagegroup-fsl-optee-imx"
BAD_RECOMMENDATIONS = " udev-hwdb"
#MKUBIFS_ARGS="--leb-size 126976 --min-io-size 2048 --max-leb-cnt 3600"
#UBINIZE_ARGS="--peb-size 128KiB --min-io-size 2048 --sub-page-size 2048"
#IMAGE_FSTYPES += " ubi ubifs"

Related

Yocto include cmake project with custom steps

I am trying to include this simple cmake-based project to my image: https://github.com/MatrixOrbital/HTT-Utility
The steps to build in Linux are:
mkdir build
cd build
cmake ..
make
I am trying to reproduce these steps within my Yocto recipe. The generated binary (./build/htt_util) should be installed in /usr/bin.
So far with the help of devtool and some manual tuning I ended up with this recipe:
LICENSE = "MIT & Unknown"
LIC_FILES_CHKSUM = "file://LICENSE;md5=ff75ee274f4c77abeee3db089083fec7 \
file://hidapi/LICENSE.txt;md5=7c3949a631240cb6c31c50f3eb696077"
SRC_URI = "git://github.com/MatrixOrbital/HTT-Utility.git;protocol=https"
SRC_URI += "file://0001-Adding-ctype.patch;"
PATCHTOOL = "git"
# Modify these as desired
PV = "1.0+git${SRCPV}"
SRCREV = "2045d5eacc67b89a02dafe41edfd032179333aee"
S = "${WORKDIR}/git"
inherit cmake
# Specify any options you want to pass to cmake using EXTRA_OECMAKE:
EXTRA_OECMAKE = ""
DEPENDS += "udev"
What should I add to my recipe to achieve the goal of generating a binary and installing into /usr/bin?
I have been trying to play with:
do_configure() {
...
}
do_compile() {
...
}
do_install() {
...
}
But so far I did not manage to do anything useful.
Any help would be appreciated.
do_install() {
install -m 0644 mybinary ${D}${bindir}
}
FILES_${PN} = " \
${bindir} \
"

using EXTRA_OECMAKE doesn't have any effect in cmake variable in bitbake recipe

I wanted to add my application in a yocto Image and I used this recipe:
DESCRIPTION = "my application"
SECTION = "examples"
LICENSE = "CLOSED"
PR = "r0"
DEPENDS += "opencv"
SRC_URI = "git://address/to/myApplication.git;protocol=https;tag=v0.1"
inherit pkgconfig cmake
after running bitbake my-application, I faced this error:
fatal error: string: No such file or directory #include <string>
I searched on the internet and I found that I need to pass this variable to my CMake in my recipe:
EXTRA_OECMAKE += "-DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON"
but nothing had changed. again I faced the error. then I decided to add the variable to my CMake:
set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON)
after my next try, everything got fine and I didn't face any error.
I opened cmake.bbclass file and I saw these lines in a cmake_do_configure() function:
cmake \
${OECMAKE_GENERATOR_ARGS} \
$oecmake_sitefile \
${OECMAKE_SOURCEPATH} \
-DCMAKE_INSTALL_PREFIX:PATH=${prefix} \
-DCMAKE_INSTALL_BINDIR:PATH=${#os.path.relpath(d.getVar('bindir'), d.getVar('prefix') + '/')} \
-DCMAKE_INSTALL_SBINDIR:PATH=${#os.path.relpath(d.getVar('sbindir'), d.getVar('prefix') + '/')} \
-DCMAKE_INSTALL_LIBEXECDIR:PATH=${#os.path.relpath(d.getVar('libexecdir'), d.getVar('prefix') + '/')} \
-DCMAKE_INSTALL_SYSCONFDIR:PATH=${sysconfdir} \
-DCMAKE_INSTALL_SHAREDSTATEDIR:PATH=${#os.path.relpath(d.getVar('sharedstatedir'), d. getVar('prefix') + '/')} \
-DCMAKE_INSTALL_LOCALSTATEDIR:PATH=${localstatedir} \
-DCMAKE_INSTALL_LIBDIR:PATH=${#os.path.relpath(d.getVar('libdir'), d.getVar('prefix') + '/')} \
-DCMAKE_INSTALL_INCLUDEDIR:PATH=${#os.path.relpath(d.getVar('includedir'), d.getVar('prefix') + '/')} \
-DCMAKE_INSTALL_DATAROOTDIR:PATH=${#os.path.relpath(d.getVar('datadir'), d.getVar('prefix') + '/')} \
-DCMAKE_INSTALL_SO_NO_EXE=0 \
-DCMAKE_TOOLCHAIN_FILE=${WORKDIR}/toolchain.cmake \
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=1 \
${EXTRA_OECMAKE} \
-Wno-dev
by default CMAKE_NO_SYSTEM_FROM_IMPORTED is set to 1. therefor, logically I don't need to set this variable in my recipe or cmake.
why EXTRA_OECMAKE and CMake cmake_do_configure() didn't work correctly?
I checked my cmake, and I am sure that I didn't change any CXX flags in it.

How to Compile SampleApp of Alexa-SDK using bitbake for RaspberryPi

I am trying to add a custom layer for Alexa-SDK. I created *.bb file and when I run bitbake alexa command every task completes successfully. But I am unable to find SampleApp executable in /tmp /deploy or /work direrctory.
Here is my *.bb file
SUMMARY = "bitbake-alexa recipe"
DESCRIPTION = "Alexa SDK"
SECTION = "alexa"
LICENSE = "CLOSED"
SRC_URI = "git://github.com/alexa/avs-devicesdk.git;branch=master;protocol=https"
SRCREV = "8bf0160c5e56a3d5ebc1e1caeab14afc8658b0da"
INSANE_SKIP_${PN} = "dev-so"
TARGET_CC_ARCH += "${LDFLAGS}"
S = "${WORKDIR}/git"
SB = "${WORKDIR}/build"
AVS_DIR ?= "/home/root/Alexa_SDK"
inherit cmake
EXTRA_OECMAKE = "-DCMAKE_BUILD_TYPE=RELEASE \
-DGSTREAMER_MEDIA_PLAYER=ON \
-DCMAKE_INSTALL_PREFIX=${D}${AVS_DIR}/avs-sdk-client \
-DPORTAUDIO=ON \
-DPORTAUDIO_LIB_PATH=${STAGING_LIBDIR}/libportaudio.so \
-DPORTAUDIO_INCLUDE_DIR=${STAGING_INCDIR} \
"
RDEPENDS_${PN} += "bash perl"
DEPENDS = "curl sqlite3 portaudio-v19 gstreamer1.0-plugins-base"
do_compile() {
cd ${SB}
oe_runmake ${PARALLEL_MAKE} SampleApp
}
do_install() {
install -d -m 0755 ${D}${AVS_DIR}
install -d -m 0755 ${D}/sounds
install -d -m 0755 ${D}/database
install -d -m 0755 ${D}${AVS_DIR}/avs-sdk-client
cd ${SB}
find ./ -executable -type f -exec cp --parents -v {}
${D}/${AVS_DIR}/avs-sdk-client \;
find ./ -name *.py -exec cp --parents -v {} ${D}/${AVS_DIR}/avs-sdk-client \;
find ${D}/${AVS_DIR}/avs-sdk-client -name "*.py" -exec sed -e s#${SB}#${AVS_DIR}/avs-sdk-client#g -i {} \;
mkdir ${D}/${AVS_DIR}/avs-sdk-client/Integration
mkdir ${D}/${AVS_DIR}/libs
cd ${D}/${AVS_DIR}/libs
find ../avs-sdk-client -executable -type f -exec ${WORKDIR}/libsInstall.sh {} \;
cp -r -L ${S} ${D}/${AVS_DIR}/avs-device-sdk
cd ${D}/${AVS_DIR}/avs-device-sdk
git repack -a -d
}
FILES_${PN} = "${AVS_DIR} /sounds /database"
BBCLASSEXTEND = "native"
Please suggest what I am missing as I want to make SampleApp part of the image and run it on RaspberryPi
Updated .bb file
SUMMARY = "bitbake-alexa recipe" DESCRIPTION = "Alexa SDK" SECTION = "alexa" LICENSE = "CLOSED"
SRC_URI = "git://github.com/alexa/avs-device-sdk.git;branch=master;protocol=https"
SRCREV = "8bf0160c5e56a3d5ebc1e1caeab14afc8658b0da"
S = "${WORKDIR}/git" SB = "${WORKDIR}/build"
TARGET_CXXFLAGS += " -D_GLIBCXX_USE_CXX11_ABI=0
-Wno-error=class-memaccess"
inherit cmake
INSANE_SKIP_${PN} = "install-vs-shipped"
INSANE_SKIP_${PN} = "ldflags"
AVS_DIR ?= "/home/root/Alexa_SDK"
EXTRA_OECMAKE = " \ -DCMAKE_BUILD_TYPE=DEBUG \ -DGSTREAMER_MEDIA_PLAYER=ON \
-DCMAKE_INSTALL_PREFIX=${D}${AVS_DIR}/avs-sdk-client \ -DPORTAUDIO=ON \ -DPORTAUDIO_LIB_PATH=${STAGING_LIBDIR}/libportaudio.so \ -DPORTAUDIO_INCLUDE_DIR=${STAGING_INCDIR} \ " RDEPENDS_${PN} += "bash
perl"
DEPENDS = " \ curl \ sqlite3 \
portaudio-v19 \ gstreamer1.0-plugins-base \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \ gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \ "
do_install(){
install -d -m 0755 ${D}${AVS_DIR}
install -d -m 0755 ${D}${AVS_DIR}/avs-sdk-client
find ./ -executable -type f -exec cp --parents -v {}
${D}/${AVS_DIR}/avs-sdk-client \;
find ./ -name *.py -exec cp --parents -v {} ${D}/${AVS_DIR}/avs-
sdk-client \;
find ${D}/${AVS_DIR}/avs-sdk-client -name "*.py" -exec sed -e
s#${SB}#${AVS_DIR}/avs-sdk-client#g -i {} \;
mkdir ${D}/${AVS_DIR}/libs
cd ${D}/${AVS_DIR}/libs
find ../avs-sdk-client -executable -type f -exec
${WORKDIR}/libsInstall.sh {} \;
cp -r -L ${S} ${D}/${AVS_DIR}/avs-device-sdk
cd ${D}/${AVS_DIR}/avs-device-sdk
git repack -a -d
rm .git/objects/info/alternates
}
FILES_${PN} += "${bindir}/SampleApp \
${AVSDIR} \"
Since you are using cmake here you don't need to write do_compile() here as cmake bbclass will take of it when you do inherit cmake.
If the CmakeLists.txt for you are application is fine, yocto will compile it out and created the required bins/libs as part of it.
You can add
FILES_${PN} += "${bindir}/sample app \
${AVSDIR} \
sounds"
And then add your package into corresponding package group or add in local.conf.
IMAGE_INSTALL_append = "sampleApp"
Check whether now you are getting the required bins in rootfs.

QXcbIntegration: Cannot create platform OpenGL context

I've been trying to add Qt5 support to a core-image-sato image using Yocto's Poky Pyro on Raspberry Pi 3.
In my bblayer.conf I added these lines:
BBLAYERS ?= " \
/poky-pyro/meta \
/poky-pyro/meta-poky \
/poky-pyro/meta-yocto-bsp \
/poky-pyro/meta-openembedded/meta-oe \
/poky-pyro/meta-openembedded/meta-multimedia \
/poky-pyro/meta-openembedded/meta-networking \
/poky-pyro/meta-openembedded/meta-perl \
/poky-pyro/meta-openembedded/meta-python \
/poky-pyro/meta-raspberrypi \
/poky-pyro/meta-qt5 \
"
In my local.conf I added these lines:
DISTRO_FEATURES_append = " opengl "
IMAGE_INSTALL_append = " qtbase qtdeclarative qtquickcontrols2 qtmultimedia qttools cinematicexperience "
Bitbake finished building the image successfully, but when I run Qt5_cenimaticExperience on the target I get this error message:
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled.
This is the default configuration of Qtbase and based on what you have:
PACKAGECONFIG_GL ?= "${#bb.utils.contains('DISTRO_FEATURES', 'opengl', 'gl', '', d)}"
PACKAGECONFIG_DEFAULT ?= "dbus udev evdev widgets tools libs freetype tests"
PACKAGECONFIG_SYSTEM ?= "jpeg libpng zlib"
As you can see, we only enabled -opengl desktop; What we need is opengl es2 for embedded system.
To correct this, add this line to your local.conf:
PACKAGECONFIG_append_pn-qtbase = " gles2 "
By the way, this is my qtbase configuration:
PACKAGECONFIG_append_pn-qtbase = " gles2 fontconfig \
gstreamer \
accessibility \
tslib examples \
"

qmake .pro file could not be parsed

I'm running OS X Mavericks and trying to convert a Qt4 application to Qt5. I've also never compiled the application on this machine before. I have Qt 5.1.* installed on this machine, which parses the file just fine. As soon as I switch over to my Qt 5.2.0 kit and look at the run settings, underneath my "Run configuration" there's a warning: "The .pro file '.pro' could not be parsed.".
I've looked at other solutions on SO and the qt-project website -- none of which have helped. My Qt 5.2.0 kit is a manually-added kit since I installed it using Homebrew.
Here is a screenshot of my settings:
Note that if I run qmake (/usr/local/opt/qt5/bin/qmake) in the project directory, no errors are output.
Here is my .pro file:
QT += core widgets concurrent
TARGET = Up
TEMPLATE = app
CONFIG += c++11
SOURCES += main.cpp\
MainForm.cpp \
AboutForm.cpp \
progressdialog.cpp
HEADERS += MainForm.h \
AboutForm.h \
progressdialog.h
FORMS += MainForm.ui \
AboutForm.ui \
progressdialog.ui
INCLUDEPATH += $$PWD/../FATX/FATX
RESOURCES += \
MainForm.qrc
CONFIG(debug, debug|release) {
macx: LIBS += -L$$PWD/../FATX-BUILD-OSX/debug/ -lFATX
INCLUDEPATH += $$PWD/../FATX-BUILD-OSX/debug
DEPENDPATH += $$PWD/../FATX-BUILD-OSX/debug
macx: PRE_TARGETDEPS += $$PWD/../FATX-BUILD-OSX/debug/libFATX.a
} else {
macx: LIBS += -L$$PWD/../FATX-OSX/release/ -lFATX
INCLUDEPATH += $$PWD/../FATX-BUILD-OSX/release
DEPENDPATH += $$PWD/../FATX-BUILD-OSX/release
macx: PRE_TARGETDEPS += $$PWD/../FATX-OSX/release/libFATX.a
}
cache()
The solution was to update Qt Creator to Qt 3.0.0.