Ubuntu kernel for OMAP4
This page describes simple instructions for getting and generating OMAP4 Ubuntu kernel packages.
The standard compilation and packaging for Ubuntu kernel is made natively (on ARM device) on ti-ubuntu-L24.* and glp1.4 branches.
Since Kernel 3.0, Cross Compilation is supported and encouraged.
These instructions are for a Ubuntu target and/or host.
For any support, feel free to join us on irc at #ubuntu-arm, #pandaboard or #linux-omap on irc.freenode.net or to join firstname.lastname@example.org.
 Introduction to kernel packages
Ubuntu kernels are delivered in the form of Debian packages. For OMAP4, you need at 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 regenerate 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.
 Build Environment Setup
Kernel packages can be build natively on OMAP4 boards with Ubuntu Filesystem or Cross Compiled on Ubuntu Machine.
We encourage to use Cross Compilation environment.
 Cross Compiler setup
Since Ubuntu precise (12.04), hardware floating-point support was introduced (armhf). So armhf cross-compiler are required for precise (12.04) environment and after whereas armel cross-compiler shall be used.
 armhf cross-compiler setup
On precise machine and after, you just need to install the following meta-packages:
$ sudo apt-get install gcc-arm-linux-gnueabihf cpp-arm-linux-gnueabihf
If your are on oneiric machine or lower distro, you can either upgrade to more recent distro or install armhf standalone linaro cross compiler, please refer to the following page: https://launchpad.net/linaro-toolchain-binaries and download the most recent linux armhf cross compiler. Please refer to the README.txt to complete the setup and to export Compiler directory to the PATH.
 armel cross-compiler setup
Just execute the following commands:
$ sudo apt-get install gcc-arm-linux-gnueabi cpp-arm-linux-gnueabi
You can also use code-sourcery armel cross-compiler.
 Additional Build Environment Prerequisites
- Install packages required for kernel packages build - this is valid on Cross Compilation and Native environment:
sudo apt-get build-dep linux-image-$(uname -r) sudo apt-get install dpkg-dev kernel-wedge
 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 then you need to find the tree for your Ubuntu Release, e.g.: ubuntu/ubuntu-precise.git. Then consider 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.x and GLP1.x.
The preferred way of retrieving the kernel sources is to use git. For example:
- Official Ubuntu git tree:
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-precise.git git checkout -b working origin/ti-omap4
- TI Ubuntu git tree:
git clone git://dev.omapzoom.org/pub/scm/integration/kernel-ubuntu.git git checkout -b working origin/ti-ubuntu-3.4-1486
Note: an alternative to git to retrieve the kernel sources is to run: apt-get source linux-image-<kernel version>-<abi>-omap4. This is valid only for native build.
 Building the kernel: generate a kernel package
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) => The kernel packages (*.deb) will be generated in the parent folder.
 ARMHF Cross-Compilation
- Export Variables:
export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabihf-
- Generate the kernel package
fakeroot debian/rules clean do_tools=false skipabi=true skipmodule=true dpkg-buildpackage -B -aarmhf -uc -us
 ARMEL Cross-Compilation
- Export Variables:
export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabi-
- Generate the kernel package
fakeroot debian/rules clean do_tools=false skipabi=true skipmodule=true dpkg-buildpackage -B -aarmel -uc -us
 Native Compilation
- Just Generate the kernel package
fakeroot debian/rules clean skipabi=true skipmodule=true dpkg-buildpackage -B -uc -us
 Customize the kernel
 GLP kernel modification and rebuild guidelines
Developer might need to rebuild a kernel with his own modifications, generating packages is a good solution to ease module installation and do comply with dkms packages. The only recommendation is to update the package version before to generate new packages to distinguish your work with existing packages.
To do this, proceed as follow:
- Checkout the reference commit id / tag of the kernel you want to modify
- Apply your patch(es)
- Edit file debian.ti-omap4/changelog and modify the current version (first line of the file) with "+<comment><id>", for example:
linux-ti-omap4 (3.4.0-1486.4+mytest1) precise; urgency=low. DO NOT USE "_" or "-" character.
- Commit this small modification into a dedicated commit.
 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(s) (Do you want to edit config: arm[el|hf]/config.flavour.omap4). The debian environment is designed to support armel and armhf environment, modifying config through menu might not have the expected behavior, you might for example enable an option only in armel...
This is the reason why it might be easier to modify directly debian.ti-omap4/config/config.common.ubuntu and to check/regenerate it through the above procedure. Then say "yes" to all questions and exit without modifying from kernel menu.
You might then archive the new generated config locally in your git tree.
 Install a kernel package
 Case 1: the kernel packages .deb files are available
Above build instructions shall have generated at least these 3 files (other udeb files can be ignored):
linux-headers-<kernel version>-<abi> linux-headers-<kernel version>-<abi>-omap4 linux-image-<kernel version>-<abi>-omap4
Copy these 3 files on your Panda and install them in the same dpkg command, e.g.:
sudo dpkg -i linux-*_<version>_armhf.deb
On Precise: Sometimes, the pvr-omap dms module is not rebuilt whereas it should, if after the reboot, module "omapdrm_pvr" is not loaded, please execute following command to force the rebuild:
sudo apt-get install --reinstall pvr-omap4-dkms
 Case 2: 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
 Install the kernel uImage to the boot partition
With recent Ubuntu distro (precise at least) there is no need to execute this step, kernel is flashed automatically into the boot partition.
On older Ubuntu distro, you need to execute manually:
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.
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