[Galaxy S5 Mini Android Development] hennymcc:
This is a short tutorial on how to compile and flash a (customized) Linux kernel on your G800H.

Note that this tutorial is only for the G800H as G800F/M/Y/... have a totally different architecture (SoC,...).

Toolchain

First of all get a decent toolchain (gcc,...). There are some prebuilt ones at android.googlesource.com.

If you have git installed fetch the arm-eabi-4.6 toolchain with:

git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6

Fetch the Linux Kernel sources

Now you have to fetch the kernel sources. At the moment there are only the official sources from Samsung's open source server.

http://opensource.samsung.com/reception/receptionSub.do?method=sub&sub=F&searchValue=SM-G800H

Select a source package:

The source packages at this server contain the kernel sources (Kernel.tar.gz), some part of the Android system (Platform.tar.gz) and some build instructions (README_*). There are multiple versions of the source packages. You can find an explanation of the versioning scheme here: samsung-firmware-version-number.html

For example the version part of a source package G800HXXU1ANGG is NGG which stands for N=2014, G=July, G=release G.

In addition Samsung adds country code post-fixes like "_LA" which might contain regional adaptions. See http://xdaforums.com/showpost.php?p=57410625&postcount=5 for an explanation and list of country codes

SER: RUSSIA

SWA: SOUTH WEST ASIA

MEA: unknown (maybe MIDDLE EAST ASIA?)

LA: unknown (could be ATLANTIC, as kernel config for G800H LA is named: msm8228-sec_atlantic3geur_defconfig)

SKZ = KAZAKHSTAN

As every source package for the G800H has a different country code it is hard to determine which one to use. Probably the regional differences only concern the Android system but not the kernel. According to the versioning scheme the last release should be G800HXXU1ANGG (LA).

Mirror:

Note that downloading a source package from Samsung's Open Source server takes a lot of time as the download speed is very poor. It took 12-24 hours for me.

You can also download the sources from my github repository:

https://github.com/tobigun/samsung-kernel-smg800h

At the moment the master contains the G800HXXU1ANGG kernel sources but might be updated as soon as a newer kernel source is released.

Compile the Kernel

Prepare the build by applying the S5 Mini kernel config:

ARCH=arm CROSS_COMPILE=<PATH_TO_TOOLCHAIN>/bin/arm-eabi- make msm8226-sec_defconfig VARIANT_DEFCONFIG=msm8228-sec_atlantic3geur_defconfig

If you want to change the config now, you can do this with:

ARCH=arm CROSS_COMPILE=<PATH_TO_TOOLCHAIN>/bin/arm-eabi- make menuconfig

After you have done some changes to the kernel sources you can build it with:

ARCH=arm CROSS_COMPILE=<PATH_TO_TOOLCHAIN>/bin/arm-eabi- make -j4

If you do not want to build with multiple CPUs you can remove the "-j4" from the command line (which also is handy if an error occurred).

In either case the resulting kernel image will be in "arch/arm/boot/zImage".

Flashing the Kernel

Almost done. It is not possible to flash the kernel image directly. Instead you have to put the kernel image and a ramdisk together into a flasable boot.img. The easiest way to get such a boot.img is to use an existing boot.img and replace just the kernel image.

1. Get a decent boot.img

Download the current firmware image from SamMobile (http://www.sammobile.com/firmwares/database/SM-G800H/) and extract the boot.img. With 7-zip there will be an error message if you extract the .tar.md5 inside the zip - just ignore the message and extract the boot.img file.

2. Replace kernel image

For this step AIK (Android Image Kitchen) is required.

Download it at http://xdaforums.com/showthread.php?t=2073775. Probably you want AIK-Linux-v1.7-ALL.tar.gz (or newer).

Extract the files.

Now unpack the boot image, replace the kernel image and repack it (with the original ramdisk) to a new boot.img:

./unpackimg.sh boot.img
cp <KERNEL_BUILD_DIR>/arch/arm/boot/zImage split_img/boot.img-zImage
./repackimg.sh --original

Note that the zImage name inside split_img might differ from boot.img-zImage.

The new boot.img is "image-new.img". Rename it to boot.img and flash it.

3. Flash new boot.img

Important notice:

- You flash this image at your own responsibility. I am not responsible for any damage that might be caused by flashing this image (bricked device, lost data, ...)

- Flashing this kernel image will trigger the KNOX counter, so your warranty will be void.

- The image is only for S5 Mini SM-G800H (msm8228)

- The kernel might be instable, crash your device, drain your battery, or even might damage your smartphone

- Backup your data before flashing

- Make sure you have the current firmware of your device (e.g. from SamMobile) so you can flash it back in case something goes wrong.

There are multiple ways to flash the boot.img to your device:

a) From recovery with an update.zip

b) Using Odin

a) From recovery with an update.zip

TODO

b) Using Odin

Create tar.md5:

At least some versions of Odin3 (e.g. v3.07) need a tar.md5 instead of a "simple" tar file. Although a simple tar-file can be selected in Odin, the image will not be flashed correctly.

Download tar-Tool_Odin3-v3.07_by_mkh.mourad.zip

Extract it.

On windows copy the boot.img file into the tar-Tool folder first and then drag and drop the boot.img on ImgToTar.MD5.bat. Alternatively you can also pass the filename as a command line parameter to ImgToTar.MD5.bat.

Now you should have a boot.tar.md5.

Flash tar.md5:

Download Odin (for example Odin3-v3.07 contained in CF-Auto-Root)

Reboot your device into Odin mode: turn off your device, then press Volume-Down + Home + Power button at the same time and release them. Confirm the following message with the Volume-Up button.

Connect your device to your PC via USB

Make sure the device driver's are installed on your PC

Start Odin

Select PDA and select the kernel image (boot.tar.md5)

Check that only "Auto Reboot" and "F. Reset Time" is set

Click on "Start": the kernel image should be flashed now and the device should reboot afterwards

Done

You can now check in "Settings - Device Info - Kernel-Version" if your kernel is used.