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

Discussion in 'Xiaomi Mi 2 / Mi 2S' started by redmaner, Apr 30, 2013.

Thread Status:
Not open for further replies.
  1. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
    #1redmaner,Apr 30, 2013
    Last edited: Nov 18, 2013
    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
     
    deini, becham2382, type-R and 6 others like this.
  2. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
    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
     
    MSephiroth, deini, Wolf230 and 4 others like this.
  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.
     
  4. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
    Thanks, I hope so too.

    BTW: I pushed my modified initramfs to github: https://github.com/Redmaner/aries-initramfs-modified
     
  5. xeGox

    xeGoxMembers

    Feb 26, 2013
    395
    57
    60
    Male
    Wow!

    Inviato dal mio MI 2 con Tapatalk 2
     
  6. alakyr

    alakyrMembers

    Mar 5, 2013
    96
    11
    28
    Male
    ITaly
    congratulation for you work....till xiaomi don't release the souce code, this is a big beginning!
     
  7. eddie9684

    eddie9684Members

    May 10, 2012
    215
    29
    50
    Male
    nice good stuff, hopefully there are future port for mi-one
     
  8. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
    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.
     
  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?
     
  10. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
    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
     
  11. Gianluca85

    Gianluca85Members

    Apr 19, 2013
    2
    0
    11
    Male
    Thi kernel work on moto defy with miui v5 version 3.4.26? or wait new version?
     
  12. jmp

    jmpMembers

    Apr 2, 2013
    72
    5
    18
    Male
    No. You are in the wrong topic in the wrong forum.
     
  13. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
    It's only for Xiaomi Mi2
     
  14. jenicekk

    jenicekkMembers

    Jul 15, 2011
    62
    3
    28
    GREAT. and whatabout color set up? something like voodoo color?
     
  15. mialwe

    mialweMembers

    Jun 23, 2012
    68
    43
    28
    Male
    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 :)
     
  16. eddie9684

    eddie9684Members

    May 10, 2012
    215
    29
    50
    Male
    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...
     
    redmaner likes this.
  17. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
  18. Desmond

    DesmondMembers

    Apr 5, 2013
    96
    27
    38
    Male
    CARCAIXENT, Spain
    Is this a first step for developing another Roms not Miui?
     
  19. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
    No, kernel sources are required for that
     
  20. Pele

    PeleGuest

    Awesome stuff redmaner!

    This is surely beginning of great things to come!
     
    redmaner likes this.
  21. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
    I've uploaded the kernel for MIUI 3.5.3.
     
    Desmond, grondinm and Pele like this.
  22. xeGox

    xeGoxMembers

    Feb 26, 2013
    395
    57
    60
    Male
    Could I create kernel.conf like yours in wiui?

    Inviato dal mio MI 2 con Tapatalk 2
     
  23. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
    You can, but you need this kernel to let it work.
     
  24. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
    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
     
  25. redmaner

    redmanertranslators.xiaomi.eu maintainer
    Staff Member

    Jan 12, 2013
    533
    547
    180
    Male
    The Netherlands
    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
     
    Wajk likes this.

Share Our Site