Red Magic 5G MOD Kernel GPUOC 900/940mhz +battery 1.4 STABLE!

237 posts
Thanks Meter: 242
Post Reply Email Thread
Click image for larger version

Name:	Screenshot_2020-08-26-16-24-00-987.jpg
Views:	610
Size:	127.3 KB
ID:	5087629Click image for larger version

Name:	682K-MOD-1.3_RM5G.jpg
Views:	1362
Size:	70.9 KB
ID:	5072269Click image for larger version

Name:	680K-AnTuTu.png
Views:	1770
Size:	201.9 KB
ID:	5065225Click image for larger version

Name:	Fastest_1.25BETA_MOD.png
Views:	1890
Size:	150.8 KB
ID:	5061951Click image for larger version

Name:	Screenshot_2020-07-01-21-26-47-058.png
Views:	2406
Size:	164.6 KB
ID:	5051605 Click image for larger version

Name:	Screenshot_2020-07-01-21-26-22-741.png
Views:	2172
Size:	131.1 KB
ID:	5051607 Click image for larger version

Name:	Screenshot_2020-07-01-21-26-12-488.jpg
Views:	2086
Size:	172.7 KB
ID:	5051609 Click image for larger version

Name:	Screenshot_2020-07-08-19-59-45-419.png
Views:	1914
Size:	130.9 KB
ID:	5057001

*** Please click Thanks (Thumbs up icon) on my post here if you like my kernel and rate the thread 5 stars, then just use it and enjoy - if you want to send me a beer or two feel free - you don't have to use PayPal - Revolut and (USA) gift cards avoid fees. I like to hear from happy users I hope you are glad that you have the fastest phone in the world currently. The active cooling in this device is utilized to the extreme with MOD kernel, meanwhile your battery usage will be much improved at the same time. How? Well, that's all in the source code, free for all to fork it on GitHub and modify to your liking. Just don't forget to credit me and the many great devs that made the improvements possible... without them, there would be no MOD kernel. This is just a hobby of mine and I like to produce a nice product that all can enjoy. I'm also quite friendly and although I may tell you no I won't add that feature (such as network hacking tools), I won't hold anything against you for asking. I have not been compensated other than by some generous folks on my Telegram channel, so this whole project is basically self funded. Red Magic will not support it, unfortunately, but you can if you feel the improvements are worth it. I believe they are, but I come from a biased point of view as the sole developer for RM5G ***

************************************************** ************************************************** ************************************************** ************************************************** ************************
************************************************** ************************************************** ************************************************** ************************************************** ************************
Easy root method: although I suggest still using Magisk 20.4 for root.

Note: if you've already rooted and want to upgrade, people have had success saving the kernel as boot.img and TWRP as recovery.img in SmartPack, vbmeta skip as vbmeta.img and placing into the ROM using MT Manager (a root browser) and saving the updated file. Then do a Settings / System Update / click the 3 dots / local update and select your modified file. In fact I upgraded from 3.13 to 3.16 NA ROM without losing anything this way. Now for normal installation:

Custom kernels require root and Magisk to be installed. This is due to the signature not being signed by Red Magic (the company) itself. Following the above method you will still pass SafetyNet and most apps will work without trouble. If you have a specific app that detects root, well, Magisk Hide the app from Magisk Manager and see if that fixes it. You should also Hide Magisk Manager from various forms of detection (under Settings). Last case is to move the installation of Magisk under a random directory (which I have not had to do and all my banking apps still work), only if the root detection methods used by your app providers are more picky.



Block mode I/O has been changed to Multi-Queue from Single-Queue so your default scheduler is now MQ-deadline (credits to PappaSmurf, excellent kernel dev). You can choose between mq-deadline, kyber, and none in a kernel manager under I/O scheduler. From my benching with Androbench, it doesn't make much difference which one you use. Some have parameters you can tweak. None literally means no scheduler which is fine on an SSD, and has no overhead if you want to select it in a kernel manager. I always recommend SmartPack. To get settings to stick you Toggle "Apply on Boot" and it will go to what you've selected after 5-10 seconds on the next boot.

All debugging has been turned off completely on BBRv2 - thanks to PappaSmurf (I missed a few spots), and debug can't be turned back on from the userspace now. BBRv2 is selected as the default TCP algorithm which users have explained as a "no-lag" algorithm while gaming. It's just generally a fast algorithm all around. For me it works great, but you can still choose from many different algorithms in a kernel manager if you want to.

In SmartPack / Misc / TCP Congestion Algorithm, you have many choices: reno / bbr / bbr2 / bic / cdg / cubic / dctcp / westwood / highspeed / hybla / htcp / vegas / veno / scalable / lp / yeah / illinois. A SmartPack script is included below you can add in SmartPack to show the true TCP algorithm as it will always show Reno (a bug also shared by FK kernel manager). Below it's called just go to SmartPack / Script Manager / Import / Afterwards, click Execute to see the active algorithm. If you set it on boot, this is the algorithm that will run, despite what the field says in Misc.

Battery is running very well on normal usage I'm getting around 7.5% active screen on drain over 7 hours and <0.7% screen off drain over 13 hours at 90hz screen setting. This is with actively using the phone for multiple "normal" purposes, reading emails, browsing websites with Chrome, reading news, streaming videos, etc. various shopping (Amazon/eBay) and tracking, Reddit feeds and live video, and other random "daily" tasks, up to 10 apps open at a time. Gaming of course will drain more, as will 144hz. I also have dark mode enabled in Settings. To get idle drain down I disabled 3 additional wakelocks that were causing high screen off drain, and so far I haven't seen an issue with blocking them. I also removed wakelocks that no longer exist since the Boeffla WL Blocker default list was created (it was quite old) so it now should be relevant for this device, with no interaction on the users part to disable anything via a kernel manager. Still, in SmartPack you will see a Wakelocks menu in case you install an app that causes idle drain to rise, this can be used to find and block wakelocks causing the problems. It can sort by wakeups and also by time. As it states though, you should be very careful what you disable. There can be unintended consequences and most wakelocks are not well documented as to what they actually control.

Dynamic Stune Boost is entirely removed from the kernel code now, as I didn't see any benefit from using it with this kernel.

Don't forget Dynamic Fsync is hidden under Misc in SmartPack which if you turn on will speed up your SQLite speeds. AnTuTu will penalize you for this, ignore it, your phone will be faster - but I leave it off by default. Androbench will show the true memory benefit. It is significant if an app does a lot of operations on databases. Journaling for the database is held in memory until the screen is off, then it is written. Although there is a chance of a data loss or corruption with this on if the device were to crash, it is safer than just turning off fsync. If you have any unstable apps, just leave it off - better to be safe. On a solid system though, you may notice better performance.

Also remember under SmartPack / GPU there is AdrenoBoost - it is set to low. You can alter to medium or high to get faster transfer between GPU frequencies, although it has worked great for me the way I use the phone. For you another setting may suit you better. Recall RedMagic OS only allows several frequencies which I spaced out as well as possible at 305mhz, 400mhz, 525mhz, 670mhz, 800mhz, and either 900 or 940mhz depending on the version you installed.

Overall I'm very satisfied with this kernel build and don't plan on adding or subtracting anything from it for the time being. It does what it should do, gives solid performance, and good battery life. My last score on AnTuTu setup with defaults 12GB/256GB was 682K which currently is still the top performing phone out there - running at 940mhz GPU. Not all phones can handle 940mhz so use 900mhz if yours cannot. If there are enough requests for an intermediate build (say 925mhz) I can add one later off the same code base. Also note in releases there are "gaming" builds that don't keep track of CPU times at each frequency, which was a request by users to remove any potential lag while gaming. I run the non gaming version, useful if you want to tweak battery usage, but nonetheless, both versions are there for you to use.

I'm on Telegram as long as I have the phone. Which will be quite a while if Red Magic / Nubia decides to fix N41 5G in the USA.

Also note that all the features of this kernel (besides ones specifically added by me) are the creation of other developers whose contributions are all notated in the kernel source code. Some of the developers that have contributions here or helped me in some fashion: Resurrect88, DD3Boh, PappaSmurf, kdrag0n, Ayrton990, Flar2, Lord Boeffla, plus many more across the globe. Without them, I wouldn't be making any kernels! And I'm sure there are many other devs I've forgotten to mention, I thank all you guys for your help and support.

MOD 1.4 Download Link:


8th Release:


This is an intermediate release - I realized that the prior release was draining far more battery than it should, and I found the source was debug related code in BBRv2 from Google. So this is the updated kernel that gives you battery life like before this TCP algorithm was added.

CONFIG_CPU_FREQ_TIMES=y has also been added so you can see in a kernel manager how much time is spent in each mhz block for each set of processors. This can be useful if you set in a kernel manager (like SmartPack) a minimum CPU mhz to see how much time is actually spent at each level.

The code base also has Dynamic Stune Boost, but I haven't had time to optimize it for the device, so it's just on default settings. So there are 2 versions of this 1.35-bbr2 release. At some point it will be enabled as part of a regular release (some 17 commits squashed together into 1, Stune Assist was causing issues so I turned it off). The main idea of that set of code additions is to run the device at lower frequencies, saving battery, while still achieving the same performance level to the user of the phone. If you want to try different options for it in SmartPack or FK Kernel Manager you can.


7th Release:


Added the 31+ commits for BBRv2 from Google. Squashed the commits down to 6 by author from Google (for easy code maintenance). It's said to be the best TCP (internet congestion) algorithm so this sets it by default. You can still select from the others added in 1.3, as mentioned only EX Kernel manager properly shows them. But SmartPack if you choose the one you want under Misc, then click Apply on Boot, it actually will load the TCP algo you selected. It's just a visual defect. I also made a script for SmartPack uploaded to show you the TCP algo that's selected in my repo you can install so you can verify for yourself. Give it 10 seconds (default on boot setting) before you check.


6th Release:


All this release adds is TCP congestion algorithms. The only kernel manager which correctly shows the algo set correctly is EX Kernel Manager. Using SmartPack or FK Kernel Manager will tell you that you're always on Reno, when in fact, you aren't. I'm not quite sure if this is bug related to 865 kernels as a fellow dev had the same experience (on an Op8 Pro). Now the default is set to BBR. Why? No reason specifically, although it is one of the better algorithms for internet usage. You can easily change in any kernel manager and set on boot which one you'd like to use (see above RELEASE NOTES if using SmartPack). But this gives you plenty of options:


You can Google the benefits of each and pick what you like. Or just leave it alone. The prime idea of MOD kernel is that you don't need to adjust anything it just works optimally without any intervention. Read the release notes for prior features that have been added. There are many just not summarized in a single place at the moment. All the optimization has been done for Red Magic OS.


5th Release:


This release is mostly about battery savings. I'm averaging around 6.5% active drain on normal tasks with this version (90hz setting), and around 0.5% screen off drain. A big improvement over the stock kernel. So I ended up with about 13 hours SOT + 24 hours screen off on 1 charge! See the picture, I stopped at 11% left. Now I didn't say anything about gaming. If you want to game and have power saving benefits, don't enable any of the built in boosting modes in the game launcher - the Red Magic OS will override everything. Let the kernel do the work for you. And if you're seeing any graphics lag, go into SmartPack kernel manager (free) and go under GPU, Adreno Boost is enabled on low, you can set it to medium or high. That will increase the speed at which the GPU throttles up and down.

1) Switch to the Energy Model for CPUs: Several subsystems (thermal and/or the task scheduler for example) can leverage information about the energy consumed by CPUs to make smarter decisions. This config option enables the framework from which subsystems can access the energy models.

2) Added CPUMASKS for the Little, Big, and Prime cores from Sultan Alsawaf Sultan: SultanXDA, prime added by Danny Lin: kdrag0n.

3) Added kernel control of the minimum frequencies for the little and big clusters by Danny Lin kdrag0n. They are set to run at their minimum running frequencies when idle 691mhz (little) and 710mhz (big) which results in nice power savings when web browsing or just under low load in general. Prime cluster min is not set as it makes the CPU scheduler function poorly.

4) Added AdrenoBoost by Aaron Segaert: Flar2, with all its changes squashed into 1 commit. Defaults to low setting. As mentioned before, you can change in SmartPack, and set on boot if you need a higher value than low:

5) Uploaded the various GPU OC files to the repo, It still will just build off the default one, but they are here to be complete. 940mhz version again is posted, Building direct from the repo will give you 900mhz max GPU.


4th Release:

RELEASE NOTES: (Note a 940mhz GPU clock edition is available, if you want to try it, a few of us have had good results on it. Likely the max an 865 GPU can run. You'll sacrifice the power savings, however):

1) Enable Power-efficient workqueues by default, add a toggle that can turn this off via a kernel manager (under CPU in SmartPack). Enabling this makes the per-cpu workqueues which were observed to contribute significantly to power consumption unbound, leading to measurably lower power usage at the cost of small performance overhead. Have also added many other power saving features to the defconfig. The phone is a beast, power savings is a good thing to implement.

2) Update the LZ4 decompressor algorithm with a much faster variant for the ZRAM swap, now version 1.8.3-9 credits Gao Xiang [email protected] and many others (check commits). Speed improvement below (should help on 8GB devices):

Compressor name Compress. Decompress. Compr. size Ratio Filename
lz4hc 1.7.3 -9 12 MB/s 653 MB/s 42203253 42.20 enwik8
lz4hc 1.8.3 -9 11 MB/s 965 MB/s 42203094 42.20 enwik8

3) Default scheduler is set to SQ deadline. Should see minimal improvements in speed until I get a MQ variant working. On the task list ahead.

Download Link:

940mhz GPU release here, it's still 1.2BETA, just with the max clock a few of us have been able to use. That doesn't mean your device can for sure handle it, but give it a try if you'd like! Note the power savings will likely not be there vs the other release at 900mhz:

3rd Release:

This is a HEAVILY updated release of the MOD kernel 1.10BETA - I realized the phone's software will allow 6 frequency clocks, although 1 did not have a regulator defined (now patched). NOW I VERY HIGHLY suggest installing SmartPack Kernel manager. It will give you insights into the kernel and how it's performing and it's free. It also will let you adjust added options now in the kernel. Just root your phone and flash from TWRP. If you haven't already installed Magisk, then install that too. There's a guide I posted on XDA about that. Use the experimental method there is no reason to unlock your bootloader.

1) Bugfix: there was 1 missing 800mhz GPU frequency regulator clock on the prior version. This has been set to TURBO, 1 level under the 900mhz regulator of TURBO_L1.
2) Boeffla WakeLock blocker (v1.10 + tweaks) has been added to reduce battery drain when the phone is not being used, using the latest version and all patches. A default block list is included. You can access in SmartPack Kernel Manager under the new menu that will appear "Wakelocks" - especially investigate if your phone has high idle drain, you can experiment with blocking other wakelocks (which don't allow your phone to sleep). Or you can leave as is. I get just under 1% drain (screen off) and the phone sleeps quite often with this version. Take a look at the screen shot! That's just normal phone usage, not gaming.
3) All debug entries (except those required) have been stripped completely out of the kernel. This results in less wasteful debug information being generated.
4) The default algorithm for ZRAM has been changed from LZO (high compression, but slow) to LZ4 (slightly less compression, but fast). LZ4 algo was added. It still defaults to 4GB.
5) Dynamic Fsync has been added to the kernel as well. This patch allows journal entries to be written only when the screen is off. I.e. they are cached and written afterwards. This increases database performance. It is disabled by default so in SmartPack Kernel manager, if you'd like to turn it on, go under Misc, select Dynamic Fysnc, and select apply on boot. There is always a risk of data loss when delaying writes, although I've personally never have had issues - it only happens if the phone crashes, and mine has never crashed on this kernel. This won't normally increase your benchmark scores (except AndroBench), it increases SQLite database access speed. Up to you to use or not, works fine on my device.
6) Here are the updated frequencies (note there is 1 more). Will have to wait for AOSP before I can add back more. Note the 670MHz is likely the 865+ max frequency per the release notes today on the device (which I assumed by the source code anyhow pre-announcement): 900MHz / 800MHz / 670MHz / 525MHz / 400MHz / 305MHz


Github Source:

Initial Release:

Second release - gets over the "reset to 490mhz" bug caused by the system software, at the expense of reducing frequencies to 6 total:

Newest release -> will be posted on the top from now on.


And note the AnTuTu benchmark is just a first run after installing. 670K is likely a record on any 865 phone. The last bench turning off 4GB ZRAM (12gb/256gb device) I got 673K. AnTuTu doesn't equal performance, but if you've benched you'll see this is an insane improvement over the stock kernel. Only when the demand is there will it scale up to 900mhz. I've been using for a while now and notice no difference in battery life. The Adreno driver is very good at handling extra clock frequencies efficiently without modification (despite an "Adreno Boost" that is often added to kernels). The gamers using the kernel are making statements that they couldn't imagine the game play any better than it already was, but now it's even smoother.

Unfortunately the way the Nubia software behaves, it auto-resets to power level 5 (which was 490mhz) on the 1.0BETA on boot and also after boosting the frequencies up. I tried every possible way to bypass this but eventually just gave in and removed frequencies. So the BETA1.10 and above have less frequencies but will always revert to 305mhz, the base minimum frequency of the device. Hopefully once we have AOSP ready I can add more.

I.e. M.O.D. Kernel Developer
The first Red Magic 5G OC kernel.
Xiaomi Mi9 / Mi9T Pro Pie V2 and Q V1.5 Kernel Dev
The Following 38 Users Say Thank You to mslezak For This Useful Post: [ View ] Gift mslezak Ad-Free
9th June 2020, 11:41 PM |#2  
MishaalRahman's Avatar
Editor in Chief
Thanks Meter: 2,125
Nice work. Do you notice any benefits to OCing the GPU like that? I don't think there are many games that would benefit atm.
10th June 2020, 04:56 AM |#3  
ps000000's Avatar
Senior Member
Flag Nonthaburi / Bangkok
Thanks Meter: 348
This is amazing !!!
10th June 2020, 01:46 PM |#4  
Junior Member
Thanks Meter: 1
Is this going to work on all roms like CN, NA or EU Roms? Im currently running NA 3.11 flash from CN rom with root and twrp
The Following User Says Thank You to shaifabra5 For This Useful Post: [ View ] Gift shaifabra5 Ad-Free
10th June 2020, 04:36 PM |#5  
OP Senior Member
Flag Houston
Thanks Meter: 242
Donate to Me
We have people using it on CN Global and NA versions no problem at all. Works fine on every model.
10th June 2020, 05:40 PM |#6  
Junior Member
Thanks Meter: 1
Kernel is fully functional no issues at all.
CN Rom to NA Rom v3.11

305mhz min to 900mhz max confirmed and using smart pack to control the frequency

Thank you for this hopefully there is more development i really appreciate ur effort
10th June 2020, 07:30 PM |#7  
OP Senior Member
Flag Houston
Thanks Meter: 242
Donate to Me
Kernel building is just a hobby of mine, I was posting a minimal kernel to get some more kernel developers on board to hopefully add more features. I usually add Boeffla Wakelock Blocker and Dynamic Fsync and call it a basic kernel. The last super kernel I made took way too long, and I don't have that kind of time anymore - boost functions and underclocking to balance out the battery life and such. Development work doesn't pay anything, I didn't get the phone free, all my donations go to other developers. And I have a full time job and family. But if anyone wants to port over my MOD Kernel Q 1.5 Mi9 features, well that would be a super kernel. It's just really, really time consuming, time I don't have at the moment. And the merging of source has to be EXACT or you end up with a really slow phone rather one that balances underclocking, boost, and overclocking.
11th June 2020, 12:45 AM |#8  
OP Senior Member
Flag Houston
Thanks Meter: 242
Donate to Me
Originally Posted by MishaalRahman

Nice work. Do you notice any benefits to OCing the GPU like that? I don't think there are many games that would benefit atm.

All the gamers using the kernel are reporting that the games run smoother than before, which no one thought was possible. It is already a flagship device. But the GPU OC with the Adreno driver scales when needed up to the frequencies that it has in the table and has no issue on 670, 800, and 900mhz reported so far. There are gamers on NA, Global, and CN ROMs, with no bugs reported. No issues and everything works properly. I have tested myself and although I'm not a gamer, all the functions work as they should. It still connects via Bluetooth, it still takes photos and videos, etc. There is no lag whatsoever. Overall I think the frequencies are ideal for this device with it's advanced active cooling system. Other devices however, with passive cooling, are unlikely to handle the increased GPU clocks.
The Following User Says Thank You to mslezak For This Useful Post: [ View ] Gift mslezak Ad-Free
11th June 2020, 04:30 AM |#9  
Junior Member
Thanks Meter: 1
I found an unusual bug where the GPU Minimum Frequency will reset on its own to 490mhz even if i set the minimum frequency to 305mhz im using smart pack kernel manager that you provided and cool tool btw to monitor the gpu frequency.

I also set the battery optimization to off on smart pack so it wont turn off itself.

This also happens when i played games that actually boost to 800 to 900mhz then after i close the game it sets back the minimum frequency to 490mhz so i have to set it again to 305mhz on the kernel manager to save more battery and lower the temps.

I also notice it sets back to 490mhz minimum frequency by just watching youtube videos so i have to set it back to 305mhz again. I tried different kernel manager too like Franco Kernel Manager and Kernel Audiator and still doesnt fix the issue

I think this was a minor bug for sure
I never touch the GPU governor btw

Performance was super nice thou i scored 645k on antutu on my first run but for now im going back to stock and gonna wait for your next update
11th June 2020, 01:44 PM |#10  
Junior Member
Thanks Meter: 0
What to do to root the phone without breaking the fingerprint please. I read the article publish nothing understood someone can explain to me step by step. I am an amateur I never root a phone. I have cn 2.55 16gb.
13th June 2020, 09:19 PM |#11  
OP Senior Member
Flag Houston
Thanks Meter: 242
Donate to Me
I don't have the same issue - I just tried to recreate it by watching a YouTube video and I went back to SmartPack and it still shows 305MHz GPU frequency. Although I'm using the debloated / optimized ROM I created Black Magic 5G which has everything setup properly, Nubia apps frozen, everything moved to 3rd party apps. NETFLIX patched to 4K HDR10, YouTube Vanced, a ton of root utilities, AdAway ad blocker, etc. You can find it on the Telegram channel (I'm using the NA/Global version of Black Magic 5G). Then I watched Netflix, still at 305mhz. As I have no idea how you've setup your phone, I just can't recreate it.

Originally Posted by shaifabra5

I found an unusual bug where the GPU Minimum Frequency will reset on its own to 490mhz even if i set the minimum frequency to 305mhz im using smart pack kernel manager that you provided and cool tool btw to monitor the gpu frequency.

I also set the battery optimization to off on smart pack so it wont turn off itself.

This also happens when i played games that actually boost to 800 to 900mhz then after i close the game it sets back the minimum frequency to 490mhz so i have to set it again to 305mhz on the kernel manager to save more battery and lower the temps.

I also notice it sets back to 490mhz minimum frequency by just watching youtube videos so i have to set it back to 305mhz again. I tried different kernel manager too like Franco Kernel Manager and Kernel Audiator and still doesnt fix the issue

I think this was a minor bug for sure
I never touch the GPU governor btw

Performance was super nice thou i scored 645k on antutu on my first run but for now im going back to stock and gonna wait for your next update

Post Reply Subscribe to Thread

android10, complete, kernel, overclock, source

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

Advanced Search
Display Modes