[Hero CDMA Android Development] cteneyck:
You should do a nandroid backup and reboot your phone before trying to flash anything to your phone. This how to involves flashing directly to mtd2, if you don't know what you are doing then please use one of the custom roms available in the Sticky Wiki.

#### Update One Fixed scripts

#### Update Two Added instructions to compile and install the wlan.ko module

#### Update Three Fixed get-CDMAHero-source.sh typo

#### Update Four Added Instructions for Jaunty repo's for Ubunut 9.10

First off i would like to give credit to all the people who have made information and scripts available. I used bits and peices of info and tools written by and or made available by these people.

Armin Coralic http://blog.coralic.nl for creating some nice scripts and making them available

chuckhriczko for helping me out in the middle of the night.

LoxDev for creating a wonderfull how to about creating img's and zip's

tkirkton for helping out with enabling legacy jaunty repos to install java 1.5

Second I am writing this How To, so a complete newbie would be able to understand.

REQUIREMENTS....

Ubuntu Desktop 9.04 or better 32bit (cause thats what i used)

Android SDK (Needed to push and pull files as well as shell access to the phone. You will need to set this up by following the instructions found at http://www.android.com)

Legacy repo's enabled in apt to allow java 1.5 to install

Root access. I ran all commands below as root

I created a dir called "heroc" in my /root directory.

Download zip file below and unzip it in the heroc dir that you should have created.

STEPS

.5 Enable Legacy Repo's to allow java 1.5 to install (below is a cut from tkirktons post on page 7)

in Ubuntu 9.10, the Java 1.5 package doesn't even list. Here's what I had to do to get it to load:

1. Access a repository from the previous build (9.04 Jaunty will work: commands to put into /etc/apt/sources.list -

deb [URL]http://mirrors.us.kernel.org/ubuntu[/URL] jaunty main restricted universe multiverse
deb [URL]http://mirrors.us.kernel.org/ubuntu[/URL] jaunty-backports main restricted universe multiverse
deb [URL]http://mirrors.us.kernel.org/ubuntu[/URL] jaunty-security main restricted universe multiverse
deb [URL]http://mirrors.us.kernel.org/ubuntu[/URL] jaunty-updates main restricted universe multiverse

2. Set the max age higher than the default. This can be accomplished by editing the /etc/apt/apt.conf.d/20archive. Here's what my lines in that file look like:

APT::Archives:MaxAge "2880";
APT::Archives:MinAge "2";
APT::Archives:MaxSize "1000";

Making these two changes should work...although I have the Intrepid, Hardy and Dapper repositories in mine as well (didn't know which one would work, so I overkilled it).

Run the script again after making the changes and let me know if it works.

.

to update just run

# apt-get update

1. Create your work environment by running createandroidRepo.sh. This will take some time depending on your internet connection. Make sure you are in the heroc dir.

# unzip Scripts.zip
# chmod a+x *
# ./createAndroidRepo.sh

This will create a dir call my android and setup all the files and programs needed to compile the kernel. This will take some time to complete.

2. You need to download the source using the get-CDMAHero-source.sh

# ./get-CDMAHero-source.sh

This will download the source, and extract it to its own directory.

3. you will need to have your .config file handy for the next steps. If you don't have it then you will need to get it by doing the following

# adb pull /proc/config.gz /root/heroc/config.gz
# gunzip config.gz

The first command will pull the gzipped config from your phone and place it into the heroc dir. the second command will extract the file as "config"

4. This is where it gets fun. We now have everything downloaded and are going to start the process of compiling our kernel.

# cd heroc_ef05d31a
# export ARCH=arm
# export CROSS_COMPILE=arm-eabi-
# export PATH=$PATH:~/heroc/myandroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin

# make menuconfig

After you run "make menuconfig" it will bring up a the config menu for our kernel. Go to the bottom and select "Load an alternate configuration file". It will then prompt you to select the config file you want to use. You will need to point it to where you have the config file. So type in "/root/heroc/config"

After you have loaded the config file you can edit what ever you want. however if you don't know what do disable or enable then i wouldn't mess around to much.

Next you will need to save your config file. Choose "Save an alternate configuration file", and save it as "/root/heroc/heroc_ef05d31a/.config"

You can now exit menuconfig

5. Time To Compile the kernel and wlan.ko module

# make
# export KERNEL_DIR=/root/heroc/heroc_ef05d31a/
# cd myandroid/system/wlan/ti/sta_dk_4_0_4_32/
# make

The kernel will take some time. go grab a drink and have a snack. If all goes well you should end up with a zImage file in "~/heroc//arch/arm/boot/". After the kernel is compiled you need to compile the wlan.ko module by executing the last three commands

6. Next we need to copy the zImage back to the heroc dir

# cp /root/heroc/heroc_ef05d31a/arch/arm/boot/zImage /root/heroc/zImage

7. Ok so now we need to get the boot image from our phone. We need this cause it has more than just the kernel. I contains the ramdisk image as well. and we need to take the boot image and decompress it and remove the old kernel and add our new compiled kernel, then recompress it to newboot.img

# adb shell
# cat /dev/mtd/mtd2 > /sdcard/mtd2.img
# exit
# adb pull /sdcard/mtd2.img /root/heroc/mtd2.img
# mv mtd2.img boot.img

The first two commands will open a terminal shell to your phone and copy the boot image to your sdcard. the last two commands will pull the the boot image from your phone, place it in your heroc dir and rename the file to boot.img

8. Now we will split apart the boot.img using some scripts.

# ./extract-kernel.pl boot.img
# ./extract-ramdisk.pl boot.img
# rm boot.img-kernel
# cp zImage boot.img-kernel
# ./mkbootfs boot.img-ramdisk | gzip > ramdisk-boot
# ./mkbootimg --kernel boot.img-kernel --ramdisk ramdisk-boot --cmdline "no_console_suspend=1 console=null" -o newBoot.img --base 0x19200000

The first command extracts the stock kernel from boot.img. The second command extracts the ramdisk from boot.img. The third command will delete the stock kernel. the fourth command renames our zImage to boot.img-kernel. The fifth command takes boot.img-ramdisk folder and zips it up into ramdisk-boot. The sixth comand takes our kernel (renamed to "boot.img-kernel") and ramdisk-boot and combines it back to form a new file called newboot.img.

9. Now we need to flash our "newboot.img" file to our phone. You should reboot your phone before flashing this will insure that you don't get any out of memory errors and will keep your phone from booting into fastboot (Thx Obelisk79).

# adb push newBoot.img /sdcard/newBoot.img
# adb shell
# cat /dev/zero > /dev/mtd/mtd2 (you may get an error here. don't worry about it)
# flash_image boot /sdcard/newBoot.img
# reboot

The first command will push your boot image to the phone. the second command will bring up shell access to your phone. the third command will zero out mtd2 and get it ready to write your image. the fourth command will flash boot(mtd2) with newboot.img. the last command will reboot your phone

10. After the phone reboots we need to get the wlan.ko file to the phone so that wireless will work

# adb push /root/myandroid/system/wlan/ti/sta_dk_4_0_4_32/wlan.ko /sdcard/wlan.ko
# adb shell
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
# cp /sdcard/wlan.ko /system/lib/modules/wlan.ko
# exit

Now you have a kernel that you compiles with everything work with the exception of power mgmt.