How to write own package for recipe in arago project build - linux

How can i write own package for recipe in arago project build? I know little bit that it can be bitbake files. But how can i write, no idea. I searched on internet, but failed to find any good source to start. can someone provide me link or example to start?
Regards
Linux Learner.

Create own recipe with Yocto using Bitbake:
Use Yocto Project for Embedded systems. It's documentation and support is awesome. You can get started Yocto Project.
Build your own recipe(for the first time build takes quiet good amount of time)
Getting Yocto Project:
Follow step-by-step procedure given Gumstix-YoctoProject-Repo till bitbake gumstix-console-image
Now you got yocto project on your machine. Start writing your own recipes. I will show you how to create a hello world recipe.
1) goto /yocto/poky/<create a folder as meta-robot>
2) goto /yocto/poky/meta-robot/<create a folder as /recipes-robot> and <another folder /conf>
3) goto /yocto/poky/meta-robot/recipes-robot/<create another folder /hello>
4) goto /yocto/poky/meta-robot/recipes-robot/hello/<create a file as 'hello_2.7.bb'>
5) Paste this in your hello_2.7.bb
DESCRIPTION = "GNU Helloworld application"
SECTION = "examples"
LICENSE = "GPLv3+"
LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
PR = "r0"
SRC_URI[md5sum] = "fc01b05c7f943d3c42124942a2a9bb3a"
SRC_URI[sha256sum] = "fd593b5bcf6d1bb6d7d1bb7eefdccdc0010cf2c4985ccb445ef490f768b927c0"
SRC_URI = "ftp://ftp.gnu.org/gnu/hello/hello-2.7.tar.gz"
inherit autotools gettext
6) goto /yocto/poky/meta-robot/conf/<create a file as layer.conf>
7) paste this in your layer.conf file
# We have a conf directory, append to BBPATH
BBPATH .= ":${LAYERDIR}"
# We have a recipes directory, add to BBFILES
BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"
BBFILE_COLLECTIONS += "meta-robot"
BBFILE_PATTERN_meta-robot := "^${LAYERDIR}/"
BBFILE_PRIORITY_meta-robot = "7"
8) Open /yocto/build/conf/bblayers.conf file
9) Add your recipe folder path in bblayers file
ex: /home/xyz/yocto/poky/meta-robot \
10) open /yocto/poky/meta-gumstix-extras/recipes-images/gumstix/gumstix-console-image.bb file and under TOOLS_INSTALL add your recipe name i.e.hello \
11) Open your terminal type $ cd /yocto
12) $ source ./poky/oe-init-build-env
13) type bitbake gumstix-console-image
That's it. Your image with your own package will be ready in some time.
You can find your image in /yocto/build/tmp/deploy/images/
All the Best.

Arago is a distribution based on OpenEmbedded project and Bitbake build tool. Logically, you should start with Bitbake manual and OpenEmbedded manual. These are slightly outdated, but still relevant in most part. After that, there is a good, simple tutorial found here.
Also I find #oe channel on FreeNode to be very useful.
EDIT: There is a newer manual for Yocto/Poky that also covers Bitbake and OpenEmbedded.

I think what the other guy has answered to create a new recipe is actually creating a layer.
You can do it by
$ . ./setup-environment build-dir
$ yocto-layer create custom #here you may change the name to your custom layer name.
If you do this, it will automatically ask you to create an example recipe for you.
But I guess that's not the question.
You need to change or customize .bb file.
It has few fields namely
SOURCE_URI=" "
This is the one where you are getting the source tar file for the package.
Then do_compile = " " and do_install = " ". This may not be easy for a newbee like you and me.

You can create a recipe using create-recipe or recipetool.
Check the below link for their usage
http://ashversity.blogspot.in/2016/02/creating-new-yocto-recipe.html

Related

How to transfer python3-flask project into yocto image?

I am a beginner in yocto. Till now i have learnt about how to build a yocto image and add recipes through layers.openembedded. But i am not able to figure out e.g. i have developed a python3-flask project in my PC and then i want to copy/transfer that project into my yocto os. how can i do that? do i have to make something like executable of that project and then copy that into my os using some recipe?
I have seen this recipe but i am not able to understand what does LIC_FILES_CHSUM means and where to get it? where should i put these file e.g. setup.py? in the same directory as my .bb file?
and on building where my project would be copied in the yocto os?
DESCRIPTION = "Simple Python setuptools hello world application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://setup.py \
file://python-helloworld.py \
file://helloworld/__init__.py \
file://helloworld/main.py"
S = "${WORKDIR}"
inherit setuptools
do_install_append () {
install -d ${D}${bindir}
install -m 0755 python-helloworld.py ${D}${bindir}
}
The LICENSE field should obviously correspond to the license you picked for your SW. LIC_FILES_CHKSUM needs a file that holds the actual license defined in LICENSE and its md5sum passed as an "argument". It is just a way to monitor if the license ever changes. Then its md5sum changes and then the recipe fail to build because the license probably changed and requires the maintainer's attention.
THISDIR being the directory containing the recipe (not exactly but enough for the example), files in SRC_URI will be searched for in FILESPATH (which is first ${THISDIR}/<recipe_name>-<recipe_version> then ${THISDIR}/<recipe-name> then ${THISDIR}/files). So you need to put files (the ones starting with file://) declared in SRC_URI into one of those directories.
Best would actually to have your SW in a git repo somewhere. This better follows the philosophy of having SW source code separate from your build system (what if you decide you want to use a different build system later?).
When you're wondering what some variables or tasks are doing, I highly recommend looking them up on the mega manual: https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html. This works extremely well as a "dictionary". The documentation is great albeit dense and long but it is rare not to found what you look for as a beginner.
Update
LIC_FILES_CHKSUM can be found in yocto meta/files/common-licenses in the Source Directory. You can also take your own license and check the checksum with md5sum filename and copy that to bb file. If your SW is to be distributed, it is highly recommended to have the license mentioned somewhere in your sources. So better use that part of the code in LIC_FILES_CHKSUM than using the ones in ${COMMON_LICENSE_DIR} so that people will know if and when there is a license change in your project.
The below recipe works fine and you can find your app in /usr/bin directory.
DESCRIPTION = "Simple Python setuptools application"
SECTION = "examples"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://setup.py \
file://packagetest.py \
file://example/__init__.py \
file://example/file1.py \
file://example/file2.py \
file://example/file3.py"
S = "${WORKDIR}"
inherit pypi setuptools3
do_install_append () {
install -d ${D}${bindir}
install -m 0755 packagetest.py ${D}${bindir}
}

Yocto generated nativesdk-cmake SDK is incomplete

For the past couple of days I have been trying to generate a viable CMake SDK with Yocto Project. I'm trying to generate SDK based on an image file which is given below:
#To build SDK, use bitbake meta-toolchain
DESCRIPTION = "Embeddev-LXDE image."
LICENSE="CLOSED"
IMAGE_INSTALL = "packagegroup-core-boot \
packagegroup-core-x11 \
packagegroup-lxde-base \
kernel-modules \
"
IMAGE_INSTALL_append = " nano git cmake qtbase qtchooser dbus packagegroup-core-ssh-openssh xterm"
#Framebuffer driver for tft
IMAGE_INSTALL_append = " xf86-video-fbdev"
IMAGE_INSTALL_append = " apt dpkg sudo tzdata glibc-utils localedef networkmanager pointercal xinit xkeyboard-config base-passwd liberation-fonts pkgconfig"
IMAGE_INSTALL_append = " wiringpi"
#Maybe consider connman instead of networkmanager
#vc-graphics is problematic with userland..
inherit populate_sdk
## SDK stuff, to build sdk use bitbake rpi-embeddev-lxde-image -c populate_sdk
# Add all static packages: SDKIMAGE_FEATURES += "staticdev-pkgs"
SDKIMAGE_FEATURES += "staticdev-pkgs"
SDKIMAGE_FEATURES += "dev-pkgs"
TOOLCHAIN_TARGET_TASK_append = " wiringpi-dev"
TOOLCHAIN_HOST_TASK_append = " nativesdk-cmake"
##
inherit distro_features_check
REQUIRED_DISTRO_FEATURES = "x11"
IMAGE_LINGUAS ?= " "
LICENSE = "MIT"
export IMAGE_BASENAME = "rpi-embeddev-lxde-image"
inherit core-image
ENABLE_SPI_BUS = "1"
ENABLE_I2C = "1"
# qtwebengine qtwebkit ...
do_image_prepend() {
}
I create my SDK with bitbake rpi-embeddev-lxde-image -c populate_sdk.
I would like to describe the exact problem. The problem is that nativesdk-cmake is not correctly installed in the SDK. Cmake 3.10.2 recipe gives:
do_install_append_class-nativesdk() {
mkdir -p ${D}${datadir}/cmake
install -m 644 ${WORKDIR}/OEToolchainConfig.cmake ${D}${datadir}/cmake/
mkdir -p ${D}${SDKPATHNATIVE}/environment-setup.d
install -m 644 ${WORKDIR}/environment.d-cmake.sh ${D}${SDKPATHNATIVE}/environment-setup.d/cmake.sh
}
FILES_${PN}_append_class-nativesdk = " ${SDKPATHNATIVE}"
FILES_${PN} += "${datadir}/cmake-${CMAKE_MAJOR_VERSION}"
FILES_${PN}-doc += "${docdir}/cmake-${CMAKE_MAJOR_VERSION}"
BBCLASSEXTEND = "nativesdk"
Tracing the root of the problem, I have seen that the cmake/ directory that should be created is created in:
/home/<user>/poky/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-cmake/3.10.2-r0/image/opt/poky/2.4+snapshot/sysroots/x86_64-pokysdk-linux/usr/share/cmake/
However, this cmake directory is not valid in /opt/poky/2.4+snapshot/sysroots/x86_64-pokysdk-linux/usr/share/, -where it is actually needed- when I install the SDK to /opt, unfortunately.
Do I need to know anything else or do anything else regarding how to properly generate SDK?
I am really stuck here any help is much appreciated indeed.
Thanks in advance.
EDIT: I moved TOOLCHAIN_TASK statements to layer.conf and used bitbake meta-toolchain which also didn't work.
EDIT2: I used cmake version 3.6 with PREFERRED_PROVIDER_cmake = "3.6.1", which also did not work.
There seems to be a bug in the imminent Yocto Project 2.5, Sumo, release. Here, sysroots/x86_64-chargestorm-linux/usr/share/cmake/OEToolchainConfig.cmake seems to be omitted.
The temporary solution for this is to add
TOOLCHAIN_HOST_TASK += "nativesdk-cmake-dev"
And yes, using a release is always helpful, especially if your new to some project. Just remember to always use the same release branches for all your included layers. And personally, I'd not start a new project based on Morty, which was released 1.5 years ago when writing this, as it's likely to go out of official Yocto Project support rather soon.
As an aside, it seems that it is still a bug (Or would this be mis-feature at this point...?) in Sumo. Just got bit by this...workaround looks to be the same as described.
(Note: This is a release at this point in time... X-D)
Problem solved by using a release (I used "morty", and not the "master branch") for every layer and poky itself. This is apparently very important.

Library installation with yocto recipe

have a bit of a problem creating a recipe for yocto. More specifically i have to install a library from git that normally installs like this:
./bootstrap
./configure --sysconfdir=/etc
make
sudo make install
My question is how can I add this to the recipe functions do_configure, do_compile, do_install. Haven't found much information or examples online.
Update 1:
This is the library that i want to integrate into yocto
https://github.com/NXPNFCLinux/linux_libnfc-nci
It's just a regular autotools based library. The main issues, that someone ought to fix, are to make the build create versioned libraries and to add a LICENSE or COPYING file.
However, a quick recipe could look like:
SUMMARY = "Linux NFC stack for NCI based NXP NFC Controllers"
HOMEPAGE = ""
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://src/include/linux_nfc_api.h;endline=17;md5=42fdb99b3ff2c12f594b22a774cb7308"
SECTION = "libs"
SRC_URI = "git://github.com/NXPNFCLinux/linux_libnfc-nci.git"
SRCREV = "118ea118cecda55c1b6a87d151a77b04515687df"
PV = "2.0+git${SRCPV}"
S = "${WORKDIR}/git"
inherit autotools
FILES_${PN} += "${libdir}/libnfc_nci_linux-1.so"
# Make sure it isn’t in the dev package’s files list
FILES_SOLIBSDEV = "${libdir}/libnfc_nci_linux.so"
A versioned library would allow us to remove the last three lines.

How to add a new library using Yocto

I am using Yocto and I just would like to integrate a new library in my project.
I create a new recipe name "libxerces" which contains a file "libxerces-3.1.1.bb". The bb file is quite simple because it is based on autotools :
DESCRIPTION = "Xerces-c is a validating xml parser written in C++"
HOMEPAGE = "http://xerces.apache.org/xerces-c/"
PRIORITY = "optional"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"
PR = "r1"
SRC_URI = "http://mirror.bit.edu.cn/apache//xerces/c/3/sources/xerces-c-${PV}.tar.gz"
s="${WORKDIR}/xerces-c-${PV}"
inherit autotools pkgconfig
SRC_URI[md5sum] = "6a8ec45d83c8cfb1584c5a5345cb51ae"
SRC_URI[sha256sum] = "a42785f71e0b91d5fd273831c87410ce60a73ccfdd207de1b805d26d44968736"
PACKAGES =+ "${PN}-utils"
FILES_${PN} = "${libdir}/*.so"
FILES_${PN}-utils = "${bindir}/*"
FILES_${PN}-staticdev = "${libdir}/*.a"*
BBCLASSEXTEND += "native"
I added "libxerces" to my bb image by using IMAGE_INSTALL += " libxerces". Then, I try to build my image thru bitbake my-image-test and eveything is done correctly but libxerces returns an error because it can not be installed. Howerver, I note that libxerces-dbg, libxerces-utils, libxerces-samples are visible under /tmp/work/deploy/ipk. I know that libxml2 is integrated by default into poky layer but I have to use xerces..
I solved the error
ERROR: Unable to install packages.
Collected errors:
* opkg_install_cmd: Cannot install package libxerces.
overriding the PACKAGES variable.
In your case:
PACKAGES = "${PN} ${PN}-utils ${PN}-staticdev"
I think that is because the .so files goes to ${PN}-dev package by default.
I hope there is a smarter solution, but for now I fixed in this way.
If you are building a library and the library offers static linking, you can control which static library files (*.a files) get included in the built library.
The PACKAGES and FILES_* variables in the meta/conf/bitbake.conf configuration file define how files installed by the do_install task are packaged. By default, the PACKAGES variable includes ${PN}-staticdev, which represents all static library files.
FILES_${PN}-staticdev ="" # for static libs
FILES_${PN}-dev ="" # for dynamic libs
FILES_${PN}-dbg ="" # for debug options
you need to add above line to your recipe

Turn off Source Checksum Check Yocto

Where do I specify
BB_STRICT_CHECKSUM = "0"
in Yocto to disable checksum check of source code?
I get:
ERROR: No checksum specified for /PATH/TO/ti-linux-kernel.git, please add at least one to the recipe:
SRC_URI[md5sum] = "e8e287fd725bea8b4220ebe9094cda86"
SRC_URI[sha256sum] = "4a4f522b05e6c1fcd1872f2fc7c82061dfdc4a19c5f866858005daa198f89bbb"
Regarding this page BB_STRICT_CHECKSUM is a variable which can be used in .bb files. So, you can simply add the following line to the corresponding .bb file, which your SRC_URI has been set in it, to avoid the checksum checking error:
BB_STRICT_CHECKSUM = "0"
By adding this line the checksum check error (saying: No checksum specified for blah/blah/blah, please add at least one to the recipe OR the other error saying: Missing SRC_URI checksum) won't break the compile process anymore and just a warning will be thrown.
Hope it helps
I don't see a variable named BB_STRICT_CHECKSUM in the Yocto documentation.
As far as I can tell, you shouldn't need to specify the SRC_URI[...] checksums for a git repository. In your bitbake recipe, does /PATH/TO/ti-linux-kernel.git have a git:// at the front of it? Bitbake uses that to determine the type of SCM tool to use. If you want to access a git repo via http you would specify
SRC_URI = "git://server.com/PATH/TO/ti-linux-kernel.git;protocol=http"
Maddeningly, this is only hinted at in documentation for SRC_URI.
The SRC_URI[md5sum] and SRC_URI[sha256sum] are instead intended for ensuring downloaded tarballs are the same as when you write the recipe. If you were adding a tarball (say, http://server.com/path/to/some-project.tar.gz), the recommended way is to
... comment the statements out and then attempt to build the software. The build will produce an error for each missing checksum and as part of the error message provide the correct checksum string. Once you have the correct checksums, simply copy them into your recipe for a subsequent build.
You can see in your error message that in this case they have indeed been provided.
If your cloning the repo with https://some_path you will need
SRC_URI[md5sum] = "e8e287fd725bea8b4220ebe9094cda86"
SRC_URI[sha256sum] = " 4a4f522b05e6c1fcd1872f2fc7c82061dfdc4a19c5f866858005daa198f89bbb"
while you clone the repo with git://some_path you will need
md5sum of any other file like
LIC_FILES_CHKSUM = "file://LICENSE;md5=a77c327d4d1da3707d42dde9725d4769"

Resources