Jump to: navigation, search

Compiling kernel modules for Milestone's original kernel


  • Linux system
  • Build essentials
  • Java JDK 5.0
  • Flex
  • Bison
  • Gperf
  • SDL
  • ESD
  • WxGTK 2.6
  • Zip
  • Curl

For Ubuntu 9.10 32-Bit:

$ sudo apt-get install git-core gnupg sun-java5-jdk flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev

For Ubuntu 9.10 64-Bit:

$ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl sun-java5-jdk zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

Set the system to use the right version of java by default:

$ sudo update-java-alternatives -s java-1.5.0-sun

X11: Ubuntu doesn't have packages for the X11 libraries, but that can be worked around with the following command:

$ sudo ln -s /usr/lib32/ /usr/lib32/

Setting up the Environment

  1. Refer to this page to find the kernel sources as they are specifically made for the Milestone...
  2. Download repo (a tool provided by Google to pull down the source code)
$ mkdir ~/bin
$ export PATH=$PATH:~/bin
$ curl >~/bin/repo
$ chmod +x ~/bin/repo

Getting the Source

$ mkdir ~/foo
$ cd ~/foo
$ repo init -u git://
$ repo sync


Create a kernel environment in your working directory

$ cd ~/foo
$ mkdir kernel

After untarring archive_0115-kernel.tgz into the kernel directory, we're ready to build the kernel and modules. [1]'s a config file prepared by xvilka in case you need it.

$ cd ~/foo
$ make -f kernel/ ENG_BLD=1

Your zImage (the kernel) will be located at ~/foo/motorola/bsp/prebuilt/target/images/zImage Your modules can be found in ~/foo/motorola/bsp/prebuilt/target/images/system/lib/modules/

Compiling mtd-hack.c

  1. Place mtd-hack.c inside: ~/foo/kernel/drivers/mtd/
  2. Add this line to the Makefile: obj-m += mtd-hack.o
  3. Compile it with the same command as above.
    $ make -f kernel/ ENG_BLD=1

Compiling kernel for Milestone

Follow the instructions for cupcake for HTC Dream replacing cupcake with eclair and Dream with Milestone.

Kernel compilation on Windows(or other OSes that Colinux supports)

Kernel compilation on Windows could be a bit tricky. [[2]]((suggested by playya)) is used to ease the life. The smallest tool set is examined and the required storage space is provided for constrained build environment.

In this guide, the Ubuntu 9.04 1GB file system(download size is 4xMB) will be used.

Minimum storage requirement:

^ ^Size ^Description ^ | |1GB|Ubuntu 9.04 FS + basic tool + 74MB ARM tool chain| | |1.3GB(accounting for wasted size)|763MB build output + 384MB Kernel source + 2.6MB zImage and ko| |Total|2.3GB| |

Colinux setup

Colinux consists of a user space kernel and a front-end(or layer) that sits on the OS side. It is capable of running a Linux natively on Windows. Due to the small download size required(around 60MB, Colinux+Ubuntu 9.04 FS), it could provide a quick jump into the Linux world on Windows.


The directory layout on Windows:

^Path ^Description ^ |[somewhere]\coLinux|Installation folder of coLinux| |[somewhere]\coLinux\fs|Sub-folder to put our linux|

Follow these steps or work on your own:

 - Visit [[3]] download link.
 - Download and install coLinux-0.7.5.exe((the lastest as of the time of writing)).
   - Skip the image download.(You may choose one there provided that they have apt-get)
 - Download [[4]]
 - Unzip Ubuntu-9.04-1gb.7z to coLinux\fs.
 - Create a 1.3GB(or 1.5GB if u have more spaces) file as coLinux\fs\cobd2.img. See [[5]]. Create the file with the desired size first, then format it in coLinux later.
 - Copy coLinux\example.conf to coLinux\fs\ubu.conf.
 - Modify ubu.conf appropriately. Here is the diff: <file properties>

--- ../example.conf 2009-09-14 22:26:42.000000000 +0000 +++ ubu.conf 2010-03-03 07:32:13.000000000 +0000 @@ -20 +20 @@ -cobd0="c:\coLinux\root_fs" +cobd0="fs/Ubuntu-9.04.ext3.1gb.fs" @@ -41 +41 @@ -#cocon=120x40 +cocon=120x40 @@ -47 +47 @@ -#eth0=slirp +eth0=slirp,,tcp:22:22 @@ -50 +50 @@ -#eth1=tuntap +eth1=tuntap @@ -57,0 +58,4 @@ +cofs0=d:\ +cofs1=r:\ + +cobd2=fs\cobd2.img </file> Edit the file to see most meaning of the settings. cofs0=d:\ will expose Windows d:\ drive to the cofs0 that can be mounted inside coLinux. To mount:

 mkdir /mnt/d
 mount -t cofs 0 /mnt/dRemove cofs0=d:\ and cofs1=r:\ if you don't have these drives. Exposing a drive is important to extract downloaded tools from Windows. cobd2=fs\cobd2.img will expose a image file to the cobd2 device that will be used to store the build output.
 - Open a command prompt, cd to the directory of coLinux then start it by executing colinux-daemon @fs\ubu.conf. You should see a linux console popped up.


User id: root Password: root

Use alt+f1, alt+f2, ......etc to switch to another terminal.


Alternately, use ssh client like putty to connect to the host machine's port 22 as set by "eth0=slirp,,tcp:22:22". Putty gives better control on the scroll history and coloring.

Accessing the host's file system

To access host's file system, first specify<file properties>cofs0=r:\</file> in the ubu.conf above where r:\ is the drive you want to expose. Next start up coLinux then execute:mkdir /mnt/r mount -t cofs 0 /mnt/r

Attach a new file system to store the kernel build output

The kernel build output is about

 - See [[6]] for how to create a file of size at least 1.3GB at coLinux\fs\cobd2.img. No need to format the image as it may take time.
 - Add <file properties>cobd2=fs\cobd2.img</file> to coLinux\fs\ubu.conf if you haven't done so yet.
 - Restart coLinux if it's running.
 - Login to linux, execute these:mkfs.ext3 /dev/cobd2   # Be careful to type cobd2, not others!!

mkdir /mnt/cobd2 # Create an empty folder for mounting. mount -t ext3 /dev/cobd2 /mnt/cobd2

 - Add the mounts to /etc/fstab if u want to save them from a reboot:<file>

/dev/cobd2 /mnt/cobd2 ext3 defaults 0 1 </file>

Minimum tool set

The basic

Install the needed tools:

 apt-get install flex bison gperf build-essential zip

flex, bison and gperf are needed by the make to do some pre-processing on the source files.

Cross-compiler toolchain

There're several options:

 - [Open Source Platform prebuilt snapshot]. Click on the snapshot link to get a tar. It's about 74MB uncompressed.
 - Android ndk (as tested 1.6 is arm-eabi-4.2.0 which doesn't support armv7-a architecture)
 - [G++ arm eabi tool-chain]. It is very large because all of its binary are statically linked. So it is not recommended.

Assume you've chosen 1 since it is the best current option. After downloaded the toolchain to r:\prebuilt-balhbalhbalbhabalh.tar.gz, execute: tar xzf /mnt/r/prebuilt-balhbalhbalbhabalh.tar.gz -C ~ A prebuilt folder will be created in user home.

Build the kernel

Grab the source

Visit tools:kernel_sources to see the location of the kernel source. Milestone 01.15.0 has been tested. Extract the source to ~/android.

Prepare the build folder

 /root                    # Home
   prebuilt               # Untar the ARM tool chain to ~
   android -> /mnt/cobd2  # ln -s /mnt/cobd2 android
     kernel               # Milestone kernel source                 # Shell script to make

<file bash>

  1. !/bin/bash

make -f kernel/ KERNEL_CROSS_COMPILE=~/prebuilt/bin/arm-eabi- $* </file>

Build now

cd ~/android ./

You may see an error about wilink_6_1. As long as you aren't going to build a whole system, you can ignore it. Otherwise, download the system-wlan source from tools:kernel_sources too.