Kernels!

chadcspencer

Senior Member
Aug 11, 2010
175
25
0
Fort Worth
Hi all,
I so wish I knew how to develop because I hate to ask, I would much rather do and share. But man Asus has posted the Kernel for JB and I would love for a good tweaked OC'ed Kernel. Sooooo, please! :D
 

Tw1tchy

Senior Member
May 28, 2011
385
77
0
VanCoVer
Sadly there are no kernel developers for the 300t at the moment. Asus had all the kernel sources on the Asus website and i guess nobody tried to build their own.

Sent from my ASUS Transformer Pad TF300T using xda app-developers app
 

untermensch

Senior Member
Apr 4, 2009
480
622
0
Portland
ASUS has removed the proprietary code from the kernel, you can download it
but it wont build until you remove references to the missing code then some
of the tablet hardware does not work. so you are left to reverse engineer the
missing code from the chip spec's and manual probing of the hardware.

EDIT: NVM finely got it to build, time to see what's not working.
 
Last edited:

gaze57

Member
Sep 2, 2012
14
5
0
ASUS has removed the proprietary code from the kernel, you can download it
but it wont build until you remove references to the missing code then some
of the tablet hardware does not work. so you are left to reverse engineer the
missing code from the chip spec's and manual probing of the hardware.
Really ?
As far as I can tell the V10.4.2.9 kernel source from Asus website builds just fine (with one minor correction).

But perhaps I'm missing your point, sorry in that case.

My biggest problem so far is to successfully flash a custom kernel on JB custom ROM (ASU-JellyBean-Hydro 1.4.6).

This leads me to my actual question:

Anyone managed to successfully flash seanzscreams' modded kernel (Asu-JellyBean-HYDROKernel.zip)
on his excellent ROM ASU-JellyBean-Hydro 1.4.6 ?

As far as I can tell the entire kernel flash process seems to finish successfully (using TWRP 2.2.2.0)
but when checking kernel version in Settings it seems to be the same (stock) version as previously,

3.1.10-00003-g6293ea6 [email protected] #1 SMP PREEMPT Thu Aug 9 15:59:38 CST 2012

Looking forward for any ideas/tips.

(I know question better belongs in the Dev forum, but as I just registered at XDA I'm not allowed to post there.)
 

gaze57

Member
Sep 2, 2012
14
5
0
I got it to build using, tegra3_android_defconfig was trying the cardhu_defconfig before.

builds but does not boot :-<
OK, this indicates at least you have managed to get your custom kernel to run/load, very interesting.

Do you flash an update.zip using CWM/TWRP or using fastboot method sending blob to boot partition (LNX) ?

Care to share more details how you get from resulting zImage from build to something flashable ?

Something like this...

1. cp arch/arm/boot/zImage kernel.gz
2. repack-bootimg.pl kernel.gz ramdisk boot.blob.lnx
3. blobpack boot.blob LNX boot.blob.lnx

?
 

untermensch

Senior Member
Apr 4, 2009
480
622
0
Portland
I am using the same scripts that I use to build the CWM-Touch.blob, I just replace
the stock kernel with the on I have built, then use fastboot to install the new recovery
it just stalls.
 

gaze57

Member
Sep 2, 2012
14
5
0
I am using the same scripts that I use to build the CWM-Touch.blob, I just replace
the stock kernel with the on I have built, then use fastboot to install the new recovery
it just stalls.
Thanks, but I'm a bit confused...

How does kernel and recovery (CWM-Touch.blob) relate ?

I was of the impression that a recovery image is to be flashed to the recovery partition (SOS), e.g.,

fastboot.exe -i 0x0B05 flash recovery <blob>

...while kernel+ramdisk to boot partition (LNX), e.g.,

fastboot.exe -i 0x0B05 flash boot <blob>

Are the build scripts you mention publicly available and directions of where to look if that's the case ?
 

untermensch

Senior Member
Apr 4, 2009
480
622
0
Portland
a recovery is just a kernel and ramdisk with the recovery executable.

the stock LNX and SOS kernel have the same md5 sum so it does not matter
which partition I test the kernel on, it was just convenient for me to test it on
the SOS partition.

I got most of the tools to pack a SOS blob here
https://github.com/skirata/android-utils
I had to build a newer version of the blob tools
https://github.com/AndroidRoot/BlobTools

Thanks, but I'm a bit confused...

How does kernel and recovery (CWM-Touch.blob) relate ?

I was of the impression that a recovery image is to be flashed to the recovery partition (SOS), e.g.,

fastboot.exe -i 0x0B05 flash recovery <blob>

...while kernel+ramdisk to boot partition (LNX), e.g.,

fastboot.exe -i 0x0B05 flash boot <blob>

Are the build scripts you mention publicly available and directions of where to look if that's the case ?
 
Last edited:

gaze57

Member
Sep 2, 2012
14
5
0
Probably I can answer some of my questions myself...

Obviously both recovery and boot partition each contain a kernel+ramdisk of their own.

The difference is probably that,

- in the recovery partition the ramdisk actually contains the complete filesystem, including
the recovery application (e.g. TWRP) and everything is just meant to run from RAM.

while,

-in the boot partition there is only a minimal ramdisk enabling proper loading of the
system partition (called APP if not mistaken).

Perhaps my problem is just that kernel command line is not correct or simething similar.

Also I just discovered that fastboot.exe has a command called "boot" which actually might
be a much faster way to test custom kernels. Have to try it out...
 

chadcspencer

Senior Member
Aug 11, 2010
175
25
0
Fort Worth
Has ASUS ever wanted custom kernels running on there stuff? Anyway, the did give us a unlock for the boot loader, so looks to me like they are taking the, can't beat make sure they can return'em approach.

I tried the fastboot boot commands wont even boot the stock kernel, it kinda seems like ASUS does not
want custom kernels to be run on the tablet.
 

untermensch

Senior Member
Apr 4, 2009
480
622
0
Portland
Really ?
As far as I can tell the V10.4.2.9 kernel source from Asus website builds just fine (with one minor correction).

But perhaps I'm missing your point, sorry in that case.

My biggest problem so far is to successfully flash a custom kernel on JB custom ROM (ASU-JellyBean-Hydro 1.4.6).

This leads me to my actual question:

Anyone managed to successfully flash seanzscreams' modded kernel (Asu-JellyBean-HYDROKernel.zip)
on his excellent ROM ASU-JellyBean-Hydro 1.4.6 ?

As far as I can tell the entire kernel flash process seems to finish successfully (using TWRP 2.2.2.0)
but when checking kernel version in Settings it seems to be the same (stock) version as previously,

3.1.10-00003-g6293ea6 [email protected] #1 SMP PREEMPT Thu Aug 9 15:59:38 CST 2012

Looking forward for any ideas/tips.

(I know question better belongs in the Dev forum, but as I just registered at XDA I'm not allowed to post there.)
I unpacked the Asu-JellyBean-HYDROKernel.zip kernel looks like the stock kernel, any changes
have probably been made to the initrd so the kernel version would not change.

Code:
43538fd617c95623ce71fa39897f4a94  zImage
43538fd617c95623ce71fa39897f4a94  ../boot.blob.lnx-kernel.gz
zImage is the stock kernel I use for the touch recovery and boot.blob.lnx-kernel.gz is
the unpacked Asu-JellyBean-HYDROKernel.zip kernel the md5 sums are the same.
 

untermensch

Senior Member
Apr 4, 2009
480
622
0
Portland
Just for ****s and giggles, I unpacked the stock kernel zImage found the string
and changed it to
repacked to a zImage with a md5 sum of
Code:
727525cb198a130dfd532cfbde713d29
made a recovery and flashed via fastboot, and it booted fine. This proves that
the new bootloader is not checking the signature of the kernel against a stored
value so custom kernels are possible and I'm just not smart enough to build
a working kernel form the ASUS source.
 

chadcspencer

Senior Member
Aug 11, 2010
175
25
0
Fort Worth
That's funny, someone out there is, Man just an OC'ed Kernel would be awesome. Since EzOverclock doesn't work with JB you I can really tell the difference in speed on JB.
Just for ****s and giggles, I unpacked the stock kernel zImage found the string
and changed it to
repacked to a zImage with a md5 sum of
Code:
727525cb198a130dfd532cfbde713d29
made a recovery and flashed via fastboot, and it booted fine. This proves that
the new bootloader is not checking the signature of the kernel against a stored
value so custom kernels are possible and I'm just not smart enough to build
a working kernel form the ASUS source.
 

KAD79

Senior Member
Jul 8, 2012
54
15
0
I pulled the config from my tf300 and and managed to build the zImage

I get warning notices about the one of the mpu sensors
if you get it to flash that might be something that may not work

as for myself, I'll be looking into some UMS features, we'll see how far I get
it appears all the needed code is already included in the kernel download from asus,
just need to configure it
 

gaze57

Member
Sep 2, 2012
14
5
0
Seems I finally managed to build and flash my own JB kernel for the TF300T ! :good:

This will just be a quick and dirty wrap-up of what I did as my spare time is somewhat limited.
Hope to be able to make it more structured and with proper credits in the near future.

Anyone feel free to compile a better structured how-to with correct references and credits.

Quick credits/thanks:
seanzscreams
untermensch


Stuff needed:
- Asus kernel source (10_4_2_9_kernel.zip)
- Android NDK R8B (I'm using Linux version, android-ndk-r8b-linux-x86.tar.bz2)
- Asu-JellyBean-HYDROKernel.zip (to get a proper update package structure with update binary/script and META-INF directory)
- signing-tools.zip, BlobTools and re/unpack-bootimg.pl (can't remember where I found these :( will have to update post later...)


Preparations:
- Unpack kernel source, e.g. to $HOME/TF300/stock_kernel
- Unpack Android NDK, e.g. to $HOME/android-ndk-r8b
- Unzip Asu-JellyBean-HYDROKernel.zip, e.g. to $HOME/my_kernel
- Setup/install BlobTools and the other scripts


Step-by-step instructions:


1. Build kernel (zImage)

a) Fix minor issue in kernel source

> cd $HOME/TF300/stock_kernel

Change line 11 in file drivers/ril/ril.c

from,
#include <../../arch/arm/mach-tegra/include/mach/board-cardhu-misc.h>
to,
#include "../../arch/arm/mach-tegra/include/mach/board-cardhu-misc.h"

b) Setup build environment for cross compilation

> export PATH=$HOME/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin:$PATH
> export ARCH=arm
> export CROSS_COMPILE=arm-linux-androideabi-

c) Fetch /proc/config.gz from your TF300 and copy/gunzip to $HOME/TF300/stock_kernel/.config

d) Build

> make

If everything went fine you should have a new kernel under,
$HOME/TF300/stock_kernel/arch/arm/boot/zImage


2. Repack kernel

> cd $HOME/my_kernel

a) Create a 28 byte file using a hex editor for the signblob header (I named the file signblob_magic)

It should have the following contents when checked with hexdump:

> hexdump -C signblob_magic
00000000 2d 53 49 47 4e 45 44 2d 42 59 2d 53 49 47 4e 42 |-SIGNED-BY-SIGNB|
00000010 4c 4f 42 2d 00 00 00 00 00 00 00 00 |LOB-........|
0000001c

b) Unpack the boot.blob from Asu-JellyBean-HYDROKernel.zip (unzipped earlier under Preparations)

This step is just to get a proper blob directory structure and the initramfs.

> blobunpack boot.blob
> unpack-bootimg.pl boot.blob.lnx

c) Pack new kernel

Might as well post the script I made to perform this task, check comments.


#!/bin/sh

SRC_HOME=$HOME/TF300/stock_kernel
KERNEL_NAME=my_kernel

# replace kernel
cp ${SRC_HOME}/arch/arm/boot/zImage boot.blob.lnx-kernel.gz

# repack
repack-bootimg.pl boot.blob.lnx-kernel.gz boot.blob.lnx-ramdisk out.blob.lnx
blobpack out.blob LNX out.blob.lnx

# add signblob header
cat signblob_magic out.blob > boot.blob

# create zip package
zip -9 -r ${KERNEL_NAME}.zip boot.blob META-INF/

# Sign zip package using SignApk
java -Xmx1024m -jar signapk.jar -w testkey.x509.pem testkey.pk8 ${KERNEL_NAME}.zip ${KERNEL_NAME}-signed.zip


3. Flash kernel

From previous steps you should now have a signed kernel called,

my_kernel-signed.zip

Flash it using TWRP and reboot.

If flash was OK a blue status bar should appear during boot and then your TF300 will reboot again.

Confirm you have a custom kernel by checking Kernel-version under Settings once system has completed the bootup.
 

untermensch

Senior Member
Apr 4, 2009
480
622
0
Portland
Confirmed! I have built a working kernel from ASUS source not sure if it was the
NDK or pulling the config from the device.

good work gaze57!

Code:
~ # uname -a
Linux localhost 3.1.10 #2 SMP PREEMPT Sat Sep 15 16:49:52 PDT 2012 armv7l GNU/Linux
link to my recovery build setup with source built kernel
http://www.mediafire.com/?hnstxi9so5970y0

EDIT:
it was the config that was causing my previous attempts to fail, I have an Android build setup
with this as the path
Code:
/home/untermensch/Android/android-4.1.1_r4/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/
then these exports
Code:
export ARCH=arm
export SUBARCH=armv7-a-neon
export CROSS_COMPILE=arm-eabi-
then pull the config from the tablet and got a working kernel.

EDIT:

I opened a source repository with the fix to ril.c and the device config saved to arch/arm/configs/tf300t_defconfig

https://github.com/untermensch/tf300t_kernel
 
Last edited:

Valantur

Senior Member
Aug 19, 2010
101
31
28
Linux kernel

Congratulations guys!
Thanks for sharing your work.

Since you've been keeping your hands busy with the kernel for some time now, I was wondering if you have ever tried to build a Linux system (kernel + working environment) for the TF300, and whether you know it's possible or not.

I've downloaded the kernel from Asus and trying to get tegra3_defconfig to build (currently having problems with "make[1]: *** [arch/arm/mach-tegra/board-cardhu-sensors.o] Error 1". Am I using the right defconfig? Is it possible to build an Android kernel but have it boot a GNU/Linux environment.

I appreciate your help :)

EDIT: Regarding the error message, it was a bad reference. The file was expected to be in another folder. I fixed the reference and it went on building.
 
Last edited: