[Android Software Development] HTC_M7:
How to build a sense kernel from source

Judging that you are reading this and going to try and build a kernel make sure you have looked at the previous posts above as they may be needed to complete this task.

Below is the readme from htc dev's website. But why do all this work. Lets use Linux and bash scripts to our advantage.

defconfig file: m7wls_defconfig (arm-eabi-4.6)

Download:
=========
If you are not already using an AOSP toolchain (included in an AOSP build tree), download the corresponding official android toolchain for the arm-eabi specified above for this device:

git clone [url]https://android.googlesource.com/platform/prebuilt[/url] for 4.4.3
git clone [url]https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6[/url] for 4.6
(use darwin-x86 in place of linux-x86 for mac)

Build the kernel:
=================
set the following environment variables:

export TOP= [where you installed the toolchain or top of android AOSP code base]
export PATH=$TOP/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin:$PATH (use corresponding arm-eabi bin path)
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-eabi-

make [the defconfig file for this device above]
make clean (for subsequent builds)
make -j4 (in this example 4 is the number of processors of your build machine)

Output Binary Files:
====================
After the build process is finished, there should be a file named "zImage" found in arch/arm/boot/
If you are building a rom with this kernel ZImage, copy it into your build's output folder and rename it to "kernel".

You will also need the following kernel modules. These will eventually be installed into /system/lib/modules on the device.

kernel modules:
./driver/*.ko

The only thing I will ask you to get are the following.

-Download the source from htcdev.

-Get your toolchain and put it in your desired folder. Do that with this command.

**On a sidenote you need to know your devices defconfig and what toolchain your device uses. (This is given on the top of the readme as per the one above.)**

git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6"

-for me I put the toolchain in my directory like this. It is different for each toolchain and device. It doesn't matter. /android/kernel/**toolchain**. That's where the extracted toolchain is.

-Next step open a file and add the following text. Make sure the file is executable so you can run it. Add this....

-This is a quick script that does all the work for me. No need to add paths, etc. As long as your folders and filed match the paths of the script all will be ok. Now this script will have to be edited to suite your computer and the destinations of your kernel folders.

-Now once the script is fully correct and everything is setup just cd to the directory your script is in and type the following assuming your file name is m7wls type:

./m7wls

Once the script has fully run. It should take a while in the folders I made you should see zImage and kernel modules. From there you will need to know how to pack the kernel.

Notice if you downloaded sprints htc one kernel source the source is named m7wls-jb-crc-3.4.10-eb45596. I changed this to just m7wls to make it easier for the script.

Finally, remember you will have to make directories to suit the script for example this line "rm -f /android/kernel/htcone/STOCK-m7wls/boot.img-ramdisk/lib/modules/*" this is where the modules go "*" but I had to make these folders first boot.img-ramdisk/lib/modules/.

If you followed my instructions and did your own fooling around you should have a sense kernel built from source. This is not for beginners. If you have any questions just ask. Message me if you really need some more help.

Happy Building!