• Home
  • Kernel
  • Compiling an HTC Desire Kernel for Sense Rom – Gingerbread

Compiling an HTC Desire Kernel for Sense Rom – Gingerbread

Resources:

http://arighi.blogspot.com/2011/01/howto-install-custom-kernel-on-htc.html

 

using Ubuntu on Vmware Workstation

Installed Android SDK and NDK

Downloaded HTC Desire GB Kernel from HTC

All are in my ~/ folder

Set paths like this:

$gedit ~/.bashrc

Add path:

PATH=$PATH:~/android/sdk:~/android/android-ndk-r6b:~/android/sdk/tools:~/android/sdk/platform-tools:~/android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:~/android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/arm-linux-androideabi/bin

Now pull the kernel config file from adb:

Setup Adb

First you have to set up permissions

[email protected]:~$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 003: ID 0424:2512 Standard Microsystems Corp. USB 2.0 Hub
Bus 004 Device 002: ID 046d:c03d Logitech, Inc. M-BT96a Pilot Optical Mouse
Bus 001 Device 004: ID 0bb4:0c87 High Tech Computer Corp. Desire (debug)
Bus 001 Device 005: ID 0781:5406 SanDisk Corp. Cruzer Micro U3

Or alternately:

[email protected]:~$ lsusb | grep ‘Desire’
Bus 001 Device 004: ID 0bb4:0c87 High Tech Computer Corp. Desire (debug)

Note: ID 0bb4:0c87

 

Create/Edit /etc/udev/rules.d/99-android.rules

sudo gksu kate /etc/udev/rules.d/99-android.rules

Here,

SUBSYSTEM==”usb”, ATTRS{idVendor}==”1d6b:0c87″, SYMLINK+=”android_adb”, MODE=”0666″ GROUP=”plugdev”
TEST==”/var/run/ConsoleKit/database”,
RUN+=”udev-acl –action=$env{action} –device=$env{DEVNAME}”

Or

$ sudo gedit /etc/udev/rules.d/99-android.rules

SUBSYSTEM=="usb", ATTRS{idVendor}=="1d6b:0002", SYMLINK+="android_adb", MODE="0666" GROUP="plugdev"
TEST=="/var/run/ConsoleKit/database",
RUN+="udev-acl --action=$env{action} --device=$env{DEVNAME}"[/code]

sudo restart udev[/code]
Now, adb devices shows my device

Next: Compilation of Kernel:

cd to the path where kernel has been downloaded:

Now, pull the config:

adb pull /proc/config.gz

cp config.gz .config

In my experience getting a good .config is the most difficult step. So here you go, my configured .config, rename the file to .config
[Download not found]
If you dont want your present kernel config, but to start with default:

[email protected]:~/bravo_2.6.35_gb-mr$ make bravo_defconfig ARCH=arm CROSS_COMPILE=/home/droidzone/android/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-

Else: make menuconfig

Finally, when everything is ready, compile:

[email protected]:~/bravo_2.6.35_gb-mr$ make ARCH=arm CROSS_COMPILE=/home/droidzone/android/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-

At the end:

  OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
Building modules, stage 2.
MODPOST 1 modules
CC      drivers/net/wireless/bcm4329_204/bcm4329.mod.o
LD [M]  drivers/net/wireless/bcm4329_204/bcm4329.ko

That's it... Kernel has been compiled.

 

Now, fetching Koush's Anykernel updater:

mkdir flasher

cd flasher
git clone [email protected]:droidzone/AnyKernel.git
cd AnyKernel

git remote add upstream git://github.com/koush/AnyKernel.git

git fetch upstream

[email protected]:~/bravo_2.6.35_gb-mr$ cp /home/droidzone/bravo_2.6.35_gb-mr/arch/arm/boot/zImage /home/droidzone/koush/AnyKernel/kernel/

cp /home/droidzone/bravo_2.6.35_gb-mr/drivers/net/wireless/bcm4329_204/bcm4329.ko /home/droidzone/koush/AnyKernel/system/lib/modules/

 

The initial compile gave errors, so:

cp config.gz .config

make ARCH=arm CROSS_COMPILE=/home/droidzone/android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- oldconfig

make bravo_defconfig ARCH=arm CROSS_COMPILE=/home/droidzone/android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-

make ARCH=arm CROSS_COMPILE=/home/droidzone/android/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-

Update 23-Sept-11

Successfully compiled a kernel. The mistake was two fold.

Using the newer NDK. The one which worked was ndk-r4 and the file path: '/home/droidzone/android/android-ndk-r4/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/arm-eabi-'

The second issue was getting a config.gz and expecting it to be plain text

Finally fixed that by:

adb pull /proc/config.gz

zcat config.gz > .config

make menuconfig   #Needed to install ncurses-devel to get menuconfig
make ARCH=arm CROSS_COMPILE=/home/droidzone/android/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-[/code]