How To Guide Getting Freedreno Turnip (Mesa Vulkan Driver) on a Poco F3

Search This thread

astronomy2021

Senior Member
May 1, 2021
470
267
Sir, please, how do I patch, rename, flash turnip on this aethersx2
I just copy that file in AethersSX2 folder and place it to zip of Mesa and flash it.

Su

Cd /data/data/xyz.aethersx2.custom/drivers

Cp libvulkan_freedreno.so /storage/emulated/0
You have to have file permission for Temux do do that in Android settings.

Then changed name to vulkan.adreno.so and replace it zip from here.
If you send this file I can repack to zip.
 

RM CHOUU 00

Senior Member
Feb 21, 2022
52
0
I just copy that file in AethersSX2 folder and place it to zip of Mesa and flash it.

Su

Cd /data/data/xyz.aethersx2.custom/drivers

Cp libvulkan_freedreno.so /storage/emulated/0
You have to have file permission for Temux do do that in Android settings.

Then changed name to vulkan.adreno.so and replace it zip from here.
If you send this file I can repack to zip.
how to write a rename command in termux sir?
 

RM CHOUU 00

Senior Member
Feb 21, 2022
52
0
I just copy that file in AethersSX2 folder and place it to zip of Mesa and flash it.

Su

Cd /data/data/xyz.aethersx2.custom/drivers

Cp libvulkan_freedreno.so /storage/emulated/0
You have to have file permission for Temux do do that in Android settings.

Then changed name to vulkan.adreno.so and replace it zip from here.
If you send this file I can repack to zip.
I've run the su command, when writing cd and cp the result failed, did I write it wrong?
 

Attachments

  • Screenshot_20220227-210940.png
    Screenshot_20220227-210940.png
    188.8 KB · Views: 24

astronomy2021

Senior Member
May 1, 2021
470
267
Android version make that is in different place try using Root explorer and finding that file in that folder
 

RM CHOUU 00

Senior Member
Feb 21, 2022
52
0
all you have to do is extract the vulkan file sir, it's there, you just have to reinstall the zip file again
 

RM CHOUU 00

Senior Member
Feb 21, 2022
52
0
that's your module that I repacked earlier, I just replaced your vulkan module with mine, when I repacked, and installed via magisk the result didn't add to my vulkan Extension lVK_ARM_rasteriz ation_order_attachment_access.
 

RM CHOUU 00

Senior Member
Feb 21, 2022
52
0
what i wonder is why my driver runs fine using the turnip in this aethersx2 turnip, while i do the compilation of vulkan the freedreno driver can't? can you change the mesa system sdk 31 to 28 for me?
 
Last edited:

samantas5855

Senior Member
Jan 26, 2017
145
36
what i wonder is why my driver runs fine using the turnip in this aethersx2 turnip, while i do the compilation of vulkan the freedreno driver can't? can you change the mesa system sdk 31 to 28 for me?
What you are saying doesn't make much sense. You can use the driver and you have errors compiling it but these two aren't related. I doubt the target sdk will change something.
 

RM CHOUU 00

Senior Member
Feb 21, 2022
52
0
What you are saying doesn't make much sense. You can use the driver and you have errors compiling it but these two aren't related. I doubt the target sdk will change something.
actually it's not unreasonable sir, it's actually like that after all, I have already given evidence to you that my Vulkan has no problems when I run the aether turnip
 

samantas5855

Senior Member
Jan 26, 2017
145
36
actually it's not unreasonable sir, it's actually like that after all, I have already given evidence to you that my Vulkan has no problems when I run the aether turnip
The fact that you can use Turnip doesn't mean you can compile it. Completely unrelated. I compile Turnip on my pc which has an NVIDIA gpu and can't use Turnip
 

Top Liked Posts

  • There are no posts matching your filters.
  • 12
    Bellow follows a compilation and magisk packaging guide for the Turnip driver, if you just want an optimized build for magisk and don't care to compile get it from https://cdn.discordapp.com/attachments/930104429309460533/942122346960027698/mesa_lto.zip This build is built as release with LTO enabled. Just make sure that on /vendor/lib64/hw you have a file called vulkan.adreno.so ,if the name is different then you have to patch it with patchelf and rename it as stated bellow.

    In this guide I'm going to teach you how to compile the mesa's Turnip vulkan driver of the Freedreno project for any smartphone with a Snapdragon SOC on a PC. If you want to compile on your phone (guest) check the second post.
    You are going to need Linux in order to follow this guide and recommended is a distro with latest packages, for example Arch Linux (including derivatives like EndeavourOS, Manjaro, Garuda, Calamarch, etc.), while this may also work on WSL/WSL2 I haven't tested it and you are on your own for this.
    You are also going to need a mobile phone that’s rooted with the latest magisk and magisk manager.

    Before starting you need to satisfy some dependencies:
    • git to clone the mesa repository
    • patchelf to patch the binary with the name your phone expects
    • meson which is mesa’s build system
    To get all these on Arch you can use the below command:
    Code:
    sudo pacman -Syu git patchelf meson

    You also need NDK since you are compiling native code for Android. There are two ways to get this:
    • From the SDK Manager on Android Studio Beta or Canary (Stable Android Studio doesn’t have the latest NDK) by going to More Actions>SDK Manager>SDK Tools on the welcome screen or Tools>SDK Manager>SDK Tools if a project is open and download the latest one. If you already have it and it shows a – sign you need to click it again to become a tick since you already have it but it is an older version. After you get the NDK you can close Android Studio.
    • Manually from https://developer.android.com/ndk/downloads. Make sure to get the latest NDK for Linux at the bottom of the page.

    Now you need to find the absolute path of the NDK, which will be referred to as NDKDIR from now on.
    If you got the NDK from Android Studio, then there should be a folder called Android on your home folder with a folder called Sdk inside it, get in. Click the ndk folder then get inside the folder of the biggest version (25.0.8141415 at the time of writing this) and copy the path. In my case the path is
    Code:
    /home/username/Android/Sdk/ndk/25.0.8141415

    If you downloaded the NDK manually then you need to extract it somewhere. For example I created a folder called Turnip in the root of my home folder and extracted it there. The latest NDK is android-ndk-r25-beta1-linux.zip at the time of writing this so my NDKDIR is
    Code:
    /home/username/Turnip/android-ndk-r25-beta1

    Inside your NDKDIR create a folder called pkgconfig and another folder for dependencies which I will call deps.

    Next you must create a meson cross file. To do this create a file called android-aarch64 at ~/.local/share/meson/cross/ (~ means your home folder). If you don’t see any folders starting with a dot you need to press ctrl+h, if the path doesn’t exist create it.
    On that file paste the following and using your text editor automatically find and replace all instances of NDKDIR with your NDKDIR from above.
    Code:
    [binaries]
    ar = 'NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar'
    c = ['ccache', 'NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android31-clang']
    cpp = ['ccache', 'NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android31-clang++', '-fno-exceptions', '-fno-unwind-tables', '-fno-asynchronous-unwind-tables', '-static-libstdc++']
    c_ld = 'lld'
    cpp_ld = 'lld'
    strip = 'NDKDIR/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip'
    # Android doesn't come with a pkg-config, but we need one for meson to be happy not
    # finding all the optional deps it looks for.  Use system pkg-config pointing at a
    # directory we get to populate with any .pc files we want to add for Android
    pkgconfig = ['env', 'PKG_CONFIG_LIBDIR=NDKDIR/pkgconfig', '/usr/bin/pkg-config']
    
    [host_machine]
    system = 'linux'
    cpu_family = 'aarch64'
    cpu = 'armv8'
    endian = 'little'

    Now you need to download a binary of libdrm compiled for Arm64. It’s available at https://archlinuxarm.org/packages/aarch64/libdrm, just click the Download button on the right. Open the .tar.xz archive using your archive manager. Inside there’s a folder called usr that contains three other folders. You must extract the include and lib folders on the deps folder you created. After you do so, close your archive manager. The lib folder has a folder called pkgconfig, from that folder copy the file libdrm.pc to the pkgconfig folder that you created before deps.

    Edit the libdrm pc file after you transfer it and change its first line so that it points to deps. For example in my case it's
    Code:
    prefix=/home/username/Turnip/android-ndk-r25-beta1/deps

    And last, you need a clone of the MESA repository. To clone the repo you need to use the terminal so open a terminal at the folder you want the mesa folder to be downloaded onto or cd there otherwise the mesa folder will be placed at the root of your home folder. To clone you use the bellow command:
    Code:
    git clone https://gitlab.freedesktop.org/mesa/mesa.git
    and cd inside by doing
    Code:
    cd mesa
    Then generate the build files using
    Code:
    meson build-android-aarch64 --cross-file android-aarch64 -Dbuildtype=release -Dplatforms=android -Dplatform-sdk-version=31 -Dandroid-stub=true -Dgallium-drivers= -Dvulkan-drivers=freedreno -Dfreedreno-kgsl=true -Db_lto=true
    And compile with
    Code:
    ninja -C build-android-aarch64
    When this is done you can find our compiled driver binary at build-android-aarch64/src/freedreno/vulkan/ inside the mesa folder named libvulkan_freedreno.so.

    Now you must find the name of the binary that our phone has. The easiest way to do this is to open a terminal emulator on your phone like termux or do adb shell and run
    Code:
    ls /system/vendor/lib64/hw|grep vulkan
    In my case the driver is called vulkan.adreno.so.

    Now open a terminal on the folder where libvulkan_freedreno.so and use patchelf to patch it with the name of the driver on your phone, for example in my case I’d do
    Code:
    patchelf --set-soname vulkan.adreno.so libvulkan_freedreno.so
    and then rename libvulkan_freedreno.so to the name the driver on your phone has.

    You now need to create a magisk package containing Turnip. Simply download my existing package from https://cdn.discordapp.com/attachments/930104429309460533/942122346960027698/mesa_lto.zip and replace /system/vendor/lib64/hw/vulkan.adreno.so with the Turnip binary you compiled, patched and renamed. Now you can flash it on Magisk and reboot your phone. If you have other Magisk packages that are Vulkan drivers please disable them before rebooting. If you want compile again at a later time cd inside the mesa repo you had cloned and do a git pull before running meson and compiling. You may also have to delete the build-android-aarch64 folder.
    3
    hello, I was trying to follow ur instructions, Im stuck at
    Bash:
    ninja -C build-android-aarch64

    The error is:

    Code:
    ld.lld: error: /home/user/Android/Sdk/ndk-bundle/deps/lib/libdrm.so is incompatible with aarch64linux
    clang++: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.

    I'm using ubuntu, not arch linux
    I got the same error.

    The link in the post for the libdrm was for arm

    The link for arm64 libdrm was:

    I replaced the lib and include files again, and it successfully compiled.

    I did the patchelf commands

    I replaced the vulkan file in the vendor partition

    It did not work when I rebooted, so I changed the permissions of the freedreno vulkan driver to 644.

    When I rebooted, the freedreno vulkan driver was now working.

    Edit:
    The file "aarch64-linux-android-ar" in the new versions of the ndk bundles was renamed to "llvm-ar". I was able to compile using a newer version of ndk instead of the deprecated one.
    3
    @samantas5855
    @MrMiyamo

    Hello, can any of you help me? Could you please compile turnip drivers but add these commits. They fix the crash with switch emulators (skyline and egg ns) after a certain time.
    ...
    Done, i replace files from first link (merge request link)
    2
    Some of you wanted to compile Turnip on Termux so here's a tutorial.

    You are going to need an arm64 phone and Termux from https://f-droid.org/en/packages/com.termux/. If you have Termux from PlayStore delete it since it no longer works and it uses a different signature so it can't be updated either.
    Once you install Termux go to your phone's app settings and give it storage permissions manually then launch it.

    You must run some pkg commands, answer Y if it asks you to.
    First update the repositories and upgrade the packages using
    Code:
    pkg update
    Next you must install some dependencies
    Code:
    pkg install binutils bison flex git ninja patchelf python wget zip
    The pip version Termux provides isn't always the latest so it must be updated too using
    Code:
    /data/data/com.termux/files/usr/bin/python3 -m pip install --upgrade pip
    You will use pip3 to install the rest of the dependencies
    Code:
    pip3 install mako meson
    Since you aren't cross compiling you need to create the path that hosts the native file
    Code:
    mkdir -p ~/.local/share/meson/native
    and then download the native file for meson using
    Code:
    curl https://pastebin.com/raw/zdVCZASL>~/.local/share/meson/native/mesa
    This file is made for android-ndk-r23b so if a new version gets released use nano to edit it and replace all occurencies of android-ndk-r23b.
    You need to download the latest Termux-NDK
    (at the moment of writing this the latest is android-ndk-r23b if that changes obviously replace the commands of the guide with the new name and the url bellow)
    Code:
    wget https://github.com/Lzhiyong/termux-ndk/releases/download/android-ndk/android-ndk-r23b-aarch64.zip
    then extract it
    Code:
    unzip android-ndk-r23b-aarch64.zip
    and remove the archive since it isn't needed anymore
    Code:
    rm android-ndk-r23b-aarch64.zip
    Then you need to download libdrm for arm64 from the alarm project's repositories. Simply go to https://archlinuxarm.org/packages/aarch64/libdrm, hold the Download button and copy the url. At the moment the latest one is the one below so change the commands depending on the latest version.
    Code:
    wget http://mirror.archlinuxarm.org/aarch64/extra/libdrm-2.4.109-1-aarch64.pkg.tar.xz
    Then you need to extract it
    Code:
    tar -xf libdrm-2.4.109-1-aarch64.pkg.tar.xz -C android-ndk-r23b
    You then delete the archive since it's no longer of use
    Code:
    rm libdrm-2.4.109-1-aarch64.pkg.tar.xz
    Now you must change the prefix of the libdrm pc file to point to our local pkgconfig
    Code:
    sed -i 's#prefix=#&/data/data/com.termux/files/home/android-ndk-r23b#g' ~/android-ndk-r23b/usr/lib/pkgconfig/libdrm.pc
    You may now clone the mesa repository
    Code:
    git clone https://gitlab.freedesktop.org/mesa/mesa.git
    and get inside it
    Code:
    cd ~/mesa
    Configure the build environment using the meson command below
    Code:
    meson build-android-aarch64 --native-file mesa -Dbuildtype=release -Dplatforms=android -Dplatform-sdk-version=31 -Dandroid-stub=true -Dgallium-drivers= -Dvulkan-drivers=freedreno -Dfreedreno-kgsl=true -Dcpp_rtti=false -Db_lto=true
    and then compile
    Code:
    ninja -C build-android-aarch64
    Linking might take some time but once it's finished go back to Termux' home directory using
    Code:
    cd ~
    Now download the template for the Magisk Driver package
    Code:
    wget https://cdn.discordapp.com/attachments/894694753684320296/943268696426684456/mesa_lto.zip
    and extract it
    Code:
    unzip mesa_lto.zip -d mesa_lto
    then cd inside
    Code:
    cd mesa_lto
    and copy the blob you compiled
    Code:
    cp ~/mesa/build-android-aarch64/src/freedreno/vulkan/libvulkan_freedreno.so ./system/vendor/lib64/hw/
    If you are building for another phone you have to run termux on that other phone and get the name of the vulkan library using
    Code:
    ls /system/vendor/lib64/hw/|grep vulkan
    and then run patchelf and rename the blob.
    If not, you can just run these commands that will fetch the name of your phone's library and perform elf name patching
    Code:
    patchelf --set-soname $(ls /system/vendor/lib64/hw/|grep vulkan) system/vendor/lib64/hw/libvulkan_freedreno.so
    and renaming
    Code:
    mv system/vendor/lib64/hw/libvulkan_freedreno.so  system/vendor/lib64/hw/$(ls /system/vendor/lib64/hw/|grep vulkan)
    Finally zip the package
    Code:
    zip -r ../mesa_lto.zip *
    and go back to Termux' home directory
    Code:
    cd ..
    Delete the extracted folder, it's not needed anymore
    Code:
    rm -rf mesa_lto
    Push the Magisk package to your phone's home folder
    Code:
    cp mesa_lto.zip /storage/emulated/0
    Close Termux
    Code:
    exit
    Flash with Magisk and reboot.

    If you have other Magisk driver packages, disable them.
    If you want to compile again you don't have to reclone, just cd into the mesa directory and do
    Code:
    git pull
    You may also have to delete the build-android-aarch64 folder.
    2
    Can you give magisk module for latest mesa vulkan drivers ?
    @samantas5855 @astronomy2021
    Here it is complied yesterday .