yashsingh1/xdaforums huggingface dataset:
[Fire Original Android Development] theophile2:
This is a collection of add-on modules for the stock November 2016 boot image kernel, as found in the latest versions of the CM 12.1 and Fire Nexus roms by [MENTION=5749760]ggow[/MENTION]. This started as a personal project to see if I could compile a working kernel module for the PegasusQ CPU governor.

There are now ROM-specific packages depending on whether you are using CM 12.1 or Fire Nexus. So before downloading, check which ROM version and build date you are using to make sure you grab the right package.

Package for ROMs Based on 5.3.2.0 Boot Image

If you are using any of the following CM 12.1 builds:

-2016-11-21

-2016-11-22

OR any of the following Fire Nexus builds:

-24 November 2016

-02 February 2017

Then you need the package for 5.3.2.0 boot image. <--(Link updated as of 6 Feb 2017)

Package for ROMs Based on 5.1.4 Boot Image

If you are using any of the following CM 12.1 builds:

-2016-06-14

-2016-07-10

-2016-08-10

-2016-09-22

-2016-10-21

OR any of the following Fire Nexus builds:

-15 June 2016

-28 July 2016

-12 August 2016

-08 February 2017 (or later)

OR any build of Lineage-12.1

Then you need the package for 5.1.4 boot image. <--(Link updated as of 12 Feb 2017)

Instructions:

Download the correct package for your ROM

Flash in TWRP or FlashFire. (Can be "dirty" flashed; no need to wipe anything)

Use Kernel Adiutor or your favorite kernel tuner to set your desired parameters.

Notes:

If something goes wrong, or if you flash the wrong package and end up with a bootloop, flash this REMOVER zip to disable the script that loads the modules. The REMOVER zip should work on any ROM. I recommend downloading it and copying it to your SD card at the same time you flash the main package so that it's already on the device in the event you need to use it.

The hotplug drivers may need some experimentation to get right. Alucard seems to work pretty well out of the box, but is pretty aggressive. It may cause a lot of lag on games. Thunderplug may have an issue. In my brief test, it seemed to peg one of the cores at 100% continually, but YMMV.

If you find a combination of settings that work well for any of these modules, please let me know so I can consider changing the default tunables.

(Side note: I'm not a developer by any stretch and just did this as a self-challenge. If there are any other specific modules such as governors, hotplug drivers, or schedulers you'd like me to try, let me know. No promises, but we'll see what happens!)

Credits:

ByungChang Cha (for the PegasusQ governor)

@osm0sis (for the AnyKernel2 installer)
[Fire Original Android Development] theophile2:
Change log

12 February 2017

-Built and started maintaining separate packages, one for Fire Nexus 2/8/17 build and newer, and the other for last CM 12.1 and Fire Nexus pre-2/8/17.

06 February 2017

-Added a bunch of TCP congestion control algorithms (Highspeed, Illinois, Vegas, Yeah, HTCP, LP, Veno, Hybla, Scalable, Westwood)

04 February 2017

-Added Smartmax CPU governor

-Added ThunderX CPU governor

-Added Alucard hotplug driver

-Added Thunderplug hotplug driver

-Added BFQ I/O scheduler

-Added TripNDroid I/O scheduler

-Added ZEN I/O scheduler

02 February 2017

Initial release
[Fire Original Android Development] tonibm19:
Awesome! How's performance and battery comparing to stock? :confused:

I wonder if you could make cpu or gpu OC. Or some gpu governor with better perf.
[Fire Original Android Development] theophile2:
I'm not sure. It's been a while since I used the Fire on a regular basis (my kids are the main users these days). But with PegasusQ, I noticed ~2% battery drain overnight (8 hours), and it seemed to me to be below average drain when in use with no noticeable performance penalty. Granted, I haven't tested it thoroughly, so I'm interested in comments from others.

Unfortunately, I don't think overclocking is going to be possible with the locked bootloader. CPU/GPU overclocking requires modifying the kernel drivers and recompiling the kernel, but we can't boot custom kernels with the bootloader locked. Alternative GPU governors might be possible. I don't have the Fire in front of me right now, but is there a GPU tab in Kernel Adiutor?
[Fire Original Android Development] nirogu325:
[MENTION=2748225]theophile2[/MENTION] - Works wonderfully on the Fire Nexus ROM and sticks even after reboot provided using a Kernel Manager. I now have renewed hype for this tablet, lol. This was hugely needed to enhance performance. I see you are planning on adding more governors down the line and I'm looking forward to it! Huge thanks for this advancement!
[Fire Original Android Development] Marsu42:
Is there any way to put this into an existing installation w/o re-flashing the rom, i.e. either simply copy it or use FlashFire with just this zip (which exact settings in FlashFire)?

Sorry for this noob question, but I don't want to go through a whole recovery procedure if I get it wrong...
[Fire Original Android Development] nirogu325:
1. Select Flash Zip in FlashFire.

2. Select the Zip and flash it.

3. Look for any kernel manager in the Play Store.

4. Change your CPU Governor and set it to boot so it sticks after a device restart.
[Fire Original Android Development] tonibm19:
No, there isn't.
[Fire Original Android Development] Marsu42:
There's one in EX Kernel Manager though, but it says "not supported" :-\

Thanks, after some trial & error I'm now using "No Frills CPU Control" to set it on boot.
[Fire Original Android Development] theophile2:
Added a bunch more modules and updated the OP with new link. Let me know how it works for you!
[Fire Original Android Development] nirogu325:
I suggest adding an update date in the thread's title as a heads up to users.
[Fire Original Android Development] Marsu42:
I have admit when first reading about these replacement modules, it sounded rather nerdy to me, but I'm amazed how much more responsive the device is with pegasusq and bfq.

http://www.alliance-rom.com/wiki/governors-explained/

http://algo.ing.unimo.it/people/paolo/disk_sched/

Let's hope someone takes a week off, tries all possible combinations of these modules and reports back on stability and performance :->
[Fire Original Android Development] nirogu325:
Here's another reference link for those interested. This one's very detailed when it comes to schedulers advantages, disadvantages and many other things such as read-ahead: LINK
[Fire Original Android Development] Marsu42:
Based on that, could we have the ROW scheduler, pretty please with sugar on it :-> ? " It is a good all-round scheduler despite being biased to read operations. Your device may feel more responsive after selecting ROW because it was designed for mobile devices. Older devices may see more of a boost in performance compared to newer devices."

Btw; ZEN hangs my "No Frills CPU Control" app when trying to set it, while the others work fine.
[Fire Original Android Development] nirogu325:
ZEN is also force closing EX Kernel Manager here. Something's funny going on with ZEN.
[Fire Original Android Development] theophile2:
I looked at ROW, but most implementation I've seen require patching the kernel, which we can't do (locked bootloader). I'll keep my eyes out to see if there's an implementation that doesn't require this.

Zen works for me with Kernel Adiutor.

In other news, I just upped a new version that adds a new thing to get nerdy about: TCP congestion control algorithms. I've built modules for all the ones in the stock kernel that Amazon stripped out (Highspeed, Illinois, Vegas, Yeah, HTCP, LP, Veno, Hybla, Scalable, and Westwood).

In a nutshell, if you want max download/upload speed with no noticeable latency penalty, switch to Westwood.

BTW, Google submitted a kernel patch a couple of months ago to add a new algorithm they developed. I plan to check that out and see if it will compile against this relatively old kernel (3.10).
[Fire Original Android Development] BeeWall:
BTW, the new version of Fire Nexus uses boot.img from Fire Is 5.1.4, so I don't think this is compatible anymore. Is it?

EDIT: No, it is not. Bootloops.
[Fire Original Android Development] jrk190:
Yeah I just tested it earlier and had no idea what was wrong :/ that explains it.
[Fire Original Android Development] theophile2:
That's odd. Nothing in the zip should be capable of causing a bootloop, even on an incompatible kernel. At worst, it should just "not work."
[Fire Original Android Development] theophile2:
I'm grabbing the 5.1.4 source tree to compile against. Might be the weekend before I'm able to post an updated package because I'll have to migrate my Fire over to the Nexus rom for testing purposes. In the meantime, could someone post what the kernel string is on the latest Fire Nexus rom?
[Fire Original Android Development] BeeWall:
Kernel version from settings:

3.10.54+
build@ip-10-11-3-120 #1
Fri May 6 03:55:18 UTC 2016

Is that what you meant, or is "kernel string" something else?
[Fire Original Android Development] Marsu42:
In that case, the zip package should indicate what kernel is required ...

... it would be nice to still have releases for the latest CM build which uses a newer kernel before ggow switched back to 5.14 for aosp.
[Fire Original Android Development] theophile2:
[MENTION=7559542]PorygonZRocks[/MENTION], could there be a different reason for your bootloop? As I said, this zip shouldn't be capable of causing a bootloop. Plus, the 5.1.4 kernel appears to be the same kernel as in 5.3.2 anyway, so the modules should be working.
[Fire Original Android Development] BeeWall:
I flashed only this and Fire Nexus. Fire Nexus first, obviously. It was bootlooping really early, at the Amazon logo, so I'm not sure what else would be running. Maybe it's not boot.img, and is another binary started by boot. All I know is the bootlooping started before the boot animation. So whatever it is starts very early.
[Fire Original Android Development] jrk190:
I can confirm this as well
[Fire Original Android Development] theophile2:
What happens if you flash Fire Nexus only, let it reboot and load the ROM cleanly, and then flash the modules?
[Fire Original Android Development] BeeWall:
Is there an easy uninstall zip if it fails?

Or would deleting the file "90modules" from init.d be enough?
[Fire Original Android Development] jrk190:
I think you can just reflash your ROM zips I think.
[Fire Original Android Development] BeeWall:
I have a bunch of apps I manually moved to system. It would be difficult to remember which, and I'd rather not until Fire Nexus is updated. Thanks though.
[Fire Original Android Development] BeeWall:
It still bootloops. Booting TWRP and deleting /system/lib/modules fixes it, so it is definitely caused by this zip.

EDIT: Yeah... Deleting /system/lib/modules is a bad idea. Looking at the contents in normal Fire Nexus, it seems important. Deleting the init.d script probably works better.
[Fire Original Android Development] theophile2:
Okay, so it bootloops at the Amazon logo, but if you delete the init.d script, it boots fine again?
[Fire Original Android Development] BeeWall:
I haven't tried deleting the script. I forgot init.d is in /system/etc not /system , so I couldn't find it. Instead I deleted /system/lib/modules, which worked. This means it is indeed this zip. Maybe some modules don't work with the old kernel.

I might test again tomorrow, now that I remember where init.d actually is ?, but I'd rather not deal with dangerous stuff while tired. I'm worried about screwing up and bricking things. Maybe I'll go through and test the modules one by one to see which work and which don't.

Also, according to ggow, the kernels don't support init.d. How does this work, then?
[Fire Original Android Development] theophile2:
I'll work on it this weekend.
[Fire Original Android Development] theophile2:
I have recompiled all the modules against the 5.1.4 kernel source, so it should in theory now be working with the latest Fire Nexus, although I haven't tested them yet. So I need a brave soul to give it a shot. BETA download link here. Please let me know if this fixes the bootloop on Fire Nexus. Thanks!
[Fire Original Android Development] BeeWall:
Tganks for the update. It's not bootlooping, but none of the options are showing up in Kernel Adiutor. I checked, all the modules are in place, and so is the script.
[Fire Original Android Development] theophile2:
If you adb shell into the tablet (or use terminal emulator) what is the output of 'lsmod'?
[Fire Original Android Development] BeeWall:
ufsd 216010 - - Live 0x00000000 (PO)
selinux_permissive 711 - - Live 0x00000000 (O)

Also, interactive governor, included without flashing this, just reboots the device whenever I set it. Any idea why?
[Fire Original Android Development] DB126:
Not just interactive; several other governors included with the stock kernel behave the same way.
[Fire Original Android Development] BeeWall:
For me, it's only interactive. Weird. Do you have any idea why the device reboots?
[Fire Original Android Development] theophile2:
OK, the modules aren't being loaded. Is there an init.d tab in Kernel Adiutor? If so, is the 90modules script shown there?
[Fire Original Android Development] DB126:
Nope - could be an incompatibility with the hotplug solution. After some fiddling I decided the stock governor was adequate and moved on (didn't even bother w/tuning). Tough to get fired up over CPU performance on this pup given other device constraints. Also not the most energy efficient gizmo, although again - perfectly adequate for my needs.
[Fire Original Android Development] BeeWall:
Yes and yes.
[Fire Original Android Development] theophile2:
Okay, from terminal/shell again, what's the output of:

su; insmod /system/lib/modules/cpufreq_pegasusq.ko

?
[Fire Original Android Development] BeeWall:
insmod: init_module '/system/lib/modules/cpufreq_pegasusq.ko' failed (Exec format error)
[Fire Original Android Development] eric93se:
On CM12.1 I toggled SeLinux in Kernel Aiuditor to enforcing, it force rebooted and now it boots and then is not stable and within a few seconds does a full boot again. Can someone give me an outline of what I need to do to get it booting right again.

I was able to choose pegasusq, bfq, westwood, alukard. I re-selected the item in the cpu menu and then I saw the extra options.
[Fire Original Android Development] DB126:
Best course IMO is to restore (adb sideload) the version of FireOS that was last on the device (no lower). That will refresh the stock kernel and restore stability. Of course you'll need to root, reinstall SuperSU, FlashFire, etc unless you're one of the lucky few that can boot TWRP.
[Fire Original Android Development] eric93se:
I was able to get into factory recovery and do a factory reset and then wipe cache. Rebooted into a fresh install of CM12.1 :) (everything wiped).
[Fire Original Android Development] DB126:
Creative (and quite logical) approach since the stock kernel can not be directly modified. Sounds like the system partition was ok so rolling back to to FireOS was unnecessary. Sorry for the bum guidance; got my wires crossed juggling devices :( .
[Fire Original Android Development] eric93se:
No worries, appreciated the help. Back up and running, kernel addons were intact, everything is running well, thank you theophile2 !
[Fire Original Android Development] theophile2:
The package has been fixed for Fire Nexus. The problem was that some of the modules require symbols that are not exported by the stock kernel. Normally it's easy enough to simply export the necessary symbols and recompile the kernel, but since we don't have that option, it was necessary to build into the modules the ability to do on-the-fly kernel memory patching of the running kernel, by hardcoding the memory address for sys_call_table. But that address in the 5.1.4 image kernel is not the same as in the 5.3.2.0 image, so when those modules loaded, they caused a kernel panic, hence the bootloop.

So it's fixed now, and I'll be updating the OP momentarily. The downside is that it will definitely be necessary to maintain two separate packages, one for CM 12.1 and one for Fire Nexus. But I'm now maintaining this via GitHub, which I should have done in the first place, so hopefully that will make it easier going forward.
[Fire Original Android Development] Mr McBoatface:
Just an FYI . It may not be a good idea to have your release's labeled for use with CM12 and a separate one for Nexus. Many CM12 user may still be using 2016-05-30 release because it has working camera and working miracast which is broken in later releases . Like the present nexus ROM it uses the 5.1.4 binary so it would be compatible with your "Nexus release" but not your "CM release"

It might be better to either draw a line and support only the Nexus ROM which is now the only active ROM, or base you release on image binary and instruct the user to verify what binary their ROM works on.

IMHO the end user should really be able to find out what binary their chosen ROM has by themselves with little difficulty and choose as required.
[Fire Original Android Development] theophile2:
Right. I forgot that the "new" build is actually using an old boot image. I'll try to rewrite the OP later this evening to make it a little clearer.
[Fire Original Android Development] Ultraschorsch:
Hi,

I installed this on my device on top of the latest Fire Nexus build through Flashfire and got a bootloop. I installed the package for 5.3.2.0 boot image, as recommended in the OP. Is there a way to get my device back to a working state without installing it from scratch?

Thanks,

Jan
[Fire Original Android Development] Mr McBoatface:
The latest Nexus rom requires the 5.1.4 Boot Image files. Unless you're using a twrp compatible device it's back to scratch
[Fire Original Android Development] Ultraschorsch:
Ok, reading sometimes really helps preventing from extra work... Thanks for your help!
[Fire Original Android Development] Mr McBoatface:
? Believe me I've done similar, happens to the best of us.
[Fire Original Android Development] jrk190:
Yeah it was worded kinda weird to me. Made no sense that the latest ROM used an older(?) Kernel version.
[Fire Original Android Development] BeeWall:
The older, 5.1.4 binaries are the latest that work with Miracast. Originally, ggow was updating the image and binaries, but he realized that the new binaries didn't offer too much of a security benefit, so he reverted to the latest binaries that worked with Miracast.
[Fire Original Android Development] Mr McBoatface:
Also newer broke the camera recording function. Newer is not always better, 5.14 seems stable and offers a good Base. More than likely the newer version only updated issues to prevent rooting and stop OS roll backs.

Im sure staying with the 5.14 binary cuts out lots of re-coding for goww. Updating security fixes and what ever small bugs would consume enough time as it is. This is not the only rom he supports and we are very lucky to such an excellent rom with all hardware features working.

Ad to it the tweaks available from tools in this thread, xposed and others we are really lucky. Other devices are lucky to have an alternate rom with just one or two issues like no Bluetooth , we've an alternative rom with 100% hardware utilisation and more features than the original.
[Fire Original Android Development] jrk190:
Not op's fault you didn't read the instructions carefully.
[Fire Original Android Development] Mr McBoatface:
Really ? You're blaming the OP for you not reading the instructions and you upgrading to the unrootable 5.3.2.1 rather than the last rootable OS 5.3.1 ?

Very nice of you.
[Fire Original Android Development] DB126:
Sorry for your experience. Disclaimers are clear. No requirement to sideload 5.3.2.1. Errors on your part contributed to the outcome.
[Fire Original Android Development] basicreece:
Read perfectly thank you. And seems this wasn't a lack of me not reading or following instructions but the OP messing this up.

I went for 5.3.1 and was stuck in another boot loop. 4 attempts later I had to opt for 5.3.2.1.

Very nice of you.

Disclaimer are very clear. This was at my own risk. Just letting others no it doesn't work due to poor workmanship. They need to avoid this until its tested and works correctly.
[Fire Original Android Development] Mr McBoatface:
You see thats a constructive comment, had you of posted that here you probably would have been advised to upgrade to 5.3.2 and then see if a downgrade to 5.3.1 resulted in a boot loop.

Would be interesting to see if anyone else returning to stock after a bootloop has the same problem. This shouldn't affect TWRP users.
[Fire Original Android Development] basicreece:
I also tried 5.3.2. This failed. My options were a lovely amazon boot logo or upgrade to this terrible fireOS. Either way it's a paperweight until I can put a custom rom on it.
[Fire Original Android Development] Mr McBoatface:
So what custom rom and build date where you trying to flash the cpu governors over ? What governor package did you use ?
[Fire Original Android Development] DB126:
In the future suggest posting situation before taking irreversible actions. Many talented contributors willing to help and often able to find a clear path through choppy waters.
[Fire Original Android Development] basicreece:
I followed the guide to a T.

I'm also very aware of how these things work. This has nothing to do with what I done but more the OP linking us all to a dodgy incomplete file.

Luckily I've got 5.3.2.1 rooted after numerous attempts so I will dig about more and see what I can do.

And a plus my 'spare' kindle fire is still working fine with custom rom. I just won't be touching the files here.
[Fire Original Android Development] ms372591:
Did you use Kingroot to root 5.3.2.1?
[Fire Original Android Development] basicreece:
Yeah
[Fire Original Android Development] DB126:
Okey-dokee. Seems like your experience is unique on several levels. Good luck moving forward. Make use of community resources as needed.
[Fire Original Android Development] basicreece:
Thank you for recognising my unique skill-set.
[Fire Original Android Development] Mr McBoatface:
[MENTION=4904639]basicreece[/MENTION] I understand you might feel a bit fed up having to restore fire OS especially if you have as you claim followed all instruction to a T. However there is a possibility the situation you faced was caused by something as simple as a corrupt download or a file system error on the tablet. Others have hit bootloops and recovered . In fact having just re-read the thread one user recovered the fire tablet simply by entering recovery at boot wiping cache and doing a factory reset - https://xdaforums.com/showpost.php?p=70999985&postcount=48.

It would also be very helpful for others if you could expand on which version of kingroot you used to root 5.3.2.1

Might be a good idea for the OP to include hash value of the files so users can check for corrupt downloads.

[MENTION=627356]Ultraschorsch[/MENTION] seems I missed the post on the previous page to yours. If you've not had time to ADB recovery your tablet from the boot loop you could try entering recovery at boot wiping cache and doing a factory reset as per - https://xdaforums.com/showpost.php?p=70999985&postcount=48.
[Fire Original Android Development] basicreece:
I also wiped cache and factory restored after seeing that comment. Still in boot loop.
[Fire Original Android Development] theophile2:
There's a remover script in the OP. If you screwed up and flashed the wrong file or flashed it over an incompatible ROM, just flash the remover zip and you'll be fine.

Next releases will have a check in the installer so it won't install unless it's the right package. Until then, if you want to test to make sure it's the right one, download the zip, unzip it, take the alucard_hotplug.ko module from the modules folder, copy it to your device, then from terminal or adb shell, do 'su; insmod alucard_hotplug.ko'

If you don't get errors, it's the right package. If you get an instant reboot, it's not the right package.
[Fire Original Android Development] Mr McBoatface:
That is brilliant, fair play to you. Thanks for your eforts on this it's very much appreciated.