Oct 23, 2014

Building the Ubuntu 14.04 LTS kernel on Ubuntu 14.04 LTS

To experiment with device drivers in the self-hosted configuration (the target and the host are the same), the Linux kernel must first be built.  I started from a Ubuntu help page.

Clone Ubuntu git: just the source ma'am

I got the Trusty source
  • git clone git://kernel.ubuntu.com/ubuntu/ubuntu-trusty.git
And then copy the config from /boot
  • henry@Zotac64:~/work/ubuntu-trusty$ cp /boot/config-3.13.0-37-generic .config
Bring the config up to date with the latest kernel changes
  • henry@Zotac64:~/work/ubuntu-trusty$ make oldconfig
Build the kernel (on for x64, don't need ARCH definition):
  • henry@Zotac64:~/work/ubuntu-trusty$ make
When done, the vmlinux ELF file ready.  It's huge; even larger than the Buildroot rootfs for the  Zynq eval platform I've been using:
  • henry@Zotac64:~/work/ubuntu-trusty$ ls -lh vmlinux
    -rwxrwxr-x 1 henry henry 151M Oct 23 19:18 vmlinux
Since this kernel should be compatible with my running kernel (where I am typing this blog entry) I can use this repository to write kernel modules and play around, WITHOUT changing my working kernel.

The "debian way": not so useful for kernel module development

  • apt-get source linux-image-$(uname -r)
Get the build tools with this command:
  • sudo apt-get build-dep linux-image-$(uname -r)
Undefine CROSS_COMPILE, otherwise the build gets confused:
  • export CROSS_COMPILE=
The kernel source is at ~/work/ubuntu/linux-3.13.0.  First generate the config files (use generic) with these commands:
  • chmod a+x debian/scripts/*
    chmod a+x debian/scripts/misc/*
    fakeroot debian/rules clean
    fakeroot debian/rules editconfigs
After entering the last command, type 'n' a few times.  Build the kernel with this command:
  • fakeroot debian/rules clean
    fakeroot debian/rules binary-headers binary-generic
If the build is successful, a set of three .deb binary package files will be produced in the directory above the build root directory, as you can see below:
  • henry@Zotac64:~/work/ubuntu$ ls
    linux-3.13.0
    linux_3.13.0-37.64.diff.gz
    linux_3.13.0-37.64.dsc
    linux_3.13.0.orig.tar.gz
    linux-cloud-tools-3.13.0-37-generic_3.13.0-37.64_amd64.deb
    linux-headers-3.13.0-37_3.13.0-37.64_all.deb
    linux-headers-3.13.0-37-generic_3.13.0-37.64_amd64.deb
    linux-image-3.13.0-37-generic_3.13.0-37.64_amd64.deb
    linux-image-extra-3.13.0-37-generic_3.13.0-37.64_amd64.deb
    linux-tools-3.13.0-37-generic_3.13.0-37.64_amd64.deb

No comments:

Post a Comment