FORUMS
Remove All Ads from XDA
Honor 7x
Win an Honor 7X!

Nexus 4 Fixes: Custom kernel installer mods & more

1,329 posts
Thanks Meter: 1,412
 
By xenyz, Senior Member on 8th July 2016, 02:11 AM
Post Reply Email Thread
Intro

Over the past while I've finally decided to fix all minor annoyances on my Nexus 4. Here is a guide where I'll share all my modifications to make Mashmallow on the Mako as good as can be.

Kernel

Kernel Proper

The actual kernel included in this guide is HellSpawn kernel by @spezi77 which is based on hells-Core for Marshmallow, with all up-to-date Linux patches (3.4.112) and Google security patches (June 1). (Although I use, advocate, and absolutely recommend HellSpawn, feel free to use another custom kernel in the installer. You'll have to replace zImage and make your own changes to kernel/sema-boot.sh if your kernel doesn't include the same governors, hotplugs, etc.)

Here are a few highlights of HellSpawn itself:

- Includes the elementalx governor from @flar2 and lightweight mako_hotplug driver from @franciscofranco, which are much better than the stock ondemand governor and mpdecision hotplugs.

- Includes franciscofranco's gamma control, which is a much better default gamma for your screen and can be changed with franco's Nexus Display Control app or other Kernel Tweaker Apps.

- Includes a GPU overclock (400 -> 487 MHz) for when really demanding graphics operations require it.

- Includes BFQ, an optimized version of the default kernel's CFQ i/o scheduler. It helps when Play Store updates occur or when apps perform a lot of disk activity.

- Includes double tap to wake feature, which uses minimal extra battery and is much more convenient than the power key.

- When the screen is off, and not sleeping, only one CPU is active and it's limited to 1 GHz, which helps standby battery life with running background services.

Custom Kernel Installer
(original post with r1 was made on reddit)

I've adjusted many default kernel settings, based on a few years experience of running custom kernels. It uses the optimized elementalx governor from ElementalX kernel and lightweight mako_hotplug from franco kernel, with some of flar2's N5 settings, some of @hellsgod's N6 settings, and some of mine. There are other governors and hotplugs available, but from my experience, these offer the best balance of speed and battery life.

It includes a small, safe, -50 mV undervolt for a bit less heat from the CPU. - a user on reddit reported a reboot with r1, so I've removed voltage settings. It's probably useless to include such a small undervolt anyway. Change voltage settings in an init.d script or Kernel Tweaker app if you wish.

It activates double tap to wake by default, and also turns on power key suspend. If you press the power key with the screen on, double tap to wake will be turned off. Those on custom ROMs or Xposed's GravityBox can activate features to turn the screen off (double tap status bar, lock screen, nav bar, etc.) and keep double tap to wake on. Those without custom ROMs can perhaps use something like Greenify which can remap the home button long-press to turn the screen off.

It includes a patch to sepolicy which allows Viper4Android to work in selinux enforcing mode. You need to have SuperSU installed to have this work.

I've adjusted the io scheduler and page cache for better performance, tuned towards random reads.

It includes stock thermald and a tweaked thermald configuration that scales CPU frequencies up and down a little smoother when your temps get high. It should be noted that most custom kernels disable thermald for their own in-kernel thermal driver. I never liked doing this, as thermald does more than just adjust CPU frequencies - it also throttles GPU, screen brightness, and most importantly, battery charging. When your device gets too hot while charging, the worst thing to do is keep up the current and let the battery go over 45 degrees.

It includes a service to do 'Shared Cpufreq Policy', which lets thermald throttle all cores properly, and also lets the Battery Saver feature work correctly, by limiting all cores. This hasn't worked since KitKat and was one of my biggest annoyances. Many, if not all custom kernels just deleted the Power HAL libraries so battery saver feature doesn't work at all!

Includes Semaphore's 'mpdfake', a service to eat the touch boost spam that the Power HAL generates when not using mpdecision. If a custom kernel does not delete the Power HAL libraries, then your logcat is being spammed and logd process uses a lot of background CPU!

Includes a service to attempt to fix once and for all the location/GPS issues. I'm not going to state it works 100% yet, as I've only had max 24 hr uptime while making changes from the r1 release, but so far so good. Fingers crossed...

Includes a service to give SystemUI and Phone/Dialer higher priority. I haven't had a chance to really test it, as my device is sans-SIM at the moment, but it hopefully will lead to better responsiveness when you receive a call. (Under testing: giving some background processes lower priority, so they don't interrupt app usage.)

Move dalvik-cache to /cache partition and free 300-500 MB:

On each boot, it will check to see if you have a /cache/dalvik-cache folder, and will use it as the dalvik-cache if so.

If you are clean flashing a ROM and want to use /cache for dalvik-cache, create an empty dir in TWRP: /cache/dalvik-cache

If you just want to switch from /data to /cache, copy the /data/dalvik-cache to /cache/dalvik-cache and reboot.

Remember to be careful not to wipe /cache when 'dirty' flashing if you do this!

How to reset the mediaserver process quickly to get videos playing:

While your screen has been on for a few seconds or longer, double press the power key. You'll have to try it a few times to get the timing right, because a quick double press activates the camera in some ROMs. Also you're waiting for the screen to go off, not just dark. Practice a few times in low light, and you'll get the hang of the timing: each press should be followed by about half a second. You'll feel a short vibration when the service resets mediaserver to give some feedback that it's working. If it doesn't run the first time, keep cycling the screen off and on again until you get that vibration.

Remember: you have to start with the screen on, this allows you to quickly check on notifications from screen off without resetting mediaserver.


How to reset the sensors if ambient brightness, auto rotation, GPS, or any other sensors stop working:

Same as above, but this time you do the action twice. That is, screen on - double press power - vibrate once - double press power. You must do the two double presses within a second or two, so a little more practice may be needed. You'll feel two short vibrations when the service resets the sensors.

*** As of mod-r4, the new method to reset both mediaserver and sensors is Hold Volume Up and Power.

How to reset the touch screen if it becomes unresponsive:

If you happen to double tap to wake, the screen comes up, but no touches are being registered, tap on the screen with five fingers. If this doesn't reset it, turn the screen off and on again with the power key, and tap on the screen with both hands, all ten fingers. This will reset the driver and get it going again without a reboot.

Download & Installation

The installer is attached to this post. It's for AOSP ROMs, and uses the UberTC 5.4 toolchain. I'll post up CM versions on request.

Flash the zip with TWRP 3.0.2. If you have made any changes to your Marshmallow ROM (other custom kernels, etc.) you must remember to always flash custom kernels after (dirty) flashing custom ROMs! This is especially important, as if you are missing thermald you're going to have a bad time. FLASH YOUR ROM BEFORE THIS KERNEL INSTALLER UNLESS YOU HAVEN'T MADE ANY CHANGES. You can kill your device without thermal throttling!

Wiping dalvik-cache, and /cache is never necessary when flashing a custom kernel only.

ROM

Graphics Drivers

Audio

SuperSU - System or systemless?


Changelog: r14-mod-r3 - r13-mod4 - r16-mod-r5 - r04-mod-r6 - r05-mod-r7
The Following 6 Users Say Thank You to xenyz For This Useful Post: [ View ] Gift xenyz Ad-Free
 
 
8th July 2016, 02:36 AM |#2  
OP Senior Member
Thanks Meter: 1,412
 
More
Sorry, ran out of time for now but I'll continue the post soon...
9th July 2016, 05:48 AM |#3  
Senior Member
Thanks Meter: 591
 
More
If I want to customise the features, do I only comment out the features which I don't need in sema-boot.sh? Thx!
9th July 2016, 07:39 PM |#4  
jolas's Avatar
Senior Member
Flag Athens
Thanks Meter: 405
 
More
Hi @xenyz,

Thank you for your new kernel, I have to say that I missed using your projects.
Until now I'm testing it and the only cons I found is that with mako_hotplug when (temp increases) 1026 frequency makes mako very unresponsive.

Is there a way to change this frequency through a init.t script?

Thanks for keeping mako alive!
9th July 2016, 08:06 PM |#5  
OP Senior Member
Thanks Meter: 1,412
 
More
Quote:
Originally Posted by jer_ying_fd

If I want to customise the features, do I only comment out the features which I don't need in sema-boot.sh? Thx!

Sure, or another option is to put your overrides in /system/etc/init.d

Quote:
Originally Posted by jolas

Until now I'm testing it and the only cons I found is that with mako_hotplug when (temp increases) 1026 frequency makes mako very unresponsive.

Is there a way to change this frequency through a init.t script?

Carefully edit /system/etc/thermald.conf either in the installer before flashing, or on your device after flashing, and make your changes near the end of the file.


Can anyone comment on whether their location services are working better? I'm still undecided.

Sent from my Nexus 4 using Tapatalk
The Following 2 Users Say Thank You to xenyz For This Useful Post: [ View ] Gift xenyz Ad-Free
10th July 2016, 03:49 AM |#6  
Senior Member
Thanks Meter: 591
 
More
With the introduction of the new features of hellspawn r14, will it still work as it is?
10th July 2016, 09:49 PM |#7  
OP Senior Member
Thanks Meter: 1,412
 
More
Quote:
Originally Posted by jer_ying_fd

With the introduction of the new features of hellspawn r14, will it still work as it is?

I'm testing it out to make sure it's stable first. At least one change has to be made, turning off the new msm_hotplug which is enabled by default in r14.

Sent from my Nexus 4 using Tapatalk
The Following User Says Thank You to xenyz For This Useful Post: [ View ] Gift xenyz Ad-Free
11th July 2016, 11:00 AM |#8  
Senior Member
Thanks Meter: 591
 
More
Quote:
Originally Posted by xenyz

I'm testing it out to make sure it's stable first. At least one change has to be made, turning off the new msm_hotplug which is enabled by default in r14.

Sent from my Nexus 4 using Tapatalk

Ahh of course, I forgot to edit that out....
11th July 2016, 06:40 PM |#9  
I've gotten strange behavior after installing the kernel on my Chroma ROM Nexus 4.
  • The touchscreen began to have bouts of unresponsiveness, when it never had it prior to installation
  • Extremely slow on wakeup after a long time in sleep mode. Once again, never had that issue before
  • Overall lag and slowdown that wasn't present on the stock kernel

I've enabled only D2TW, the new I/O scheduler, 1 core active on sleep, Schedule workqueues on awake cores, and ThermalId

Just now, it did a random reboot. Any idea on what the issue could be?
11th July 2016, 07:21 PM |#10  
OP Senior Member
Thanks Meter: 1,412
 
More
Quote:
Originally Posted by ArtOfSnaila

I've enabled only D2TW, the new I/O scheduler, 1 core active on sleep, Schedule workqueues on awake cores, and ThermalId

Just now, it did a random reboot. Any idea on what the issue could be?

Could you try it without changing any settings? Force stop the kernel app and reboot.

Do you use any Doze modification apps? Greenify aggressive doze?

Was it a reboot or a SystemUI restart? Did you see the Google bootloader logo? If so, send me last_kmsg

Sent from my Nexus 4 using Tapatalk
11th July 2016, 08:01 PM |#11  
Quote:
Originally Posted by xenyz

Could you try it without changing any settings? Force stop the kernel app and reboot.

Do you use any Doze modification apps? Greenify aggressive doze?

Was it a reboot or a SystemUI restart? Did you see the Google bootloader logo? If so, send me last_kmsg

Sent from my Nexus 4 using Tapatalk

Alright, I'll try it without any settings modified.

I do use Aggressive Doze, could that be conflicting with the kernel? It never seemed to affect the stock kernel besides making the wake take a bit longer, but no lag afterwards.

It was a complete reboot, with the Google logo and everything. Here's the last_kmsg.
Attached Files
File Type: txt last_kmsg[1].txt - [Click for QR Code] (220.5 KB, 10 views)
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes