Ubuntu kernel for OMAP4
From OMAPpedia
This page describes simple instructions for getting and generating OMAP4 Ubuntu kernel packages. More detailed or alternative approaches are available on other pages linked here
The standard compilation and packaging for Ubuntu kernel is made natively (on ARM device).
So these instructions are for native compilation / packaging. However when applicable, additional instructions are also provided for cross-compilation.
These instructions are for a Ubuntu target or host.
For any support, feel free to join us on irc at #ubuntu-arm, #pandaboard or #linux-omap on irc.freenode.net.
Contents |
Introduction to kernel packages
Ubuntu kernels are delivered in the form of Debian packages. For OMAP4, you needat least the following kernel packages:
- 1 package for the kernel image and modules: linux-image-<kernel version>-<abi>-omap4
- installs kernel modules in /lib/modules
- installs kernel image (stripped vmlinuz), config, abi, map and initrd in /boot.
- 2 packages for the kernel header files (and configuration): linux-headers-<kernel version>-<abi>, linux-headers-<kernel version>-<abi>-omap4
- installs kernel headers and configuration into /usr/src
- headers are optional and are usually only required if you need to build kernel modules.
- If your file-system hosts some DKMS-handled kernel modules (like WLAN and SGX for OMAP4), installing these header files will trigger the re-build and re-install of the DKMS kernel modules.
=> Using packages, Ubuntu kernel can be handled like almost any other Ubuntu package, using Aptitude, apt or dpkg. This allows very easy kernel upgrades, and installation of kernel headers when necessary. For this reason, it is favored to re-gerenerate kernel packages and install these packages to upgrade your Ubuntu file-system with a new kernel. This is what this page deals about. However for some cases it may be more convenient to just re-build a kernel and not package it. This is also described in this page: Ubuntu kernel build alternatives.
Ubuntu kernel sources
There are several git trees hosting the sources for Ubuntu kernel supporting OMAP4:
- Official Ubuntu git tree: http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-maverick.git;a=shortlog;h=refs/heads/ti-omap4 (ti-omap4 branch)
- TI Ubuntu git tree: http://dev.omapzoom.org/?p=integration/kernel-ubuntu.git
The instructions in this page apply to both the official Ubuntu tree and the TI tree from release L24.10.
TI tree contains additional features, but may be less stable than the official Ubuntu tree (which contains Ubuntu Maverick for OMAP4 code).
The preferred way of retrieving the kernel sources is to use git. For example:
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-maverick.git git checkout -b working origin/ti-omap4
(Note that an alternative to git to retrieve the kernel sources is to run: apt-get source linux-image-<kernel version>-<abi>-omap4)
All the following instructions shall be run from the kernel root folder. (this is the one with arch, debian debian.ti-omap4 etc. directories in it)
Building the kernel: generate a kernel package
- Install packages required for building:
(Considering that you already run a quite recent Ubuntu kernel - means: supported by these instruction)
sudo apt-get build-dep linux-image-$(uname -r)
- Generate the kernel package
fakeroot debian/rules clean dpkg-buildpackage -B -uc -us
=> The kernel packages (*.deb) are generated in the parent folder.
Alternative commands for cross-compilation (using code-sourcery for example):
fakeroot debian/rules clean CROSS_COMPILE=<path to cross-toolchain/bin>/arm-none-linux-gnueabi- do_tools=false dpkg-buildpackage -B -aarmel -uc -us
(note that the do_tools=false option will prevent the tools package from beeing generated. Building this package fails with some cross-toolchains like CodeSourcery 2010q1)
Customize the kernel
Change the kernel config
The Ubuntu kernel config is located in debian.ti-omap4/config/config.common.ubuntu. To edit the config, run the 'editconfigs' command:
# You must have run the following 'clean' command at least once before: fakeroot debian/rules clean fakeroot debian/rules editconfigs
... and answer 'y' to the question (Do you want to edit config: armel/config.flavour.omap4).
ABI or modules list change
The kernel ABI (Application Binary Interface) are the exported functions that modules (AKA drivers) can use to do things in kernel space (see here for more information)
The kernel packaging tools will fail package creation if the kernel ABI or modules-list changed since the last packaged version. This test can be skipped to complete the package creation in spite of ABI or modules list change. Add the following option to your dpkg-buildpackage command-line:
skipabi=true skipmodule=true
Change the package version
To generate a package with a different version number: edit debian.ti-omap4/changelog and modify the 1st line version number. For example:
- linux-ti-omap4 (2.6.35-980.1release3) maverick; urgency=low + linux-ti-omap4 (2.6.35-980.1release3+test1) maverick; urgency=low
=> then generate the package. Its name will include this new version information.
Install a kernel package
Case 1: the kernel packages are on a PPA
If the package you want to install is on a PPA, make sure the PPA is listed in your /etc/apt/sources.list file, and run:
sudo apt-get update sudo apt-get install linux-headers-<kernel release> linux-image-<kernel release>
where <kernel release> is the information returned by uname -r. for example for official Ubuntu 10.10: 2.6.35-903-omap4.
Note that several versions of a package may be available, This can be seen by running:
apt-cache show <package name> | grep Version
To install one specific version of a package:
sudo apt-get install <package-name>=<package version>
Ex: sudo apt-get install linux-image-2.6.34-900-omap4=2.6.34-900.1~ti+release0
Case 2: the kernel packages .deb files are available
Installing is as simple as:
sudo dpkg -i <kernel packages>.deb
Important point: install all 3 following packages in this order (the order is important between the headers packages):
linux-headers-<kernel version>-<abi> linux-headers-<kernel version>-<abi>-omap4 linux-image-<kernel version>-<abi>-omap4
(This order will ensure that any DKMS modules relying on the kernel headers will be able to build upon install of these new headers)
For example:
sudo dpkg -i linux-headers-2.6.35-980-omap4_2.6.35-980.1release3_armel.deb linux-headers-2.6.35-980_2.6.35-980.1release3_armel.deb linux-image-2.6.35-980-omap4_2.6.35-980.1release3_armel.deb
(Does not this example exchange the installation order of the linux-headers from the order shown above? i.e. -omap4 first)
Install the kernel uImage to the boot partition
Once the kernel packages are installed, installing the new kernel image to the boot partition is as easy as:
sudo flash-kernel
Note on flash-kernel: This script will take some input files into the /boot folder (vmlinuz, Initrd, boot.script), generate u-boot friendly version of these images (uImage, uInitrd and boot.scr), and install them on the boot partition. flash-kernel grabs the path to the target boot partition in /etc/flash-kernel.conf (UBOOT_PART variable).
Updating kernel bootargs
Kernel command line is passed through u-boot and by the mean of a boot.scr file hosted on the boot partition. To update the boot.scr script:
- modify /boot/boot.script
- re-generate boot.scr: sudo flash-kernel
Note: it you don't have a /boot/boot.script file, you can generate one from the boot.scr located on your boot partition by doing a strings boot.scr > boot.script
Alternate method to generate boot.scr from boot.script
mkimage -A arm -T script -C none -n "Boot Image" -d boot.script boot.scr
kernel and WLAN / SGX kernel drivers
On Ubuntu 10.10 and TI Ubuntu releases for OMAP4, two out of tree kernel modules need to be re-built each time the kernel image changes: WLAN and SGX (omap_gpu)
(Note: the need for modules re-build for each new kernel image is enforced by not defining the CONFIG_MODVERSIONS kernel flag. This is a requirement from current WLAN driver itself)
To make re-building of these modules transparent to the Ubuntu user, WLAN and SGX (omap_gpu) modules are handled through DKMS. So when installing new kernel header packages, DKMS will try to re-build WLAN and SGX modules for this new kernel. (note that if you build the kernel packages, they must be built natively: cross-compiled kernel headers packages will make DKMS modules build fail. See Bug 666267)
If you use a non-packaged kernel, you need to re-build the out of tree drivers yourself. Note that DKMS may still help you in this task, but would will have to provide the proper pointers to your kernel source tree and configuration to DKMS manually.
Some links about DKMS: DKMS manpage, DKMS homepage, DKMS tutorial, DKMS Ubuntu package tutorial
Links
Ubuntu kernel build alternatives
Launchpad OMAP4 Ubuntu kernel bugs tracking: https://bugs.edge.launchpad.net/ubuntu/+source/linux-ti-omap4/
Ubuntu kernel page: https://wiki.ubuntu.com/Kernel
Ubuntu kernel dev: https://wiki.ubuntu.com/Kernel/Dev
How to package your kernel from scratch: https://wiki.linaro.org/Resources/HowTo/PackageYourOwnKernel
Step by step blog guide to compiling the Ubuntu Kernel http://adventuresinsilicon.blogspot.com/2011/02/pandaboard-ubuntu-how-to-recompile.html