补档

由于 AKR 社区及其下载站已挂,于是在此处补档一个 Horizon Kernel 。
先前发布的版本是 B1 到 R17 ,由于旧的代码基本上都被 force push 掉了,因此只能补档一个之前不存在的 R18 版本。

R18 版本在 R17 的基础上进行了一些上游更新和稳定性改进,不过都是很早以前的修改了,具体细节已经记不清了。
另外还修复了 R17 上,设备温度高时可能导致部分处理器无负载的问题,这个是刚改的所以记得非常清楚。
还有,如果你还记得我当年说 R18 版本里会有什么,那确实是有的,我没忘,你找找。

下载:

用法:
先 root ,再用“内核刷入器”刷内核,有需要的话可以用“内核控制器”调节。

编译方法

首先,创建工作空间,获取内核本体代码:

$ mkdir workspace
$ cd workspace
$ git clone https://github.com/libxzr/android_kernel_oneplus_sm8250 -b oos11/final

然后,获取内核压缩包的代码:

$ git clone https://github.com/libxzr/AnyKernel3 -b op8/11

然后,获取编译工具链,此处推荐 Horizon Clang ,R18 版本是基于其 16.x 版本编译测试的。
工具链在解压后放在 workspace 的 clang 目录处,不可有额外的目录嵌套,即需要确保 workspace/clang/bin/clang 是编译器的可执行文件。

然后,获取内核本体中的 submodules:

$ cd android_kernel_oneplus_sm8250
$ git submodule init
$ git submodule update

参考的编译脚本:

horizon_build.sh

#!/bin/bash
set -e

DIR="$( cd "$( dirname "$0"  )" &&cd ..&& pwd  )"
source="$( cd "$( dirname "$0"  )" && pwd  )"

CLANG_PATH="${DIR}/clang"

args="-j$(nproc --all) \
O=out \
ARCH=arm64 \
CLANG_TRIPLE=aarch64-linux-gnu- \
CROSS_COMPILE=${CLANG_PATH}/bin/aarch64-linux-gnu- \
CC=${CLANG_PATH}/bin/clang \
CROSS_COMPILE_COMPAT=${CLANG_PATH}/bin/arm-linux-gnueabi- \
AR=${CLANG_PATH}/bin/llvm-ar \
NM=${CLANG_PATH}/bin/llvm-nm \
LLVM_AR=${CLANG_PATH}/bin/llvm-ar \
LLVM_NM=${CLANG_PATH}/bin/llvm-nm \
OBJCOPY=${CLANG_PATH}/bin/llvm-objcopy \
OBJDUMP=${CLANG_PATH}/bin/llvm-objdump \
STRIP=${CLANG_PATH}/bin/llvm-strip \
LD=${CLANG_PATH}/bin/ld.lld "

device="all"
clean="false"
action="build"
version="`date +"%m%d%H%M"`"
release="false"

print (){
case ${2} in
    "red")
    echo -e "\033[31m $1 \033[0m";;

    "blue")
    echo -e "\033[34m $1 \033[0m";;

    "yellow")
    echo -e "\033[33m $1 \033[0m";;

    "purple")
    echo -e "\033[35m $1 \033[0m";;

    "sky")
    echo -e "\033[36m $1 \033[0m";;

    "green")
    echo -e "\033[32m $1 \033[0m";;

    *)
    echo $1
    ;;
    esac
}

input=${*}

for i in ${input}
    do
        case ${i} in
            "op8")
            device="op8";;

            "op8p")
            device="op8p";;

            "op8t")
            device="op8t";;

            "all")
            device="all";;

            "--clean"|"-c"|"clean")
            clean="true";;
        *)
        did="false"

        if [[ $i =~ "-r=" ]];then
        release="true"&&version="${i#*r=}"&&did="true"
        fi

        if [[ $i =~ "-v=" ]];then
        version="${i#*v=}"&&did="true"
        fi
        
        if [ $did == "false" ]
        then
        print "Error input" red&&exit
        fi

        ;;
        esac
    done
    
mkzip (){
    if [ "${release}" == "true" ];then
    zipname="(${1})Horizon-Kernel-R${version}.zip"
    else
    zipname="(${1})Horizon-Kernel-${version}.zip"
    fi
    cp -f out/arch/arm64/boot/Image.gz ${DIR}/AnyKernel3
    #find ${source}/out/arch/arm64/boot/dts/vendor/qcom -name '*.dtb' -exec cat {} + > ${DIR}/AnyKernel3/dtb
    cp ${source}/out/arch/arm64/boot/dts/vendor/qcom/kona-v2.1.dtb ${DIR}/AnyKernel3/dtb
    #cp ${source}/out/arch/arm64/boot/dts/vendor/qcom/instantnoodle-t0.dtb ${DIR}/AnyKernel3/dtb
    cp ${source}/out/arch/arm64/boot/dtbo.img ${DIR}/AnyKernel3
    cd ${DIR}/AnyKernel3
    zip -r "${zipname}" *
    cp -f "${zipname}" ${DIR}
    rm -f "${zipname}"
    cd ${source}
    print "All done.Find it at ${DIR}/$zipname" green
}
    
build_op8(){
    print "Building Kernel for op8..." blue
    make $args instantnoodle_defconfig&&make $args
    mkzip "op8${1}"
}

build_op8p(){
    print "Building Kernel for op8p..." blue
    make $args instantnoodlep_defconfig&&make $args
    mkzip "op8p${1}"
}

build_op8t(){
    print "Building Kernel for op8t..." blue
    make $args kebab_defconfig&&make $args
    mkzip "op8t${1}"
}

bclean(){
    rm -rf ${source}/out/arch/arm64/boot
}

clean(){
    if [ "${clean}" == "true" ]
    then
        print "Doing cleanups" red
        make ${args} mrproper
    else
        bclean
    fi
}

if [ "${action}" == "build" ]
then
    if [ $release == "true" ]
    then
        print "You are building a release version:R${version}" green
        args+="LOCALVERSION=-R${version} "
    else
        print "You are building a snapshot version:${version}" yellow
        args+="LOCALVERSION=-${version} "
    fi
    
    if [ ${device} == "all" ]
    then
        git reset --hard
        
        clean
        build_op8t "-OOS"
        
        bclean
        git apply lineage.diff
        build_op8t "-Lineage"
        git reset --hard
        
        bclean
        build_op8p "-OOS"
        
        bclean
        git apply lineage.diff
        build_op8p "-Lineage"
        git reset --hard
        
        bclean
        git apply lineage.diff
        build_op8 "-Lineage"
        git reset --hard
        
        bclean
        build_op8 "-OOS"
        
    elif [ ${device} == "op8" ]
    then
        clean
        build_op8
    elif [ ${device} == "op8p" ]
    then
        clean
        build_op8p
    elif [ ${device} == "op8t" ]
    then
        clean
        build_op8t
    fi
fi

脚本要求的目录结构如下:

workspace
├── AnyKernel3
├── android_kernel_oneplus_sm8250
│   ├── horizon_build.sh
├── clang
│   ├── bin
│   │   ├── clang

workspace 的目录名称是无所谓的,只需要确保 AnyKernel3clang 在内核源码文件夹的同级目录下即可,编译脚本则放在内核源码文件夹中。

然后在内核源码文件夹中执行命令即可:

# 编译所有机型/系统的版本
./horizon_build.sh
# 编译所有机型/系统的版本(干净编译)
./horizon_build.sh -c

# 编译一加 8 的版本(仅氢氧)
./horizon_build.sh op8
# 编译一加 8 的版本(仅氢氧)(干净编译)
./horizon_build.sh op8 -c

# 编译一加 8P 的版本(仅氢氧)
./horizon_build.sh op8p
# 编译一加 8P 的版本(仅氢氧)(干净编译)
./horizon_build.sh op8p -c

# 编译一加 8T 的版本(仅氢氧)
./horizon_build.sh op8t
# 编译一加 8T 的版本(仅氢氧)(干净编译)
./horizon_build.sh op8t -c

原帖

实际上并不是原帖,真正的原帖已经挂了找不到了,这是把 XDA 上的帖子部分重新翻译了回来。

这是一个聚焦于日常体验与功耗平衡的内核

特性:

  • 基于 CAF "LA.UM.9.12.r1-12500-SMxx50.0" 版本重构 (实际上应该还要新一点,具体版本无从考证)
  • 采用 Clang 14 + polly + O3 + A55 优化 进行编译
  • 内联编译了所有内核模块
  • 采用 lz4 作为 ZRAM 算法
  • 移除大量调试代码与未使用驱动
  • 支持使用 BBR 作为 TCP 拥塞控制算法(需要手动调整),默认采用 Westwood+ 算法
  • 采用 fq_codel 作为默认流控算法
  • 采用 128kB 的 IO 预读
  • 采用 urandom 作为默认的熵生成器
  • 采用 schedhorizon 作为默认的 CPU 调速器
  • GPU 默认超频到 670 MHz
  • Wireguard 支持
  • CIFS 支持
  • KCAL & Klapse 支持
  • ......

上古更新日志:

R17
- Merge CAF LA.UM.9.12.r1-12500-SMxx50.0
- Update dts to LA.UM.9.12.r1-12000-SMxx50.0
- Update ion drivers
- Update simple lmk drivers
- touchscreen: Adapt PM QoS usage to incoherent OnePlus code
- Slightly optimize performance on scrolling

R16.3
- Rebase on CAF msm-4.19 and remove all upstream linux stable changes ( Rollback to 4.19.157 )
( This could solve at least deep sleep issue and avoid a lot of potential issue )
- Inline the spin lock function family to improve performance
- Correct capacity value of big cluster in energy model

R16.2
- Merge Linux 4.19.198
- Revert back to old scheduling policy

R16.1
- Merge CAF "LA.UM.9.12.r1-12200-SMxx50.QSSI12.0"
- Further optimize on scheduling
- May fix a wlan connection problem introduced in last build

R16
- Linux 4.19.197
- Merge CAF "LA.UM.9.12.r1-12000-SMxx50.0"
- Rework scheduling policy
- Optimize touchscreen latency and interrupt CPU usage

R15.1
- Linux 4.19.196
- Fix kernel panic when screen casting with "windows connect"
- Fix UI lagging and inaccurate network speed when a proxy is running in the background
( This dropped BBR and set Westwood as default congestion algorithm )
- Move back to Simple LMK as lowmemory killer

Controller Update
- Add a switch for BBR congestion algorithm for those who need it

R15
- Merge CAF "LA.UM.9.12.r1-11800-SMxx50.QSSI12.0"
- Fix random lags on R14.3
- Relax performance restrictions for schedhorizon
- Move to 10ms for WALT window size for faster response
- Cleanup and optimize fuel gauger driver

R14.3
- Linux 4.19.195
- Fix google photos video lag on custom ROMs

R14.2
- Linux 4.19.193
- Move back to userspace lmkd to improve multitasking experience
- Synchronize oneplus changes from oss

R14.1
- Fix kernel panic when using terminal

R14
- Merge CAF "LA.UM.9.12.r1-11500-SMxx50.0"
- Merge Linux 4.19.192
- Optimize camera launching speed

R13.3
- Fix kernel panic when subsystems crash

R13.2
- Merge Linux 4.19.191
- Fix modem unable to reset after a crash
- Cleanup some more oneplus codes
- Custom build: Synchronize changes with LineageOS kernel and apply new FOD patches
Note: If you are facing disappeared fod, just wait for your maintainer to update fod on the ROM side.

R13.1
- Merge Linux 4.19.190
- Fix zram compression algorithm not setting to lz4 on kebab
- Perform PID map reads on the little CPU cluster

R13
- Merge CAF "LA.UM.9.12.r1-11300-SMxx50.0"
- Implement fuse short circuit to improve i/o performance under /sdcard
- Ignore modem crash event

R12.4
- Merge Linux 4.19.186 187 188 189
- Fix unable to apply system update on kebab
- 20X optimize PID map reads
- Increase vmstat interval to reduce overhead
- Fix kernel warning when triggering tri-state-key
- Apply some backports to vmalloc & jump label
- Enable jump label for branch optimization
- Enable automatic compaction for ZRAM
- Upstream Simple LMK
- Some more I forgot

R12.3
- May fix some problems with pd charging
- Fix kernel panic when modem crash sometimes

R12.2
- Merge Linux 4.19.184 185
- Implement f2fs rapid gc from arter97
- Shorten auto-hiberate idle timer
- May fix kernel panic when modem crash sometimes

R12.1
- Fix random crash & reboot ( mostly happends on 8T )

R12
- Merge Linux 4.19.183
- Merge CAF "LA.UM.9.12.r1-11000-SMxx50.0"
- Update lots of codes from oneplus oss
- Enable UFS HPB feature
- Add support for custom ROMs

R11.2
- Merge Linux 4.19.180 181 182
- Add haptic level adjustment
- Add back 1.2GHz for big cluster
- Move to rewritten ashmem driver by sultan

R11.1
- Merge CAF "LA.UM.9.12.r1-10800-SMxx50.0"
- Merge Linux 4.19.179
- Fix SurfaceFlinger spams errors in logcat

R11
- Merge CAF "LA.UM.9.12.r1-10700-SMxx50.0"
( Including kernel, wlan and audio, video techpacks )
- Merge Linux 4.19.178
- Upstream lz4 zram algorithm
- Hardcode swappiness to 160 for more aggressive zram strategy
- Enable 4GB ZRAM
- Add back 691mhz for small cluster
- Prevent EAS from affecting cpuidle
- Apply some more optimization patches

R10.5
- Merge Linux 4.19.177
- Remove cpu cooling & devfreq cooling drivers
( Fix big cluster being limit at min freq sometimes when playing genshin impact )
- Improve deep sleep time under mobile data
- Apply some more optimization patches

R10.4
- Merge Linux 4.19.176
- Update kernel devicetree to "LA.UM.9.12.r1-10000-SMxx50.0"
- Add back lowest frequencies for big & prime cluster
- Fix broken energy model due to inappropriate optimizations

R10.3
- Merge Linux 4.19.175
- Update display panel commands from qssi-user-11-RP1A.201005.001-2102011801-release-keys

R10.2
- Fix cyberpunk theme
- Fix cloud service on hydrogen os

R10.1
- Merge Linux 4.19.174
- Cleanup and optimize defconfig
- Simplify dtbo building
- Reduce zip size ~ 30%

R10
- Merge CAF "LA.UM.9.12.r1-10300-SMxx50.0"
( Including kernel, wlan and audio, display techpacks )
- Cleanup unused debug codes in wlan drivers
- Don't allow userspace trigger process reclaim
- Remove cpuidle sleep_disable usage in haptic drivers, and remove sleep_disable node from userspace.

R9.3
- Merge Linux 4.19.173
- Ship builds with zips

R9.2.1
- Fix blurred screen and crashes on some Oneplus 8P when playing videos with MEMC on.
- Oneplus 8 Pro Only

R9.2
- Merge Linux 4.19.172
- Fix ufs workqueue overheads
- Optimize memcpy, memmove, memcmp, crc32, checksum, xor libraries
- Affine unbound workqueues to little CPUs by default
- Make the devfreq monitor workqueue high priority
- Add automatic memory compaction mechanism
- More I forgot
- Theres no change in dtbo compared to R9.1, so no need to update

R9.1
- Merge Linux 4.19.168 169 170 171
- Move to simplified frequency table
- Fix wifi not working on new Chinese version of Oneplus 8T
- Don't limit CPU frequency when gaming
- Optimize GPU scheduling under high refresh rate
- Theres no change in dtbo compared to R9, so no need to update

R9
- Merge CAF "LA.UM.9.12.r1-10000-SMxx50.0"
( Including kernel, wlan and audio, video, display techpacks )
- Merge Linux 4.19.166
- Merge Linux 4.19.167
- Add support for checking cpu voltage via kernel logs
- Theres no change in dtbo compared to R8.4, so no need to update

R8.4
- Merge Linux 4.19.165
- Disable ZRAM & SWAP
- Theres no change in dtbo compared to R8.3, so no need to update

R8.3
- Merge Linux 4.19.164
- Theres no change in dtbo compared to R8.2, so no need to update

R8.2
- Don't force run display & touchscreen irqs and threads on big cluster to save power
- Remove max boost for little cluster on switching apps to save power
- Introduce dynamic cpuset for display group, migrating tasks to big cluster on switching apps to improve smoothness
- Fix lags when little cluster is under heavy load
- Relax touchscreen cpu latency requirement to save power
- Relax UFS cpu latency requirement to save power
- Align CPU latency requirements with kona C-States
- Remove iowait boost from schedhorizon
- Don't force 4k buffer allocations for ION
- Update Magisk in the image to v21.2
- Fix force 240hz fails after exiting a game
- Theres no change in dtbo compared to R8.1, so no need to update

R8.1
- Merge CAF "LA.UM.9.12.r1-09500-SMxx50.0"
( Including kernel, wlan and audio, video, display techpacks )
- Build oneplus param read/write drivers, cyberpunk theme should work now
- Optimize pm_qos usage for touchscreen drivers on OP8 & OP8P
- Re-enable pm_qos usage for UFS drivers
- Use 100Hz timer frequency
- Never allow irq affine on more than one cpu
- Optimize pm_qos framework
- Optimize pm_qos usage for UFS drivers
- Optimize cpuidle framework
- Force run important display & touchscreen & lmk irqs and threads on big cluster
- Cleanup codes in kgsl & display techpack and optimize pm_qos usage
- Move to rewritten iommu & ion drivers
- ........... ( Check github for details )
- Theres no change in dtbo compared to R7.2, so no need to update

R7.2
- Merge Linux 4.19.163
- Theres no change in dtbo compared to R7.1, so no need to update

R7.1
- Merge Linux 4.19.162
- Re-enable lpm idle prediction
- Move to fq_codel qdisc
- Enable TCP ECN negotiation by default
- Don't force enable panel ULPS suspend
- Theres no change in dtbo compared to R7, so no need to update

R7
- Merge CAF "LA.UM.9.12.r1-09300-SMxx50.0"
( Including kernel and audio, display techpacks and wlan drivers )
- Merge Linux 4.19.161
- Build and enable vDSO32
Kernel Configuration | Android Open Source Project
source.android.com source.android.com
- Don't force offline big & prime cluster on screen off ( Fix fp reject and lags on AOD )
- Move back to mem deep sleep mode
- Don't force 240Hz touchpanel sample rate on Oneplus 8T & 8Pro ( But you can still enable it by writing 1 to /proc/touchpanel/force_game_switch_enable )
- Cleanup rx_wakelock codes in wlan drivers
- Force enable ULPS(Ultra Low Power State) and ULPS suspend for display panel
- Force allow panel phy power off on idle
- Re-align gpu idle timeout & input boost duration with display panel ULPS delay
- Enable Clang ThinLTO optimizations
- Lower the priority of f2fs gc task
- Disable expedited RCU grace periods for powersave
- Remove display ramdump memory region (free 8MB of RAM)
- Disable cpuidle idle prediction feature for powersave
- Implement fast refcount checking for arm64
- Prefetch operands to speed up atomic operations
- More I forgot
- Theres no change in dtbo compared to R6.4, so no need to update

R6.4
- Merge linux 4.19.160
- Theres no change in dtbo compared to R6.3, so no need to update

R6.3
- Merge linux 4.19.159
- Theres no change in dtbo compared to R6.2, so no need to update

R6.2
- Merge linux 4.19.158
- Move to s2idle deep sleep mode
- Apply some touchscreen drivers' simplifying and optimizations
- Theres no change in dtbo compared to R6.1, so no need to update

R6.1
- Update Proton Clang version

dtbo image has been updated:
- Fix random kernel panic caused by freeing too much reserved memory

R6
- Merge Linux 4.19.157
- Merge CAF “LA.UM.9.12.r1-09000-SMxx50.0”
( Include kernel, wlan and audio, video, display techpacks )
- Update wireguard to v1.0.20201112
- Merge Simple Lmk update
- Force 240Hz touchpanel sample rate for Oneplus 8 Pro & Oneplus 8T
- Touchpanel sample rate will no longer drop after switching to 60Hz screen refresh rate on Oneplus 8T & Oneplus 8Pro
- Update magisk to v21.1

dtbo image has been updated:
- Remove unused reserved memory regions (~12MB)

R5.5
- Merge Linux 4.19.156
- Move to Simple Lmk as lowmemorykiller
- Disable userspace lmkd
- Enable userspace CNTVCT_EL0 access for vDSO to accelerate request
- Theres no change in dtbo compared to R5.4, so no need to update.

R5.4
- Merge Linux 4.19.155
- Theres no change in dtbo compared to R5.3, so no need to update.

R5.3
- Fix cpu cores oscillationally on/off on aod fingerprint pressing
- Fix logic of screen on/off detection
- Improve speed of aod fingerprint
- Theres no change in dtbo compared to R5.2, so no need to update.

R5.2
- Optimize logic of "Optimize fingerprint speed on aod mode"
- Fix priority of fingerprint hal not changing successfully
- Optimize smoothness when entering recent apps
- Optimize smoothness when switching between apps
- Optimize app launching speed
- Theres no change in dtbo compared to R5.1, so no need to update.

R5.1
- Optimize fingerprint speed on aod mode
- Theres no change in dtbo compared to R5, so no need to update.

R5
- Merge Linux 4.19.154
- Fix camera on Oneplus 8T
- Speed up mremap by 20x on large regions
- Disable Privileged Access Never emulation, speed up syscalls 2x
- Theres no change in dtbo compared to R4, so no need to update.

R4
- Merge Linux 4.19.153
- Merge CAF "LA.UM.9.12.r1-08900-SMxx50.0"
( Including kernel and wifi drivers, audio, video, display techpacks )
- Update boot image base to OOS OB3 for OP8 & OP8P
- Camera on 8T havent been fixed on this build
- Theres no change in dtbo compared to R3, so no need to update.

R3
- Merge oneplus oss update
- Add support for Oneplus 8T
- Enable 1.2GHz input boost for big cluster
- Remove schedhorizon governor 1.6GHz(prime) 1.2GHz(big) efficient_freq
- Allow foreground apps migrate to big cluster on touch
- Relax boost duration on no input to 3s

UI Bench Result
- Jitter: ~0.3ms -> ~0.2ms
- Total duration: ~4ms -> ~3ms

- Dtbo image has been updated, reflashing is recommended

R2
- Merge Linux 4.19.152
- Merge CAF "LA.UM.9.12.r1-08600-SMxx50.0"
- Update wifi drivers to "LA.UM.9.12.r1-08600-SMxx50.0"
- Update display & video techpacks to "LA.UM.9.12.r1-08600-SMxx50.0"
- Theres no change in dtbo compared to R1.1, so no need to update.

R1.1
- Merge Linux 4.19.151
- Theres no change in dtbo compared to R1, so no need to update.

R1
- Stable release is here
( Coz no one reports bug to me lol )
- Merge Linux 4.19.150
- Enable ntfs & exfat drivers
- Theres no change on dtbo image compared to B2, so no need to update

B2
- Merge Linux 4.19.149
- Update audio & video & display techpacks to CAF "LA.UM.9.12.r1-08300-SMxx50.0"
- Add Klapse support
( Now you can turn brightness )
- Disable unused arm64 errata
- Disable wireless charging drivers for oneplus8
- Disbale iris drivers for oneplus8
- Start building dtbo image, flash it as you want.
( It could provide node /proc/touchpanel/glove_mode_enable for glove mode, you can write 1 to enable it )

B1
- Initial bring up

后记

COS 13 的内核还是有希望的,因为我原来觉得官核挺好的,结果现在又发现挺烂的。