[Galaxy S Advance I9070 Android Development] cocafe:
This custom kernel is base on diego-ch's TWRP kernel.

I call it CoCore. :)

( Responsibility )

I'M IN NO WAY RESPONSIBLE OF ANY DAMAGE CAUSED BY USING THIS CUSTOM KERNEL.

( Compatibility )

This kernel works well on i9070.

I am sorry that it causes high cpu load on i9070P!

( What is needed )

* An I9070 (Andorid 2.3.6)

* Some Android experience

* Know some knowledge of how to use Android Terminal

* More patience :)

( Features )

TWRP Recovery 2.2.1

28 CPU Governers

8 I/O Schedulers

IO Unlocked (increased a bit speed)

Init.d Script

Custom Bootanimation

Deeper Sleep Mode

zRAM, SWAP Supported

NTFS(Read Only)

CIFS

ARM ThumbEE

ARM VFP with neon

Optimized RWSEM Algorithm

Mali GPU Tweakes/Controls

LZO Kernel Compression ( for faster boot )

Removed Useless Drivers ( for faster boot )

SLUB Memory Allocator

Automatic readahead cache size

Audio Boost*

Linaro GCC Toolchain

And many miscellaneous tweaks, it's hard to make a list for them.

Maybe i also forgot them. :p

A ton of new features in my updates,please Check the updated version.( See below ) :)

( Detailed explanation )

CPU Governers Supported:

Performance, OnDemand(default), Lionheart, Powersave, Userspace,
Conservation, OndemandX, SmartassV2, Interactive, Scary, Sakuractive,
PegasusQ, Intellidemand, Lazy, Wheatley, HotPlug,
SmartAss, LagFree, BrazilianWax, InteractiveX, MinMax, SavagedZen,
Aggressive, AggressiveX, Gallimaufry, GallimaufryX, AbyssPlug, Skywalker

* To get stable scores, please use Performance to run benchmarks.

* For daily using, i recommend PegasusQ.

* Please test the governors by yourself.

* And the PegasusQ will hotplug the second cpu when screen turns off,that might cause music skip when system load is heavy.

* If unsure,please use ondemand(default)

IO Schedulers Supported:

NOOP, Deadline, CFQ, BFQ(default), SIO, VR, anticipatory, ZEN

* To get more information about governers/io schedulers, here:

http://xdaforums.com/showthread.php?t=1369817

* For daily using, i recommend SIO/BFQ/ZEN

* Please choose a best io scheduler by yourself.

Init.d Script:

* Please make sure there is a latest busybox in your system.I found that init.d didn't work properly on some devices which have old version busybox.

* The init.d folder (/system/etc/init.d) must have 0755 permissions.

* If the scripts dont have execution permissions,it wont be execute automatically.

Custom Bootanimation:

* Please put the bootanimation.zip in /system/media with right permissions(0644).

* If there isn't any custom bootanimation, kernel will load Samsung official bootanimation.

DeepSleep Mode:

* Default mode is State4, i changed it to State5. Increased standby life time.

* If you use a hotplug governor,it might be unstable when you use the deepest sleep mode.

* Some users reported that ondemand works well with deepest sleep mode.

* If you mind the standby time of the phone,please give it a try.

* You can get information about CPU sleep states:

cat /d/cpuidle/stats

* To change the allowed deepest sleep mode: (e.g. Allow State6)

#echo 6 > /d/cpuidle/deepest_state

zRAM & SWAP:

* zRAM must be enabled by script/command.

mkswap /dev/block/zram0
swapon /dev/block/zram0

* SWAP must use with a SWAP partition in sdcard.

mkswap /dev/block/mmcblk1p2
swapon /dev/block/mmcblk1p2

* Because we have a large memory, the zRAM/SWAP is low activity.

* Some users said that zRAM/SWAP wont help the performance of games,they might drop more battery.

NTFS:

* Need a binary called "ntfs-3g" to read/write ntfs sdcard. Built-in NTFS feature only can read.

* Stock Android 2.3 cannot mount NTFS sdcard automatically.

Mali GPU:

* Allowed larger memory.

* Allowed larger OS memory for buffer. ( 6m -> 10m )

* L2 cache max reads tweakable

* Enabled some features in Makefile.

* Disable a big debugging checking

Audio Tweaks:

* Enabled directly rendering

* Enabled 32k_clk ( a feature of AB8500 )

* Volume Boost! ( v3.6-3.8rc,optional in v4.0 )

* Dynamic Range Enhanced! ( v3.6-3.8rc,optional in v4.0 )

( Installation )

Method 1

1. Flash the kernel which has TWRP via Odin. You can flash diego-ch's TWRP kernel, or flash "GT-I9070-Kernel-CoCore.tar.md5" in attachments.

Here diego-ch's TWRP kernel: http://xdaforums.com/showthread.php?t=1873119

( flash custom kernel will increase binary counter!! )

2. Run Odin, Put the md5 files in PDA, Pit files doesn't need.

3. Only check "Auto Reboot" and "F.Reset Time"

4. Click Start to flash, wait for phone reboot.

5. Boot into TWRP, Tap Install, Select i9070_kernel_CoCore_TWRP.zip, Flash it.

And, if you have TWRP kernel already, flash the zip via TWRP directly.

Method 2 (Experienced users only)

This method will not increased binary counter, but ROOT permission is needed.

1. Get kernel.bin.md5 from i9070_kernel_CoCore_TWRP.zip

2. Put kernel.bin.md5 in sdcard

3. Run your favourite terminal app, type these codes

$su
#dd if=/sdcard/kernel.bin.md5 of=/dev/block/mmcblk0p15

4. Reboot

If you typed a wrong patition number, perhaps it will brick your phone!!!

Think twice before you hit Enter. :)

( Updates )

01/03/2013 Update: CoCore v4.1

Hmm,This is BETA version. :)

Block: Added ZEN io scheduler (Bases on noop,deadline and sio)

CPUFreq: Added Skywalker governor (FreqTable tweaked)

Mali: Increased the default l2 max reads 28kb -> 48kb

Mali: Disabled a big debugging tracking

RCU: jRCU -> TreeRCU (For better CPU/RAM throughput!)

NWFPE: Enabled ex-nwfpe

Please remove the mali l2 init.d script tweaks,guys :)

CoCore-mini 1.4 is at #842 post.

12/23/2012 Update: CoCore v4.0

Mali: Driver updated, re-tweak the parameters

ASoC/ab8500: Driver updated

NET/conf: Enable HSTCP(high-speed tcp),Westwood+,Veno,Hybla,YeAh configs. Cubic(stock) conf is default.

Block: Set BFQ as default io scheduler

Block: Automatic readahead cache size limit (depend on the size of your sdcard)

Block: Re-tweak SIO/VR/Deadline for flash nand devices

MM: SLQB -> SLUB

SCHED: Remove fair_sleepers, revert the parameters back to stock

MISC: Remove a ton of juck!!!, Highest complie optimization level, boot faster(compare to old versions,8800ms~9100ms now)

PS.

The cifs.ko and smbfs.ko have been put out ramdisk.They will be installed to /system/lib/modules (for faster boot)

And i forgot the changes,see my source on my github.There is a changelog.

To change the net configs:

Create a new init.d script:

Change the 'highspeed' to other confs.

Use `sysctl -a | grep cubic` to know what conf you can change to.

`ping` is the simple way to test whether the conf you use fix you or not.

For me,i am using highspeed now. If unsure,keep default(Cubic)

#!/system/bin/sh

sysctl -w net.ipv4.tcp_congestion_control=highspeed;

I have set the mali l2 cache back to 28kb by default.

To set it to 48kb(max).Use an init.d script.

#!/system/bin/sh

echo 0x00000030 > /sys/module/mali/parameters/mali_l2_max_reads;

The game fps should be improved a bit,

The values you `echo` must be HEX

BUT,if it doesnt or feels lagged,remove this script.

For me,48kb works well.

The volume++ version is volume boosted. (Someone requires this)

The lagged sound will be increased,too! :eek:

12/09/2012 Update: CoCore v3.9Beta8

This is BETA VERSION!!

CpuFreq: Added AbyssPlug (Base on OnDemand+Hotplug)

Mali: Increased the priority of OSMEM (5 -> 1) (See the dmesg)

Mali: Unlocked mali_l2_max _reads in sysfs (You can tweak this parameter now) (Dont set over 48)

(If you find a good value,please share with us!) :)

Mali: Misc tweaks

Kernel/hz: Fix the defconfig issue (Thanks! [MENTION=4285986]hafidzduddin[/MENTION])

Net/SCH: Reverted back to stock (To experiment the latency of enabling mobile data)

Makefile: More optimization flags

PS.

The Mali parameters are in /sys/module/mali/parameters/

Use scripts/terminal to set them.

12/07/2012 Update: CoCore v3.9Beta3

This is BETA VERSION!

J4FS: J4FS driver works! Bugfree now!

CpuIdle: Revert the ApDeepSleep to stock,and added ApSleep++ custom state

(ApSleep++ and ApDeepSleep only works with non-hotplug governors,e.g: ondemand)

(New sleep state is disabled by default.You can enable them by yourself,if you prefer longer battery.)

CpuFreq: Added Aggressive, AggressiveX, Gallimaufry and GallimaufryX (These are optimazed version of Conservation/OnDemand)

CpuFreq: Fix a hotplug bug of PegasusQ

FS/SYNC: Removed Dynamic Fsync Control,added Ezekeel FSync Control

ASoc/ux500: Raise the pcm buffer size to MAX

NET/Scheduler: Re-tweaked, to experiment the latency of mobile data

Unknown: Fix the touchscreen sudden lost response (According to my using these days,it has been happended again!)

PS.

The FSYNC is enabled by default.Disabling FSYNC can improve IO performance.

In AnTuTu IO Test: Enabled: 350-400 Disable: 540-560

But disabling FSYNC can cause losing data!! It is at your own risk!!

Check the TIPS part to get how to disable it.

12/02/2012 Update: CoCore v3.9Beta1

This is BETA version, at #344 post.

12/02/2012 Update: CoCore v3.8.6rc

ASoC/ab8500: Use another gain mode in order to fix the terrible audio issue.

Sched: Reduce the latency of CFS Scheduler

PS.

The dyn_fsync will casue screen lag when you turn off the screen and there is a heavy io load.

If there isnt any heavy io load,it goes normally.

If you hate this,see the Tips part (#2 post) to get HOW TO disable dyn_fsync. :)

12/01/2012 Update: CoCore v3.8rc

CpuFreq: Tweaked the freq table of PegasusQ

Blcok: Updated BFQv1 -> BFQr2-1,Fixed the latency of BFQ issue. (BFQv5 is incompatible with Linux 2.6.35)

Sched: Tuned the patamerters of CFS scheduler (Use ThunderBolt's)

Sched_features: Enable Fair_Sleepers,Disable HRTICK

Mali: L2 cache max reads -> 48kb,Fix the mem leak issue.

NET: Set WestWood+ as default CONFIG

fs/sync: Added Dynamic FSync Control

(Improve IO performance greatly.When the screen is on,fsync is off.When the screen is off,fsync is on.)

ASoc/ab8500: Fixed the FMRadio volume balance issue. (Thanks [MENTION=2991046]shut_down[/MENTION])

MISC: Removed a TON of JUNK!!!,And added a workaround to flash kernel quickly.

PS.

The benchmark screenshot is in the #304 post.

How to disable DYN_FSYNC? Check the TIPS part. (#2 post)

What is the flash kernel workaround?

In TWRP,use the Terminal fucntion,SELECT the folderr which has a kernel named "kernel.bin.md5",Start the Terminal,

And just type "fkernel"(No quotes),it will flash the kernel.bin.md5 automatically.

And i found that V(R) is a good io scheduler too.

The BFS CPU Scheduler is incompatible with our kernel.I am about to introduce this in the JellyBean kernel.

11/25/2012 Update: CoCore v3.7

RamDisk/TWRP: Added a temporary workaround to mount emmc(internal memory)

Block: SIO io scheduler updated. (2012 version) (Thanks [MENTION=4285986]hafidzduddin[/MENTION])

CpuFreq: Fixed the name issues of governors (SetCPU cannot tune the parameters of governors, now fixed)

CpuFreq: Added LagFree, BrazilianWax, InteractiveX, MinMax and SavagedZen governors

(New governors havent been tested fully!If unsure, PegasusQ is recommended.)

I have tweaked the freq tables of most governors.

Mali: L2 cache max reads: 48kb -> 44kb , FPS increases (1-8fps) in simple scenes.

(Reserved 4kb for buffering, perhaps it will fix the sudden lag in games)

Sched: Fix SAMSUNG source code errors

Sched: Added AutoGroup Scheduler v4

Net/Sched: Re-changed the scheduler of net

android/logger: Reduced the logger size

ASoc/ab8500: Headset Volume adjusted, Dynamic Range enhanced! (i recommend using PowerAMP/RockBox)

PM(PowerManagement): Added a new feature, Operating Performance Point (OPP) Layer library

MISC: Disabled something useless(for faster boot),

Added GenLock API, MM&DMA hacked,

Added a new feature DM_CACHE,

more GCC optimizations in MakeFile

PS.

Dont use high volume to listen to music over 1 hour, it it not good for your ears.

Just reduce some volume.And i havent gained the speaker volume, dont worry. :)

The TWRP has some grapics issues when entering the emmc folder(it happends soemtimes, not always),

if it happended just tap back button and enter again.

(Some guys required this becaues them havent an external sdcard! :) )

And about the SetCPU issues. If you cannot tweak the parameters of some governors,

go to /sys/devices/system/cpu/cpufreq/(governor_name)/, you can tweak them here.

Make a script to tweak them quickly.

I think there is no point in updating to 2.6.35.14, because it updates a lot of useless drivers.

11/18/2012 Update: CoCore v3.6

Block: Added anticipatory io scheduler

CpuFreq: Added HotPlug and SmartAss governors

CpuFreq: Tweaked SmartAss and SmartAssV2 freqtable in order to match our device

Kernel: Adjusted many parameters

Lernel: Built with optimized compiler options

Sched: Added Fair_Sleepers feature,

disabled Gentle_Fair_Sleepers feature,

enabled HRTICK feature

MM: Increased Min readahead 16k -> 32k

JHash: Added JHash v3 speed tweak

Mali: Use another timestamp mode

ab8500/asoc: Headset volume gain boosted! (Sounds perfectly.My ears will be satisfied with i9070+Edifier H850. :p)

11/11/2012 Update: CoCore v3.5

Kernel: Revert LZO compression ( LZO is the fastest, but it makes kernel largest )

Kernel: Removed some bad tweaks

Kernel: Compile with Linaro GCC 4.4.5 ( The final version of Linaro GCC 4.4 series )

Ramdisk: For power saving, cifs.ko and smbfs.ko will not be loaded by default

Block: SIO, V(R) and Deadline io scheduler tweaked ( Better IO throughput )

FS: EXT2, EXT3 and EXT4 speed up

JHash: Updated to JHash v3

Sched: Enabled HRTICK

RCU: Added and use JRCU

TCP: Change TCP_Config to VENO ( Faster on wireless network ), and enabled HSTCP ( High-speed TCP )

NET: Net schedulers tweaked, in order to work with VENO config

NET: Introduce u64_stats_sync infrastructure

MM: Added vzalloc() and vzalloc_node() helpers

MM: Added and use SLQB memory allocator

MM: Added fudgeswap

SYNC: Added synchronization framework

BCM4330(WLAN): Enabled PM_FAST mode in standby

CGroup: Enabled FREEZER feature

PS. And many misc tweaks. :)

And i added some modules in /lib.

I tweaked mali parameters again (MEM -> 48MB OSMEM -> 8MB).

Because i find that when the memory is too big, it feels lag.

According to my test, in simple scence, fps increases (1-2fps); in complex scence, fps reduces (1-2fps).

But UI is faster in low frequencies! ( i often use signle core at 800Mhz )

10/28/2012 Update: CoCore v3.1

Mali: Fixed the fps issue.

RCU: Use Tiny-PREEMPT RCU (To reduce memory footprint, and feel more smooth)

Kernel: Removed some bad tweaks.

10/28/2012 Update: CoCore v3.0

Bug Fixed: Rolled back to old ramdisk (TWRP 2.2.1) in order to fix wifi hotspot issue.

MM: Increased sdcard max read ahead to 2048kb. (It's nice to work with my class-4 sdcard)

FS: Added AUFS,AutoFS4 support.

FS: Improved a bit perfromance of ext4.

RCU: Added Tiny-PREEMPT RCU.

RCU: Boosted. (Prefered real-time response)

CFS: Boosted.

Log: Reduced the log buffer size.

TCP: Enabled some features, optimized.

Net: Removed some schedulers.

Kernel: Removed some bad tweaks.

CGroup: Boosted.

CGroup: Added timer slack subsystem feature.

CpuIdle: ApDeepSleep(State6) worked! (Experimental,enable by yourself. Default is State5.)

LIB/CRC32: Added optimized CRC32 algorithm.

And lots of misc tweaks. :)

10/23/2012 Experimental Update

CpuIdle: State6( ApDeepSleep ) works!! Added "ARM_OFF" to State5!!

10/21/2012 Small Update

Update: TWRP 2.3.1.1 ( Thanks! @diego-ch )

Mali: Increase OS memory for buffer ( 8M -> 16M )

init.d: Make it as service

LIB: Add memcopy macoros and functions

ARM: Add optimized AES and SHA1 routines

ARM: Add optimized SHA1 implementations ( boot faster )

ARM: Enable ICache feature

ARM: Enable BPredict feature

ARM: VFP hard+neon float flag

ARM: JIT network Compiler ( experimental )

CPUIDLE: Add a custom sleep state ( state6,experimental )

Kernel: Use LZMA compresstion ( boot faster )

Kernel: Add XZ compresstion support

CFS: Tweaked

Revert: Gentle_Fair_Sleepers ( for smooth UI )

Compatible with JetMOD now

( Old versions downloads )

*** These have j4fs bug! ***

CoCore v3.1 http://d-h.st/1Q5

CoCore v3.5 http://d-h.st/qKY

CoCore v3.6 http://d-h.st/wvi

CoCore v3.7 http://d-h.st/48k

CoCore v3.8rc http://d-h.st/Eui

CoCore v3.8.6rc http://d-h.st/XEf

( Thanks )

Thanks to everyone who helped me. :)

Special Thanks:

@diego-ch

[MENTION=4309448]varun.chitre15[/MENTION]

[MENTION=4285986]hafidzduddin[/MENTION]

[MENTION=2991046]shut_down[/MENTION]

[MENTION=990100]hackbob[/MENTION]

@Adi_Pat

[MENTION=3203394]JackStow[/MENTION]

The source code is available on my github now.

If there are any issues, please report.

And if you like my work, Press THANKS Button Please. It encourages me. :)