TipsAndTricks/KernelDevelopmentWithEsdk: Difference between revisions

From Yocto Project
Jump to navigationJump to search
Line 18: Line 18:
  bitbake -c populate_sdk_ext core-image-minimal
  bitbake -c populate_sdk_ext core-image-minimal


The ESDK installer can be found in /path_to_build_directory/kernel-dev/tmp/deploy/sdk/
The eSDK installer can be found in /path_to_build_directory/kernel-dev/tmp/deploy/sdk/
  ./tmp/deploy/sdk/poky-glibc-x86_64-core-image-minimal-corei7-64-toolchain-ext-2.3.sh
  ./tmp/deploy/sdk/poky-glibc-x86_64-core-image-minimal-corei7-64-toolchain-ext-2.3.sh


Alternatively, if you are not using a yocto-linux kernel, you can use a prebuilt esdk installer that included the toolchain you need. For example, the pyro core-image-minimal esdk release for core2-64 is located [[http://downloads.yoctoproject.org/releases/yocto/yocto-2.3/toolchain/x86_64/poky-glibc-x86_64-core-image-minimal-core2-64-toolchain-ext-2.3.sh here]].
Alternatively, if you are not using a yocto-linux kernel, you can use a prebuilt eSDK installer that included the toolchain you need. For example, the pyro core-image-minimal esdk release for core2-64 is located [[http://downloads.yoctoproject.org/releases/yocto/yocto-2.3/toolchain/x86_64/poky-glibc-x86_64-core-image-minimal-core2-64-toolchain-ext-2.3.sh here]].


== Install Extensible SDK ==
== Install Extensible SDK ==

Revision as of 22:40, 27 June 2017

Overview

This article describes an efficient workflow for Linux kernel development using Yocto Project. The goal is to get the build, deploy and test cycle to under a minute. We will be working with the Intel Minnowboard Turbot in this article but the process is the same for any platform and CPU architecture.

The extensible SDK (eSDK) is a key part of this workflow for a number of reasons

  1. It contains the target toolchain which is not easily accessible in the bitbake environment
  2. It contains devtool which gives use an easy way of getting the the kernel source your target is using (if using linux-yocto)
  3. devtool will also automatically create patches for your updates and add them to the the kernel recipe

There are two separate steps to this process

  1. Build and extensible SDK (eSDK) for your platform
  2. Install and use that eSDK to build your kernel


Build Extensble SDK

Follow instructions in the Quick Start Guide to build a image for the Minnowboard. Open a new terminal window and navigate to your poky directory. We'll refer to this terminal as your 'bitbake terminal'. The following commands will configure the Yocto build environment and build the eSDK installer

source poky/oe-init-build-env
bitbake -c populate_sdk_ext core-image-minimal

The eSDK installer can be found in /path_to_build_directory/kernel-dev/tmp/deploy/sdk/

./tmp/deploy/sdk/poky-glibc-x86_64-core-image-minimal-corei7-64-toolchain-ext-2.3.sh

Alternatively, if you are not using a yocto-linux kernel, you can use a prebuilt eSDK installer that included the toolchain you need. For example, the pyro core-image-minimal esdk release for core2-64 is located [here].

Install Extensible SDK

Follow the installer instructions and provide a target directory for your ESDK installation e.g /path_to_esdk/

Checkout the kernel source tree and construct .config

Check out the Linux kernel source and construct a .config from the Yocto kernel configuration segments. The sources can be found in /path_to_build_directory/kernel-dev/workspace/sources/linux-yocto.

devtool modify linux-yocto

If you are just using a kernel from somewhere else, for example kernel.org, you can just clone it instead of using devtool modify in this step.

Setup your ESDK build environment (ESDK terminal)

Open a new terminal and setup your build environment. We'll refer to this terminal as your 'ESDK terminal'

. /path_to_esdk/environment-setup-corei7-64-poky-linux

NOTE: If you see the message below you will really need to open a new terminal :).

"SDK environment now set up; additionally you may now run devtool to perform development tasks. Run devtool --help for further details. WARNING: attempting to use the extensible SDK in an environment set up to run bitbake - this may lead to unexpected results. Please source this script in a new shell session instead."

Build your kernel (ESDK terminal)

Navigate to your workspace directory e.g /path_to_build_directory/kernel-dev/workspace/sources/linux-yocto and build the kernel

make

Modify your kernel and commit your changes (ESDK terminal)

You can navigate to the Linux source directory (/path_to_build_directory/kernel-dev/workspace/sources/linux-yocto) and modify the kernel. Commit your kernel changes.

Build an image with your kernel changes (optional) (bitbake terminal)

devtool build-image core-image-minimal

For faster iteration, in 2.4 some wic commands are being included to allow you to insert the kernel in an image without going through the full recreation of the image. For older releases you can do:

sudo kpartx -a <foo>.wic
sudo mount /dev/mapper/loopNpM /mnt/wic-partionM

In this case, it will be the next available loopback device. If you are not using any , it will be loop0. so in the std case it would look like

sudo mount /dev/mapper/loop0p1 /mnt/wic-partion1

Then you could dd the kernel into the kernel partion. Then unmount and unkaprtx...

sudo umount mnt/wic-partionM
sudo kaprtx -d /dev/loopN

Note that this requires root/sudo rights. The assumption here is most kernel devs would have this or could do it in a vm/container.

Export patches and create a bbappend file (bitbake terminal)

To export your commits to patches and a bbappend file use the following command.

devtool finish linux-yocto /path_to_poky_directory/meta-yocto-bsp/

The patches and the bbappend can be found in /path_to_poky_directory/meta-yocto-bsp/recipes-kernel/linux.

Build image with your modified kernel (bitbake terminal)

You can now build an image which will include your kernel patches.

Execute the following command from your build directory ( e.g /path_to_build_directory/kernel-dev/)

bitbake core-image-minimal