[Samsung Galaxy Mini] Doc_cheilvenerdi.org:
[DEV] Increase Internal Memory Size to Whatever You Want!

KERNEL MODULES - FIRST RUN

First of all I setup a cross compiling environment: that is a toolchain used on Linux to create arm executables.

I usually build with the Sourcery CodeBench Lite toolchain, but it's well suited also the one prebuilt inside the AOSP source code...

This time I'll use this one; I find it on my PC starting from this path:

/home/doc/builds/WORKING_DIRECTORY/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/

Notice: I have to download it from the AOSP home page... could take a while...

Others known toolchains are Linaro (actually not working for me) or Gentoo Crossdev arm-vfp-linux-gnueabi (selfmade and my favourite one).

NOTICE: Anyway, from now on, I consider the building environment already up and running!

After downloading the Linux-to-Android toolchain I need the Kernel Source Code.

Starting from Samsung Open Source Release Center I Find my one and several others...

I download and unzip it into

/home/doc/boot_mod/kernel

So, this is now my working directory:

doc@gandalf ~/boot_mod $ ls -l
...
-rw-r--r-- 1 doc doc 6377472 May 7 2011 boot.img
-rw-r--r-- 1 doc doc 3221952 Jan 31 09:56 boot.img-kernel
-rw-r--r-- 1 doc doc 3146572 Jan 31 09:56 boot.img-ramdisk.gz
[b]d[/b]rwxr-xr-x 24 doc doc 4096 Jan 26 2011 kernel
-rwxr-xr-x 1 doc doc 28614 Jan 31 10:08 mkbootimg
[b]d[/b]rwxr-xr-x 9 doc doc 4096 Jan 31 10:17 ramdisk
-rwxr-xr-x 1 doc doc 6121 Jan 31 09:44 split_bootimg.pl
...
doc@gandalf ~/boot_mod $

First of all I check for the kernel version, looking the first five lines of its Makefile:

VERSION = [b]2[/b]
PATCHLEVEL = [b]6[/b]
SUBLEVEL = [b]35[/b]
EXTRAVERSION = [b].7[/b]
NAME = Yokohama

The Bold Numbers must match the ones read from Settings -> About Phone -> Kernel Version otherwise the modded image will never work!

Now I can edit the Makefile inside the kernel directory (need to do only once!) searching for a line starting with

CROSS_COMPILE = ...

...changing it to the full path of my toolchain binaries:

/home/doc/builds/WORKING_DIRECTORY/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/[b]bin/arm-eabi-[/b]

Last (but THE MOST IMPORTANT) I setup the kernel configuration for my phone (need to do only once!):

doc@gandalf ~/boot_mod/kernel $ make [b]tass_rev02_defconfig[/b]

...

#
# configuration written to .config
#
doc@gandalf ~/boot_mod/kernel $

How do I know that?

...with the following command

doc@gandalf ~/boot_mod/kernel $ make help

I find out all the phone supported by this kernel...

...and there are also beni and cooper ones (that means S5670 and S5830!) and really many many others...

WILL IT WORK?

Now I simply try to compile the default kernel modules:

doc@gandalf ~/boot_mod/kernel $ make modules

...

Building modules, stage 2.
MODPOST 7 modules

...
doc@gandalf ~/boot_mod/kernel $

Wow! I built something!

WHAT NEXT?

In the next post I'll finally tweak the ramdisk and then I'll compile the needed kernel modules suited for the XXKPF firmware!

...continued on post n. 54

IN THE MEANWHILE

Optional... but really usefull!

In the meanwhile I'll compile a single module suited for my own kernel, just to try it for free...

...or just to verifiy that everything works fine!

The master command is this:

doc@gandalf ~/boot_mod/kernel $ [b]make menuconfig[/b]

From the kernel menu I can change any config option for the kernel and related modules... but How do I suit it to my phone kernel?

From Settings -> About Phone -> Kernel version I read

2.6.35.7-perf-CL561937
root@DELL88 #1

I simply put last string of the first line (-perf-CL561937) inside the kernel menu option

General setup -> Local version - append to kernel release

where i write exactly

[b]-perf-CL561937[/b]

...eh eh... this is the trick that opened to me the kernel doors to my modded image tweaks... (10+)

After that I simply choose, for example, the following option:

File systems -> Network File Systems -> CIFS support

where I should see something like this:

< > ...
<[b]M[/b]> CIFS support (advanced network filesystem, SMBFS successor)
[ ] ...

Notice: <M> means "Module"

Now I exit from the menu saving "my new kernel configuration" and repeat the build command:

doc@gandalf ~/boot_mod/kernel $ make modules

...

LD [M] fs/cifs/cifs.ko
doc@gandalf ~/boot_mod/kernel $

I reduce the size of the module removing unused stuffs (...to save space - I'm not going to debug any module for bugs... I'll simply use them...):

doc@gandalf ~/boot_mod/kernel $ /home/alberto/builds/WORKING_DIRECTORY/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-[b]strip --strip-unneeded[/b] fs/cifs/cifs.ko
doc@gandalf ~/boot_mod/kernel $

(more details about stripping later...)

Now I connect the Phone to the PC and push the compiled module to /data/local using adb:

doc@gandalf ~/boot_mod/kernel $ adb push fs/cifs/cifs.ko /data/local
3687 KB/s (252908 bytes in 0.066s)
doc@gandalf ~/boot_mod/kernel $

...and finally, using "adb shell" (my phone needs to be rooted) I try to insert the module into my running kernel:

doc@gandalf ~/boot_mod/kernel $ adb shell
$ su
# lsmod
...
# [b]insmod /data/local/cifs.ko[/b]
# lsmod
[color=blue][b]cifs 210416 0 - Live 0xbf1b9000[/b][/color]
...
# exit
$ exit
doc@gandalf ~/boot_mod/kernel $

NO ERRORS! GREAT!

The error I don't want to see looks like:

# insmod /data/local/cifs.ko
[color=red][b]insmod: init_module '/data/local/cifs.ko' failed (Exec format error)[/b][/color]

where I, probably, mismatched the Kernel Local Version...

...easy play... and waiting for next post...