[Android] Albe96:
Part-II

How To Add Features To Kernel?

Ah.So Here I'm With Following Guides.What We're Gonna Learn Today?.Lets Go Ahed.

Here are some features you can add via cherry-picking.Check out those-> https://xdaforums.com/showpost.php?p=77089212&postcount=41

How To Upstream Android Kernel?

Well,I'm Not Gonna Spam Or Do Somethings Like This,Here's A Simple Guide By [MENTION=6842057]The Flash[/MENTION] To Upstream!

Here Is The Link-->> [url]https://xdaforums.com/android/software-hacking/reference-how-to-upstream-android-kernel-t3626913[/URL]

How To Add I/O Scheduler Or Governor To Kernel?

To Add Governor Or I/O Scheduler To Kernel,You Have To Learn Cherry-Picking! Well,I'm Not Gonna Make A Tutorial For That![Or Maybe I'll].For Now Follow What I Say In Next Steps.

A.

1. So Basically There's Many Governors/IO Schedulers Available In Internet To Add.Choose One Governor,Well I Choosed Nightmare Governor For Example.

I'm Showing How To Add A Governor In The Guide.

2. Now What You Have To Do Is To Go To Github,And Type "Add Nightmare Governor" In Search Bar Then Hit Enter.

3. You'll Get Some Many Results,Open One Of Them That Include Many Files About The Governor.Like This -->>

4. Now Where You'll Find The Commit ID To Cherry-Pick It To Your Kernel Source? See Below Pick To Get Idea Which One Is The Idea -->>

5.Yay,So You Got It! Now Open A Terminal And Go To Your Kernel Source Folder! For Me I Typed -->>

cd android/kernel

6. Now To Cherry-Pick You Have To Fetch The Kernel Source From Which You'll Cherry-Pick.To Do That Type Following In Terminal -- >>

git remote add <anyname> <link of the kernel source from which you're taking the governor commit>

For Me I Typed This -->>

git remote add lol [url]https://github.com/B14CKB1RD-Kernel/B14CKB1RD_Kernel_OnePlus3_Unified.git[/url]

Explaination:

1. <anyname> - What Ever You Want.

2. <link of the kernel source from which you're taking the governor commit> - Where You'll Find? Check Below Image.The Blue Selected Image In URL Bar Is the "<link of the kernel source from which you're taking the governor commit>"

7.Then Type This In Terminal -->>

git fetch <anyname>

For Me I Typed This -->>

git fetch lol

B.

1.In Terminal Type -->>

git cherry-pick <commit id>

For Me I Typed This Change <commit id> with the id you copied from github-->>
[code]git cherry-pick 042b5123de94e9875e717efb0ac1d344fdf2282e

2.Now You'll Get Some Conflicts,How To Solve Them? Use This Guide By [MENTION=4803464]jabza[/MENTION] .

Here Is The Guide -->> [url]https://xdaforums.com/showthread.php?t=2763236[/URL]

3.Solve The Conflicts And You're Done Adding Governor To Kernel!

How To Add Support Force Fast Charging?(Only For Snapdragon Devices)

1. In Kernel Source Go To "arch/arm/mach-msm" Folder.

2. Then Open The "Kconfig" File And The Following Code -->>

config FORCE_FAST_CHARGE
bool "Force AC charge mode at will"
default y
help
A simple sysfs interface to force adapters that
are detected as USB to charge as AC.

3. Save It,Then Open "Makefile" And Add The Following Code-->>

obj-$(CONFIG_FORCE_FAST_CHARGE) += fastchg.o

4. Save The Makefile,Now Create/Add The Fast Charge File In That Directory! Where Is That File? Here Is It -->> Here

5. Now Go To kernel source/drivers/usb/otg directory And Open "msm_otg.c" File, And Add The Following Code -->>

#ifdef CONFIG_FORCE_FAST_CHARGE
#include <linux/fastchg.h>
#define USB_FASTCHG_LOAD 1000 /* uA */
#endif

And This Code -->>

#ifdef CONFIG_FORCE_FAST_CHARGE
if (force_fast_charge == 1) {
mA = USB_FASTCHG_LOAD;
pr_info("USB fast charging is ON - 1000mA.\n");
} else {
pr_info("USB fast charging is OFF.\n");
}
#endif

6. Save msm_otg.c File.Now Go To "include/linux" Directory And Add "fastchg.h" File.Here's The Link For That File -->> Here

7. Well Done You've Added Force Fast Charging Support! :fingers-crossed:

How To Add Support Voltage Control For MSM Devices?

1. Go To arch/arm/mach-msm Folder,And Open "Kconfig" File,And Add Following Codes-->>

config CPU_VOLTAGE_TABLE
bool "Enable CPU Voltage Table via sysfs for adjustements"
default n
help
Krait User Votlage Control

2.Save Kconfig File.Now open "acpuclock-krait.c" File.Add This Code-->>

#ifdef CONFIG_CPU_VOLTAGE_TABLE

#define HFPLL_MIN_VDD	800000
#define HFPLL_MAX_VDD	1350000

ssize_t acpuclk_get_vdd_levels_str(char *buf) {

int i, len = 0;

if (buf) {
mutex_lock(&driver_lock);

for (i = 0; drv.acpu_freq_tbl[i].speed.khz; i++) {
/* updated to use uv required by 8x60 architecture - faux123 */
len += sprintf(buf + len, "%8lu: %8d\n", drv.acpu_freq_tbl[i].speed.khz,
drv.acpu_freq_tbl[i].vdd_core );
}

mutex_unlock(&driver_lock);
}
return len;
}

/* updated to use uv required by 8x60 architecture - faux123 */
void acpuclk_set_vdd(unsigned int khz, int vdd_uv) {

int i;
unsigned int new_vdd_uv;

mutex_lock(&driver_lock);

for (i = 0; drv.acpu_freq_tbl[i].speed.khz; i++) {
if (khz == 0)
new_vdd_uv = min(max((unsigned int)(drv.acpu_freq_tbl[i].vdd_core + vdd_uv),
(unsigned int)HFPLL_MIN_VDD), (unsigned int)HFPLL_MAX_VDD);
else if ( drv.acpu_freq_tbl[i].speed.khz == khz)
new_vdd_uv = min(max((unsigned int)vdd_uv,
(unsigned int)HFPLL_MIN_VDD), (unsigned int)HFPLL_MAX_VDD);
else
continue;

drv.acpu_freq_tbl[i].vdd_core = new_vdd_uv;
}
pr_warn("faux123: user voltage table modified!\n");
mutex_unlock(&driver_lock);
}
#endif	/* CONFIG_CPU_VOTALGE_TABLE */

3.Save The File.Done! You've Added It To Your Kernel. :)

How To Add Init.d Support To Kernel?

1. Copy Your boot.img To A Folder In Ubuntu And Open A Terminal With boot.img directory.

2. Now Type The Following In Terminal -->>

abootimg -x boot.img

3. You'll Get 3 Files From It(bootimg.cfg, initrd.img, zImage)

4. Now Create A New Work Folder And Decompress "initrd.img" Using The Following Commands -->>

mkdir work
cd work
zcat ../initrd.img | cpio -i

5. Now Open The Work Folder.Now Open The "init.rc" File And Add This Line At The End Of This File -->>

# Execute files in /etc/init.d during boot
service userinit /system/xbin/busybox run-parts /system/etc/init.d
oneshot
class late_start
user root
group root

6.Save "init.rc" File And You're Done!

Or Try This Guide By

[MENTION=4825267]alireza7991[/MENTION] -->> Here :laugh:

How To Make Kernel Boot In Permissive Mode(A Small Guide)

1. Go To "Kernel Source/security/selinux" Folder And Open "hooks.c".

2. Find This Line -->>

selinux_enforcing = enforcing ? 1 : 0;

3. Change It To -->>

selinux_enforcing = 0;// enforcing ? 1 : 0;

4. Now Save "hooks.c" File.Now Open "selinuxfs.c" File And Search For This Line -->>

if (new_value != selinux_enforcing) {

5. Add Below Code Above "

if (new_value != selinux_enforcing) {

" line -->>

new_value = 0;

6. Yo.You Finally Made The Kernel Boot In Permissive Mode,To Check If It Got Permissive Or Not -->> Go To Settings -> About Phone -> SE-Linux Status (You'll See Its "Permissive")