How to apply patch file of dtsi(or dts) in yocto - linux

I'm using yocto(ver.rocko) on ubuntu 18.04 and trying to apply patch file but I can't...
My target machine is qemuarm64 and linux kernel is linux-yocto.
Once do $ bitbake core-image-base, kernel source files are unpacked then target dtsi file is located at poky/build/tmp/work/aarch64-poky-linux/linux-libc-headers/4.12-r0/linux-4.12/arch/arm64/boot/dts/arm/juno-base.dtsi
And my custom meta-data files to patch are below:
poky/meta-custom/recipes-kernel/linux/linux-yocto_4.12.bbappend
poky/meta-custom/recipes-kernel/linux/files/juno-base.dtsi.patch
# poky/meta-custom/recipes-kernel/linux/linux-yocto_4.12.bbappend
FILESEXTRAPATHS_prepend := "${THISDIR}/files"
SRC_URI += "file://juno-base.dtsi.patch"
But after bitbake, patch file is created at poky/build/tmp/work/qemuarm64-poky-linux/linux-yocto/4.12.28+gitAUTOINC+2ae65226f6_e562267bae-r0/juno-base.dtsi.patch and patch-application doesn't work
I don't know what's wrong, what to do...
Plz let me know what should I do?

To create a simple patch for Yocto recipe sources, you can use git command in a simple way:
Your Linux work directory is:
poky/build/tmp/work/qemuarm64-poky-linux/linux-yocto/4.12.28+gitAUTOINC+2ae65226f6_e562267bae-r0
as you can see it is already a "git" directory which means that it is intialized with git already.
Here are clear steps for you to understand the method:
After adding your patch(juno-base.dtsi.patch) to SRC_URI I think your linux-yocto work directory is messed up, so follow me:
Clean the build
bitbake linux-yocto -c cleansstate
Remove the patch from SRC_URI
Apply any default patches
bitbake linux-yocto -c patch
Go to
poky/build/tmp/work/qemuarm64-poky-linux/linux-yocto/4.12.28+gitAUTOINC+2ae65226f6_e562267bae-r0
Make your modifications on
poky/build/tmp/work/qemuarm64-poky-linux/linux-yocto/4.12.28+gitAUTOINC+2ae65226f6_e562267bae-r0/arch/arm64/boot/dts/arm/juno-base.dtsi
and not in
poky/build/tmp/work/aarch64-poky-linux/linux-libc-headers/4.12-r0/linux-4.12/arch/arm64/boot/dts/arm/juno-base.dtsi
Now, open a terminal and change directory to
poky/build/tmp/work/qemuarm64-poky-linux/linux-yocto/4.12.28+gitAUTOINC+2ae65226f6_e562267bae-r0
Run: git status (You should see something like: modified arch/arm64/boot/dts/arm/juno-base.dtsi)
Run: git add arch/arm64/boot/dts/arm/juno-base.dtsi
Run: git commit -m "Patch for juni base dtsi"
Run: git format-patch -1
Now a new patch is created with the name "Patch-for-juni-base-dtsi.patch",
Now you can add it to linux-yocto_%.bbappend:
SRC_URI_append = " file://Patch-for-juni-base-dtsi.patch"
If the dtsi is not exist and you want to add it as a patch, do the same thing, when you run "git status" you will see a new added file, add it with "git add" and continue the commands.
After all of this, you can continue the build process with:
bitbake linux-yocto -C patch
Or, if you add the patch to SRC_URI the linux-yocto build will start from do_fetch.

Related

How to add header file to /usr/include in Yocto

I am working with Linux built with Yocto. I would like to add to the image my app to /bin and some header file to /usr/include. I have no problem with adding the app to /bin, but I am not able to add the header file to my rootfs. The .h file is added to a proper package, but it is not copied to rootfs.
Here is my recipe:
bindir = "${localdir}/bin"
incldir = "${localdir}/usr/include"
FILESEXTRAPATHS_prepend := "${THISDIR}/files/:"
SRC_URI = "file://My_app_dir/* \
\
"
S = "${WORKDIR}"
FILES_${PN} += "${incldir}/*"
do_compile() {
cd My_app_dir/src
make
}
do_install() {
install -d ${D}${bindir}
cp "${S}/My_app_dir/src/my_app" "${D}${bindir}/my_app"
install -d ${D}${incldir}
cp "${S}/My_app_dir/some_lib.h" "${D}${incldir}/some_lib.h"
}
After building the image, the include file exists in /build/tmp/work/<machine>/<my_app>/image/usr/include.
Do you have any idea why I cannot add .h file to /usr/include in rootfs? Thank you in advance for any help.
The header files (among other files like pkgconfig and shared library symlinks) are not added to the main package (say foo), but to the development package (e.g. foo-dev). This is called package split and you can learn more in the Package Splitting of the official documentation. The development packages (and BTW also the debug foo-dbg) are not installed by default.
But please be aware that adding the development package may pull other dependencies (because of various runtime dependencies) and files (there are other files in the development package).
Please note that your line FILES_${PN} += "${incldir}/*" has no effect, as the files in $includedir (i.e. FILES_${PN}-dev) are split before the FILES_${PN} are processed. The order is defined in the variable PACKAGES (check the official documentation).
BTW, there are minor things in the recipe which you can update (unrelated to your question though):
You can use location of standard system paths in the respective variables bindir, includedir etc.
install is preferred over the cp in do_install.
The line FILESEXTRAPATHS_prepend := "${THISDIR}/files/:" is needed only in bbappends. The files directory inside the recipe's directory is in the standard search path of files (among other paths like ${PN} etc.).

Yocto - adding out of tree kernel module

I would like to add a wifi out-of-tree kernel module to my Yocto project. I found a layer on Open Embedded Layer Index with the driver that I need (https://layers.openembedded.org/layerindex/branch/master/layer/meta-rtlwifi/). I cannot build an image because I get the following error from bitbake:
install: cannot stat
'build/tmp/work/<machine_dir>/rtl8821cu/5.8.1.2-git-r0/git/8821cu.ko': No
such file or directory WARNING: exit code 1 from a shell command.
This file should be created by Makefile, but I have no errors generating by make.
The recipe for the driver is as follows:
SUMMARY = "RTL8821CU kernel driver (wifi)"
DESCRIPTION = "RTL8821CU kernel driver"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://LICENSE;md5=b234ee4d69f5fce4486a80fdaf4a4263"
SRCREV = "2dace83e5f4cada52bbe3930b864c3eb82390b1f"
SRC_URI = "git://github.com/spriteguard/rtl8821CU;protocol=https "
S = "${WORKDIR}/git"
PV = "5.8.1.2-git"
DEPENDS = "virtual/kernel"
inherit module
#This is the only line added by me to this recipe because sh wasn't able to find `bc`
EXTRA_OEMAKE += "-I${S}/usr/bin' "
EXTRA_OEMAKE += "ARCH=${ARCH}"
EXTRA_OEMAKE += "KSRC=${STAGING_KERNEL_BUILDDIR}"
MODULES_INSTALL_TARGET="install"
do_install () {
install -d ${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless
install -m 0644 ${B}/8821cu.ko ${D}${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/rtl8821cu.ko
}
FILES_${PN} += "${nonarch_base_libdir}/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/rtl8821cu.ko"
RPROVIDES_${PN} += "kernel-module-${PN}-${KERNEL_VERSION}"
I have tried to add the following task:
do_compile () {
oe_runmake
}
But it changed nothing. I needed to add one line to this recipe: EXTRA_OEMAKE += "-I${S}/usr/bin' " because sh wasn't able to find bc. Maybe bitbake doesn't see one more file/library?
When I cloned the repo on my PC and just run make, the file *.ko was created. What can cause problems in Yocto with creating this module? I use the official layer and recipe so I suppose it should works.
You have to replace SRCREV. Because as far as I can see, the SRCREV of the above recipe is using the old version. You can check "git log" and choose the latest commit.
I used master branch and bitbake successfully.

why fabric release 1.1.0 could not make?

From fabric makefile ,I wanna compile the orderer and peer ,It throws the error
friendsdeMacBook-Pro:fabric friends$ make orderer
make: *** No rule to make target `build/bin/orderer', needed by `orderer'. Stop.
friendsdeMacBook-Pro:fabric friends$
I changed the official makefile a little, my changed Makefile file:
changed Makefile
After taking a git clone of https://github.com/hyperledger/fabric check which branch or tag you are in before invoking make commands.
$ git clone of https://github.com/hyperledger/fabric
$ git checkout v1.1.0
$ make release

How to use an own kernel configuration for a raspberry pi in yocto?

I like to remove some unused drivers for my RPI2 + custom board. For that I am creating an own configuration via:
bitbake linux-raspberrypi -c menuconfig
and save the new kernel preset to the file defconfig.
After this I created an append file for the linux-raspberryp recipe.
So I created the file
linux-raspberrypi%.bbappend
and filled it with:
FILESEXTRAPATHS_prepend := "${THISDIR}/linux-raspberrypi:"
SRC_URI += "file://defconfig"
PACKAGE_ARCH = "raspberrypi2"
I put the defconfig file to:
<meta-mylayer>/recipes-kernel/linux/linux-raspberrypi/raspberrypi2/defconfig
When recompiling the kernel via:
bitbake linux-raspberrypi -c clean
bitbake linux-raspberrypi
The standard RPI2 configuration is taken.
Any idea how to overcome this problem?
I am working on the "actual" pyro branch of meta-raspberrypi and yocto.
Well, unfortunately, the easiest way is probably to patch the kernel source... Or copy your defconfig over the in kernel-tree one.
The meta-raspberrypi layer does some unfortunate things in their kernel recipes, and even though this has become better with time, they're still not really nice...
If you take a look at recipes-kernel/linux/linux-raspberrypi.inc, the following lines explains the issue:
KERNEL_DEFCONFIG_raspberrypi2 ?= "bcm2709_defconfig"
do_kernel_configme_prepend() {
install -m 0644 ${S}/arch/${ARCH}/configs/${KERNEL_DEFCONFIG} ${WORKDIR}/defconfig || die "No default configuration for ${MACHINE} / ${KERNEL_DEFCONFIG} available."
}
Thus,they're copying the in-tree defconfig to ${WORKDIR}/defconfig, thereby overwriting your own defconfig.
You in you .bbappend, you could try to add:
do_kernel_configme_prepend() {
install -m 0644 ${WORKDIR}/defconfig ${S}/arch/${ARCH}/configs/${KERNEL_DEFCONFIG} || die "No default configuration for ${MACHINE} / ${KERNEL_DEFCONFIG} available."
}
Thus, first overwriting the in-kernel-tree one with your own defconfig.
Please take a look at how to use devtool to modify source code for the jethro:
http://www.yoctoproject.org/docs/2.0/dev-manual/dev-manual.html#using-devtool-in-your-workflow
I would start by having a fork at the git repository that it is using;
http://git.yoctoproject.org/cgit/cgit.cgi/meta-raspberrypi/tree/recipes-kernel/linux/linux-raspberrypi_4.9.bb
Using devtool in Yocto;
in your build directory: create a my-linux-raspberry folder;
mkdir linux-raspberry-test
devtool modify -x linux-raspberry ./my-linux-raspberry
This will put unpack the source code into my-linux-raspberry for you to modify; It also create the git repository in there;
Then, modify the code in my-linux-raspberry; To test build, run devtool build linux-raspberry; Once you are satisfied, add this git repository to your fork;
git add .
git commit -m "my-linux-raspberry"
devtool update-recipe linux-raspberry
Optional: run devtool reset linux-raspberry to remove the bbappend file;

Makefile.inc: No such file or directory

I don't have much experience with makefiles, but I am trying to compile and run the program "hdf5ToMds.c" found on this Github repository: https://github.com/MDSplus/mdsplus/tree/alpha/hdf5
My steps towards using the Makefile.in in the folder were as follows:
autoscan
mv configure.scan configure.ac
aclocal
autoheader
autoconf
./configure
make
Now when I run the make I get the error:
Makefile:1: Makefile.inc: No such file or directory
make: *** No rule to make target 'Makefile.inc'. Stop.
Am I missing something obvious? I'm not very familiar with this whole process of getting the code from Github and having to make it. I do have the entire repository cloned, just in case that's relevant.

Resources