[LG Optimus 2x] Firtecy:
How to build your own kernel:

You need a Linux PC with either 32 or 64Bit. I'm using Linux Mint Debian Edition 64Bit. And you will need the following packages:

build-essential kernel-package libncurses5-dev bzip2

For example to install them run:

sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2

Hint: If you run into troubles with installing packages, check this post

1. Create a new directory for your kernel building (for example: ~/kernel_p990)

mkdir ~/kernel_p990

2. cd to your kernel dir

cd ~/kernel_p990

3. Run this command to download the source code for compiling:

git clone https://github.com/Firtecy/kowalski

4. Now we need to download the toolchain for compiling: Download it from here: http://www.linaro.org/downloads/ under the Bare-Metal section. It is labeled GCC ARM Embedded. Version: 4.7-2013.q3 ; Release: 13.11

5. Now extract the toolchain to a new dir, for example: ~/kernel_p990/toolchain

6. Now we have to define some values for the build enviroment:

Set the CROSS_COMPILE var to your path where you have downloaded your toolchain. For example:

export CROSS_COMPILE=~/kernel_p990/toolchain/gcc-arm-none-eabi-4_7-2013q3/bin/arm-none-eabi-

Notice at the end you find this prefix: arm-none-eabi- this is not a dir, but the prefix for all files inside the bin directory(for example: arm-none-eabi-gcc)

7. Set the architecture (processor architecture) for which the kernel should be build. So in our case arm:

export ARCH=arm

and

export SUBARCH=arm

8. The next step defines the configurations for the kernel (in this case the configuration is named kowalski_defconig)

make kowalski_defconfig

Notice: this takes the configuration from the file located under arch/arm/configs and will write it to .config

9. Now we can finally build the kernel :victory: Run:

make

You will find the kernel under: arch/arm/boot/zImage. You just have to copy the zImage and replace the one found in the flashable zip (e.g. my downloads) under kernel/zImage with your own.

Troubleshooting:

Before you can build or run any from step 8 or 9 you have to make sure that all three vars are set correctly (so ARCH, CROSS_COMPILE and SUBARCH). You can check it by running:

echo $ARCH

for ARCH (for CROSS_COMPILE and SUBARCH it is the seem, but you have to change the name)

If they are not set correctly repeat step 6 and 7.

If you get a compile error first try to run:

make clean

and try to build the kernel again.

How to diff 2 files or directories in linux

If you are running linux and have two files on your computer and you want to find the differences you can run the diff command in the terminal.

Let's say you have a file "hjunii/traps.c" and "kowalski/traps.c", this is how you compare them:

diff -u hjunii/traps.c kowalski/traps.c

The command will compare both and will print an output to the terminal that will be similar to this:

@@ -27,6 +27,7 @@
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/sched.h>
+#include <linux/slab.h>

#include <linux/atomic.h>
#include <asm/cacheflush.h>
@@ -483,25 +484,38 @@
static inline void
do_cache_op(unsigned long start, unsigned long end, int flags)
{
-	struct mm_struct *mm = current->active_mm;
-	struct vm_area_struct *vma;
-
if (end < start || flags)
return;
+	return flush_cache_user_range(start, end);
+}
+
+static inline int
+do_cache_op_iov(const struct iovec __user *uiov, unsigned long cnt, int flags)
+{
+	int i, ret = 0;
+	unsigned long len = cnt * sizeof(struct iovec);
+	struct iovec *iov = kmalloc(len, GFP_KERNEL);

-	down_read(&mm->mmap_sem);
-	vma = find_vma(mm, start);
-	if (vma && vma->vm_start < end) {
-	if (start < vma->vm_start)
-	start = vma->vm_start;
-	if (end > vma->vm_end)
-	end = vma->vm_end;
+	if (iov == NULL) {
+	ret = -ENOMEM;
+	goto out;
+	}

-	up_read(&mm->mmap_sem);
-	flush_cache_user_range(start, end);
-	return;
+	if (copy_from_user(iov, uiov, len)) {
+	ret = -EFAULT;
+	goto out_free;
}
-	up_read(&mm->mmap_sem);
+
+	for (i = 0; i < cnt; ++i) {
+	unsigned long start = (unsigned long __force)iov[i].iov_base;
+	unsigned long end = start + iov[i].iov_len;
+	do_cache_op(start, end, flags);
+	}
+
+out_free:
+	kfree(iov);
+out:
+	return ret;
}

/*
@@ -550,6 +564,10 @@
do_cache_op(regs->ARM_r0, regs->ARM_r1, regs->ARM_r2);
return 0;

+	case NR(cacheflush_iov):
+	do_cache_op_iov((const struct iovec __user *)regs->ARM_r0,
+	regs->ARM_r1, regs->ARM_r2);
+
case NR(usr26):
if (!(elf_hwcap & HWCAP_26BIT))
break;

Each line starting with a "+" are lines that were added, for example:

+#include <linux/slab.h>

On the other side lines starting with a "-" are lines that were deleted, for example:

-	struct mm_struct *mm = current->active_mm;

A line like the following should just show you were you find the changes:

@@ -550,6 +564,10 @@

with the following syntax:

@@ -[line number in 1. file],[number of lines that were printed from 1.file] + [line number in 2. file], [number of lines that were printed from 2.file] @@

But the basic syntax is the following:

diff -u [base file] [file containing the changes you want to display]

You can also compare whole directories!

ProTip: Install the program "colordiff". It will color the console output, that means the output is more readable!

Syntax:

diff -u [base file] [file containing the changes you want to display] | colordiff

Example:

[COLOR="Plum"]@@ -1,8 +1,8 @@[/COLOR]
[COLOR="Red"]-VERSION = 2
-PATCHLEVEL = 6
-SUBLEVEL = 39
-EXTRAVERSION = .4
-NAME = Flesh-Eating Bats with Fangs[/COLOR]
[COLOR="RoyalBlue"]+VERSION = 3
+PATCHLEVEL = 1
+SUBLEVEL = 10
+EXTRAVERSION =
+NAME = "Divemaster Edition"[/COLOR]