[KERNEL][MIUI V5/QDTXX] Stock kernel with init.d support / fstrim


Status
Not open for further replies.

redmaner

translators.xiaomi.eu maintainer
Staff member
Jan 12, 2013
534
546
182
#1
Post #1: Introduction, features, installation, downloads, FAQ and special thanks
Post #2: Features explained (kernel.conf and sysct.conf)

Introduction
I've been searching for a way to get init.d working on the Xiaomi Mi2 (stock MIUI).
So I updated the boot.img (kernel) with a modified ramdisk (initramfs) to add support for init.d and some other features.

Disclaimer
* I'm not a kernel developer this is a very simple mod which everyone could accomplish.
* This kernel is tested but that's not a 100% guarantee that it's safe.
* Flashing knowledge is required to keep yourself out of trouble.
* I am not responsible for your bricked or not working devices.
* If you have any concerns or don't know what this all means do some research.

Features
- Latest stock kernel (MIUI or AOSP)
- init.d support
- Support for sysctl.conf (see post #2)
- busybox with symlinked applets
- TRIM for /data, /cache and /system

Installation
Make a nandroid backup just in case something goes wrong (Link
1. Put universal zip on your sdcard (for MIUI and QDTXX)
2. Boot in ClockWorkMod recovery.
3. Flash kernel to system1 or system2 (depends where the ROM is installed).
4. Reboot.

Universal downloads
This will add the custom ramdisk to your kernel. This means it will work on all kernels (also for upcoming releases).
If something will change in the ramdisk I will update this ofcourse.
Compatible with:
- MIUI V5 weekly builds
- MIUI V5 stable builds (JLB) (in theory - not tested)
- MIUI V4 downgraded --> Follow this link
- Xiaomi AOSP (QDTXX)
- Custom roms based on the above

20130923 | Download for android 4.1.1 only!! MIUI 3.11.1 and Lower only!!
20130728 | Download for android 4.1.1 only!!

Old Downloads
3.6.28 Custom | Stock
3.6.21 Custom | Stock
3.6.14 Custom | Stock
3.6.7 Custom | Stock
3.5.31 Custom | Stock
3.5.24 Custom | Stock
3.5.17 Custom | Stock
3.5.10 Custom | Stock
3.5.3 Custom | Stock
3.4.28 Custom | Stock

QDT14 Custom | Stock

FAQ
What is init.d?
Init.d plays an important role in the world of Android development and customization.
It allows users to install scripts and mods to be run at boot. Everything from battery tweaks to performance tweaks.
It essentially opens the door to a world of mods only possible through the Init.d process, which in turn is usually only available on custom kernels.

How do I know if init.d works?
There is a test script after installation.
If you have "initd.log" in you data partition (/data/initd.log) then init.d works.

Test it with terminal emulator or adb
Code:
su
cat /data/initd.log
Help my phone is not booting!
Flash back stock kernel if available (for old downloads)
Else Switch system, reflash the ROM, restore a nandroid backup, flash with miflash or flash kernel with fastboot

What is xxxx governor or xxxxx scheduler
Follow this link

What is read_ahead_kb?
Follow this link

Does this work on Xiaomi Mi2A?
NO, hardware/rom/kernel is diffrent, don't try it.

Does this work on Xiaomi Mi2S?
Yes, it will

Does this work on WIUI?
WIUI already has init.d and sysctl support, besides that Wajk integrated some other tweaks too so kernel.conf isn't required. But in theory it should work.

Is this the start for other ROMS, like not MIUI?
No, this is a kernel modification without sources. Kernel sources are required to port other ROMS like CyanogenMod, Paranoidandroid ect.

Can you integrate more features in this kernel (e.g. screen colors, sound ect.)?
No, kernel sources are required for that. I am restricted to the ramdisk (initramfs).

Special thanks
- The CyanogenMod team / used their source to compile mkbootfs and used their init.d method.
- Gilles Grandou / for abootimg.
- M1cha / for ClockWorkMod recovery / kernelreplacer
 
Last edited:

redmaner

translators.xiaomi.eu maintainer
Staff member
Jan 12, 2013
534
546
182
#2
Kernel.conf Addon
This is a small script which allows you to configure various kernel components (CPU governor, I/O scheduler and read_ahead_kb).
This configuration can be set by editing the configuration file, located at /system/etc/kernel.conf.
By default this file does not exist, that means it uses the kernel defaults.
You can flash this addon to enable kernel.conf in

Download:
Kernel.conf addon | Remove kernel.conf addon
Note: flash in recovery

Supports..
- CPU governors (msm-dcvs - ondemand - interactive - powersave - performance)
- I/O schedulers (noop - deadline - cfq)
- read_ahead_kb (up to 4096kb)

Edit manually
You can edit the file manually, the format of the file is:
Code:
cpu_governor=[your preferred governor here]
io_scheduler=[your preferred scheduler here]
read_ahead_kb=[your preferred value here]
Note: no brackets

Edit using binary
I've integrated a simple binary to set your preferred configuration.
Start Terminal emulator and issue the following commands with root:

View current configuration
Code:
kernelconf -v
kernelconf --view
Disable custom configuration
Code:
kernelconf -d
kernelconf --disable
If you removed /system/etc/init.d/01kernelconf and want to enable it again
Code:
kernelconf -e
kernelconf --enable
Set CPU governor
Code:
kernelconf -g [governor]
kernelconf --cpu_governor [governor]
Set I/O scheduler
Code:
kernelconf -i [scheduler]
kernelconf --io_scheduler [scheduler]
Set read_ahead_kb
Code:
kernelconf -r [value]
kernelconf --read_ahead_kb [value]
Remove a line (e.g. you don't want to use a custom CPU governor)
Code:
kernelconf -g -e
kernelconf -g --erase
Apply changes...
Reboot your device.

Test your configuration after reboot
Code:
kernelconf -t
kernelconf --test
Sysctl.conf
sysctl is used to modify kernel parameters at runtime. The parameters available are those listed under /proc/sys/.
Most kernels support the sysctl.conf located at /system/etc/sysctl.conf, but Xiaomi Mi2 kernel doesn't support this file.
I've integrated support for this file. The kernel will use the list of sysctl commands in /system/etc/sysctl.conf at boot, if the file exsists.

Example:
Code:
#!/system/bin/sh
#
vm.dirty_background_ratio=65
vm.dirty_ratio=90
 
Jul 24, 2011
465
234
65
#3
wow this is nice work. Will try later tonight. thank you. hopping for full custom kernel soon to enable us to flash other roms.
 
Mar 5, 2013
96
11
28
#6
congratulation for you work....till xiaomi don't release the souce code, this is a big beginning!
 

redmaner

translators.xiaomi.eu maintainer
Staff member
Jan 12, 2013
534
546
182
#8
nice good stuff, hopefully there are future port for mi-one
Well as I stated in the disclaimer it's a simple mod so the port won't be a problem.
The method I use to pack the kernel with the modified ramdisk will probably work with the Mi One and Mi2A too.

The problem is the restore procedure if the kernel doesn't boot.
With no CWM the only solution is to switch from system and if that system doesn't boot either or doesn't work then I assume you have to restore the whole phone only because the kernel doesn't boot.
 

M1cha

Members
May 29, 2011
1,747
2,839
297
#9
the way via install-recovery.sh doesn't work because CWM deletes this file :)
Did you go the Cyanogenmod way now via init-scripts?
 

redmaner

translators.xiaomi.eu maintainer
Staff member
Jan 12, 2013
534
546
182
#10
the way via install-recovery.sh doesn't work because CWM deletes this file :)
Did you go the Cyanogenmod way now via init-scripts?
I used their /system/bin/sysinit
The only diffrence is that I did the modification to init.rc. CyanogenMod has an extra file with more CM specific stuff in init.cm.rc
 
Jun 23, 2012
68
43
28
#15
I remember Supercurios voodoo color from SGS1 - if I remember right the graphics driver had to be patched, kernel recompiled plus voodoo color was developed to enhance Samsungs AMOLED screen. We cant' recompile a kernel because we don't get sources from Xiaomi and we do not have SAMOLED :)
 
May 10, 2012
221
30
52
#16
Well as I stated in the disclaimer it's a simple mod so the port won't be a problem.
The method I use to pack the kernel with the modified ramdisk will probably work with the Mi One and Mi2A too.

The problem is the restore procedure if the kernel doesn't boot.
With no CWM the only solution is to switch from system and if that system doesn't boot either or doesn't work then I assume you have to restore the whole phone only because the kernel doesn't boot.
there are CWM from m1cha
http://miuiandroid.com/community/threads/2013-04-13-clockworkmod-recovery-6-0-3-0.19686/

available for mi-1
http://d-h.st/users/M1cha/?fld_id=11513#files

At least thats what im using right now, because the stock recovery from xiaomi its so basic...
 
Likes: redmaner

redmaner

translators.xiaomi.eu maintainer
Staff member
Jan 12, 2013
534
546
182
#24
The 3.5.10 kernel will be out tonight or tomorrow morning.
I will do some small cleanups to the kernel and maybe some improvements to kernel.conf
 

redmaner

translators.xiaomi.eu maintainer
Staff member
Jan 12, 2013
534
546
182
#25
I've uploaded the kernel for MIUI 3.5.10 with the following changes:​
- cleaned up sysctl execution (no seperate file in /system anymore)​
- kernel.conf is no longer executed by the kernel, it's moved to the init.d folder​
- some improvements to kernel.conf​
I've uploaded an addon for WIUI to enable kernel.conf on WIUI ROMS. see post #2
 
Likes: Wajk
Status
Not open for further replies.