[Nothing Phone 2] arter97:
arter97 kernel for Nothing Phone 2​

/* Features */

Rebased to latest Qualcomm BSP kernel

Android 13 kernel merged

Latest Google's security fix merged

BBR as the default TCP network congestion control

Modules support disabled for lighter kernel

Various debugging removed for lighter kernel

Power optimizations

Latest Wi-Fi drivers from Qualcomm

Built with Clang 17 and ThinLTO

Memory management optimizations

Latest f2fs backported from mainline

Optimized zram (memory compression)

SSG I/O scheduler ported from Samsung

Optional builds for incorporating KernelSU

/* Details */

- Fully rebased kernel -

This kernel is based on the latest Qualcomm BSP kernel with the latest Android 13 kernel from Google merged.

The stock kernel is based on Qualcomm's Jan 2023 BSP, while this kernel is based on Aug 2023 (at the time of writing). There are approximately 130K lines of code difference.

Due to GRF, Qualcomm's BSP kernel for the Snapdragon 8 Gen 1 is based on the Android 12 kernel from Google. This kernel has the latest Android 13 kernel merged. Approximately 40K lines of code differ.

- Power optimizations -

This kernel makes some conscious decisions for reducing power consumption.

First, this kernel disables wakelocks upon Wi-Fi's RX unicast packet transmissions. qcom_rx_wakelock is one of the major culprits to increased idle power consumption. Although its total wakelock time is quite low, it's catched very frequently and prevents the system from entering suspend repeatedly.

As dropping unicast or local ARP packets doesn't pose practical issues on Android, this kernel disables qcom_rx_wakelock.

Second, this kernel reduces the duration of the Bluetooth ISR wakelock from 2 seconds to 100ms. This was done from an observation that the average userspace response time from ISR is less than 10ms.

My kernels have been doing this for years and no Bluetooth-related issues were reported.

There are other small improvements throughout the kernel tree as well.

- Memory management optimizations -

This kernel enables MGLRU with relevant improvements from upstream backported.

MGLRU is a big deal in everything Linux related, especially for Android.

Esper have a great article on what is MGLRU in a nutshell: https://blog.esper.io/android-dessert-bites-22-linux-memory-management-38419756/

TL;DR:

This kernel also tunes how memory compression (swap/zram) works.

Swapping to storage (zram writeback) is disabled on this kernel. For a device with light OS and 12 GB of RAM, this is unnecessary and causes slowdowns.

The compression algorithm for zram is changed from lzo-rle to lz4 for faster operations.

The zram driver is backported from the latest Linux mainline.

- I/O -

This kernel also backports f2fs (Flash-Friendly File System) from mainline Linux. This includes bug fixes and performance improvements.

The BFQ I/O scheduler is removed to improve power efficiency. Its heaviness is measurably consuming more CPU cycles. As a replacement, the SSG scheduler from Samsung is ported and enabled.

- Battery charging current/percentage limiting -

This kernel allows you to use limit charging current and battery percentage to prolong battery health.

To use this feature, the "Battery Charge Limit" app can be used:

Battery Charge Limit [ROOT] - Apps on Google Play

Stop charging at desired level to preserve battery health for most devices!

play.google.com

1. Go to the app's settings

2. Enable "Configurable CTRL File Data"

3. Enter "Configure Control Data"

4. Write the following in each order:

/sys/class/qcom-battery/scenario_fcc
-1
0

5. Disable "Enforce Charge Limit"

Details:

The "scenario_fcc" node works with the ADSP firmware, specific to Nothing Phone 2. It limits the charging current (not the input current).

The unit is in mA.

It works with the system's limit, so even if you set a high value (e.g., 5000 mA), NothingOS can limit it to a lower value. Conversely, if you set a lower value than the system, your limit is used instead.

If you write "0", it effectively disables charging and work in power-passthrough mode.

To reset the value, write "-1".

From the above's "Configure Control Data", if you write "1000" instead of "-1", it will limit the charging current to 5W.

Do note that the voltage is assumed to be 5V. So if you write 3000 to scenario_fcc, it will charge at max of 15W no matter the charger's voltage. If the charger's voltage is 5V, it will pull up-to 3A. If the charger's voltage is 9V, it will pull up-to 1.67A.

Also note that Nothing Phone 2's on-device charge current monitoring is quite inaccurate. Do not rely on an app's readings to determine how much wattage is flowing to the device or the battery.

- Vibration strength customization -

Kernels starting from r17 provides the ability to customize vibration strength.

Writing to /sys/class/leds/aw_vibrator/custom_gain will make the vibration weaker or stronger.

If a value lower than 127 is written, vibration strength is effectively

reduced. If a value higher than 127 is written, it's strengthened.

The maximum is 255 (uint8_t).

The default is 0, which disables custom gain.

Note that akin to any other kernel sysfs tunables, it will be reset when the device reboots. Use a separate app or script to make it persistent across reboots.

/* Disclaimer */

Always perform backup. Always.

Before first installation, before installing each update.

The Linux kernel is a gigantic piece of software responsible for controlling various hardware. Data corruption and hardware damage are all theoretically possible.

Your warranty is now void.

I am not responsible for bricked devices, dead storage, thermonuclear war, or you getting fired because the alarm app failed. Please do some research if you have any concerns about features included in this kernel before flashing it! YOU are choosing to make these modifications, and if you point the finger at me for messing up your device, I will laugh at you. Hard. A lot.

/* Thanks to */

kerneltoast (SultanXDA)

/* Builds */

Optional build with KernelSU is also provided. For more information, visit here.

The main build doesn't have any root solution included and is compatible with Magisk.

The builds are distributed as a plain boot.img file. You can install from a PC with fastboot or with root by directly overwriting the boot partition with the file.

Please backup the stock boot partition prior to installation.

r1: Only Android 13 is supported.

r2+: Only Android 14 is supported.

/* Instructions */

1. Read the above. Please.

2. Repeat step 1.

/* Downloads and links */

arter97.com

Kernel source

Telegram chat link