2.1.1. Getting Ready to Develop Using devtool

Follow these steps to prepare to update the kernel image using devtool. Completing this procedure leaves you with a clean kernel image and ready to make modifications as described in the "Using devtool to Patch the Kernel" section:

  1. Initialize the BitBake Environment: Before building an extensible SDK, you need to initialize the BitBake build environment by sourcing the build environment script (i.e. oe-init-build-env):

         $ cd ~/poky
         $ source oe-init-build-env
                            

    Note

    The previous commands assume the Source Repositories (i.e. poky) have been cloned using Git and the local repository is named "poky".

  2. Prepare Your local.conf File: By default, the MACHINE variable is set to "qemux86", which is fine if you are building for the QEMU emulator in 32-bit mode. However, if you are not, you need to set the MACHINE variable appropriately in your conf/local.conf file found in the Build Directory (i.e. ~/poky/build in this example).

    Also, since you are preparing to work on the kernel image, you need to set the MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS variable to include kernel modules.

    This example uses the default "qemux86" for the MACHINE variable but needs to add the "kernel-modules":

         MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "kernel-modules"
                            

  3. Create a Layer for Patches: You need to create a layer to hold patches created for the kernel image. You can use the bitbake-layers create-layer command as follows:

         $ cd ~/poky/build
         $ bitbake-layers create-layer ../../meta-mylayer
         NOTE: Starting bitbake server...
         Add your new layer with 'bitbake-layers add-layer ../../meta-mylayer'
         $
                            

    Note

    For background information on working with common and BSP layers, see the "Understanding and Creating Layers" section in the Yocto Project Development Tasks Manual and the "BSP Layers" section in the Yocto Project Board Support (BSP) Developer's Guide, respectively. For information on how to use the bitbake-layers create-layer command to quickly set up a layer, see the "Creating a General Layer Using the bitbake-layers Script" section in the Yocto Project Development Tasks Manual.

  4. Inform the BitBake Build Environment About Your Layer: As directed when you created your layer, you need to add the layer to the BBLAYERS variable in the bblayers.conf file as follows:

         $ cd ~/poky/build
         $ bitbake-layers add-layer ../../meta-mylayer
         NOTE: Starting bitbake server...
         $
                            

  5. Build the Extensible SDK: Use BitBake to build the extensible SDK specifically for use with images to be run using QEMU:

         $ cd ~/poky/build
         $ bitbake core-image-minimal -c populate_sdk_ext
                            

    Once the build finishes, you can find the SDK installer file (i.e. *.sh file) in the following directory:

         ~/poky/build/tmp/deploy/sdk
                            

    For this example, the installer file is named poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-2.6.sh

  6. Install the Extensible SDK: Use the following command to install the SDK. For this example, install the SDK in the default ~/poky_sdk directory:

         $ cd ~/poky/build/tmp/deploy/sdk
         $ ./poky-glibc-x86_64-core-image-minimal-i586-toolchain-ext-2.6.sh
         Poky (Yocto Project Reference Distro) Extensible SDK installer version 2.6
         ============================================================================
         Enter target directory for SDK (default: ~/poky_sdk):
         You are about to install the SDK to "/home/scottrif/poky_sdk". Proceed[Y/n]? Y
         Extracting SDK......................................done
         Setting it up...
         Extracting buildtools...
         Preparing build system...
         Parsing recipes: 100% |#################################################################| Time: 0:00:52
         Initializing tasks: 100% |############## ###############################################| Time: 0:00:04
         Checking sstate mirror object availability: 100% |######################################| Time: 0:00:00
         Parsing recipes: 100% |#################################################################| Time: 0:00:33
         Initializing tasks: 100% |##############################################################| Time: 0:00:00
         done
         SDK has been successfully set up and is ready to be used.
         Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
          $ . /home/scottrif/poky_sdk/environment-setup-i586-poky-linux
                            

  7. Set Up a New Terminal to Work With the Extensible SDK: You must set up a new terminal to work with the SDK. You cannot use the same BitBake shell used to build the installer.

    After opening a new shell, run the SDK environment setup script as directed by the output from installing the SDK:

         $ source ~/poky_sdk/environment-setup-i586-poky-linux
         "SDK environment now set up; additionally you may now run devtool to perform development tasks.
         Run devtool --help for further details.
                            

    Note

    If you get a warning about attempting to use the extensible SDK in an environment set up to run BitBake, you did not use a new shell.

  8. Build the Clean Image: The final step in preparing to work on the kernel is to build an initial image using devtool in the new terminal you just set up and initialized for SDK work:

         $ devtool build-image
         Parsing recipes: 100% |##########################################| Time: 0:00:05
         Parsing of 830 .bb files complete (0 cached, 830 parsed). 1299 targets, 47 skipped, 0 masked, 0 errors.
         WARNING: No packages to add, building image core-image-minimal unmodified
         Loading cache: 100% |############################################| Time: 0:00:00
         Loaded 1299 entries from dependency cache.
         NOTE: Resolving any missing task queue dependencies
         Initializing tasks: 100% |#######################################| Time: 0:00:07
         Checking sstate mirror object availability: 100% |###############| Time: 0:00:00
         NOTE: Executing SetScene Tasks
         NOTE: Executing RunQueue Tasks
         NOTE: Tasks Summary: Attempted 2866 tasks of which 2604 didn't need to be rerun and all succeeded.
         NOTE: Successfully built core-image-minimal. You can find output files in /home/scottrif/poky_sdk/tmp/deploy/images/qemux86
                            

    If you were building for actual hardware and not for emulation, you could flash the image to a USB stick on /dev/sdd and boot your device. For an example that uses a Minnowboard, see the TipsAndTricks/KernelDevelopmentWithEsdk Wiki page.

At this point you have set up to start making modifications to the kernel by using the extensible SDK. For a continued example, see the "Using devtool to Patch the Kernel" section.