[GUIDE] How to build AOSP kernel from source S4 Mini (i9195 & i9190)

proxuser

Senior Member
Jul 2, 2010
1,836
5,711
0
www.emexci.com
Welcome to Kernel build guide.

WITH THIS METHOD YOU WILL GET installable zip for your kernel.
My english is not best but i think you all will understand this guide :cowboy:. I write this guide because i dont own S4 Mini anymore and unfortunally i cant build kernels or roms anymore for s4 mini.

this is my kernel build method. you will have everything (tools) for build a kernel for s4 mini device. if you have questions, then ask it here. this kernel method is working only aosp based kernel (not tested for tw kernel but it may also work but you need ramdisk of tw kernel)

be sure you have packages installed for build something like this, or edit or clone a github source. look at cm kernel build guides.

1. Download build-s4-mini-kernel.zip [here]
extract it to root of your user directory (my is /home/proxuser/)
2. We need toolchain 4.7.4 by Christopher83 original thread [here]
download
arm-unknown-linux-gnueabi-linaro_4.7.4-2013.07-build_2013_07_12.tar.bz2
extract arm-unknown-linux-gnueabi-linaro_4.7.4-2013.07 folder to toolchains folder (home/yourusername/toolchains) and name it linaro_4.7.4

Download Build scripts from my source here
download:
- abooteur_3g.img
- abooteur_lte.img
- build_all.sh
- build_eur_3g.sh
- build_eur_lte.sh
- build_master.sh
- mkbootfs
- mkbootimg

and put them to your kernel folder "root folder of your kernel".


if you want clone a kernel source: example CyanogenMod's cm-10.2 kernel then

open Terminal, and be in user root folder /home/yourusername (just open terminal and your there)

Code:
git clone https://github.com/CyanogenMod/android_kernel_samsung_msm8930-common.git -b cm-10.2
if you want clone my Kartal kernel then

Code:
git clone https://github.com/proxuser/kartal.git -b master
it will named "if you cloned cyanogenmod kernel android_kernel_samsung_msm8930-common" if you clone my kernel then it will named "kartal"
you can rename kernel folder, its not problem.

if you want change of kernel name(example kartal), then go yourkernel/arch/arm/configs/kartal_defconfig and edit CONFIG_LOCALVERSION="-Kartal" change only "Kartal" for your kernel's name. if you want change defconfig example "kartal_defconfig" to "yourkernel_defconfig" then you need change it in build_master.sh too that it builds with your config file.

if you downloaded your kernel source and your build tools are there then lets start

Open terminal
type

Code:
cd yourkernelfolder
for build both phones i9195 & i9190
Code:
./build_all.sh
if it denies access for build_all.sh then type
Code:
chmod 777 build_all.sh
you can give all files access with this command.

for build i9195
Code:
./build_eur_lte.sh
for build i9190
Code:
./build_eur_3g.sh
finally it will start building. it will done within 4-5 min. depend your pc speed.

after it builds succesfully, your kernel will be in your /home/yourusername/Packages/ folder

IF YOU WANT add new changes from CM or other kernel to your kernel

then open Terminal
cd yourkernelfolder
git remote add CyanogenMod https://github.com/CyanogenMod/android_kernel_samsung_msm8930-common.git
git fetch CyanogenMod

this will fetch CyanogenMod kernel changes but it will not apply to your kernel. you will add changes step by step yourself. copy commits SHA from CyanogenMod kernel and

open Terminal

Code:
git cherry-pick 2108e6c3109ae126590a81876145a1f17d6771b5
if you get success on pick a commit then you will get a message like this

Code:
[email protected]:~/kernel$ git cherry-pick a41564437a0eb910d0347d274456f3f0116c3c77
[master 5dd0694] net-fixes: flow_dissector: prevent an infinite loop (CVE-2013-4348)
 Author: Eric Dumazet <[email protected]>
 1 file changed, 3 insertions(+), 1 deletion(-)
if you get an error like this
Code:
[email protected]:~/kernel$ git cherry-pick 63ee35463ea3ec5d4e8f2c60ad0f70abd8463733
error: could not apply 63ee354... ARM: 7809/1: perf: fix event validation for software group leaders
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
thats mean it is not applied to your files. just type "git status" to see what files are not modified.
then type: git reset --hard for go to your last commit.
this will make changes of error commit back.

Work always with git because with this way you can save a lot your changes and you can restore anything anytime.

Credits:

XDA Community
Christopher83 for toolchain
ktoonsez for build scripts
arco68 for s4 mini kernel development
cyanogenmod
 
Last edited:

junkyde

Senior Member
May 26, 2011
581
327
93
I have built your kernel successfully, but after flashing the .zip the device is stuck on the "Samsung Galaxy S4mini" Bootscreen.

I tested it with the this two roms:
- cm-10.2-20131102-SNAPSHOT-M1-serranoltexx
- CARBON-JB-UNOFFICIAL-20131026-1327-serranoltexx

Do you have any idea why it's not working?

Edit: I used arcos source and it is working fine now :)
 
Last edited:

Keon91

Senior Member
Jun 25, 2010
178
28
0
@junkyde

Can't get the stock kartal kernel to build.
What for OS are you running in your virtual box? ubuntu? 86x or 64x?

Did you install any other buildtools?
 

junkyde

Senior Member
May 26, 2011
581
327
93
there isn't a stock kartal kernel. kartal kernel is aosp. I am using Linux Mint 15 in a 64bit version on Virtual Box.

Ps: I had also my troubles with ubuntu x86 and x64, thats why I switched.
 
Last edited:

Keon91

Senior Member
Jun 25, 2010
178
28
0
there isn't a stock kartal kernel. kartal kernel is aosp. I am using Linux Mint 15 in a 64bit version on Virtual Box.

Ps: I had also my troubles with ubuntu x86 and x64, thats why I switched.
Thanks for you reply!
With "stock" I meant: without changing anything....

I will try mint 15 64bit with xfce!
 

junkyde

Senior Member
May 26, 2011
581
327
93
After installing : "sudo apt-get install ia32-libs" everything was fine.
Yes I know, that this is required, when you are working with a 64bit system. But I couldn't get this installed in Ubuntu. On Mint everything worked fine. But I am glad you made it ;)
 

Keon91

Senior Member
Jun 25, 2010
178
28
0
@junkyde

After some trial and error I've succesfully compiled the cm 10.1 kernel.

Can you give me any direction on how to compile the custom liblights?
Do I need to download the full cm 10.1 source?
 

file2mail

Member
Dec 20, 2010
12
0
0
Can someone build a kernel for the i257m
It would be nice if there was some kernel mods for this. especially just a near stock one with insecure root permissions.

The source is out if anyone was wondering
opensource.samsung.com/reception/receptionSub.do?method=search&searchValue=i257
 

rpgdev

Senior Member
Jul 31, 2011
516
63
58
IF YOU WANT add new changes from CM or other kernel to your kernel ...
What do you mean by this? Add changes that cm has done after you last downloaded them or changes you want to do to customize the kernel?

git cherry-pick 2108e6c3109ae126590a81876145a1f17d6771b5
What does this means and where do you get that ID? I would think that after fetching the changes from the source it will have been added to all the files you have already downloaded. Thanks for the tutorial!

---------- Post added at 05:58 PM ---------- Previous post was at 05:55 PM ----------

I used proxusers tutorial on how to build carbon rom. Downloaded full rom, modified lights.c and compiled whole rom.
junkyde here you don't mention lights.c, aren't they needed for 10.1? http://forum.xda-developers.com/showpost.php?p=49958578&postcount=215
 

junkyde

Senior Member
May 26, 2011
581
327
93
yes you need custom liblights for BLN, but since I have compiled them already, you can use the one from inside the .zip of my kernel.
 
  • Like
Reactions: rpgdev

rpgdev

Senior Member
Jul 31, 2011
516
63
58
Welcome to Kernel build guide.
WITH THIS METHOD YOU WILL GET installable zip for your kernel.
On ubuntu I got this message after the process took a while:
KERNEL DID NOT BUILD! no zImage exist
At some point in the process it printed:
[email protected]:~/Development/SGS4Mini/build-s4-mini-kernel/android_kernel_samsung_msm8930-common$ ./build_all.sh
...
...
...
rm: cannot remove `/home/rpgdev/Development/SGS4Mini/build-s4-mini-kernel/Packages/AOSP/zImage': No such file or directory
rm: cannot remove `arch/arm/boot/zImage': No such file or directory
Make the kernel
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/zconf.lex.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
***
*** Can't find default configuration "arch/arm/configs/kartal_defconfig"!
***
...
...
...
And if I go there I indeed can't find the zImage, where can I get it?

PS: Used the characters "..." to denote abridgment of the compilation verbose printout.

Forgot to add, I'm downloaded the cyanogenmod kernel from build 10.1 since that's the cyanogenmod version I use and for the one I need to make this mod, could this be the cause of the problem? Googling it seems that the kernel version you use may need a specific toolchain version.
 
Last edited:

rpgdev

Senior Member
Jul 31, 2011
516
63
58
I think it doesn't matter, I used the same for different roms and it worked. Source is as I said the lights.c file inside of the rom.

This is why zImage can't be build.
I'm not using kartal but the one downloaded from cm. Thought the instructions were generic and the script took into account wether you had downloaded the kernel from cm or kartal :/, I did go inside the directory with all the defconfig files, how do I know which one should I point it to on cm-10.1 kernel?

Regarding the lights.c then I just have to include that library on the same directory you put it in your kernel AND add the changes you pointed to here http://forum.xda-developers.com/showpost.php?p=49958578&postcount=215 and I would be set?

Thanks!