Install CANopen package in yocto - yocto

I have tried installing CANopen in yocto using below command. But the CANOpen is not getting installed.
bitbake canopensocket_git
In local.conf file I had added
CORE_IMAGE_EXTRA_INSTALL += " canopensocket_git "
How I can install canopen package?
Any input is also considered.

First of all, that's a syntax error canopensocket_git.
The recipe name ${PN} is canopensocket and every thing after the_ is the version number ${PV}.
So, you need to only specify the recipe name. Or if you have different versions you can specify one by:
PREFERRED_VERSION_canopensocket = "version_here"
That being said, I found a recipe for canopensocket in here.
But if fails and it is not updated with latest github commit.
I did some modifications on it, here is my recipe:
SUMMARY = "Linux CANOpen tools"
DESCRIPTION = "Linux CANOpen Protocol Stack Tools"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://gpl-2.0.txt;md5=b234ee4d69f5fce4486a80fdaf4a4263"
SRC_URI = "git://github.com/CANopenNode/CANopenSocket.git"
SRCREV = "ec9735165502e08b5d2e84d641833709b6faeb96"
S = "${WORKDIR}/git"
do_compile_prepend() {
cd ${S}
git submodule init
git submodule update
}
do_compile() {
cd ${S}/cocomm
make
cd ${S}/canopencgi
make
}
do_install(){
install -d ${D}${bindir}
install -m 0755 ${S}/cocomm/cocomm ${D}${bindir}
install -m 0755 ${S}/canopencgi/canopen.cgi ${D}${bindir}
}
FILES_${PN} += "${bindir}/*"
I modified do_compile, do_install and added the packaging of FILES.
And I set SRCREV to the latest v4 tag commit instead of AUTOREV.
I do not know what this recipe does, but I compiled it and the build was okay for me on a zeus build.
The build produced two binaries: cocomm and canopen.cgi .
No if you want to install it to your image, add this to you cutom image recipe:
IMAGE_INSTALL_append = " canopensocket"

Related

Installing a kernel module in rootfs in yocto build system

I have a out of tree kernel module(hello.ko) from a vendor which i need to install in rootfs using yocto build. The kernel module is built on the same kernel which yocto build system is using.
I do not have the kernel source for the above module so i cannot build it using recipe.
How can i only install the kernel module in rootfs and to which path it will be installed.
Can anyone share a recipe for this.
I am new to yocto and recently started using it.
Inputs will be helpful.
Loadable kernel module are located in /lib/modules/<kernel_version>/kernel/drivers/
You can create a recipe and add your pre-compiled kernel module in files/lib/modules/<kernel_version>/kernel/drivers/
Then, add the line MODULE_NAME = "hello" to the module_autoload list. This is an example :
#Recipe for hello.ko
SUMMARY = "Hello world"
LICENSE = "closed"
SRC_URI = "file://hello.ko"
S="${WORKDIR}"
do_install()
{
install -d ${D}/lib/modules/${KERNEL_VERSION}/kernel/drivers
install -m 0644 ${WORKDIR}/hello.ko ${D}/lib/modules/${KERNEL_VERSION}/kernel/drivers/
}
FILES_${PN} += "/lib/modules/${KERNEL_VERSION}/kernel/drivers/hello.ko"
MODULE_NAME = "hello"
module_autoload = "${MODULE_NAME}"

How to install file in include directory yocto

I'm trying install files extracted from tar file, but non of my files are installing under usr/include directory on target board, but I see my files under temp/work/aarch64/recipedir/image/usr/include/mydir/ and include/myfile.h. While building I haven't got any errors.
do_install() {
install -d ${D}${includedir}
mkdir -p ${D}${includedir}/mydir
install -m 0644 ${S}/include/myfile.h ${D}${includedir}
install -m 0644 ${S}/include/mydir/*.h ${D}${includedir}/mydir/
}
FILES_${PN} += "${includedir}/mydir
Everything in ${includedir} is put into ${PN}-dev by default.
c.f.: https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/bitbake.conf#n316
You have to remember that a file can only be in one package. To determine in which package a file is going to make it, it's pretty simple. Starting from leftmost package in PACKAGES, the first package to have the file matching any path in FILES_<pkg> will have the file.
By default, ${PN}-dev appears before ${PN} in PACKAGES.
c.f.: http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/meta/conf/bitbake.conf#n294
You can check which package has your file without "reverse-engineering" the whole thing by running oe-pkgdata-util find-path '/usr/include/mydir'.
If you really want this header file in your system (why?), you can either add ${PN}-dev to your image or hack things (remove the -dev package from PACKAGES or move ${PN} before ${PN}-dev, if you only have one file in ${includedir}, etc.).

Installing multiple folders

I'm relativly new to the whole Yocto Project.
Basically I want to add multiple folders to the image:
do_install() {
install -d ${D}/etc/wpa_supplicant
install -m 0777 wpa_supplicant-wired-eth0.conf ${D}/etc/wpa_supplicant
install -d ${D}/mydata
install -d ${D}/mydata/certs
}
wpa_supplicant needs a conf file in /etc/wpa_supplicant. So I install the folder and copy my custom conf file there.
This works FINE
Simultaneously I want to install a certificate folder under /mydata/certs where I can later upload my certificates for the wpa_supplicant.
But when I do do that Yocto tells me the old install vs shipped error
mywpa-1.0-r0 do_package: QA Issue: mywpa: Files/directories were installed but not shipped in any package:
/mydata
/mydata/certs
Please set FILES such that these items are packaged. Alternatively if they are unneeded, avoid installing them or delete them within do_install.
mywpa: 2 installed and not shipped files. [installed-vs-shipped]
ERROR: mywpa-1.0-r0 do_package: Fatal QA errors found, failing task.
ERROR: mywpa-1.0-r0 do_package: Function failed: do_package
ERROR: Logfile of failure stored in: /home/yocto/yocto/build/tmp/work/cortexa7hf-neon-vfpv4-phytec-linux-gnueabi/mywpa/1.0-r0/temp/log.do_package.31833
ERROR: Task (/home/yocto/yocto/sources/poky/../meta-mydata/meta-mywpa/recipes-mywpa/mywpa/mywpa.bb:do_package) failed with exit code '1'
Previously I just worked I had ONE folder per recipe and just added
FILES_${PN} += "${sysconfdir}/etc"
So my question is basically: How do I install two folders in two different directories? Or is impossible in a single recipe and I have to use two recipes?
The FILES_${PN} += expression can be almost arbitrarily complex, as long as it is static at parse time. So you should be able to just expand it as needed:
FILES_${PN} += " \
${sysconfdir}/etc/wpa_supplicant \
/mydata \
"
If there's any problems with that approach, please update the question then I can look into it.

Unable to copy docs to /usr/share/doc ${docdir} yocto

I am working with yocto, i want to copy some documents into rootfs.
when i copy them they are present inside
packages-split/Ex-doc/usr/share/doc/versions/Ex.txt
Now i want to copy from here into rootfs, below are the changes i have made inside recipe
do_install() {
install -m 0755 -d ${D}${docdir}/versions
install -m 0755 ${S}/Ex.txt ${D}${docdir}/versions
}
FILES_${PN}-doc += "${docdir}/versions"
But i am not able to see /usr/share/doc dir inside rootfs. Please point me where i am doing wrong.
Thank You
Did you add the package FILES_${PN}-doc to the list of packages installed in the image?

How to get to menuconfig for u-boot in Yocto environment

I'm using Yocto for the first time for an ARM embedded system with a Xilinx Zynq.
I want to make some configuration changes that requires going in the menuconfig utility. Yocto documentation shows how to do it for the Linux Kernel
bitbake yocto-xlnx -c menuconfig
Which, for Xilinx, I turned into
bitbake linux-xlnx -c menuconfig
It works very well.
Now, I want to do the same with u-boot and change the .config file using the menuconfig utility. I can't find any way to do it in Yocto or Xilinx documentation. I tried the obvious like
bitbake u-boot-xlnx -c menuconfig
just to get an error message:
ERROR: Task do_menuconfig does not exist for target u-boot-xlnx
Any Idea how to get to u-boot menuconfig with Yocto?
Edit:
here are the layers I use
BBLAYERS ?= " \
/home/sylvain/poky/meta \
/home/sylvain/poky/meta-poky \
/home/sylvain/poky/meta-yocto-bsp \
/home/sylvain/poky/openembedded-core/meta \
/home/sylvain/poky/meta-xilinx \
"
It's currently, as of 2.3 Pyro, not possible to run bitbake u-boot -c menuconfig as no-one has implemented that functionality for the U-Boot recipe. Please, file a bug if you'd have uses for this.
Normally, I'd recommend either of the following approaches:
bitbake u-boot -c devshell
Use of devtool.
Use the SDK.
All of these would not only allow you to run make menuconfig, but also to cross-compile U-Boot to verify your configuration.
I found the solution. It works for xilinx distribution. I did not test it for others but it's likely to be similar and it's likely to work for any other menuconfig of any package. It turns out that the full source package is located in my case at:
~/poky/build/tmp/work/zedboard_zynq7-poky-linux-gnueabi/u-boot-xlnx/v2016.07-xilinx-v2016.3+gitAUTOINC+95e11f6eb4-r0/build
I'll let you decode the "board, machine, version etc" coding in the folder string since it depends on each case, but just want to give the idea.
Using the terminal, just go to that folder then run just like in the old days:
make menuconfig
and voilĂ !
I guess when I get to configure busybox and things like that, it will just be the same.
I ran into the same problem.
I build u-boot-at91 for at91sam9x35, but it should be the same for other architectures as well.
Yocto still doesn't support
bitbake u-boot -c menuconfig
I managed to do it with the following steps:
In build directory run:
devtool modify u-boot-at91
This will automatically create the u-boot source files' external directory under: build/workspace/u-boot-at91.
cd build/workspace/u-boot-at91
run menuconfig using:
make menuconfig
If menuconfig doesn't show up you might have to run the do_configure task for u-boot and then retry:
bitbake u-boot-at91 -c configure
Perform required menuconfig changes in the UI and save the configuration in New.config file.
Copy the New.config file to override your target's defconfig file
(in my case at91sam9x5ek_spiflash_config) using:
cp New.config configs/at91sam9x5ek_spiflash_defconfig
Notice the defconfig suffix instead of config!
Push the change to your local git repository:
pushd build/workspace/sources/u-boot-at91
git add at91sam9x5ek_spiflash_defconfig
git commit -m "summary of changes made here"
git status
popd
Create the patch to override the default defconfig file:
devtool update-recipe u-boot-at91
This actually appends the following lines to your u-boot-at91.bb files:
SRC_URI = "git://github.com/linux4sam/u-boot-at91.git;protocol=https;branch=${UBRANCH} \
file://0001-summary-of-changes-made-here.patch \
and creates the patch file with relevant modifications to the recipe's directory.
8. Run BitBake:
bitbake u-boot-at91
or
bitbake core-image-minimal
The new u-boot binary will be built with the new configuration.