This is a quick guide on getting started with compiling Android for the Touch Pro 2 from the git repositories. I am going to try to keep this short and simple, so I will be using my personal preference of software though others will work fine. This was made at the request of few people in the NAND testing thread, but I will try to include information for the non-NAND people too.
Required Tools
Virtualbox
Ubuntu (32bit is fine) Note: I recommend 10.04 for better stability with Virtualbox, but 10.10 does work just fine.
10 GB of disk space
High Speed Internet Connection
2 hours of time (about 30 minutes of actual interaction)
Installing Linux
First, install VirtualBox leaving everything as default. Now, click New and type Ubuntu 10.4 (or 10.10) for the name. Make sure Ubuntu is in the name so it auto-configures some options for us. For memory, I recommend 1 GB unless you have more than 4GB of RAM. For drives, leave the defaults and just keep clicking Next until it finishes.
Before you click Start, we want to optimize the settings and attach the ISO so it will boot from “CD”. To do this, Select Ubuntu 10.4 (or 10.10) and click Settings. Here are the settings you need to change:
Under the System section on the Motherboard tab, check
Enable IO APIC, and on the Processor tab, Set Processor Count to the number of cores on your processor.
Under the Storage section, click on IDE Controller and
change Type to ICH6. Now, click on the CD labeled Empty, then click the Folder with the green up arrow to open the Virtual Media Manager. Click Add and browse to the ISO you downloaded, click Open, click Select, and then click OK.
Now we can start the VM and install Ubuntu. Click Start and wait for the plum background with the keyboard at the bottom, press the down arrow and select Install Ubuntu. Keep clicking Forward until you can click Install Now. Follow the rest of the prompts while Ubuntu installs.
Preparing the Environment
Once Ubuntu is up and running, we need to install three software packages: Virtualbox Additions, git-core and wine. To install the VBox Additions, click Devices-CD/DVD Devices, and select VBoxGuestAdditions.iso. It never auto-runs for me, so I have to click Places, VBOXADDITIONS, then run autorun.sh, install and
restart so we can copy/paste between Windows and Ubuntu
Terminal is where we spend the rest of our time, so click Applications-Accessories, and drag Terminal to the taskbar. Now open Terminal and copy/paste the following into it:
Code:
sudo apt-get install git-core
sudo apt-get install wine
mkdir android
cd android
git clone git://android.git.kernel.org/platform/prebuilt.git
Note: If you prefer codesourcery's toolchain, you should download this one:
Link
NAND users will also need the following:
Code:
git clone git://gitorious.org/~acl/linux-on-qualcomm-s-msm/linux-msm-rhod-nand.git
git clone git://gitorious.org/tinboot-for-linux-msm/tinboot-linux-msm.git
git clone git://gitorious.org/tinboot-for-linux-msm/bootenv.git
Haret users will need the following:
Code:
git clone git://gitorious.org/linux-on-qualcomm-s-msm/linux-msm.git
git clone git://gitorious.org/xdandroid/rootfs.git
Cloning these could take a while, especially for the prebuilt toolchain from Google. Just copy/paste and go make dinner
Compiling Kernel and Modules
Now that you have everything downloaded, we are ready to start compiling. The developers have done an awesome job with the Makefiles, so we only need to worry about the toolchain (to compile ARM code using an x86 processor) and the defconfig (configuration that determines what gets built).
If you wanted to simply compile the zImage and modules, using Terminal, copy/paste the following:
Code:
cd android
mkdir modules
cd linux-msm-rhod-nand
make clean
make ARCH=arm htc_msm_nand_defconfig
make ARCH=arm CROSS_COMPILE=~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- INSTALL_MOD_PATH=~/android/modules zImage modules modules_install
Your zImage will be located under ~/android/linux-msm-rhod-nand/arch/arm/boot/ and the modules will be output to ~/android/modules (or wherever specified by INSTALL_MOD_PATH).
Haret users should use the following:
Code:
cd android
mkdir modules
cd linux-msm
make clean
make ARCH=arm htc_msm_android_defconfig
make ARCH=arm CROSS_COMPILE=~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- INSTALL_MOD_PATH=~/android/modules zImage modules modules_install
On NAND, we are now putting all of the modules into a squash compressed file. This takes a little bit of setup, but it allows us to support multiple kernels. Keep in mind that this requires
squashfs tools version 3.4. The modules need to be in the root of the squash file, and the name must be
2.6.27.46-01192-version.sqsh.
To set upsquashfs tools, download squashfs tools from here:
ftp://ftp.slax.org/source/slax/sqlzm...shfs3.4.tar.gz
Now, extract the files, then browse into the squashfs3.4/squashfs-tools folder, then type
make, then
sudo make install.
On Haret, they load the modules from a tar.gz on in /sdcard/andboot. The name will be
modules-2.6.27.46-01192-version.tar.gz. To get the version, try running:
Code:
cat ~/android/linux-msm-rhod-nand/include/config/kernel.release
androidupdate.tgz
Since the modules are now applied through androidupdate.tgz, you will need to make a directory structure in ~/android to look like this:
~/android
|--- androidupdate
|--- data
|--- system
|--- lib
|--- modules
The modules squash file should be put under /androidupdate/system/lib/modules. Also, any files that you want updated in either data or system can be placed in here. For example, if you want to include certain APK's, you can put them under /system/app or /data/app.
Compiling Initrd.gz
For NAND, we have our own initrd.gz in the bootenv git that we cloned. We try to rebuild these and commit them every time we update bootenv, but sometimes the change doesn't affect enough rebuild and upload. So, I always recommend rebuilding initrd.gz fresh and copying that into ~/android/tinboot-linux-msm/kernel. You can build this very easily by simply browsing to ~/android/bootenv and running sh buildInitrd.sh
Compiling Tinboot
Tinboot has been changed significantly to only use 1 cmdline for all devices
. If you are compiling for NAND, you will need to use the initrd.gz from the bootenv git we cloned. If you are compiling for Haret, you will need the initrd.gz from
Main Page - The XDAndroid Project. Just grab the latest and copy that along with the zImage into ~/android/tinboot-linux-msm/kernel. If you want to overclock the processor, change the lcd density, or change anything else, you can modify ~/android/tinboot-linux-msm/tinboot/
tinboot2.S
Changing this file is extremely simple, but you can really mess things up if you change some of the code. I would only recommend changing the line that starts with
.asciz. So, let's open tinboot2.S in gedit, find
.asciz, and make the changes to the command line. If you want to overclock, add
acpuclock.oc_freq_khz=716800 (change number to whatever overclock your phone can handle). If you are cooking a ROM, you can change the mtdparts to change the size of the partitions. All values are in HEX, and I will have a separate post for NAND chefs that will explain this much better.
We are now ready to compile. Unfortunately, the scripts on git require quite a bit of tweaking to get working. For now, try using the full build or tinboot script that I have posted in the second post.
Making the RootFS (Haret Only)
The RootFS is a little different since there is no simple make command. The current way to "compile" the RootFS is through the script located here:
generate-rootfs.sh
Attempting to modify this script always ended up giving me weird genext2fs warnings, and I found it to be much cleaner to just use the script as is. Instead, I choose to inject my modified init file right before genext2fs creates rootfs.img. Also, note that the script will throw a warning about .git not found or something similar. That is something from the gitclean.sh and can be ignored.
Code:
cd "${TMPDIR}"/"${REPODIR}"
./scripts/gitclean.sh
cp -a . "${TMPDIR}"/rootfs
# copy modified init file
rm "${TMPDIR}"/rootfs/init
cp "${ANDROID}"/rootfs/init "${TMPDIR}"/rootfs
chmod u+s "${TMPDIR}"/rootfs/bin/pppd "${TMPDIR}"/rootfs
The only catch here is that you have to keep an eye out for updates to init as you will be overwriting any future updates. I used to keep a simple text file with my script that keeps track of what changes I made to init so I could easily add them back in the future if init was updated.