Kernel compilation for my rooted Samsung SM-A300FU (with Ubuntu 14.04):
1. You will need a rooted phone.
I did it this way:
Download:
Odin (this only works with:
Windows and installed:
Samsung-USB-Drivers from here:
https://mega.nz/#!jxAU0CwR!hYbYXZx76j70hlPEEzudLTNkaCWORoQI2jp_EyeWgto
) here:
https://mega.nz/#!rxZmDaAb!tM4eNzJbaB8jaFvQQ77jBp64qTCrqXbERwcQhZF_Zco
(There is an Ubuntu alternative called:
heimdall-flash (information here:
https://wiki.ubuntuusers.de/Heimdall (in German, but i think you will find enough information in english about it on the internet)).)
and:
TWRP-Recovery here:
https://mega.nz/#!K1B0jIrJ!Dur0dXJ41vRIXKOtG2OL1bwIDKfMsuO44rRb9vqehGQ
and:
hadesKernel here:
https://mega.nz/#!GtIU2YzB!onjH4qeYGTSYW5uVwAlYbLenH6TRo8ngO4W1nOSqd5Q
At first you have to flash the:
TWRP-Recovery (you can get back the original:
recovery.img by downloading the:
Firmware for you're phone.
For my phone it is called:
A300FUXXU1CPH3_DBT1CPI1_Germany_6.0.1.zip (in the:
*.zip you will find the file:
recovery.img, which can later, when the phone is rooted, be flashed back to your phone with:
Rashr).
Now install the:
Samsung-USB-Drivers from the link above.
Open:
Odin on a:
Windows-PC.
Then start your phone in:
Download mode by restarting the phone and pressing:
Volume down and
Home button together (when the phone boots again).
This works as long as the phone is on.
When the telephone is off, press:
Volume down,
Home button and
Power button together, until you see the:
Warning!!-screen.
Press:
Volume Up to enter:
Download mode or restart your phone with:
Volume down.
You can get out of the:
Download mode anytime by pressing:
Volume down and
Power button until the phone restarts.
When:
Odin has started you should see:
Added!! in the:
Log window, when you now connect your phone via:
USB-Cable to your:
Windows-PC.
Please ensure, that only:
F. Reset Time is activated in the:
Options window.
Now click:
AP and choose the:
twrp_3.0.2-1_sm-a300.tar that you've downloaded from the link above.
Then click:
Start, and when everything works well you should see:
PASS!
If not try again.
When it fails again, try another:
TWRP.
Otherwise this will not work for your phone, but there are other:
Recoveries available on the internet.
Now get out of:
Download mode, like mentioned above and restart your phone.
Connect it with an:
USB-Cable to your:
Ubuntu- or
Windows-PC and copy the file:
A300FU-hadesKernel-v2.6.zip via:
MTP mode to a folder you like.
You will have to permit:
MTP access on your phone.
Of course you also can use:
Bluetooth for this. (There are other methods to copy it to your phone, like the Android app:
WiFi File Transfer Pro)
Next get into:
Recovery mode by restarting your phone and pressing:
Volume up and
Home button together (when the telephone boots again).
When the telephone is off, press:
Volume up,
Home button and
Power button together, until the:
TWRP-Recovery starts.
At the first start it may ask you, if the:
system partition should be:
mounted read only.
You should allow to
read and write this partition.
Now in the Recovery select:
Settings.
Under:
General I have activated:
Skip MD5 generation during backup and:
Use 24-hour clock.
Everything else is deactivated.
Other things you can set to your needs.
Now go back and choose:
Install.
Select the path you copied the:
A300FU-hadesKernel-v2.6.zip to.
With:
Select Storage you can switch between:
Internal Strorage and:
Micro SDCard.
Select it and:
Swipe to confirm Flash.
Then click:
Next,
I agree with these Terms of Use,
Next,
Next.
Deactivate:
hadesKernel and choose:
SuperSU.
Then follow the remaining steps until the end.
When everything worked well, your telephone is rooted now.
2. Kernel compilation.
The:
binfmt_misc support, as for me, only comes with a self compiled kernel (with:
CONFIG_BINFMT_ELF=y,
CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS=y,
CONFIG_HAVE_AOUT=y,
CONFIG_BINFMT_MISC=y compiled into it).
First download the source:
SM-A300FU_EUR_MM_Opensource_A300FUXXU1CPH3.zip from:
opensource.samsung.com
Search for:
sm-a300fu
Then extract the:
Kernel.tar.gz from inside the:
*.zip to a folder you like.
Now do:
on the folder you extracted the:
Kernel.tar.gz to.
Then download the:
arm-eabi-4.9-Toolchain from here:
https://mega.nz/#!K151nQCI!v78s1QY2fD-ZPIwdHd7VESjnwrfipvyK-IagOAu7lWA
and extract it to a folder you like.
And again a:
on the folder you extracted the:
Toolchain to.
At next replace the:
configs in the:
Kernel/arch/arm/configs/-folder with these:
https://mega.nz/#!awphRQJB!hKjkrsY8YmqiyhF3hTp4jOS2INpWlRq04PReTE_EIec
https://mega.nz/#!ewonmQZK!v1lh5pINzpqjZKJXGn5-bh6uQiy2qggvrLdpTo6CWHI
https://mega.nz/#!SgwhHACY!eKA5tH1N1wJ7llin_GO1LKEfaiJQ4DjBpWCMW7dqQ7s
Then replace the:
Kconfig in the:
Kernel/drivers/misc-folder with this one:
https://mega.nz/#!Tk4RmCYb!lR4ZF9txs-52pjlIJsMu9mdkQ_g5IIoo2-SDAobHpZE
And replace the:
Makefile in the:
Kernel-folder with this one:
https://mega.nz/#!ekpFwI5I!a3ZOitQWtXTuZt5z9JhAcV-NJXK7WBS9dSS5Dec2ZaM
(or add the:
EXTRAVERSION of your phone's kernel, if it differs from mine, found in your:
Settings->About device->Kernel version.
It is the number after the:
Kernel version number.
For me the Kernel version is:
3.10.49. With the:
EXTRAVERSION:
-8987886.
Look how i did it in my:
Makefile.)
Now replace the:
build_kernel.sh in the:
Kernel-folder with mine:
https://mega.nz/#!v4on0SAK!oHhuYmkOrAoHk7Y6Jeu0pLX2CjTfk5ABz1tcuUH2Wb8
In the:
build_kernel.sh change the path after:
export CROSS_COMPILE= to the folder you extracted the:
Toolchain to.
Then change the line:
chmod -R a+xrw /media/anwender/EXT4/samsunga3/Kernel/output to:
chmod -R a+xrw /your/Kernel/folder/output.
And then change the line:
make -j64 -C $(pwd) O=output V=2 INSTALL_MOD_PATH=/home/anwender/Schreibtisch/module modules_install to:
make -j64 -C $(pwd) O=output V=2 INSTALL_MOD_PATH=/the/folder/you/like/module modules_install.
The compiled modules:
*.ko will be installed to this folder.
As for me, i don't need them, because everything i added to the kernel is built-in and not as modules.
And my kernel works with the original stock modules.
Otherwise copy your modules to the:
/system/lib/modules-folder on your phone [i don't know if this works, because everything i added is built-in, as mentioned above].
And finally change the line:
chmod -R a+xrw /media/anwender/EXT4/samsunga3/Kernel/output to:
chmod -R a+xrw /your/Kernel/folder/output.
Again do:
on the folder you extracted the:
Kernel.tar.gz to.
Now you're ready to go.
Open a:
Terminal in your:
Kernel-folder.
At first do:
.
Now you can start compiling with a:
.
This will take a while (about one hour for me).
You will find the compiled:
zImage in the:
Kernel/output/arch/arm/boot-folder.
3. Unpacking, Packing and Flashing the kernel image
I used this tool to unpack and repack the:
boot.img:
https://mega.nz/#!m9wBHSBR!udMbNLJ7pR-9sZ9SZsee4Q1qMq3D1XgpVw19RkFcSss
Now you need the original:
boot.img of your phone.
This can be done with the:
Android app:
Rashr (at first start it will ask you to make a backup of your:
boot.img) or with:
adb:
First install:
adb with:
Code:
sudo apt-get install android-tools-adb
or with:
synaptic.
Now add these lines to your:
/lib/udev/rules.d/70-android-tools-adb.rules:
Code:
ACTION=="add|change", SUBSYSTEM=="usb", \
ATTRS{idVendor}=="04e8", \
ATTRS{idProduct}=="685e|6860|6864|6866|6866", \
TAG+="uaccess"
and make sure the file has all permissions.
Otherwise do a:
Code:
sudo chmod a+xrw /lib/udev/rules.d/70-android-tools-adb.rules
Next enable:
USB debugging on your phone.
Go to:
Settings->About device and tab:
7 times on:
Build number to unlock:
Developer mode.
Go back to:
Settings, enter:
Developer options and enable:
USB debugging.
Now connect your phone via:
USB-Cable with your:
Ubuntu-PC.
Open a:
Terminal and enter:
Maybe you have to allow it on your phone.
And then (in:
Terminal) enter:
Now go to a folder with enough free space on your phone like this:
Next make a backup of your:
boot partition like this:
Code:
dd if=/dev/block/bootdevice/by-name/boot of=/sdcard/boot.img
.
Unpack the:
bootimagetool.zip to a folder you like and do a:
on this folder.
Copy the original:
boot.img to your:
Ubuntu-PC with methods mentioned above, but in the other way of course =-).
Next follow the steps in the:
README.md that comes with the:
bootimagetool.
When you're done, the finished:
image-new.img has to be copied to your phone.
With:
Rashr you can now flash this image to your boot partition.
Or use:
dd, like this:
Code:
dd if=/sdcard/boot.img of=/dev/block/bootdevice/by-name/boot
When the phone has booted successfully go to:
Settings->About device.
Under:
Kernel-Version you should now see, that the:
compilation date and
time and
user and
desktop-name have changed.
You can add other things to your kernel with:
CONFIG_* in the config files mentioned above, as long as their dependencies are fulfilled.
You will find help on the internet for this.
Congratulations.
4. Execute x86-binaries on your phone:
For this you'll have to mount an:
Ubuntu-Image e.g.:
ubuntu-13.10.LARGE.x86.ext2.v1.zip to a folder you like.
For this you'll have to add following lines to your:
bootscript.sh (under the:
Mount all required partitions section, or erase the:
#s in the lines, when some things are already there):
Code:
$bbox echo -n "Checking loop device..."
if [ -b /dev/block/loop256 ]
then
$bbox echo "FOUND"
else
$bbox echo "MISSING"
$bbox echo -n "Creating loop device..."
$bbox mknod /dev/block/loop256 b 7 256
if [ -b /dev/block/loop256 ]
then
$bbox echo "OK"
else
$bbox echo "FAILED"
error_exit "Unable to create loop device!"
fi
fi
$bbox losetup /dev/block/loop256 /path/to/your/ubuntu-13.10.LARGE.x86.ext2.img
if [ $? -ne 0 ]
then
error_exit "Unable to attach image to loop device! (Image = ubuntu-13.10.LARGE.x86.ext2.img)"
fi
$bbox mount -t ext2 -o suid,sync,users,acl,rw,dev,exec,user_xattr,dirsync,mand /dev/block/loop256 $mnt/mnt
if [ $? -ne 0 ]
then
error_exit "Unable to mount Ubuntux86.img to $mnt/mnt!"
fi
As for me this only works with the image laying in a folder on the external SD-Card.
Now do this:
Code:
sudo dpkg --add-architecture i386
Then go to:
https://packages.ubuntu.com, click on:
xenial, then:
Administratorwerkzeuge, then:
0install.
Now search for:
libc6 in the searchbar and click on:
xenial (16.04LTS).
Then click on:
i386 under:
libc6 herunterladen.
(You will have to do this, because the file:
is missing.)
There you will find, where the:
libc6-package can be found.
In this case it's:
pool/main/g/glibc.
At next go to:
http://old-releases.ubuntu.com/ubuntu and go to the folder where the package is.
Now look which version of:
libc6 you have installed like this:
Code:
sudo dpkg -l | grep libc6
.
In my case it's:
2.17-93ubuntu1.
This is an old version, so install a newer one with:
Code:
sudo apt-get install libc6
And install:
libgcc1 like this:
Code:
sudo apt-get install libgcc1
Now install:
binfmt-support and
qemu-user-static.
And do a:
Code:
update-binfmts --enable && update-binfmts --display
You should see, that everything is:
(enabled).
You now have installed this versions:
Code:
libc6 2.17-93ubuntu4
libgcc1 4.8.1-10ubuntu8
gcc-4.8-base 4.8.1-10ubuntu8
You'll have to download the same versions of the i386-packages like mentioned above.
Now install this packages with:
Code:
sudo dpkg -i /path/to/libc6_2.17-93ubuntu4_i386.deb /path/to/libgcc1_4.8.1-10ubuntu8_i386.deb /path/to/gcc-4.8-base_4.8.1-10ubuntu8_i386.deb
Now go to
/mnt/usr/bin-folder like this:
And execute:
It should say:
You executed an i386-binary =-).
I will update this tutorial (to be more exactly and contain more steps) later.
Have Fun. =-)