[Android] TouchPad Android kernel mini howto

Search This thread

s7mx1

Member
Jul 8, 2009
24
19
It seems there is little information on the internet regarding how to compile the kernel and how to convert to the correct image format so the boot loader will recognise and how to transfer it over to the touchpad. I ended up spent a few hours and finally figured out. I hope this will be useful for someone. I will try to make it concise as this is mainly aimed for developers.

What you will need



Prepare

Download CM7 Alpha 3 image and extract the boot.img to a temporary place.
Download Sourcery G++ Lite and install it. Add the G++ Lite tool chain binaray path to the PATH env variable. Get the kernel source from git hub and extract to local disk and change directory to the kernel source.

Compile the kernel
Still in the kernel source directory run
Code:
make  ARCH=arm CROSS_COMPILE=arm-none-eabi- tenderloin_android_defconfig
make ARCH=arm CROSS_COMPILE=arm-none-eabi- uImage

Prepare the initramfs U-boot image
Extract the initramfs from the boot.img saved in temporary folder and convert it to uboot-image format
Code:
dd if=boot.img bs=1 skip=3577748 of=img.gz
mkimage -A arm -O linux -T ramdisk -C none -a 0x60000000 -e 0x60000000 -n "Image" -d ./img.gz arch/arm/boot/uRamdisk
(The dd offset for alpha 2.1 image is 3561152)

Combine the kernel and initramfs into a single U-boot image
Create a combined U-boot image (kernel and initramfs)
Code:
mkimage -A arm -O linux -T multi -a 0x40208000  -e  0x40208000 -C none -n "multi image" -d arch/arm/boot/uImage:arch/arm/boot/uRamdisk  uImage.CyanogenMod.new

Transfer it to the device
Boot your touchpad into recovery mode and run
Code:
adb shell mount /dev/block/mmcblk0p13 /boot
adb push uImage.CyanogenMod.new /boot/uImage.CyanogenMod.new
adb shell umount /boot
adb shell reboot

After it reboot you should be able to see a new CyanogenMod.new item from the boot menu.

That's it! :)


Optimisation
For those who wants to experiment with GCC build options you can update the entry "arch-$(CONFIG_CPU_32v7" in file arch/arm/Makefile and I set mine to
Code:
arch-$(CONFIG_CPU_32v7)         :=-D__LINUX_ARM_ARCH__=7  -mtune=cortex-a8 -mfpu=neon -ftree-vectorize -mfloat-abi=softfp -O2 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a)

Warning
Please be aware you are working on the bleeding edge kernel for touchpad and there is no guarantee that the latest git version will work for you. Please try an earlier version if that's the case.
As of 2011-11-23 you will need the latest kernel source to build kernel for alpha 3. Please do not mix the kernel with an initramfs from a different version, i.e. don't use initramfs extracted from alpha 2.1 and use it with alpha3.
 
Last edited:

Leoisright

Inactive Recognized Developer
Dec 22, 2010
4,857
6,948
MN
Thanks for this. Last weekend spent a while trying to figure this out.

Sent from my HP Touchpad using Tapatalk
 

Divine_Madcat

Retired Forum Moderator
Sep 9, 2005
2,936
2,608
USA
Thank you soooooo much for this guide. Quick question if you don't mind though.. I am using an mkimage that goes back to my nook kernel days. Is there anything newer out, or would this still be ok,?
 

s7mx1

Member
Jul 8, 2009
24
19
Thank you soooooo much for this guide. Quick question if you don't mind though.. I am using an mkimage that goes back to my nook kernel days. Is there anything newer out, or would this still be ok,?

As long as the mkimage can generate a standard U-boot image it should be fine.

You can always try it yourself. In worst case you have to hard reboot the touchpad by pressing the power button and home button at the same time for more than 10 minutes. As long as you keep the original image files (UImage.*) untouched I don't think you can brick it even if you want to. :)
 

Divine_Madcat

Retired Forum Moderator
Sep 9, 2005
2,936
2,608
USA
S7

I have been trying to compile the kernel for some time now, and was hopeful reading your guide (and this last post) However, still following the steps to merge the ramdisk, i cannot make a booting kernel. I can get it flashed, as i am using the update.zip method, but moboot always gives me a crc error when booting it.

Though, before i totally go nuts, i think i need to try the source forgery toolchain, as i am using the Android ndk r6b...
 

s7mx1

Member
Jul 8, 2009
24
19
S7

I have been trying to compile the kernel for some time now, and was hopeful reading your guide (and this last post) However, still following the steps to merge the ramdisk, i cannot make a booting kernel. I can get it flashed, as i am using the update.zip method, but moboot always gives me a crc error when booting it.

Though, before i totally go nuts, i think i need to try the source forgery toolchain, as i am using the Android ndk r6b...

Could you check the md5sum of the u-boot image crated on disk and the one installed by update.zip file? Do they match? If they do then you probably will need to upgrade your mkimage tool.
 
  • Like
Reactions: Divine_Madcat

Divine_Madcat

Retired Forum Moderator
Sep 9, 2005
2,936
2,608
USA
WEll, i checked the MD5 sums, and it looks good. So, i guess it is time to try again with the toolchain listed here, and perhaps a new mkimage (if there is a "modern" one i should using, please point me to it...)

edit: Never mind.. in all my looking, i never saw that ubuntu had a nice one waiting for me.... doh
edit2: Woo! After getting the probably correct mkimage, and the CS toolchain, looks like i finally got it to pass the crc check. Now, lets see if it finishes booting. Thanks again for the guide!

Nope.. no boot. I get a dmesg with this:
<3>[ 69.978716] init: untracked pid 224 exited
<6>[ 70.086076] android_usb gadget: high speed config #1: android
<6>[ 70.086209] gadget_event: schedule host_connected
<6>[ 70.096953] max8903b_current_setup: CURRENT_500MA
<6>[ 70.097040] gadget_event: source=bus mA=500 (no change)
<4>[ 70.910953] UDC-CHG (2-2-2): usb_multi_chg_detect (591) : USB host Adaptor
(500mA)!
<6>[ 70.912805] gadget_event: schedule host_disconnected
<6>[ 70.925482] max8903b_current_setup: CURRENT_ZERO
<6>[ 71.164066] android_usb gadget: high speed config #1: android
<6>[ 71.164220] gadget_event: schedule host_connected
<6>[ 71.173640] max8903b_current_setup: CURRENT_500MA
<6>[ 71.178212] gadget_event: source=bus mA=500 (no change)
<6>[ 72.160955] gadget_event: host_connected=1 (no change)
<6>[ 74.142224] request_suspend_state: wakeup (0->0) at 74121495501 (2011-11-1
1 22:49:33.378031648 UTC)
<3>[ 74.143675] init: untracked pid 266 exited
<3>[ 74.155217] init: untracked pid 273 exited
<6>[ 79.285016] request_suspend_state: wakeup (0->0) at 79264287462 (2011-11-1
1 22:49:38.520824942 UTC)

The last three lines repeat alot, with different pid's .


Alrighty.. figured this one out - You cannot use the latest repository commits with the 2.1 alpha build. However, i was able to build commit fd70bb7aae, and it builds and actually boots. Now, i can actually play around and tweak it. Thank you again for the guide, and sorry for the edit spamming.. heh.
 
Last edited:
  • Like
Reactions: jeanfrancis

s7mx1

Member
Jul 8, 2009
24
19
WEll, i checked the MD5 sums, and it looks good. So, i guess it is time to try again with the toolchain listed here, and perhaps a new mkimage (if there is a "modern" one i should using, please point me to it...)

edit: Never mind.. in all my looking, i never saw that ubuntu had a nice one waiting for me.... doh
edit2: Woo! After getting the probably correct mkimage, and the CS toolchain, looks like i finally got it to pass the crc check. Now, lets see if it finishes booting. Thanks again for the guide!

Nope.. no boot. I get a dmesg with this:
<3>[ 69.978716] init: untracked pid 224 exited
<6>[ 70.086076] android_usb gadget: high speed config #1: android
<6>[ 70.086209] gadget_event: schedule host_connected
<6>[ 70.096953] max8903b_current_setup: CURRENT_500MA
<6>[ 70.097040] gadget_event: source=bus mA=500 (no change)
<4>[ 70.910953] UDC-CHG (2-2-2): usb_multi_chg_detect (591) : USB host Adaptor
(500mA)!
<6>[ 70.912805] gadget_event: schedule host_disconnected
<6>[ 70.925482] max8903b_current_setup: CURRENT_ZERO
<6>[ 71.164066] android_usb gadget: high speed config #1: android
<6>[ 71.164220] gadget_event: schedule host_connected
<6>[ 71.173640] max8903b_current_setup: CURRENT_500MA
<6>[ 71.178212] gadget_event: source=bus mA=500 (no change)
<6>[ 72.160955] gadget_event: host_connected=1 (no change)
<6>[ 74.142224] request_suspend_state: wakeup (0->0) at 74121495501 (2011-11-1
1 22:49:33.378031648 UTC)
<3>[ 74.143675] init: untracked pid 266 exited
<3>[ 74.155217] init: untracked pid 273 exited
<6>[ 79.285016] request_suspend_state: wakeup (0->0) at 79264287462 (2011-11-1
1 22:49:38.520824942 UTC)

The last three lines repeat alot, with different pid's .


Alrighty.. figured this one out - You cannot use the latest repository commits with the 2.1 alpha build. However, i was able to build commit fd70bb7aae, and it builds and actually boots. Now, i can actually play around and tweak it. Thank you again for the guide, and sorry for the edit spamming.. heh.


That's because dalingrin has updated the default configuration to use the HIGHMEM which seems to kill all the apps. The latest git actually works if you disable all the HIGHMEM related stuff.
 

crimsonredmk

Member
Sep 16, 2009
27
35
Great guide and I got the kernel all built, but how do you change the kernel arguments for booting? e.g. where does moboot get its whole root=/dev/ram0 ro fb...stuff, and how does the CyanogenMod kernel know where to look for the rootfs partition?
 

s7mx1

Member
Jul 8, 2009
24
19
Great guide and I got the kernel all built, but how do you change the kernel arguments for booting? e.g. where does moboot get its whole root=/dev/ram0 ro fb...stuff, and how does the CyanogenMod kernel know where to look for the rootfs partition?


The root parameter (root=/dev/ram0) that passed to kernel is not useful to you. The root / is mere extracted initramfs in memory. I assume you are looking for system, data partitions etc. With TP we have LVM partitions which you can do really fancy stuff with. The actual mount device and mount point is defined (hard coded) in file init.tenderloin.rc which you can find in the initramfs (i.e. the img.gz which is a gzipped cpio file). You can extract all the contents out from img.gz and modify init.tenderloin.rc to suit your need and then create an updated initramfs file to go with the kernel.

Since Android (at least CM7 on TP) does not use pivot_root any changes made to the initramfs will appear automatically when you boot up the device.


You can google if you are not sure how to work with initramfs file.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    It seems there is little information on the internet regarding how to compile the kernel and how to convert to the correct image format so the boot loader will recognise and how to transfer it over to the touchpad. I ended up spent a few hours and finally figured out. I hope this will be useful for someone. I will try to make it concise as this is mainly aimed for developers.

    What you will need



    Prepare

    Download CM7 Alpha 3 image and extract the boot.img to a temporary place.
    Download Sourcery G++ Lite and install it. Add the G++ Lite tool chain binaray path to the PATH env variable. Get the kernel source from git hub and extract to local disk and change directory to the kernel source.

    Compile the kernel
    Still in the kernel source directory run
    Code:
    make  ARCH=arm CROSS_COMPILE=arm-none-eabi- tenderloin_android_defconfig
    make ARCH=arm CROSS_COMPILE=arm-none-eabi- uImage

    Prepare the initramfs U-boot image
    Extract the initramfs from the boot.img saved in temporary folder and convert it to uboot-image format
    Code:
    dd if=boot.img bs=1 skip=3577748 of=img.gz
    mkimage -A arm -O linux -T ramdisk -C none -a 0x60000000 -e 0x60000000 -n "Image" -d ./img.gz arch/arm/boot/uRamdisk
    (The dd offset for alpha 2.1 image is 3561152)

    Combine the kernel and initramfs into a single U-boot image
    Create a combined U-boot image (kernel and initramfs)
    Code:
    mkimage -A arm -O linux -T multi -a 0x40208000  -e  0x40208000 -C none -n "multi image" -d arch/arm/boot/uImage:arch/arm/boot/uRamdisk  uImage.CyanogenMod.new

    Transfer it to the device
    Boot your touchpad into recovery mode and run
    Code:
    adb shell mount /dev/block/mmcblk0p13 /boot
    adb push uImage.CyanogenMod.new /boot/uImage.CyanogenMod.new
    adb shell umount /boot
    adb shell reboot

    After it reboot you should be able to see a new CyanogenMod.new item from the boot menu.

    That's it! :)


    Optimisation
    For those who wants to experiment with GCC build options you can update the entry "arch-$(CONFIG_CPU_32v7" in file arch/arm/Makefile and I set mine to
    Code:
    arch-$(CONFIG_CPU_32v7)         :=-D__LINUX_ARM_ARCH__=7  -mtune=cortex-a8 -mfpu=neon -ftree-vectorize -mfloat-abi=softfp -O2 $(call cc-option,-march=armv7-a,-march=armv5t -Wa$(comma)-march=armv7-a)

    Warning
    Please be aware you are working on the bleeding edge kernel for touchpad and there is no guarantee that the latest git version will work for you. Please try an earlier version if that's the case.
    As of 2011-11-23 you will need the latest kernel source to build kernel for alpha 3. Please do not mix the kernel with an initramfs from a different version, i.e. don't use initramfs extracted from alpha 2.1 and use it with alpha3.
    1
    S7

    I have been trying to compile the kernel for some time now, and was hopeful reading your guide (and this last post) However, still following the steps to merge the ramdisk, i cannot make a booting kernel. I can get it flashed, as i am using the update.zip method, but moboot always gives me a crc error when booting it.

    Though, before i totally go nuts, i think i need to try the source forgery toolchain, as i am using the Android ndk r6b...

    Could you check the md5sum of the u-boot image crated on disk and the one installed by update.zip file? Do they match? If they do then you probably will need to upgrade your mkimage tool.
    1
    WEll, i checked the MD5 sums, and it looks good. So, i guess it is time to try again with the toolchain listed here, and perhaps a new mkimage (if there is a "modern" one i should using, please point me to it...)

    edit: Never mind.. in all my looking, i never saw that ubuntu had a nice one waiting for me.... doh
    edit2: Woo! After getting the probably correct mkimage, and the CS toolchain, looks like i finally got it to pass the crc check. Now, lets see if it finishes booting. Thanks again for the guide!

    Nope.. no boot. I get a dmesg with this:
    <3>[ 69.978716] init: untracked pid 224 exited
    <6>[ 70.086076] android_usb gadget: high speed config #1: android
    <6>[ 70.086209] gadget_event: schedule host_connected
    <6>[ 70.096953] max8903b_current_setup: CURRENT_500MA
    <6>[ 70.097040] gadget_event: source=bus mA=500 (no change)
    <4>[ 70.910953] UDC-CHG (2-2-2): usb_multi_chg_detect (591) : USB host Adaptor
    (500mA)!
    <6>[ 70.912805] gadget_event: schedule host_disconnected
    <6>[ 70.925482] max8903b_current_setup: CURRENT_ZERO
    <6>[ 71.164066] android_usb gadget: high speed config #1: android
    <6>[ 71.164220] gadget_event: schedule host_connected
    <6>[ 71.173640] max8903b_current_setup: CURRENT_500MA
    <6>[ 71.178212] gadget_event: source=bus mA=500 (no change)
    <6>[ 72.160955] gadget_event: host_connected=1 (no change)
    <6>[ 74.142224] request_suspend_state: wakeup (0->0) at 74121495501 (2011-11-1
    1 22:49:33.378031648 UTC)
    <3>[ 74.143675] init: untracked pid 266 exited
    <3>[ 74.155217] init: untracked pid 273 exited
    <6>[ 79.285016] request_suspend_state: wakeup (0->0) at 79264287462 (2011-11-1
    1 22:49:38.520824942 UTC)

    The last three lines repeat alot, with different pid's .


    Alrighty.. figured this one out - You cannot use the latest repository commits with the 2.1 alpha build. However, i was able to build commit fd70bb7aae, and it builds and actually boots. Now, i can actually play around and tweak it. Thank you again for the guide, and sorry for the edit spamming.. heh.