Difference between revisions of "BeagleBoardLinuxKernel"

From eLinux.org
Jump to: navigation, search
(Kernel: added git URI)
m (OE)
(13 intermediate revisions by the same user not shown)
Line 18: Line 18:
 
==Tools==
 
==Tools==
  
* Patch management system [http://savannah.nongnu.org/projects/quilt quilt] is used to apply the large number of patches to Linux kernel. See [http://www.suse.de/~agruen/quilt.pdf How To Survive With Many Patches] for an introduction to quilt.  
+
* Patch management system [http://savannah.nongnu.org/projects/quilt quilt] is used to apply the large number of patches to Linux kernel. See [http://www.suse.de/~agruen/quilt.pdf How To Survive With Many Patches] for an introduction to quilt<ref name="quilt_substitute">You can substitute quilt with a command like ''(while read line; do patch -p1 < "patches/"$line; done) < patches/series''</ref>.  
  
 
* An [[ARMCompilers|ARM cross compiler]] to compile kernel.
 
* An [[ARMCompilers|ARM cross compiler]] to compile kernel.
Line 28: Line 28:
 
===OE===
 
===OE===
  
Get basic OpenEmbedded system with steps described in [[BeagleBoardAndOpenEmbeddedGit#OpenEmbedded_and_Bitbake_install|OpenEmbedded and Bitbake install]] article (ignore the "export OE_HOME" part, we only want the OE source system). As of writing in June 2009 this downloads ~100MB.
+
Get basic OpenEmbedded system with steps described in [http://www.angstrom-distribution.org/building-angstrom OpenEmbedded and Bitbake install].  You only need to do the first one and half steps (stop before "bitbake virtual/kernel"). As of writing in Nov 2012 this downloads ~300MB.
  
 
After the download is finished, we are only interested in the recipe and patches for BeagleBoard kernel. These can be found in ''setup-scripts/sources/meta-ti/recipes-kernel/linux'':
 
After the download is finished, we are only interested in the recipe and patches for BeagleBoard kernel. These can be found in ''setup-scripts/sources/meta-ti/recipes-kernel/linux'':
Line 41: Line 41:
 
Note: If you are unsure which might be the correct one, grep all recipe (.bb) files for
 
Note: If you are unsure which might be the correct one, grep all recipe (.bb) files for
  
  DEFAULT_PREFERENCE_beagleboard
+
  COMPATIBLE_MACHINE.*beagleboard
  
This should give you one .bb file.
+
The most recent of these .bb files is the OE ''recipe'' used by OE to patch and build the kernel. Looking into it should give us something like:
 
 
This .bb file is the OE ''recipe'' used by OE to patch and build the kernel. Looking into it should give us something like:
 
 
   
 
   
 
  ...
 
  ...
 
   
 
   
 
  COMPATIBLE_MACHINE = "...beagleboard..."
 
  COMPATIBLE_MACHINE = "...beagleboard..."
 
...
 
 
 
DEFAULT_PREFERENCE_beagleboard = "1"
 
 
   
 
   
 
  ...
 
  ...
Line 59: Line 53:
 
  SRCREV_pn-${PN} = "58cf2f1425abfd3a449f9fe985e48be2d2555022"
 
  SRCREV_pn-${PN} = "58cf2f1425abfd3a449f9fe985e48be2d2555022"
 
   
 
   
  SRC_URI += "git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git;protocol=git \
+
  SRC_URI += "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git;branch=linux-3.2.y;protocol=git \
 
             file://distro/0001-kbuild-deb-pkg-set-host-machine-after-dpkg-gencontro.patch \
 
             file://distro/0001-kbuild-deb-pkg-set-host-machine-after-dpkg-gencontro.patch \
 
             file://omap_cpufreq/0001-cpufreq-OMAP-cleanup-for-multi-SoC-support-move-into.patch \
 
             file://omap_cpufreq/0001-cpufreq-OMAP-cleanup-for-multi-SoC-support-move-into.patch \
Line 68: Line 62:
 
This recipes gives us the following information:
 
This recipes gives us the following information:
  
* This recipe is the recent one for BeagleBoard :) (DEFAULT_PREFERENCE_*)
+
* Where we get the kernel from (SRC_URI)
 
* The git hash for the kernel we have to check out (SRCREV)
 
* The git hash for the kernel we have to check out (SRCREV)
* Where we get the kernel from (SRC_URI) and which kernel config file to use
+
* Which kernel config file to use
 
* The patches which have to be applied (in which order) (file://...patch)
 
* The patches which have to be applied (in which order) (file://...patch)
  
Line 80: Line 74:
 
===Kernel===
 
===Kernel===
  
* First get a recent [[BeagleBoard#Linux_kernel|Linux kernel]]. This is done by fetching recent [http://git.kernel.org/?p=linux/kernel/git/tmlind/linux-omap-2.6.git;a=summary Linux kernel] using git and the URI in SRC_URI.
+
* First get a recent [[BeagleBoard#Linux_kernel|Linux kernel]]. This is done by fetching recent [http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary Linux kernel] using git and the URI in SRC_URI.
  
 
  git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git;branch=linux-3.2.y;protocol=git
 
  git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git;branch=linux-3.2.y;protocol=git
Line 94: Line 88:
 
  cp -r <path_to>setup-scripts/sources/meta-ti/recipes-kernel/linux/linux-mainline-3.2/* <path_to>/patches/
 
  cp -r <path_to>setup-scripts/sources/meta-ti/recipes-kernel/linux/linux-mainline-3.2/* <path_to>/patches/
  
* Go into the patches directory, and there create a file ''series'' (used by quilt) and add the patch description from the above recipe (patch files from the ''SRC_URI'' and ''SRC_URI_append_beagleboard'' variables). This is done by removing the leading ''file://'' (and trailing '';patch=1 \'') from patch list and putting this list into series file. With above example, the series file should look like:
+
* Go into the patches directory, and there create a file ''series'' (used by quilt) and add the patch description from the above recipe (patch files from the ''SRC_URI'' and ''SRC_URI_append_beagleboard'' variables). This is done by removing the leading ''file://'' and trailing '' \'' from patch list and putting this list into series file. E.g.
 +
 
 +
grep "^.*file:\/\/" < linux-mainline_3.2.bb |sed "s/^.*file:\/\///" | sed "s/ [\\]//" >  <path_to>/patches/series
 +
 
 +
With above example, the series file should look like:
  
 
  > cd patches
 
  > cd patches
Line 113: Line 111:
 
  ...
 
  ...
  
* Now, go back into the kernel main directory. There call
+
* Now, go back into the kernel main directory. There call<ref name="quilt_substitute"/>
  
 
  quilt push -a
 
  quilt push -a
Line 131: Line 129:
  
 
Result should be an uImage which is the same as if it would be compiled with OE.
 
Result should be an uImage which is the same as if it would be compiled with OE.
 +
 +
<references/>

Revision as of 01:59, 30 November 2012

This page is about compiling Linux Kernel for BeagleBoard manually. Manually here does mean it isn't done by any development environment (e.g. OpenEmbedded), instead you type "make uImage" at the command line and will get a recent BeagleBoard kernel.

  • Attention #1: If you just want a distribution for your BeagleBoard, i.e. something that just works, stop reading here. Have a look to development environments.
  • Attention #2: If you are already using OpenEmbedded (OE) and you are fine with the kernel generated by this, stop reading here.

This page is intended for people wanting to compile a recent Linux kernel for BeagleBoard manually. Maybe because they are real kernel hackers and don't want OE "overhead". Or they have issues with OE. Or ... . Again, if you are not such a person, stop reading here.

Still interested?

Most recent Linux kernel is available by OMAP Linux git repository, which then is heavily patched by OE. Most of these patches are grabbed from OMAP Linux mailing list, but still not applied to recent git. So OE creates a kernel by taking git kernel and then applies a lot of patches. For OE tools, this is described by OE "receipes". Looking at these recipes for BeagleBoard, grabbing the patches OE applies and then doing the stuff manually (usually done by OE automatically) gives you the same kernel OE generates.

So this page describes how to get all the pieces OE uses for kernel compilation and then patch and compile kernel manually. As this page is only for experts, some details might be missing.

Tools

Source

We need the kernel source and the basic OpenEmbedded system (containing the patches and recipe). Both we get by git.

OE

Get basic OpenEmbedded system with steps described in OpenEmbedded and Bitbake install. You only need to do the first one and half steps (stop before "bitbake virtual/kernel"). As of writing in Nov 2012 this downloads ~300MB.

After the download is finished, we are only interested in the recipe and patches for BeagleBoard kernel. These can be found in setup-scripts/sources/meta-ti/recipes-kernel/linux:

cd setup-scripts/sources/meta-ti/recipes-kernel/linux

There, identify the most recent (kernel) recipe (.bb) and patchfile directory. While writing this article, for BeagleBoard this was

linux-mainline-3.2/
linux-mainline_3.2.bb

Note: If you are unsure which might be the correct one, grep all recipe (.bb) files for

COMPATIBLE_MACHINE.*beagleboard

The most recent of these .bb files is the OE recipe used by OE to patch and build the kernel. Looking into it should give us something like:

...

COMPATIBLE_MACHINE = "...beagleboard..."

...

SRCREV_pn-${PN} = "58cf2f1425abfd3a449f9fe985e48be2d2555022"

SRC_URI += "git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git;branch=linux-3.2.y;protocol=git \
           file://distro/0001-kbuild-deb-pkg-set-host-machine-after-dpkg-gencontro.patch \
           file://omap_cpufreq/0001-cpufreq-OMAP-cleanup-for-multi-SoC-support-move-into.patch \
           file://omap_cpufreq/0002-cpufreq-OMAP-Add-SMP-support-for-OMAP4.patch \
           file://defconfig"
...

This recipes gives us the following information:

  • Where we get the kernel from (SRC_URI)
  • The git hash for the kernel we have to check out (SRCREV)
  • Which kernel config file to use
  • The patches which have to be applied (in which order) (file://...patch)

Now, looking into the directory with the same name as the .bb recipe file (linux-mainline-3.2/) we find

  • the kernel patches listed in the .bb recipe file
  • in beagleboard sub directory the kernel configuration (linux-mainline-3.2/beagleboard/defconfig)

Kernel

git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git;branch=linux-3.2.y;protocol=git

And make sure you are able to build it (e.g. cross compiler is in place etc.).

  • Check out the version given by above recipe (SRCREV). E.g.
git checkout 58cf2f1425abfd3a449f9fe985e48be2d2555022
  • Copy patches and defconfig to kernel sources. For this, in kernel main directory create a directory patches (this is used by quilt) and copy the patches from OE directory (e.g. recipes/linux/linux-omap-2.6.29/) to it. E.g.:
cp -r <path_to>setup-scripts/sources/meta-ti/recipes-kernel/linux/linux-mainline-3.2/* <path_to>/patches/
  • Go into the patches directory, and there create a file series (used by quilt) and add the patch description from the above recipe (patch files from the SRC_URI and SRC_URI_append_beagleboard variables). This is done by removing the leading file:// and trailing \ from patch list and putting this list into series file. E.g.
grep "^.*file:\/\/" < linux-mainline_3.2.bb |sed "s/^.*file:\/\///" | sed "s/ [\\]//" >  <path_to>/patches/series

With above example, the series file should look like:

> cd patches
> cat series
distro/0001-kbuild-deb-pkg-set-host-machine-after-dpkg-gencontro.patch
omap_cpufreq/0001-cpufreq-OMAP-cleanup-for-multi-SoC-support-move-into.patch
omap_cpufreq/0002-cpufreq-OMAP-Add-SMP-support-for-OMAP4.patch
...

The result of this should be a patches directory containing all the patches described by the series file:

> ls patches
...
distro/
omap_cpufreq/
...
series
...
  • Now, go back into the kernel main directory. There call[1]
quilt push -a

This should result in quilt applying all patches from patches directory in the order described by series file to OMAP Linux kernel.

  • Use defconfig from e.g. linux-mainline-3.2/beagleboard/defconfig to configure your patched kernel. If you copied as above, the defconfig file should be in patches/beagleboard/defconfig now. E.g.:
cp patches/beagleboard/defconfig .config
make menuconfig
  • Compile your kernel and modules as you are used to it. E.g.:
export PATH=$PATH:<path_to_gcc>
make -j4 uImage CROSS_COMPILE=arm-none-linux-gnueabi-
...

Result should be an uImage which is the same as if it would be compiled with OE.

  1. 1.0 1.1 You can substitute quilt with a command like (while read line; do patch -p1 < "patches/"$line; done) < patches/series