[Galaxy Tab 3 10.1 Android Development] r2d23cpo:
First Part of Tutorial => "

Part1-Compiling an uncompress Kernel for debugging

"

Note whenever you see <user> in this document it means your user name in Ubuntu. If you need a reminder do echo $HOME in terminal it will show your user name.

Continuation

Debugging the Linux kernel using Eclipse/CDT and Qemu

Part2-Kernel debugging on Eclipse

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. So here is what I did different.

Downloading Eclipse

Eclipse is one of the most used IDE. In fact almost all apk where develop in Eclipse. To day many still use Eclipse IDE for Android development. So give it a try, what you learn in Kernel Debugging can help you latter with APKs.

The Author ask you to download

h__p://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/ganymede/SR1/eclipse-cpp-ganymede-SR1-linux-gtk.tar.gz

But if you see that eclipse version is "ganymede" Were now in "luna"

So You can go to h__p://www.eclipse.org/downloads/ And select the

Eclipse IDE for C/C++ Developers Eclipse IDE for C/C++ Developers

*Now I said many times when developing for Android do yourself a favor and Install Ubuntu 32Bit even if you have 64bit. The same applies here. Download the 32bit version of eclipse. So as march/2015 download

h__p://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/luna/SR2/eclipse-cpp-luna-SR2-linux-gtk.tar.gz

*Once it downloads do

mkdir -p $HOME/bin/eclipse
cp $HOME/Downloads/eclipse-cpp-luna-SR2-linux-gtk.tar.gz $HOME/bin
cd $HOME/bin
tar xvjf eclipse-cpp-luna-SR2-linux-gtk.tar.gz
mkdir -p $HOME/workspace

*To start eclipse do

cd $HOME/bin/eclipse
./eclipse

*When ask for workspace just type "/home/<user>/workspace". We are not going to use the workspace for now. workspace is usually where you keep all eclipse projects. but we are going to work on an existing files "$HOME/bin/linux-3.4.34" & $HOME/bin/build/linux-3.4.34

Disabling Build automatically

*[Menu Bar]> Windows > Preferences > General > Workspace

*Uncheck “Build automatically” & “Apply”

Disabling Indexer

Indexer can take a lot of time. So for now we are going to disable.

*[Menu Bar]> Windows> Preferences > C/C++ > Indexer

*Uncheck Enable Indexer

*[OK]

C/C++ Window Perspective

NOTE: From Time to Time you will hit a wrong close window or anything else and lose you Project Window Perspective. If that happens to you to get it back do.

*[Menu Bar]> Window > Open perspective > Other > C/C++ [OK]

Creating our Kernel Debug Project

*To start our working project do

File>New>Project

*A new windows pop up select ( note that luna version offers different layout window)

C/C++>Makefile Project with Existing Code.

*A new windows pop up. Click in [Browse..] and navigate to

/home/<user>/bin/linux-3.4.34

*Your Project Name will be setup for you. "linux-3.4.34"

*In tool chain for Indexer Settings Select "Linux GCC" Because were are going to build for our desktop as a test an not for android.

*Click [Finish]

If you did not turn off Indexer It will take a long time to index. You can see status by looking at the bottom right side. of eclipse windows.

*If Indexing, let Eclipse finished indexing the kernel source code.

*Right-click on the project-name in the left pane (Project explorer) and select "Properties".

*Select C/C++ Build

*Uncheck "Use default build command"

*In Build Command enter

make ARCH=i386

Note: Remember you can use "make ARCH=i386 -j#" to speed up the process. Where # is the number of core dedicated.

*In Build Location enter

/home/<user>/bin/build/linux-3.4.34

*Click [Apply] & [OK]

Building the project

Note: Building the project equals to Compiling the Kernel. To do this in Eclipse you can use one of many method:

1) Menu Bar> Project > Build all ,or

2) [CTRL]+b ,or

3)Use the Icon symbol that looks like "Document with binary 101"

*Menu Bar > Project > Build all

*After some time the Linux kernel build will be completed and you see "bzImage is ready" appear in the Eclipse Console output.

*Now lets start qemu.

Installing Qemu in Ubuntu

sudo apt-get update
sudo apt-get install qemu-system-i386

NOTE: When you have a Qemu window if you click on it your Mouse will no longer shows and you Ubuntu window may seems in responsive. To get out of that situation you need to pres simultaneously [CTRL]+[ALT]+<ESC> key.

Executing Qemu emulator

Now lets fire Qemu to emulate the boot up of the Kernel we just compiled.

qemu-system-i386 -s -S -hda /dev/zero -kernel $HOME/bin/build/linux-3.4.34/arch/x86/boot/bzImage

* A new Qmu window will pop up.

Setting up Qemu in Eclipse

*Lets go back to Eclipse.

* Menu BAR > Run > Debug Configurations

*Double click "C/C++ Remote Application". Modify the "C/C++ Application" text entry to point to the actual Linux uncompress kernel(vmlinux) location,so use [Browse] or type

/home/<user>/bin/build/linux-3.4.34/vmlinux

This option is no longer available *Click on the "Debugger" tab, and in the "Debugger" listbox select the "gdbserver".

*modify the Stop on startup at: write in "start_kernel"

*On Connection Tab select

Type=TCP
Host name or IP address = localhost
Port Number = 1234

*Press [Apply] then Debug

*A new window will pop up asking you to accept Debug Perspective. Hit [Yes]

[Close]

Now resize Eclipse window such as you can see Qemu window too.

Any way we can hit Resume (F8) and we will see the Kernel execute in Qemu. Here again I am having trouble to read the passed logs print to the Qemu. I guess there is config setup to allow buffered logs or something like that.

You can see the kernel source code, place breakpoints or do single steps.

Now here is a nice pdf that shows the process. It is for Fedora but you can see graphically the installation.

h__ps://hwchoi.files.wordpress.com/2009/10/debugkerneleclipse-hyungwonchoi.pdf

Again please have in mind that all this tutorials where made some time ago and and our Eclipse Luna may have different menu layouts.

Next Tutorial => Third Part of Tutorial => "Part3-Debug the custom kernel with included Virtual intramfs"