Difference between revisions of "Kernel Build"

From Gumstix User Wiki
Jump to: navigation, search
(Main website is up to date so just add hints and tips to this entry)
Line 1: Line 1:
11 April 2012
+
This wiki entry adds a few details on building the Gumstix Linux kernel from source.
 
+
This wiki entry explains how to build the Gumstix Linux kernel from source.
+
  
 
Start by installing the [http://wiki.gumstix.org/index.php?title=Toolchain toolchain].
 
Start by installing the [http://wiki.gumstix.org/index.php?title=Toolchain toolchain].
Line 8: Line 6:
 
  $ sudo apt-get install uboot-mkimage git make
 
  $ sudo apt-get install uboot-mkimage git make
  
Next we need to get the patched kernel source that's available at www.sakoman.com.
+
The official kernel build [http://gumstix.org/basic-cross-compilation.html instructions] are the best source to describe building a kernel and are up to date. The gumstix kernels are stored on [https://github.com/gumstix/linux github] and are in different branches for differing platforms. There is a table of branches against platforms on the [http://gumstix.org/access-source-code.html gumstix.org website].
You can browse Sakoman's git repository [http://www.sakoman.com/cgi-bin/gitweb.cgi?p=linux-omap-2.6.git;a=summary here].
+
 
 +
The most usual way to pull the source code is using git:
 +
 
 +
$ git clone --branch omap-3.6 git://github.com/gumstix/linux.git Linux
 +
 
 +
will clone the entire source tree to your machine and checkout the omap-3.6 branch into the "linux" directory. There are plenty of guides online to using git but a few timesaving methods are worth mentioning:
 +
 
 +
=== Cloning a shallow tree ===
 +
 
 +
You can clone just the tip of the relevant branch using a shallow clone. This has some restrictions but saves time and bandwidth:
 +
 
 +
  <nowiki>$ git clone --depth 1 --branch omap-3.6 https://github.com/gumstix/linux.git omap-3.6</nowiki>
 +
 
 +
As of November 2013, this will pull 190MB from the server instead of over a gigabyte.
 +
 
 +
You can also pull a zip file of this branch, either using the [https://github.com/gumstix/linux website] or by finding the appropriate link (use the website!) and using curl or wget.
  
Decide where you want your kernel source to go an move to that directory.  Then use git to download it.
+
  <nowiki>$ wget https://github.com/gumstix/linux/archive/omap-3.6.zip</nowiki>
$ git clone git://www.sakoman.com/git/linux-omap-2.6 linux -b omap-3.2
+
  
The above command pulls down the omap-3.2 branch.  The omap-2.6.38 branch has proved stable for those who want to use Xenomai.  Once the above process is complete move into the new directory.  The first thing to do is to create a .config file.
+
(this will do a 301 redirect so be aware of this - you might get a very small file with html in it!)
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- omap2plus_defconfig (or maybe omap3_defconfig)
+
  
If you need to configure the kernel:
+
For the 3.6 branch, this will and pull approximately 123MB from the github server.
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
+
  
And now for the main kernel build.
+
There is absolutely no difference in result aside from the presence of the ".git" directory, but this has a few subtle consequences. If you build with the zip file, you will get kernel and module versions stamped "3.6.0". If you build from the git repository, the make process:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage -j4
+
  
When the above completes, uImage can be found in arch/arm/boot/
+
* detects the git repository presence
 +
* see that the checkout is not stamped with a tag (eg: "3.6.0").
 +
* adds a + to all versions to show that the repository is not officially 3.6.0.
  
Build the kernel modules.
+
Thus you will get kernel and module version stamped with "3.6.0+". If you try and load a 3.6.0+ module into a 3.6.0 kernel, it will fail with an "invalid module format" error. You can force it with "modprobe -f" but that isn't really a recommended action generally. The normal procedure is to install the kernel and modules together (see the [http://gumstix.org/basic-cross-compilation.html website] for details.
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules -j4
+
  
To install your kernel modules into your root file system:
+
You can override the version modification by setting LOCALVERSION (to anything) before running make.
$ make ARCH=arm modules_install INSTALL_MOD_PATH=/path-to-your-rootfs/
+

Revision as of 03:14, 19 November 2013

This wiki entry adds a few details on building the Gumstix Linux kernel from source.

Start by installing the toolchain.

You will also need the U-boot 'mkimage' utility. Debian and Ubuntu users can install it from their respective repositories. It's also compiled when U-boot is built if you can't get it otherwise. On top of that you will need 'git' and 'make'.

$ sudo apt-get install uboot-mkimage git make

The official kernel build instructions are the best source to describe building a kernel and are up to date. The gumstix kernels are stored on github and are in different branches for differing platforms. There is a table of branches against platforms on the gumstix.org website.

The most usual way to pull the source code is using git:

$ git clone --branch omap-3.6 git://github.com/gumstix/linux.git Linux

will clone the entire source tree to your machine and checkout the omap-3.6 branch into the "linux" directory. There are plenty of guides online to using git but a few timesaving methods are worth mentioning:

Cloning a shallow tree

You can clone just the tip of the relevant branch using a shallow clone. This has some restrictions but saves time and bandwidth:

 $ git clone --depth 1 --branch omap-3.6 https://github.com/gumstix/linux.git omap-3.6

As of November 2013, this will pull 190MB from the server instead of over a gigabyte.

You can also pull a zip file of this branch, either using the website or by finding the appropriate link (use the website!) and using curl or wget.

 $ wget https://github.com/gumstix/linux/archive/omap-3.6.zip

(this will do a 301 redirect so be aware of this - you might get a very small file with html in it!)

For the 3.6 branch, this will and pull approximately 123MB from the github server.

There is absolutely no difference in result aside from the presence of the ".git" directory, but this has a few subtle consequences. If you build with the zip file, you will get kernel and module versions stamped "3.6.0". If you build from the git repository, the make process:

  • detects the git repository presence
  • see that the checkout is not stamped with a tag (eg: "3.6.0").
  • adds a + to all versions to show that the repository is not officially 3.6.0.

Thus you will get kernel and module version stamped with "3.6.0+". If you try and load a 3.6.0+ module into a 3.6.0 kernel, it will fail with an "invalid module format" error. You can force it with "modprobe -f" but that isn't really a recommended action generally. The normal procedure is to install the kernel and modules together (see the website for details.

You can override the version modification by setting LOCALVERSION (to anything) before running make.