How can I get linux kernel sources (interested mainly in dts) in Yocto - yocto

I would like to see linux kernel sources that were used to build an image with bitbake in yocto. I need to verify that we are using a correct dts file, and probably to update it.
I was told that devtool can help me to see kernel sources, but I can't understand how to use devtool to get the linux kernel sources(and the dts file in special).
How do I do it?

In order to use devtool to modify the kernel, if you don't know the kernel name, you can execute in the build environment the next command:
devtool modify virtual/kernel
This will modify the recipe for virtual/linux, which underneath is an alias for the kernel you are using, for example linux-tegra, linux-imx, etc.
After you execute that command, you can see the sources that have been unpacked and patched inside your builddir folder on the following path: build/workspace/sources/<kernel recipe name>.
Devtool will create a git repo on that path, which will have the same branches as the remote SRC_URI where it is getting it from, so you can make your changes there.
It will also create a .bbappend so that bitbake knows that the actual source for the kernel is this folder and not the one on tmp. This bbappend is located in this path:
build/workspace/appends/<kernel recipe name>.bbappend
After you modify it, you can just do a bitbake virtual/kernel to build this modified kernel.
In order to find which device tree your machine is using, you can extract such information using the -e flag on bitbake and then grep:
bitbake -e virtual/kernel | grep "^KERNEL_DEVICETREE="
Then you can search for that device tree inside the kernel sources and you can modify it as well.
Hope this helps a little. If you have more doubts let me know.

Related

Building custom Linux kernel in yocto build system

I am using BSP layer meta-ti in yocto build system with poky as distro. When i set the MACHINE variable as "beaglebone", the PREFERRED_PROVIDER_virtual/kernel is "linux-ti-staging" i.e the kernel source will be downloaded from SRC_URI present in recipe linux-ti-staging-version.bb.
I have written my own kernel recipe(my-custom-kernel-version.bb) where i have specified the SRC_URI pointing to different github path to defconfig for the custom kernel source. This recipe is present in meta-mylayer/recipes-kernel/linux/
I do want to do any kernel modification in yocto using bitbake -c menuconfig virtual/kernel.
How can i make bitbake to pickup up my-custom-kernel-version.bb
rather than the linux-ti-staging-version.bb to fetch the kernel source.
Inside your distribution file. You can simply add:
PREFERRED_PROVIDER_virtual/kernel = "my-custom-kernel-version"
Make sure that you have PROVIDES += "virtual/kernel" in your kernel recipe.

Why is package included in Yocto rootfs?

I'm in the process of upgrading from Yocto Sumo to Yocto Dunfell. In this process there's quite a few packages getting added to the rootfs that wasn't there before and which I don't have use for. I would like to know why they are added? Which dependency triggers them to get added?
In previous versions of Yocto there was a pn-depends.dot file which provided this information. This has now been removed. All that is left is a task-depends.dot which I guess I should use, however it is harder to read as it lists dependencies between individual tasks and doesn't show why a certain package is added to the rootfs. The command bitbake -g <image-name> -u taskexp makes it slightly easier to read the file but it is still hard to understand as package names are not always the same as task names.
What is the preferred solution to get an answer to "why is included in my rootfs?"

-sh /usr/local/sbin/wpa_supplicant no such file or directory

I have built the TI wilink utilities which then I have integrated in my rootfs. This done using petalinux 2016.4 and have created a install template app in yocto build to copy all the tools and libraries in the rootfs.
When I bring up the BOOT.bin and image.ub, I see the files and libraries but when I try to run for example wpa_supplicant it does not work
even wpa_supplicant -h wont work.
It shows me error:
-sh: /usr/local/sbin/wpa_supplicant: no such file or directory.
The file is present and also has executable permissions.
Do you have any idea why it is not able to run ?
Thanks
Typically, this means that executable file is built for the wrong architecture, i.e. there is a mismatch between the environment where are you running and environment for which you are building. This is how you can make sure they do match or not (execute on target):
# file /usr/local/sbin/wpa_supplicant
...
# uname -m
...
If you see mismatch, then it all boils down to how are you building TI wilink.

Modifying core-image-minimal to only make rootfs

I am working on an embedded project on Zedboard. I would like (at least for now) to use Bitbake only to produce proper rootfs. I use recipe core-image-minimal, as I need only limited amount of staff there. How can I "tell" it to not compile kernel, not make u-boot, etc. and focus on rootfs only?
Here is what I've done so far:
Created my build environment
Downloaded needed layers
Modified local.conf to add needed packages to rootfs
Then after typing
bitbake core-image-minimal
I get my rootfs, and all this unnecessary staff. How can I avoid it?
I recently had the same need to only build the rootfs with yocto, skipping other things such as kernel, uboot, image creation etc. There are many legitimate reasons to do so. Anyways, this is what you have to do:
bitbake core-image-minimal -c image_cpio
in krogoth, this will populate the rootfs directory in build/tmp/work/$MACHINE/core-image-minimal/1.0-r0/ and create a rootfs.cpio file in build/tmp/deploy/images/$MACHINE/
in morty, the rootfs.cpio archives seem to be in build/tmp/work/$MACHINE/core-image-minimal/1.0-r0/deploy-core-image-minimal-image-complete/
Interesting concept. However, from what I observed, Yocto must get the defconfig in kernel and u-boot to do configuration on the image itself. Therefore, removing the process will make rootfs not bootable.
These happened for me a lot of time since I used different kernels to compile for different machines. I thought that the ARM image will be the same and will work for all machine but I was wrong.
For Debian, the image compiled need to use kernel's corresponding configuration to compile the rootfs for it to work. And Yocto is the same.
bitbake -e |grep IMAGE_FSTYPE
will give you something like:
IMAGE_FSTYPES="tar.gz cpio cpio.gz.u-boot ...."
it's a list of all the image that will be generated, to remove the undesired ones, in the local.conf file use:
IMAGE_FSTYPES_remove = " cpio cpio.gz.u-boot"
the space before the first element it's not optional.
Regards
If you don't want to build a kernel set the preferred provider of virtual/kernel to 'linux-dummy'.

Adding binaries to path with BOSH

This seems like it should be done in the packaging phase of a job, but the documentation does it in the job's control script.
However when I ssh into the machine the binaries I added to the path are not in the path anymore.
Your assumption is correct, I'm not sure what docs you reference, but binaries should be define in packages
The spec file tells director where in blobs to find the binary:
---
name: bamboo-agent
dependencies:
files:
- bamboo/atlassian-bamboo-5.9.7.tar.gz
And the packaging file tells it where to place those files on the job's vm.
# abort script on any command that exits with a non zero value
set -e
# agent jar is within the full installation tar, pull it out.
tar -xzf $BOSH_COMPILE_TARGET/bamboo/atlassian-bamboo-5.9.7.tar.gz
cp -a atlassian-bamboo-5.9.7/atlassian-bamboo/admin/agent/atlassian-bamboo-agent-installer-5.9.7.jar $BOSH_INSTALL_TARGET/
Control scripts might use those binaries, but should not manipulate them.
See https://bosh.io/docs/create-release.html#pkg-skeletons for an overview of how packages fit into BOSH releases.