[Galaxy Tab 3 10.1 Android Development] r2d23cpo:
I see then no specific driver. That is nice. I know for me learning is fun too. Keep me busy.

Debugging the Linux kernel using Eclipse/CDT and Qemu

Part1-Compiling an uncompress Kernel for debugging

The following is C&P of h__p://issaris.blogspot.com/2007/12/download-linux-kernel-sourcecode-from.html with some modifications.

That is in fact and old blog. That uses old eclipse, Linux and old kernel version "linux-2.6.29.6" Current eclipse and linux version (Ubuntu 14.04) prevent me from doing exact steps.

Setting up gcc 4.6

I had suggested many time to use a 32bit Ubuntu OS and to stick with Android tool chain gcc4.6. To minimise error we are going to install gcc4.6 an alternative and Default in our OS.

sudo apt-get install gcc-4.6 g++-4.6 gcc-4.6-multilib g++-4.6-multilib
sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
sudo update-alternatives --config gcc
sudo update-alternatives --config g++

Setting up $HOME variable

Be sure your $HOME variable is set to you user area. "echo $HOME" - will show the variable content. if you need to change it do

"export $HOME= <your linux user home>"

Kernel Version to be using in this tutorial

The blog ask us to use Kernel linux-2.6.23.9. But that is an old kernel. So I am going to use a different one.

Current kernel in my Ubuntu 14.04 is 3.16.0-23

$ uname -a
Linux mumble-PC [COLOR="Red"]3.16.0-23[/COLOR]-generic #31-Ubuntu SMP Tue Oct 21 18:00:35 UTC 2014 i686 i686 i686 GNU/Linu

But my Android JB 4.2.2 is version 3.4.34

uname -a
Linux localhost [COLOR="Blue"]3.4.34[/COLOR]-850131 #1 SMP PREEMPT Wed Sep 25 20:39:09 KST 2013 i686 GNU/Linux

So I decided to download same JB android version but from kernel.org Go and Download

h__ps://www.kernel.org/pub/linux/kernel/v3.0/linux-3.4.34.tar.bz2

Now Please note this are Linux Kernels not Android. But I decided to use it to get minimum errors while learning.

Ubuntu 14.04 - setting up working area

Problem: working outside "/home/<user>" requires root access or sudo!

First It seems Ubuntu 14.04 does not like the User to be messing around outside "/home/<user>" area. In fact in many sites the suggest us to create a folder "/home/<user>/bin" and place our stuff in there.

Blog Original	Ubuntu 12.04
Source Folder Location	/usr/local/src/linux-2.6.23.9	==>	$HOME/bin/linux-3.4.34
Build or output Folder Location	/mnt/build/linux-2.6	==>	$HOME/bin/build/linux-3.4.34

Setting source folder

Unpack you downloaded Kernel to you user bin area. We decided to use Source Directory = "$HOME/bin/linux-3.4.34"

mkdir -p $HOME/bin
cp $HOME/Downloads/linux-3.4.34.tar.bz2 $HOME/bin
cd $HOME/bin
tar xvjf linux-3.4.34.tar.bz2

Setting build folder

We decided to use Build Directory = "$HOME/bin/build/linux-3.4.34

mkdir -p $HOME/bin/build/linux-3.4.34

Configuring kernel

cd $HOME/bin/linux-3.4.34
cp $HOME/bin/linux-3.4.34/arch/x86/configs/i386_defconfig .config
yes "" | make oldconfig O=$HOME/bin/build/linux-3.4.34
make menuconfig O=$HOME/bin/build/linux-3.4.34

And enable the following options: In the "Kernel hacking" menu enable both "Compile the kernel with debug info" and "Compile the kernel with frame pointers".

Kernel hacking --->
...
[*] Compile the kernel with debug info
...
[*] Compile the kernel with frame pointers

Now save changes < Exit > < Exit > < yes > to save.

Now lets do a "make mrproper" while we are at $HOME/bin/linux-3.4.34. If we do not clean $HOME/bin/linux-3.4.34 compilation while complain later. "make mrproper" is the most powerful cleaner of make. When executed it erase all the generated output files plus the configuration. Leaving the source folder as originally when was untar.

make mrproper

Compiling kernel

Now you can test your source to see if compile.

cd $HOME/bin/build/linux-3.4.34
make ARCH=i386

Notes:

if you have multiple cores you can use -j# where # is the number of cure to dedicate in my case I use -j6

make ARCH=i386 -j6

If you get error you can tell make to clean all outputs generated in your build folder. But not the configuration files! in contrast the previous make "mrproper" will delete configuration files.

Note: It takes 6-10 minute on a 8 core machine with -j6 option or about 30minutes on a 1 core machine.

You should see "Kernel: arch/x86/boot/bzImage is ready (#1)" at the end of good compilation.

In fact your kernel will be at

$HOME/bin/build/linux-3.4.34/arch/x86/boot/bzImage

and your uncompressed kernel at

$HOME/bin/build/linux-3.4.34/arch/x86/boot/compressed/vmlinux

Note:

ARCH=i386 force the compile output to be 32bits x86. It is required Android. I had said many time to use a Linux distro 32bit. This will make you life easily on Android development. Clearly if you have 64bit and want to test this kernel build as your kernel in you 64bit machine this will not work! So if so remove ARCH=i386.

The second part of the tutorial is at ==> "

Part2-Kernel debugging on Eclipse

"