CruelKernel / samsung-exynos9820

Unified kernel tree for S10 and Note10 devices
https://cruelkernel.org/release/
Other
107 stars 295 forks source link
android exynos9820 exynos9825 galaxynote10 galaxys10 kernel linux note10 s10 samsung

Cruel Kernel Tree for Samsung S10, Note10 devices

CI

Based on samsung sources and android common tree. Supported devices: G970F/N, G973F/N, G975F/N G977B/N, N970F, N975F, N971N, N976B/N.

Contributors

How to install

First of all, TWRP Recovery + multidisabler should be installed in all cases. It's a preliminary step. Next, backup your existing kernel. You will be able to restore it from TWRP Recovery in case of problems.

How to install zip file

TWRP

Reboot to TWRP. Flash CruelKernel.zip. Reboot to system.

How to install img file (raw image)

TWRP

Reboot to TWRP. Flash boot.img to the boot slot. Reboot to system.

ADB/Termux (root required)

With ADB:

$ adb shell push boot.img /sdcard/
$ adb shell su -c 'dd if=/sdcard/boot.img of=/dev/block/by-name/boot'
$ adb shell rm -f /sdcard/boot.img
$ adb reboot

With Termux:

# Download image on the phone and copy image to, for example, /sdcard/boot.img
$ su
$ dd if=/sdcard/boot.img of=/dev/block/by-name/boot
$ rm -f /sdcard/boot.img
$ reboot

Flashify or FKM (root required)

Just flash one of boot.img files suitable for your phone's model in the app.

Heimdall

Reboot to Download Mode.

$ sudo heimdall flash --BOOT boot.img

Reboot to system.

Pin problem (Can't login)

The problem is not in sources. It's due to os_patch_level mismatch with you current kernel (and/or twrp). CruelKernel uses common security patch date to be in sync with the official twrp and samsung firmware. You can check the default os_patch_level in cruel/build.mkbootimg.* files. However, this date can be lower than other kernels use. When you flash a kernel with an earlier patch date on top of the previous one with a higher date, android activates rollback protection mechanism and you face the pin problem. It's impossible to use a "universal" os_patch_level because different users use different custom kernels and different firmwares. CruelKernel uses the common date by default in order to suite most of users.

How can you solve the problem? 6 different ways:

How to customize the kernel

It's possible to customize the kernel and build it in a web browser. First of all, you need to create an account on GitHub. Next, fork this repository. Switch to the "Actions" tab and activate GitHub Actions. At this step you've got your copy of the sources and you can build it with GitHub Actions. You need to open github actions configuration file and edit it from the browser.

First of all, you need to edit model argument (by default it's G973F) to the model of your phone. You can select multiple models. Supported models are: G970F/N, G973F/N, G975F/N, G977B/N, N970F, N971N, N975F, N976B/N.

Edit model:

    strategy:
      matrix:
        model: [ "G973F" ]

For example, you can add two models. This will create separate installers for models:

    strategy:
      matrix:
        model: [ "G973F", "G975F" ]

If you want one installer for 2 kernels, use:

    strategy:
      matrix:
        model: [ "G973F,G975F" ]

To alter the kernel configuration you need to edit lines:

    - name: Kernel Configure
      run: |
        ./cruelbuild config                    \
                     model=${{ matrix.model }} \
                     name="Cruel-v5.3"         \
                     +magisk                   \
                     +nohardening              \
                     +ttl                      \
                     +wireguard                \
                     +cifs                     \
                     +sdfat                    \
                     +ntfs                     \
                     +morosound                \
                     +boeffla_wl_blocker

You can change the name of the kernel by replacing name="Cruel-v5.3" with, for example, name="my_own_kernel". You can remove wireguard from the kernel if you don't need it by changing "+" to "-" or by removing the "+wireguard" line and "\" on the previous line.

OS patch date can be changed with os_patch_level=2020-12 argument, the default current date is in cruel/build.mkbootimg.G973F file.

Preset configurations

Available configuration presets can be found in configs folder. Only the *.conf files prefixed with "cruel" are meaningful. Presets list (+ means enabled by default, use NODEFAULTS=1 env var to drop them):

For example, you can alter default configuration to something like:

    - name: Kernel Configure
      run: |
        ./cruelbuild config                    \
                     os_patch_level=2020-12    \
                     model=${{ matrix.model }} \
                     name="OwnKernel"          \
                     toolchain=proton          \
                     +magisk=canary            \
                     +wireguard                \
                     +nohardening              \
                     +1000hz

After editing the configuration in the browser, save it and commit. Next, you need to switch to the "Actions" tab. At this step you will find that GitHub starts to build the kernel. You need to wait about 25-30 mins while github builds the kernel. If the build is successfully finished, you will find your boot.img in the Artifacts section. Download it, unzip and flash.

To keep your version of the sources in sync with main tree, please look at one of these tutorials:

Toolchain

It's possible to select a toolchain. For example, you can switch to default toolchain by adding "TOOLCHAIN: default" line in the main.yml config file.

env:
  TOOLCHAIN: default

Available toolchains:

How to build the kernel locally on your PC

This instructions assumes you are using Linux. Install heimdall if you want to flash the kernel automatically.

Next:

# Install prerequisites
# If you use ubuntu or ubuntu based distro then you need to install these tools:
$ sudo apt-get install build-essential libncurses-dev libtinfo5 bc bison flex libssl-dev libelf-dev heimdall-flash android-tools-adb android-tools-fastboot curl p7zip-full
# If you use Fedora:
$ sudo dnf group install "Development Tools"
$ sudo dnf install ncurses-devel ncurses-compat-libs bc bison flex elfutils-libelf-devel openssl-devel heimdall android-tools curl p7zip
# If you use Arch/Manjaro (from ..::M::..):
$ sudo pacman -Sy base-devel ncurses bc bison flex openssl libelf heimdall android-tools curl p7zip --needed
$ sudo link /lib/libtinfo.so.6 /lib/libtinfo.so.5

# Install avbtool
$ wget -q https://android.googlesource.com/platform/external/avb/+archive/refs/heads/master.tar.gz -O - | tar xzf - avbtool.py
$ chmod +x avbtool.py
$ sudo mv avbtool.py /usr/local/bin/avbtool

# Install mkbootimg
$ wget -q https://android.googlesource.com/platform/system/tools/mkbootimg/+archive/refs/heads/master.tar.gz -O - | tar xzf - mkbootimg.py gki
$ chmod +x mkbootimg.py
$ sudo mv mkbootimg.py /usr/local/bin/mkbootimg
$ sudo mv gki $(python -c 'import site; print(site.getsitepackages()[0])')

# Install mkdtboimg
$ wget -q https://android.googlesource.com/platform/system/libufdt/+archive/refs/heads/master.tar.gz -O - | tar --strip-components 2 -xzf - utils/src/mkdtboimg.py
$ chmod +x mkdtboimg.py
$ sudo mv mkdtboimg.py /usr/local/bin/mkdtboimg

# Get the sources
$ git clone https://github.com/CruelKernel/samsung-exynos9820
$ cd samsung-exynos9820

# List available branches
$ git branch -a | grep remotes | grep cruel | cut -d '/' -f 3
# Switch to the branch you need
$ git checkout cruel-HVJ5-v5.3

# Install compilers
$ git submodule update --init --depth 1 -j $(nproc)
# execute these 4 commands if you want to use non-default toolchains
# cd toolchain
# git remote set-branches origin '*'
# git fetch -v --depth 1
# cd ../

# Compile kernel for G970F, G973F, G975F phones.
# Use model=all if you want to build the kernel for all available phones.
$ ./cruelbuild mkimg name="CustomCruel" model=G970F,G973F,G975F toolchain=proton +magisk=canary +wireguard +ttl +cifs +nohardening
# You will find your kernel in boot.img file after compilation.
$ ls -lah ./boot.img

# You can automatically flash the kernel with adb/heimdall
# if you connect your phone to the PC and execute:
$ FLASH=y ./cruelbuild mkimg ...

# Or in a single command (compilation with flashing)
# FLASH=y ./cruelbuild mkimg name="CustomCruel" model=G973F toolchain=proton +magisk=canary +wireguard +ttl +cifs +nohardening

Support