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/libX11.so.6 /usr/lib32/libX11.so
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 http://android.git.kernel.org/repo >~/bin/repo $ chmod +x ~/bin/repo
$ mkdir ~/foo $ cd ~/foo $ repo init -u git://android.git.kernel.org/platform/manifest.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. Here's a config file prepared by xvilka in case you need it.
$ cd ~/foo $ make -f kernel/kernel.mk 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/
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/kernel.mk ENG_BLD=1
Follow the instructions for compiling cupcake for HTC Dream replacing cupcake with eclair and Dream with Milestone.
Kernel compilation on Windows could be a bit tricky. Colinux1) 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 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:
--- ../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
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/d
Remove 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.
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.
To access host's file system, first specify
cofs0=r:\
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
The kernel build output is about
cobd2=fs\cobd2.img
to coLinux\fs\ubu.conf if you haven't done so yet.
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
/dev/cobd2 /mnt/cobd2 ext3 defaults 0 1
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.
There're several options:
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.
Visit kernel_sources to see the location of the kernel source. Milestone 01.15.0 has been tested. Extract the source to ~/android.
/root # Home
prebuilt # Untar the ARM tool chain to ~
android -> /mnt/cobd2 # ln -s /mnt/cobd2 android
kernel # Milestone kernel source
b.sh # Shell script to make
#!/bin/bash make -f kernel/kernel.mk KERNEL_CROSS_COMPILE=~/prebuilt/bin/arm-eabi- $*
cd ~/android ./b.sh
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 kernel_sources too.
1. Download your device kernel, unpack this and create configs and headers:
make mapphone_defconfig make headers_install ARCH=arm INSTALL_HDR_PATH=~/build/kern_h/
You must know, what proccessor chip you have on target device, and set optimisation options from (http://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/ARM-Options.html#ARM-Options) For example, if you have Motorola Milestone - so processor chip is TI OMAP3430 - ARM Cortex a8 (armv7a arch) (http://en.wikipedia.org/wiki/ARM_architecture) So you need use configs with -omap3430 suffix. If you have HTC Hero you need configs with -msm7200a suffix.
Also, I recommend use kernel-…configs instead of XVilka-…configs for creating toolchain for kernel building and hacking.
Set enviroment variable for building options:
export _XXCFLAGS=" -march=armv7-a -mtune=cortex-a8 -mfpu=neon" (if you have Milestone/Droid or other device on TI OMAP3430) export _XXCFLAGS=" -march=armv6j -mtune=arm1136jf-s" (if you have HTC Hero or other device on Quallcomm MSM 7200A)
2. Download crosstool-ng (http://ymorin.is-a-geek.org/dokuwiki/projects/crosstool), Unpack, build (you need for: make,install,bash,cut,sed,grep,gcc,awk,bison,flex,automake,libtool,stat, wget,cvs,patch,tar,gzip,bzip2,lzma,readlink,ncurses, mpfr-dev, gmp-dev)
.configure make make install
3. Create dir toolchain-android, cd to it and copy files: XVilka-crosstool-<suffix>.config in .config XVilka-uClibc-<suffix>.config in uClibc-0.9.30.2.config and then run:
ct-ng menuconfig
change anything, if you need, and save to .config then exec:
ct-ng build
4. Done! We have toolchain in build/x-tools. All tools have this triplet: arm-android-linux-uclibsgnueabi-* just add them in PATH
export PATH=$HOME/build/x-tools/arm-android-linux-uclibcgnueabi/bin:$PATH export CROSS_COMPILE=arm-android-linux-uclibcgnueabi- export KERNEL_CROSS_COMPILE=arm-android-linux-uclibcgnueabi-
So we can run:
arm-android-linux-uclibcgnueabi-gcc
Also we have system root directory in: ~/build/x-tools/arm-android-linux-uclibcgnueabi/arm-android-linux-uclibcgnueabi/sys-root For some reasons we just copy it in ~/build/cross/sys-root
chmod +w sys-root chmod +w sys-root/usr chmod +w sys-root/usr/lib
4. Build and install libbfd with all targets support:
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src login
{enter "anoncvs" as the password}
cvs -z 9 -d :pserver:anoncvs@sourceware.org:/cvs/src co binutils
cd binutils/bfd
./configure --enable-targets=arm-android-linux-uclibcgnueabi --prefix=$HOME/build/cross
make
make install
Also we need for zlib and zlib-devel, and liberty library.
5. Build ksplice patched with ksplice.patch
git clone http://www.ksplice.com/git/ksplice.git cd ksplice patch -p0 < ksplice.patch ./configure --with-libbfd=$HOME/build/cross/lib/libbfd.a --with-bfd-include-dir=$HOME/build/cross/include make sudo make install
6. Build kernel
make mapphone_defconfig make -f kernel/kernel.mk copy files System.map and .config in directory kernel/ksplice ksplice-create --diffext=.patched_ext kernel
For compiling some small hacking utility or kernel module you don need in hole gcc toolkit (more than 60 MB) and hole libc. So we need for something small and tiny. It can be tiny C compiler (tcc) and dietlibc You can download, unpack, copy bin files in /usr/local/bin, lib files in /usr/local/lib, tiny-root in $HOME/build. Link for downloading - tiny-tool.tar.gz If you want to know how i building it - read below:
For example we choose working directory as $HOME/build Download latest release of tiny C compiler (http://tinycc.org/) from git:
git clone git://repo.or.cz/tinycc.git $HOME/build/tinycc
Download latest release of dietlibc (http://www.fefe.de/dietlibc/) from cvs:
cvs -d :pserver:cvs@cvs.fefe.de:/cvs -z9 co $HOME/build/dietlibc
After this we need to build tcc:
cd $HOME/build/tinycc ./configure --enable-cross --prefix=$HOME/build/tiny-toolchain make make install
So we have this tools in $HOME/build/tiny-toolchain/bin:
arm-eabi-tcc arm-fpa-ld-tcc arm-fpa-tcc arm-vfp-tcc c67-tcc i386-win32-tcc tcc x86_64-tcc x86_64-win32-tcc
Add them in enviroment variable PATH for easy executing:
export PATH=$HOME/build/tiny-toolchain/bin:$PATH
But also we need a C library. So make the “target root” directory:
mkdir $HOME/build/tiny-root
Building dietlibc:
cd $HOME/build/dietlibc make prefix=$HOME/build/tiny-root make prefix=$HOME/build/tiny-root ARCH=arm CROSS=arm-android-linux-uclibcgnueabi- make install-headers prefix=$HOME/build/tiny-root ARCH=arm CROSS=arm-android-linux-uclibcgnueabi- make install-bin prefix=$HOME/build/tiny-root ARCH=arm CROSS=arm-android-linux-uclibcgnueabi-
Prepare “target root” directory:
ln -s $HOME/build/tiny-root/lib-arm $HOME/build/tiny-root/lib cp $HOME/build/tiny-toolchain/include/* $HOME/build/tiny-root/include/ cp $HOME/build/tiny-toolchain/lib/* $HOME/build/tiny-root/lib/
Also, for kernel development we need for kernel headers:
cd /path/to/you/kernel/sources make headers_install ARCH=arm INSTALL_HDR_PATH=$HOME/build/tiny-root/include
So, we have all needed libraries and headers in $HOME/build/tiny-root You can use tcc for compiling your small utilities, for example by this command:
arm-eabi-tcc -nostdinc -nostdlib -I$HOME/build/tiny-root/include -L$HOME/build/tiny-root/lib -o example example.c
Enjoy!