• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!

[Guide] Running Linux on Android with 3D Acceleration / OpenGL (Root Required)

Search This thread

HolyChickenGuy

Senior Member
Jul 30, 2017
143
87
www.instagram.com
OnePlus 7T Pro
All credits go to:
Hentacler for making Sparkle
Meefik for making Linux Deploy

Now on to the tutorial!

Requirements:
Sparkle
Linux Deploy
Termux

Now you have all those apps installed lets continue

Open Termux then enter:
Code:
su
Once in root mode enter:
Code:
setenforce 0
Then exit:
Code:
exit

Open Linux Deploy and configure it to your likings

My configuration:
Code:
Distribution: Debian
Architecture: arm64
Distribution Suite: ubstable
-
Installation type: File
-
Image size: 32GB

Then set your username and password, for this tutorial I set my username to:
Code:
android

And im not gonna tell you my password :D

After you've set up your configuration scroll down and configure init, mounts and ssh

INIT:
Code:
Enable: On
Init system: run-parts

Init settings:
- Init path: /etc/rc.local
- Init user: android
- Async: Disabled

MOUNTS:
Code:
Enable: On

Mount points:
- /data/data/com.sion.sparkle/files - /sparkle

SSH:
Code:
Enable: On

SSH settings:
- Port: 22
- SSH options:

Now you've set this all up go back to the main overview screen of Linux Deploy, hit the tripple dot menu and install!

After the install is done, hit START

Now open Termux and install SSH:
Code:
pkg install openssh

then connect to linux via SSH: (username is the username set in Linux Deploy)
Code:

Now you've connected you need to install some packages:
Code:
sudo apt install weston
sudo apt install xwayland
sudo apt install nano
sudo apt install dbus-x11

Also install your desktop environment of choice, for this tutorial im going with KDE:
Code:
sudo apt install kde-full

Once everything is done installing you need to configure some scripts:
Code:
nano sparkle.sh

Now paste this: (make sure to change "startplasma-x11" to your preferred DE, if you're also using KDE then you don't need to change anything)
Code:
#!/bin/bash
set -e 
sudo chmod 777 /sparkle
sudo chmod 777 /sparkle/wayland-0
XDG_RUNTIME_DIR=/sparkle Xwayland &
sleep 1
export DISPLAY=:0
startplasma-x11

Now open Sparkle and click "edit user.sh" and delete everything then hit "save", Go back to the main screen of Sparkle and hit "Start", you should see a notification appear in your status bar

Now to start everything go back to Termux and assuming you're still SSH'ed into Linux type:
Code:
sh sparkle.sh

and enjoy!

Bonus step:

If you want everything to automatically start when pressing "START" in Linux Deploy than you can configure this

Open Termux and connect to Linux via SSH and change the permissions/edit the rc.local file: (edit username to the username set in Linux Deploy)
Code:
sudo chmod +x /etc/rc.local
sudo chmod +x /home/username/sparkle.sh
sudo nano /etc/rc.local

In nano paste: (once again change username to the username in Linux Deploy
Code:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/home/username/sparkle.sh 

exit 0


Now every time you want to use Linux just open Sparkle, hit "Start", then go to Linux Deploy and start linux and your DE will automatically load up on your screen without entering a single command!
 
Last edited:

LedBass

New member
Jan 3, 2013
4
1
Hi

What version of Sparkle did you use? I've tried this tutorial here but received an error of wayland-0 not found when I try to run my linux installation on my device

I've looked in the folder /data/data/com.sion.sparkle/files and this folder is empty

Thanks for the tutorial!
 
  • Like
Reactions: pierro78

NKS1608

Member
Mar 8, 2015
27
10
21
Luis Correia
It works

I managed to use it, but with xfce KDE had a black screen, and I couldn't use the audio even though I made the alsa plugin, and it doesn't rotate the screen, but it's very good.
 

Richard177

Member
Dec 7, 2016
16
6
I have One Plus 8 pro.
So my results with this software 3D acceleration are that the performance really suck but its amazing for now because you need this basic aceleration in almost everything i can now render videos on my phone in kdenlive and the phone has kinda good cpu performace so there is no problem basicly i can now run in this chroot everything that can be runned on raspi and i am also messing around with BOX86 which is a hardware translation of arm to x86 architectures so far i can run x86 apps for linux inside the chroot and now with this little tool i can maybe get wine x86 runnig which means windows apps support on android yeeey :D of course with this low performace of a gpu i could at best try games before year 2000 and maybe if they start up have some good fps but i highly doubt that because raspi has problem runnig (in twister os) even unreal tournament and raspi has 5 to 6 times higher performance than this software accel.
Benchmarks i did were glxgears i got anywere from 200 to 270 fps which is not really much :D
Also I used 2 desktop config started the one thats build in vnc from the app and then started sparkle connected to it and had second desktop start up using lxde on my phone on phone the screen really sucks to to work with so i used scrcpy to mirror the screen of phone to pc so basicaly a have full control remotly i hope that this will have future version development to improve on code so that we could get more performace out of this.
Image below.
zEsN.png
 
Last edited:

diejuse

Member
Aug 1, 2019
18
0
I am using LXDE with Sparkle. I would like a lower screen resolution, all things look so small. I can do that with XSDL, how in Sparkle?
 

flunkyball

Senior Member
May 20, 2019
98
68
@HolyChickenGuy
Thanks for the well done tutorial ! I followed it and it worked out of the box.
However, two issues I came accross to which I did not find the solution, yet:

1. Is there a way to rotate the screen ?
2. How can I bring the X-window to the second screen connected via USB->HDMI adapter ? I tried to set DISPLAY:1 but 1 was not found and :0 is the devices screen.

Cheers mate and keep up the good work.
 

flunkyball

Senior Member
May 20, 2019
98
68
Termux desktop is much faster and easier to use and you can experience a complete Linux GUI with termux, and it Is also lightwight.

The described way basically is using Termux the way you propose. However it adds the 3D acceleration by using sparkle which is definitely a plus.

---------- Post added at 09:49 PM ---------- Previous post was at 09:47 PM ----------

@HolyChickenGuy
Thanks for the well done tutorial ! I followed it and it worked out of the box.
However, two issues I came accross to which I did not find the solution, yet:

1. Is there a way to rotate the screen ?
2. How can I bring the X-window to the second screen connected via USB->HDMI adapter ? I tried to set DISPLAY:1 but 1 was not found and :0 is the devices screen.

Cheers mate and keep up the good work.

Okay, rotating the screen is done by rotating Termux BEFORE you start the windowmanager.
But - for bringing it up on the external monitor I haven't not found the trick, yet
 
  • Like
Reactions: pierro78

mr.knr

Member
Mar 11, 2020
15
0
but what if i want to install LXQt on my device

#!/bin/bash
set -e
sudo chmod 777 /sparkle
sudo chmod 777 /sparkle/wayland-0
XDG_RUNTIME_DIR=/sparkle Xwayland &
sleep 1
export DISPLAY=:0
startplasma-x11
what should i change in the script??????
 

pierro78

Senior Member
Jan 3, 2006
361
55
www.facebook.com
LG V20
LG G8
sorry for the probably dumb question but Xsdl seems to work work quite well in my use cases (like watching youtube videos in 360p on my Samsung Tab S5e) ...

... so I am wondering : what are the advantages of Sparkle/Wayland over Xsdl ?? ... will my youtube videos be smoother ??
... does Sparkle/Wayland has better touch support than Xsdl ?? ... for example can you scroll a web browser window by touching inside the window (not the scrollbar) with your finger ??
 

zanfix

Member
Apr 24, 2020
18
6
36
sorry for the probably dumb question but Xsdl seems to work work quite well in my use cases (like watching youtube videos in 360p on my Samsung Tab S5e) ...

... so I am wondering : what are the advantages of Sparkle/Wayland over Xsdl ?? ... will my youtube videos be smoother ??
... does Sparkle/Wayland has better touch support than Xsdl ?? ... for example can you scroll a web browser window by touching inside the window (not the scrollbar) with your finger ??
you sure can get 1080 on a tab s5e with xsdl...
sparkle app is for sure more lightweight but in some situatons xsdl is better, at least with some games, at least with my experience
did you compile and use the android-shmem library?
 
  • Like
Reactions: pierro78

pierro78

Senior Member
Jan 3, 2006
361
55
www.facebook.com
LG V20
LG G8
you sure can get 1080 on a tab s5e with xsdl...
sparkle app is for sure more lightweight but in some situatons xsdl is better, at least with some games, at least with my experience
did you compile and use the android-shmem library?
wow 1080 ! that would be awesome ! thanks for the info !!

actually 360p is not so smooth on my S5e without android-shmem library ...

if I understand correctly I just have to compile that in my chroot and then the shared memory feature is already supported in the Xserver xsdl that I installed from the playstore ??

thanks again !!
 

zanfix

Member
Apr 24, 2020
18
6
36
wow 1080 ! that would be awesome ! thanks for the info !!

actually 360p is not so smooth on my S5e without android-shmem library ...

if I understand correctly I just have to compile that in my chroot and then the shared memory feature is already supported in the Xserver xsdl that I installed from the playstore ??

thanks again !!
android-shmem library can give you a performance boost if the application you are running can use the x server MIT-SHM extension

For video playback in a web browser, firefox-esr for example, the android-shm library will not give you any performance gain...
Since there is no hardware acceleration in xsdl, In order to put the minimum possible load on the cpu you should match the screen resolution of the xserver with the target max resolution of the videos you are planning to playback.
My tab s6 has 2560x1600 native resolution, i run the xserver at 1920x1200 so I keep the aspect ratio of the screen but match the clip (tube video) native resolution (so that no rescaling will happen)

I can get acceptable youtube video playback also on my old pixelc c, that has a quadcore a57
 
  • Like
Reactions: pierro78

pierro78

Senior Member
Jan 3, 2006
361
55
www.facebook.com
LG V20
LG G8
well I don't know what I did wrong previously ... my youtube videos seem to play nice on 1080 in Xserver xsdl with arm64 vivaldi in my chroot (Tab S5e) with or without
env LD_PRELOAD="/home/pierro78/android-shmem/libandroid-shmem-aarch64.so" icewm&
now !
and I don't see any difference with or without LD_PRELOAD="/home/pierro78/android-shmem/libandroid-shmem-aarch64.so" in vivaldi although it may support x server MIT-SHM extension as you said ??


also I have errors when using /home/pierro78/android-shmem/libandroid-shmem-aarch64.so when I start icewm (same errors if regular user or root) :

[email protected]:/home/pierro78# icewm&
[1] 8527
[email protected]:/home/pierro78# Failed to connect to session manager: Failed to connect to the session manager: SESSION_MANAGER environment variable not defined
shmget: key 0 size 4096 flags 01600 (flags are ignored)
shmget: bound UNIX socket /dev/shm/00002157
listening_thread: thread started
shmget: ID 0 shmid 21570001 FD 7 size 4096
shmat: shmid 21570001 shmaddr (nil) shmflg 0
shmat: mapped addr 0x735094b000 for FD 7 ID 0
shm_remove: deleting shmid 21570001
shm_remove: shmid 21570001 is still mapped to addr 0x735094b000, it will be deleted on shmdt() call
shmdt: unmapped addr 0x735094b000 for FD 7 ID 0 shmid 21570001
shmdt: deleting shmid 21570001



and when I start vivaldi as regular user :


shmctl: cmd 3 not implemented yet!
shmget: key 0 size 2946039 flags 01606 (flags are ignored)
shmget: cannot bind UNIX socket, bailing out
[7437:7437:0426/232122.758794:ERROR:CONSOLE(0)] "Unchecked runtime.lastError: The message port closed before a response was received.", source: chrome-extension://mpognobbkildjkofajifpdfhcoklimli/browser.html (0)
shmget: key 0 size 112140 flags 01606 (flags are ignored)
shmget: cannot bind UNIX socket, bailing out
shmget: key 0 size 368460 flags 01606 (flags are ignored)
shmget: cannot bind UNIX socket, bailing out


or if I start vivaldi as root user :


shmctl: cmd 3 not implemented yet!
shmget: key 0 size 2831220 flags 01606 (flags are ignored)
shmget: bound UNIX socket /dev/shm/00001f6e
shmget: ID 0 shmid 1f6e0001 FD 36 size 2834432
shmat: shmid 1f6e0001 shmaddr (nil) shmflg 0
shmat: mapped addr 0x71b6582000 for FD 36 ID 0
shm_remove: deleting shmid 1f6e0001
shm_remove: shmid 1f6e0001 is still mapped to addr 0x71b6582000, it will be deleted on shmdt() call
shmdt: unmapped addr 0x71b6582000 for FD 36 ID 0 shmid 1f6e0001
shmdt: deleting shmid 1f6e0001
listening_thread: thread started
[7990:7990:0426/232440.532571:ERROR:CONSOLE(0)] "Unchecked runtime.lastError: The message port closed before a response was received.", source: chrome-extension://mpognobbkildjkofajifpdfhcoklimli/browser.html (0)




I am not sure how to check if my libandroid-shmem-aarch64.so is working ??
I would expect some "files" in /dev/shm but there is nothing there ...
 

pierro78

Senior Member
Jan 3, 2006
361
55
www.facebook.com
LG V20
LG G8
[email protected]:/home/pierro78# icewm&
[1] 8527
[email protected]:/home/pierro78# Failed to connect to session manager: Failed to connect to the session manager: SESSION_MANAGER environment variable not defined
shmget: key 0 size 4096 flags 01600 (flags are ignored)
shmget: bound UNIX socket /dev/shm/00002157
listening_thread: thread started
shmget: ID 0 shmid 21570001 FD 7 size 4096
shmat: shmid 21570001 shmaddr (nil) shmflg 0
shmat: mapped addr 0x735094b000 for FD 7 ID 0
shm_remove: deleting shmid 21570001
shm_remove: shmid 21570001 is still mapped to addr 0x735094b000, it will be deleted on shmdt() call
shmdt: unmapped addr 0x735094b000 for FD 7 ID 0 shmid 21570001
shmdt: deleting shmid 21570001
PS : my bad : these error messages are coming from my xfce4-terminal, not icewm ...
 

zanfix

Member
Apr 24, 2020
18
6
36
well I don't know what I did wrong previously ... my youtube videos seem to play nice on 1080 in Xserver xsdl with arm64 vivaldi in my chroot (Tab S5e) with or without
env LD_PRELOAD="/home/pierro78/android-shmem/libandroid-shmem-aarch64.so" icewm&
now !
and I don't see any difference with or without LD_PRELOAD="/home/pierro78/android-shmem/libandroid-shmem-aarch64.so" in vivaldi although it may support x server MIT-SHM extension as you said ??


also I have errors when using /home/pierro78/android-shmem/libandroid-shmem-aarch64.so when I start icewm (same errors if regular user or root) :

[email protected]:/home/pierro78# icewm&
[1] 8527
[email protected]:/home/pierro78# Failed to connect to session manager: Failed to connect to the session manager: SESSION_MANAGER environment variable not defined
shmget: key 0 size 4096 flags 01600 (flags are ignored)
shmget: bound UNIX socket /dev/shm/00002157
listening_thread: thread started
shmget: ID 0 shmid 21570001 FD 7 size 4096
shmat: shmid 21570001 shmaddr (nil) shmflg 0
shmat: mapped addr 0x735094b000 for FD 7 ID 0
shm_remove: deleting shmid 21570001
shm_remove: shmid 21570001 is still mapped to addr 0x735094b000, it will be deleted on shmdt() call
shmdt: unmapped addr 0x735094b000 for FD 7 ID 0 shmid 21570001
shmdt: deleting shmid 21570001



and when I start vivaldi as regular user :


shmctl: cmd 3 not implemented yet!
shmget: key 0 size 2946039 flags 01606 (flags are ignored)
shmget: cannot bind UNIX socket, bailing out
[7437:7437:0426/232122.758794:ERROR:CONSOLE(0)] "Unchecked runtime.lastError: The message port closed before a response was received.", source: chrome-extension://mpognobbkildjkofajifpdfhcoklimli/browser.html (0)
shmget: key 0 size 112140 flags 01606 (flags are ignored)
shmget: cannot bind UNIX socket, bailing out
shmget: key 0 size 368460 flags 01606 (flags are ignored)
shmget: cannot bind UNIX socket, bailing out


or if I start vivaldi as root user :


shmctl: cmd 3 not implemented yet!
shmget: key 0 size 2831220 flags 01606 (flags are ignored)
shmget: bound UNIX socket /dev/shm/00001f6e
shmget: ID 0 shmid 1f6e0001 FD 36 size 2834432
shmat: shmid 1f6e0001 shmaddr (nil) shmflg 0
shmat: mapped addr 0x71b6582000 for FD 36 ID 0
shm_remove: deleting shmid 1f6e0001
shm_remove: shmid 1f6e0001 is still mapped to addr 0x71b6582000, it will be deleted on shmdt() call
shmdt: unmapped addr 0x71b6582000 for FD 36 ID 0 shmid 1f6e0001
shmdt: deleting shmid 1f6e0001
listening_thread: thread started
[7990:7990:0426/232440.532571:ERROR:CONSOLE(0)] "Unchecked runtime.lastError: The message port closed before a response was received.", source: chrome-extension://mpognobbkildjkofajifpdfhcoklimli/browser.html (0)




I am not sure how to check if my libandroid-shmem-aarch64.so is working ??
I would expect some "files" in /dev/shm but there is nothing there ...
looks fine when run as root...

is /dev/shm mounted as tmpfs?
/dev/shm should then have 1777 permissions
 
  • Like
Reactions: pierro78

pierro78

Senior Member
Jan 3, 2006
361
55
www.facebook.com
LG V20
LG G8
looks fine when run as root...

is /dev/shm mounted as tmpfs?
/dev/shm should then have 1777 permissions

It looks like I am good :

[email protected]:/dev$ mount
/dev/block/mmcblk0p57 on / type ext4 (rw,noatime,seclabel,discard,journal_checksum,noauto_da_alloc,resgid=1065,errors=panic,i_version,data=ordered)
proc on /proc type proc (rw,relatime,gid=3009,hidepid=2)
sys on /sys type sysfs (rw,relatime,seclabel)
tmpfs on /dev type tmpfs (rw,nosuid,relatime,seclabel,size=2871960k,nr_inodes=717990,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,relatime,seclabel)
devpts on /dev/pts type devpts (rw,relatime,seclabel,mode=600,ptmxmode=000)
[email protected]:/dev$ ls -ld shm
drwxrwxrwt. 2 root root 40 Apr 26 23:59 shm
[email protected]:/dev$
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    All credits go to:
    Hentacler for making Sparkle
    Meefik for making Linux Deploy

    Now on to the tutorial!

    Requirements:
    Sparkle
    Linux Deploy
    Termux

    Now you have all those apps installed lets continue

    Open Termux then enter:
    Code:
    su
    Once in root mode enter:
    Code:
    setenforce 0
    Then exit:
    Code:
    exit

    Open Linux Deploy and configure it to your likings

    My configuration:
    Code:
    Distribution: Debian
    Architecture: arm64
    Distribution Suite: ubstable
    -
    Installation type: File
    -
    Image size: 32GB

    Then set your username and password, for this tutorial I set my username to:
    Code:
    android

    And im not gonna tell you my password :D

    After you've set up your configuration scroll down and configure init, mounts and ssh

    INIT:
    Code:
    Enable: On
    Init system: run-parts
    
    Init settings:
    - Init path: /etc/rc.local
    - Init user: android
    - Async: Disabled

    MOUNTS:
    Code:
    Enable: On
    
    Mount points:
    - /data/data/com.sion.sparkle/files - /sparkle

    SSH:
    Code:
    Enable: On
    
    SSH settings:
    - Port: 22
    - SSH options:

    Now you've set this all up go back to the main overview screen of Linux Deploy, hit the tripple dot menu and install!

    After the install is done, hit START

    Now open Termux and install SSH:
    Code:
    pkg install openssh

    then connect to linux via SSH: (username is the username set in Linux Deploy)
    Code:

    Now you've connected you need to install some packages:
    Code:
    sudo apt install weston
    sudo apt install xwayland
    sudo apt install nano
    sudo apt install dbus-x11

    Also install your desktop environment of choice, for this tutorial im going with KDE:
    Code:
    sudo apt install kde-full

    Once everything is done installing you need to configure some scripts:
    Code:
    nano sparkle.sh

    Now paste this: (make sure to change "startplasma-x11" to your preferred DE, if you're also using KDE then you don't need to change anything)
    Code:
    #!/bin/bash
    set -e 
    sudo chmod 777 /sparkle
    sudo chmod 777 /sparkle/wayland-0
    XDG_RUNTIME_DIR=/sparkle Xwayland &
    sleep 1
    export DISPLAY=:0
    startplasma-x11

    Now open Sparkle and click "edit user.sh" and delete everything then hit "save", Go back to the main screen of Sparkle and hit "Start", you should see a notification appear in your status bar

    Now to start everything go back to Termux and assuming you're still SSH'ed into Linux type:
    Code:
    sh sparkle.sh

    and enjoy!

    Bonus step:

    If you want everything to automatically start when pressing "START" in Linux Deploy than you can configure this

    Open Termux and connect to Linux via SSH and change the permissions/edit the rc.local file: (edit username to the username set in Linux Deploy)
    Code:
    sudo chmod +x /etc/rc.local
    sudo chmod +x /home/username/sparkle.sh
    sudo nano /etc/rc.local

    In nano paste: (once again change username to the username in Linux Deploy
    Code:
    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    
    /home/username/sparkle.sh 
    
    exit 0


    Now every time you want to use Linux just open Sparkle, hit "Start", then go to Linux Deploy and start linux and your DE will automatically load up on your screen without entering a single command!
    2
    Unfortunately, this method doesn't give hardware 3d acceleration. Just very slow software emulation. It is much harder or even not possible to achieve true acceleration on android handhelds.
    2
    I have One Plus 8 pro.
    So my results with this software 3D acceleration are that the performance really suck but its amazing for now because you need this basic aceleration in almost everything i can now render videos on my phone in kdenlive and the phone has kinda good cpu performace so there is no problem basicly i can now run in this chroot everything that can be runned on raspi and i am also messing around with BOX86 which is a hardware translation of arm to x86 architectures so far i can run x86 apps for linux inside the chroot and now with this little tool i can maybe get wine x86 runnig which means windows apps support on android yeeey :D of course with this low performace of a gpu i could at best try games before year 2000 and maybe if they start up have some good fps but i highly doubt that because raspi has problem runnig (in twister os) even unreal tournament and raspi has 5 to 6 times higher performance than this software accel.
    Benchmarks i did were glxgears i got anywere from 200 to 270 fps which is not really much :D
    Also I used 2 desktop config started the one thats build in vnc from the app and then started sparkle connected to it and had second desktop start up using lxde on my phone on phone the screen really sucks to to work with so i used scrcpy to mirror the screen of phone to pc so basicaly a have full control remotly i hope that this will have future version development to improve on code so that we could get more performace out of this.
    Image below.
    zEsN.png
    2
    Xserver XSDL is useless in terms of using OpenGL and Sparkle or Termux:X11 (based on Sparkle) works much better with them. Here is Darkest Dungeon running in Termux proot with basic GPU acceleration using Turnip with KGSL, zink and early version of box64. Not at full speed, but Turnip is missing extension required by Zink (Xserver XSDL is erroring out on try of launch).
    Screenshot_20210526-173211.jpg
    1
    Thanks For tutorial! now looks good, i test glxgears and i got 200fps in Snapdragon 665 (Xubuntu)
    Screenshot_20210714-194007_Termux.png