[myTouch 4G Android Development] faux123:
Announcement:

For ORANGE Glacier and ORANGE Sense USERS, GO TO your respective ROM threads to download the PATCH for your ROMs FIRST before coming back here for new kernel. ALL OTHER USERS DO NOT DOWNLOAD the ORANGE PATCHES you will screw up the file systems.

All other users (Rooted Stock, RoyalGlacier, RoyalThunder, Evil D's Desire Z/HD and Gr8Gorilla's Desire HD), ONLY if you experienced boot loops, download the updated "first time kernel v2", then apply the "first time kernel". Once rebooted, you can then update to newer kernels afterwards.

NOTICE: I am changing the title of my kernel thread to be clearer. ALL FROYO Sense ROMS:

All Sense/Expresso ROMs:

Rooted Stock, Ice Glacier,

Desire HD/Z, Orange Sense,

Orange Glacier, Thunderbolt​

All Gingerbread ROMs should use my Gingerbread Kernel

All Froyo AOSP ROMs should use my Froyo AOSP Kernel

Evil D's SENSE ROMs and KERNEL users ONLY: You MUST download my "First Time Kernel" below to RESET the Kernel Incompatibility coming from using his ROMs/Kernels. WITHOUT my using "First Time Kernel" will experience SEVERE LAG and VERY LOW QUANDRANT SCORES!!!

Hi XDA members and fellow MT4G users:

This is my FIRST kernel hack. I want to thank Grankin, Gr8Gorilla, Erasmux, dumfuq, Cyanogen, Zinx, Snq, Pershoot and several others I cannot recall for inspiring me to venture into this unfamiliar territory for me.

What is a Kernel? The Kernel is the Foundation in which everything else builds upon in any software system.

[Car Analogy]: Kernel is like the Engine, Electrical system and the Transmission to a car. The Library, Framework and the Apps [AKA ROM] are the body frame and the rest of the Car.

​

My goal for this Sense Based Kernel is to provide maximum Sense ROM compatibility, and only apply updates/patches/enhancements once I understand how they work and their cost/benefit to the kernel as a whole...

Please DO NOT use any task killers, they DO NOT improve performance nor battery life. They INTERFERE with your phone's stability (more crashes) and App compatibilities (Forced Close).

My kernel is based on the HTC source code directly from developer.htc.com.

MinMax Governor (Battery Saver)

This governor will try to minimize the frequency jumps/changes which cause voltage spikes/changes which supposedly drains more battery life... Supposedly designed to work with SetCPU... so give it a whirl...

SmartAss Governor (Balanced)

This governor has a built-in "profile" similar to SetCPU, so screen off will use lower clock rate thus conserve more battery, but it also has a fast wake up feature so that user interaction will not see the lag when switching from Sleep to Wake state.... (So SetCPU Profiles are sorta redundant when using this governor, you can still use SetCPU to OC to higher than default Clock frequency).

Interactive Governor (Performance)

This governor is designed to put more priority to User Interface (UI aka Apps) tasks, therefore appears more responsive then the traditional OnDemand governor. So if you want the smoothest UI interaction, this governor is for you...

Brain F*ck Scheduler - (BFS)

This scheduler is designed to be simple and speedy tailor specifically for user interface type systems such as desktop/smart phone devices where user interaction is MORE important than serving 1 million web requests at the same time (think of nimble desktop workstations vs large corporate servers). CM7 main line is using this as its default scheduler, now I bring you the same performance as CM7 with compatibility to Sense Series ROMs.

SLQB - (SLAB allocator with Queue)

This memory allocator is designed for small number of CPUs system (such as desktop or smart phone devices). This allocator is design to be simple and it is optimized for using order-0 pages as much as possible (order-0 pages are the simplest therefore quickest type of memory in a Linux system to allocate). Not all kernels are using SLQB including CM7 main line...

Fair Budget Queue (BFQ I/O scheduler)

This I/O scheduler is an improvement on top of Completely Fair Queue (CFQ). CFQ is fair in terms of time but not in terms of throughput / bandwidth, so BFQ make sure that both time and throughput / bandwidth are balanced across all requests.

Installation Instructions:

FIRST TIME STOCK USERS (or People who Experienced Boot Loops) ONLY:

If this is your FIRST TIME loading my KERNEL. You MUST LOAD THE FOLLOWING FILE FIRST:

First Time Kernel v2

Before you can update to my other kernels or any other kernels. YOU ONLY NEED TO DO THIS EXACTLY 1 TIME

Here's a step by step instruction to install this kernel to work with Froyo based ROMs:

[ Aurum Edition :cool: ]

[ CFS-Smartass ] (Mainline)

The File ==> Version 1.0.0-RC3 CFS Low Voltage #152 <==

The File ==> Version 1.0.0-RC3 CFS Stock Voltage #153 <==

[ BFS-Interactive ] (Enthusiasts Version)

The File ==> Version 1.0.0-RC3 BFS Low Voltage #154 <==

The File ==> Version 1.0.0-RC3 BFS Stock Voltage #155 <==

Post your problem IN DETAIL:

A [good example] of error reporting... (from vinsane)

Here's a template to use if you don't know how to report your issue

1. download the above file (via phone directly or to a PC)

2. copy the downloaded zip file to /sdcard/download/

3. Open ROM Manager and select "Reboot into Recovery" and select "OK"

4. Once in recovery, select "wipe cache partition", select "Yes", then select "advanced", then select "Wipe Dalvik Cache", then select "Yes" again. Once finished, click the back button to go back to the main recovery menu. On that menu, select "Install Zip From SDCad", then select "Choose zip from SDCard", then go to /sdcard/download and select the downloaded zip file and let it run its script.

5. Once the script is done, select "reboot system now"

After FLASHING, the first reboot may take longer than usual, please be patient (rebuilding cache structures)... After the first reboot, it may lag during initial load (let everything finish loading). Once everything is loaded and phone is ready for use, reboot the phone a 2nd time and the lag will be gone and everything should be silky smooth...[more detail]

I am currently running this kernel myself on my daily MT4G. I love android :D

NEWS BULLETIN:

Version 1.0.0 RC3 is OUT! :D

Added Zinx's latest fix for Glacier's light sensor values

I have SPLIT AOSP based ROMs (LiquidMetal ports, MIUI ports, G2 ports and CM6) away from Sense based ROMs (rooted Stock, Ice/Royal Glacier, Desire HD / Z, Thunderbolt)

Thanks to the following dedicated Beta Testers for all their efforts often taken for granted:

se1000, shlongwoodian, Elloco305, koshtaru, daprince047, nlarge, electronicrice, eliasadrian, kyokyle, rojoe, brwnohno

Remember NOT ALL CHIPS are created EQUAL... Especially for Low Voltage Version, it is specifically designed to balance between Performance and Battery Life. If you want to ultimate performance and stability, use the STOCK VOLTAGE version. Also remember NEW DMA Engine is more efficient, so it is putting MORE STRESS to the MEMORY SUBSYSTEMS than the old DMA Engine... Therefore, it MAY CAUSE more INSTABILITY than before when OVERCLOCKED to high frequencies!

Ultimate Final version 1.0.0 is coming soon ;)

Geek Talk Below:

[HAVS]Tried to hack HAVS to work with MT4G...

(Sigh... I can't find any documentation specific to MSM8255 chipset from Qualcomm... This lack of documentation is very frustrating because I don't have enough information on the AVSSCR registers and their meanings. Yes, I have written my own AVS based on existing HAVS, not just a copy and paste but until I can figure out all the "undocumented" registers for MSM8255, I can't get it work...)

Working on other things to reduce power consumption instead, until I can get more documentation on this chipset...

[Google Microbes Live Wallpaper]

I am humbled by a simple Google Microbes Live Wallpaper... Google is very very clever. They developed this live wallpaper as a bug/compatibility checker in disguise... I scoured the forum only to find out how many custom kernels experience all sorts of issues with this "live wallpaper". If you can run this wallpaper without any issues, you have a pretty stable ROM/Kernel combination...

[Android I/O scheduler Findings]

The more I found more how Android works, the more I realize that Android is a collection of hacks (for better or for worse)... The I/O scheduler is supremely important to Android... Any hiccups in the I/O scheduler greatly affects the Android presentation as a whole...

Users with lots of APP2SD Apps (Apps running from SD card) are most susceptible to lag issues from version 0.3.0 beta using simple NOOP I/O scheduler... Due to how kernel use loop backs to trick Apps running from SD, there can exist a condition where multiple SD Apps can access the SD card simultaneously and overwhelm a simple NOOP scheduler... I am switching back to CFQ because it is designed to address multi-tasking intensive servers which helps the above situation with multiple SD card accesses... Anyways, this should resolve the lag issue

[DMA Engine Upgrade. For Enthusiasts ONLY]

Upgraded the Direct Memory Access (DMA) code / engine to a new updated version from the Google Chrome (AKA Aurora) project. DMA is designed to off-load CPU from involving directly in data transfer, relieving it from the nitty gritty details of memory transferring, giving CPU more time to perform other more important tasks, thus increase overall system performance.. So a better DMA engine == better performance.

Unfortunately, the performance gained by this upgrade comes at a dear COST to battery life... You have been warned

[Voltage issues]

I made a coding error where I switched between Low Voltage and Stock Voltage builds... So those of you who've downloaded my old normal version were actually using STOCK VOLTAGES and those of you downloaded my old HV versions were using lower voltages.... Huge Thanks to XDD for making me double check my code... I've updated all my downloads and files again to correct the mistake...

[Touch Driver]

Touch Driver for Glacier sux (HTC should use the touch driver from their Shift 4G line for all their phones. period!)... Touch Driver for EVO Shift 4G is silky smooth... I completely transitioned to use Shift 4G's driver from now on...

[XCHG_ADD vs Generic Spin Lock]

It seemed pure HTC Sense ROMs (Desire HD/Z, Thunderbolt) are optimized for Generic Spin Lock Semaphores, so when I replaced the Generic Spin Locks with more advanced Exchange Add Algorithm Semaphores (specially optimized and written for use with ARM processors), it seemed to make these ROM to choke randomly (what appears to be lag). I decided to keep to my promise of making my Kernel 100% Sense Compatible, I REVERT back to Generic Spin Lock versions for the sake of Compatibility...

Replaced highly optimized RWSEM_XCHGADD_ALGORITHM specially written for ARM processors with RWSEM_GENERIC_SPINLOCK code...

[Optimization]

Read this post for Optimization in general...

[Expresso Issues]

Previous version 0.8.x were failures because I couldn't isolate the errors experienced (upside down lock screen) by a few STOCK/ICE GLACIER ROM users. Of course the most obvious area to look for the error was the Video driver. I have looked over the video driver at least 10x times, but the error is NOT there. I then look through the Touch Panel Driver and still the errors were not there either. What I forgot to mention in my change log was that I re-enabled a few compiler switches I have accidentally left out from since version 0.1.0 that were causing some errors shown in the LogCat captures. I went through all the changes I made step by step and the errors made NO SENSE at all (no pun intended). This whole experience has indicated to me that Expresso is NOT a copy and paste of Pure Sense framework... They are quite different internally... I am not sure if T-mobile or some neglected Dev team from HTC were responsible for Expresso framework. All I can say is Expresso is a HACK JOB of a framework. It's a shame that T-mobile didn't use a pure Sense UI for MT4G...

[BFS issues]

Revert back to CFS for scheduling... The more I play with HTC Sense (pure versions, excluding Expresso such as Stock and Iced), the more I realized that HTC has done extensive optimization in their Sense Framework... This is all good but it comes at a cost... Optimization is usually attained by taking advantage of certain behaviors of the Kernel, and since the AOSP kernel is using CFS as its default scheduler, so HTC has optimized Sense specifically for CFS scheduler. When I introduced BFS to my kernel, it seemed to cause some random slow downs in CFS-optimized Framework... From now on until version 1.0.0, I will use CFS as the default scheduler.

[Youtube Issues/Problems]

The "Real Problem" with youtube/Camera/Video players on MT4G is that the HTC Framework (closed proprietary code) DOES NOT refresh the video playback automatically, therefore, it will appear to be extremely laggy... What Zinx did was to HACK the kernel to FORCED UPDATE video playback to remove the lagginess from all video players such as Youtube/Camera/Video players (2D/3D Gallery Apps).

Most Apps exits gracefully such as Video players and Camera Apps, but the latest version of Youtube is doing something different from everyone else when EXITING in landscape mode WITHOUT notifying the kernel it's NO LONGER playing VIDEO, so the FORCED UPDATES from the kernel is unaware that Youtube has exited from LANDSCAPE MODE and continues to FORCE UPDATE the VIDEO, this will SOMETIMES result in fast Flipping/Scrolling and random Garbage on screen because the Youtube App is not notifying the kernel properly... Youtube DOES exit gracefully in Portrait mode, the problem WILL NOT OCCUR in portrait mode.

TL;DR: Exit Youtube in Portrait Mode to avoid any issues with the latest Youtube App.

[New HTC Kernel Sources]

HTC has release a NEW KERNEL SOURCE CODE for MT4G AKA GLACIER... UNFORTUNATELY, ONLY FM HeadPhone, DMA Engine and DOCK ACCESSORY parts were UPDATED, rest of the CODE are the SAME as ORIGINAL KERNEL SOURCE... FORTUNATELY for us, I've already incorporated all the NEW CODE from EVO SHIFT 4G... So we are actually ahead of HTC's own RELEASE CYCLE for MT4G AKA GLACIER :)

[CIFS + UTF-8 support]

I was notified via Twitter from user "snxat" regarding an awesome technology called CIFS, I will add CIFS as a kernel loadable module and enable its features so you can stream movies and music from anywhere (provided you have 3G/4G or Wifi) without downloading the files first...:D

Here's a CIFS front end developed by a fellow XDA Dev:

CIFS Manager

Which makes it quite simple on the Android side to set up.

Added UTF-8 kernel module to support many foreign languages or special characters used by PC share servers so CIFS mounts can read those characters properly.

[WiFi Hand-off Issue]

Many Sense Ports DO NOT HAVE NATIVE WiFi Calling support at ALL (T-Mobile ONLY FEATURE), so the FRAMEWORK (part of ROM) does NOT KNOW how to hand off between WiFi and Cell Network properly, when I added Universal WiFi Calling support to my Kernel.

THIS IS NOT A KERNEL ISSUE, this is Framework/ROM issue. I am keeping my promise to keep my Froyo/Sense Kernel as compatible as possible, so I have created a SOLUTION for EVERYONE. I made Universal Wifi Calling as an OPTIONAL kernel module (gan-eth.ko).

For Stock/Ice/RoyalGlacier users you do NOT have to do ANYTHING when loading my kernel.

For Pure Sense ROMs (Desire HD/Z, Thunderbolt, RoyalThunder), after you installed my kernel, simply use file manager of your choice with ROOT ACCESS and go to:

/system/lib/modules and DELETE the file gan-eth.ko

Once you deleted the file, you should have no issue with WiFi/Cell Network hand off at the COST of Universal WiFi Calling Support (WiFi calling might still work, just NOT as UNIVERSAL as before).

Better Solution is to MANUALLY turn ON/OFF WiFi to switch back and forth between WiFi and Cell network for Pure Sense Users.

THIS IS A KERNEL PATCH for a FRAMEWORK/ROM Issue... NOT A KERNEL PROBLEM.

[0.9.7.6]

MAJOR PROPs to user MADWOLF27!!!! Through his detailed investigative work, everyone of my kernel users (including myself :o ) benefited from it. He has found an obscure bug involving G-sensor and Sound in my kernel which may FREEZE the G-Sensor thus preventing the phone from rotating the screen properly.

[0.9.7.5]

Reverted back from 2.6.32.35 to 2.6.32.21 (using version 0.8.5 as base)

Note: My kernel was designed for performance and battery life, but as you can see above, some users have achieved amazing synthetic scores...:cool:

Benchmark Screens from users of this Kernel :cool:

Screen shot for Version 0.3.0 Beta BFS-SLQB

Screen shot for Version 0.3.0 Beta BFS-SLAB running rooted Stock @ 1.70 GHz

Screen shot for Version 0.3.0 Beta BFS-SLAB running Evil Desire Z @ 1.84 GHz

Screen shot for Version 0.5.0 Preview BFS-SLQB-BFQ-nDMA

BUGS:

None so far...

Resolved Issues / Bugs

v0.1 - Interactive Governor will FREEZE when updating frequency using SetCPU (Faux123)

v0.1 - Youtube/Camera/Camcorder/Gallery Video playback are choppy/laggy (Faux123)

v0.2 - SmartAss Governor not behaving as described (Faux123)

(pulled) v0.3 - Google Microbes Live Wallpaper freezes (ckisgen)

v0.3.0 Beta BFS-SLQN - lagging with rooted stock ROM (reported by jriv, vinsane)

v0.5.0 - upgrade DMA engine to newer version

v0.5.1 - upgrade Bluetooth stack to newer version (need dedicated beta testers)

v0.6.x - upgrade WiFi Driver (extremely risky for breaking Sense compatibility)

v0.7.0 - upgrade Video Driver (extremely risky for breaking Sense compatibility, HTC stock video driver is a HACK... Code is so ugly)

v0.7.x - Re-visit Youtube issue

v0.7.x - Re-visit DMA engine upgrade (finding root cause for battery drain)

v0.7.1b - "Smarter" SmartAss cannot handle too large of a frequency swing (reported by ckisgen & vw671). Problem exist only when overclocked above default frequency...

v0.7.9 - General UI lag (experienced by pure Sense Users), solved by switching from BFS back to CFS

v0.7.9.2 - Web Browser Lag (experienced by pure Sense Users), solved by switching from XCHG_ADD back to Generic Spin Lock

v0.8.0 - Broken WiFi for Stock/Ice (Expresso users)

v0.8.5 - Lock screen active when call > max screen off/sleep policy

v0.8.0~v0.8.6 - rare lock screen issues for Stock/Ice Glacier Users.

v0.9.x - Final kernel Optimizations

v0.9.9 - Clean up all loose ends...

TO DO:

v1.0.0 - DONE with Froyo (2.2.1). Moving on to AOSP Gingerbread (2.3.2) or AOSP MIUI ports maybe, or wait for Sense 2.1 (Gingerbread Sense UI)...

Standard Disclaimer: Not responsible for bricking your phone, voiding your warranty, or any other pain or suffering you may feel as result of using this kernel!!!

Follow me on Twiiter :

My Github in compliance with GPL :D

If you find this Kernel useful, feel free to hit the [Thanks] button below ;)