Difference between revisions of "Kernel Build"

From Gumstix User Wiki
Jump to: navigation, search
 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
11 April 2012
+
There are [https://github.com/gumstix/yocto-manifest/wiki/Kernel,-Device-Tree-and-u-boot updated instructions] for standalone compilation of u-boot and linux.  Yocto users may also find [https://github.com/gumstix/yocto-manifest/wiki/Kernel-Compilation this] useful.
  
This wiki entry explains how to build the Gumstix Linux kernel from source.
+
This wiki entry has some older details on building the Gumstix Linux kernel and bootloader 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 8:
 
  $ 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].
+
  
Decide where you want your kernel source to go an move to that directory.  Then use git to download it.
+
The most usual way to pull the source code is using git:
$ 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.
+
$ git clone --branch omap-3.6 git://github.com/gumstix/linux.git linux
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- omap2plus_defconfig (or maybe omap3_defconfig)
+
  
If you need to configure the kernel:
+
will clone the entire source tree to your machine and checkout the omap-3.6 branch into the "linux" directory. You can also use <tt>https</tt> instead of <tt>git</tt>. There are plenty of guides online to using git but a few timesaving methods are worth mentioning:
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- menuconfig
+
  
And now for the main kernel build.
+
=== Cloning a shallow tree ===
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage -j4
+
  
When the above completes, uImage can be found in arch/arm/boot/
+
You can clone just the tip of the relevant branch using a shallow clone. This has some restrictions but saves time and bandwidth:
  
Build the kernel modules.
+
  <nowiki>$ git clone --depth 1 --branch omap-3.6 https://github.com/gumstix/linux.git omap-3.6</nowiki>
$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules -j4
+
  
To install your kernel modules into your root file system:
+
As of November 2013, this will pull 190MB from the server instead of over a gigabyte.
$ make ARCH=arm modules_install INSTALL_MOD_PATH=/path-to-your-rootfs/
+
 
 +
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.
 +
 
 +
  <nowiki>$ wget https://github.com/gumstix/linux/archive/omap-3.6.zip</nowiki>
 +
 
 +
(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 pull approximately 123MB from the github server.
 +
 
 +
=== Subtleties ===
 +
 
 +
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 [http://gumstix.org/basic-cross-compilation.html website] for details.
 +
 
 +
You can override the version modification by setting LOCALVERSION (to anything) before running make.
 +
 
 +
 
 +
== U-Boot ==
 +
 
 +
The source for U-Boot is held in [https://github.com/gumstix/u-boot github]. The branch that the Yocto recipes are using is currently 2013.07 (although there is a 2013.10 branch too). You can checkout the branch with:
 +
 
 +
  $ git clone --branch v2013.07 git://github.com/gumstix/u-boot.git
 +
 
 +
or some variation of same (see above). You can also pull the zip file directly in the same way as above. You can configure U-Boot for:
 +
 
 +
Overo:
 +
  $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- omap3_overo_config
 +
 
 +
Duovero:
 +
  $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- omap4_duovero_config
 +
 
 +
Then build u-boot:
 +
  $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- all
 +
 
 +
This should create MLO, u-boot.bin and u-boot.img in your u-boot directory.

Latest revision as of 15:36, 1 April 2016

There are updated instructions for standalone compilation of u-boot and linux. Yocto users may also find this useful.

This wiki entry has some older details on building the Gumstix Linux kernel and bootloader 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. You can also use https instead of git. 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 pull approximately 123MB from the github server.

Subtleties

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.


U-Boot

The source for U-Boot is held in github. The branch that the Yocto recipes are using is currently 2013.07 (although there is a 2013.10 branch too). You can checkout the branch with:

 $ git clone --branch v2013.07 git://github.com/gumstix/u-boot.git

or some variation of same (see above). You can also pull the zip file directly in the same way as above. You can configure U-Boot for:

Overo:

 $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- omap3_overo_config

Duovero:

 $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- omap4_duovero_config

Then build u-boot:

 $ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- all

This should create MLO, u-boot.bin and u-boot.img in your u-boot directory.