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

Search This thread

astronomy2021

Senior Member
May 1, 2021
470
255
Hi,
I need help I did everything right on Ubuntu 20 LTO and patched file in the end and renamed but all apps seams broken now and crashing even Vulkan Caps viewer.

I used NDK -25Beta 2 for that can you check what is going on ?
 

Attachments

  • mesa_lto.zip
    1.8 MB · Views: 26

astronomy2021

Senior Member
May 1, 2021
470
255
Everyone on Poco F3 We have a confirmed latest Xtended ROM for Alioth has built in Turnip Vulkan drivers. You can flash and test freely
Screenshot_2022-03-20-20-23-57-914_com.android.chrome.jpg
 

astronomy2021

Senior Member
May 1, 2021
470
255
Xtended A12
Download link
Here is telegram link
Here is change log
 

samantas5855

Senior Member
Jan 26, 2017
145
26
At the moment the termux script has issues with statically linking libstdc++ so refrain from using at until further notice as the produced binary won't work
 

alou S

Member
Jul 23, 2017
25
4
So well I tried this for my Samsung M01 device. It does have a Adreno 505 GPU.
It doesn't have a DRM interface (`/dev/dri/card0`) but it does have a `/dev/kgsl-3d0`.
Besides that the phone also have the android environment as arm7 (32 bit) instead aarch64.

When starting anything that requires Vulkan it crashes with the following messages and errors in logcat (with filter)

logcat -T1 -s "vulkan","DEBUG","libc"
--------- beginning of main
--------- beginning of system
04-02 12:21:21.036 7534 7534 D vulkan : searching for layers in '/data/app/~~1uiA6JmCe7Xhpfmt3C4jkg==/com.finalwire.aida64-V1sJzpEqM2YKU638kWI2wA==/lib/arm'
04-02 12:21:21.037 7534 7534 D vulkan : searching for layers in '/data/app/~~1uiA6JmCe7Xhpfmt3C4jkg==/com.finalwire.aida64-V1sJzpEqM2YKU638kWI2wA==/base.apk!/lib/armeabi-v7a'
--------- beginning of crash
04-02 12:21:21.733 7534 7534 F libc : Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 7534 (inalwire.aida64), pid 7534 (inalwire.aida64)
04-02 12:21:21.947 10693 10693 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-02 12:21:21.948 10693 10693 F DEBUG : Build fingerprint: 'samsung/m01qins/m01q:11/RP1A.200720.012/M015GXXS4BVA2:user/release-keys'
04-02 12:21:21.948 10693 10693 F DEBUG : Revision: '0'
04-02 12:21:21.948 10693 10693 F DEBUG : ABI: 'arm'
04-02 12:21:21.948 10693 10693 F DEBUG : Timestamp: 2022-04-02 12:21:21+0530
04-02 12:21:21.949 10693 10693 F DEBUG : pid: 7534, tid: 7534, name: inalwire.aida64 >>> com.finalwire.aida64 <<<
04-02 12:21:21.949 10693 10693 F DEBUG : uid: 10209
04-02 12:21:21.949 10693 10693 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
04-02 12:21:21.949 10693 10693 F DEBUG : Cause: null pointer dereference
04-02 12:21:21.950 10693 10693 F DEBUG : r0 00000000 r1 a72d1125 r2 00000002 r3 00000000
04-02 12:21:21.952 10693 10693 F DEBUG : r4 03030000 r5 0303ffff r6 05000500 r7 00000000
04-02 12:21:21.952 10693 10693 F DEBUG : r8 cc8a7000 r9 cc8a76d8 r10 000000ab r11 ffef9aa8
04-02 12:21:21.952 10693 10693 F DEBUG : ip 00000046 sp ffef9810 lr a752b890 pc ededac4c
04-02 12:21:21.968 10693 10693 F DEBUG : backtrace:
04-02 12:21:21.968 10693 10693 F DEBUG : #00 pc 00095c4c /apex/com.android.runtime/lib/bionic/libc.so (strncmp+6) (BuildId: 25671fc300e72247ccaaf22111af90f6)
04-02 12:21:21.968 10693 10693 F DEBUG : #01 pc 002ab88c /vendor/lib/hw/vulkan.adreno.so (tu_enumerate_devices+940) (BuildId: 72b9518eb51a7c87711bc7b374144c5391bf5eb6)

Any ideas how to fix them. (I have tried enabling DRM in kernel config but there are too many errors in the build and probably can't fix them)
 

samantas5855

Senior Member
Jan 26, 2017
145
26
So well I tried this for my Samsung M01 device. It does have a Adreno 505 GPU.
It doesn't have a DRM interface (`/dev/dri/card0`) but it does have a `/dev/kgsl-3d0`.
Besides that the phone also have the android environment as arm7 (32 bit) instead aarch64.

When starting anything that requires Vulkan it crashes with the following messages and errors in logcat (with filter)



Any ideas how to fix them. (I have tried enabling DRM in kernel config but there are too many errors in the build and probably can't fix them)
Your phone is simply too old for this
 

MrMiyamo

Senior Member
Nov 6, 2018
91
13
Xiaomi Mi 8 SE
Realme C21
@samantas5855
Hi, firstly thanks you for writing guide and your effort.

I want to try turnip on my phone so i installed magisk module, but it unfortunately not working.

My device have Adreno 616 GPU and i using A11 rom.

Is my device not compatible?
 
Last edited:

erghezi

Member
Feb 23, 2011
11
1
Skip the steps about libdrm
In above link you may find some hints about unnecessary steps and additional steps from my discussion
Thanks for your reply. but without those libdrm steps I get "ERROR: Dependency "libdrm" not found, tried pkgconfig" error.

I'm using ubuntu focal also installed libdrm-dev package but it's not finding it
 

Top Liked Posts

  • There are no posts matching your filters.
  • 10
    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.
    2
    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.
    2
    Can you give magisk module for latest mesa vulkan drivers ?
    @samantas5855 @astronomy2021
    Here it is complied yesterday .
    1
    Aether with bundled Turnip, no root needed
    Doesn't replace regular Aether, installs side by side and has an orange box icon with a darker background
    You have to go to Settings>Advanced>On the bottom extract turnip driver and restart the app to use it.
    1
    Did you add the vk caps viewer to the magisk hide list and enable it?
    yes i did that