Kivy: Buster RPi4B unable to find valuable Window provider from Desktop-less console

Created on 15 Aug 2019  Â·  113Comments  Â·  Source: kivy/kivy

After logging on the Raspberry Pi 4B to the command line (using raspi-config boot to CLI), cannot execute kivy because of critical error when attempting to use any kivy Window provider: egl_rpi, sdl2, pygame, or x11. This issue lists the attempts and results of each of these Window providers. These providers are listed on the following page:

https://kivy.org/doc/stable/guide/environment.html

KIVY_WINDOW
Implementation to use for creating the Window
Values: sdl2, pygame, x11, egl_rpi

Versions

Description

The same test.py program listed below was used to test all of the Window providers listed above. The second line is changed for each test results.

import os
#os.environ['KIVY_WINDOW'] = 'egl_rpi'
from kivy.app import App
from kivy.uix.button import Button

class TestApp(App):
    def build(self):
        return Button(text='Hello World')

TestApp().run()

When no (default) KIVY_WINDOW defined (test.py above), gets the following results:

[DEBUG  ] [Window      ] Provider <egl_rpi> ignored by config
[DEBUG  ] [Window      ] Provider <sdl2> ignored by config
[DEBUG  ] [Window      ] Provider <x11> ignored by config
[CRITICAL] [Window      ] Unable to find any valuable Window provider. 
[CRITICAL] [App         ] Unable to get a Window, abort.

After changing line 2 by removing the # sign, got the following results:

[DEBUG  ] [Window      ] Ignored <egl_rpi> (import error)
[DEBUG  ] [Window      ] Provider <sdl2> ignored by config
[DEBUG  ] [Window      ] Provider <x11> ignored by config
[CRITICAL] [Window      ] Unable to find any valuable Window provider. 
egl_rpi - ImportError: cannot import name 'bcm' from 'kivy.lib.vidcore_lite' (/usr/local/lib/python3.7/dist-packages/kivy/lib/vidcore_lite/__init__.py)
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/window_egl_rpi.py", line 12, in <module>
    from kivy.lib.vidcore_lite import bcm, egl
[CRITICAL] [App         ] Unable to get a Window, abort.

After changing line 2 to os.environ['KIVY_WINDOW'] = 'sdl2', got the following results:

[DEBUG  ] [Window      ] Provider <egl_rpi> ignored by config
[INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
[DEBUG  ] [Window      ] Provider <x11> ignored by config
[CRITICAL] [Window      ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
sdl2 - RuntimeError: b'Could not initialize EGL'
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/__init__.py", line 71, in core_select_lib
    cls = cls()
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/window_sdl2.py", line 152, in __init__
    super(WindowSDL, self).__init__()
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/__init__.py", line 981, in __init__
    self.create_window()
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/window_sdl2.py", line 290, in create_window
    self.get_gl_backend_name())
  File "kivy/core/window/_window_sdl2.pyx", line 224, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
  File "kivy/core/window/_window_sdl2.pyx", line 74, in kivy.core.window._window_sdl2._WindowSDL2Storage.die
[CRITICAL] [App         ] Unable to get a Window, abort.

After changing line 2 to os.environ['KIVY_WINDOW'] = 'pygame', got the following results:

[DEBUG  ] [Window      ] Provider <egl_rpi> ignored by config
[DEBUG  ] [Window      ] Provider <sdl2> ignored by config
[DEBUG  ] [Window      ] Provider <x11> ignored by config
[CRITICAL] [Window      ] Unable to find any valuable Window provider. 
[CRITICAL] [App         ] Unable to get a Window, abort.

After changing line 2 to os.environ['KIVY_WINDOW'] = 'x11', got the following results:

[DEBUG  ] [Window      ] Provider <sdl2> ignored by config
[DEBUG  ] [Window      ] Ignored <x11> (import error)
[CRITICAL] [Window      ] Unable to find any valuable Window provider. 
x11 - ModuleNotFoundError: No module named 'kivy.core.window.window_x11'
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
[CRITICAL] [App         ] Unable to get a Window, abort.

Most helpful comment

Here are the instructions on how to install and run a Kivy app at boot on Buster lite:

First install xserver-org, as we need it to show the actual window:

sudo apt-get -y install xserver-xorg

Next I install nodm from source, so it includes the following fix: https://github.com/spanezz/nodm/pull/10:

sudo apt-get -y install libpam0g-dev help2man libx11-dev debhelper
git clone https://github.com/slashblog/nodm.git
pushd nodm
    git checkout d48a8f6266d3f464138e0e95b65896917c35c89f
    source /etc/os-release  # Will set the 'VERSION' variable
    if [ "$(echo $VERSION | sed -En 's/[0-9]+ \(([a-z]+)\)/\1/p')" == "buster" ]; then
        wget http://deb.debian.org/debian/pool/main/n/nodm/nodm_0.13-5.debian.tar.xz
    else
        wget http://deb.debian.org/debian/pool/main/n/nodm/nodm_0.13-1.3.debian.tar.xz
    fi
    tar xf nodm_0.13-*.debian.tar.xz
    sudo dpkg-buildpackage -us -uc -b
popd
sudo dpkg -i nodm_0.13-*_armhf.deb
sudo rm -rf nodm*

Now enable graphical login:

sudo systemctl set-default graphical.target

Configure nodm and start our app at boot:

# Has the same effect as calling 'sudo dpkg-reconfigure nodm'
sudo sh -c 'echo "NODM_ENABLED=true" > /etc/default/nodm'
sudo sh -c 'echo "NODM_USER=$SUDO_USER" >> /etc/default/nodm' # Note that the variable SUDO_USER is used
sudo sh -c 'echo "NODM_FIRST_VT='\''7'\''" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_XSESSION=/etc/X11/Xsession" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_X_OPTIONS='\''-nolisten tcp'\''" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_MIN_SESSION_TIME=60" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_X_TIMEOUT=300" >> /etc/default/nodm'

# Start the app using nodm
echo '#!/bin/bash' > ~/.xsession
echo 'export DISPLAY=:0.0' >> ~/.xsession
echo "~/venv-kivy/bin/python3 ~/app.py" >> ~/.xsession

Setup a virtual enveriment:

sudo apt-get -y install python3-pip python3-venv
sudo pip3 install -U pip
python3 -m venv venv-kivy
source ~/venv-kivy/bin/activate

Install Kivy dependencies:

sudo apt-get -y install python3-dev libmtdev1 libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
sudo apt-get -y install pkg-config libgl1-mesa-dev libgles2-mesa-dev libgstreamer1.0-dev gstreamer1.0-plugins-{bad,base,good,ugly} gstreamer1.0-{omx,alsa} libmtdev-dev
pip3 install -U pygments docutils Cython==0.29.10 wheel

Now it's time for compiling and installing Kivy. Note that I use my fork with a patch, so it does not use the proprietary Broadcom drivers that are not available on the Raspberry Pi 4 (https://github.com/Lauszus/kivy/commit/9cdcada34a6149b7fd6bd4c57285afc828d69948):

export VIDEOCOREMESA=1; pip3 install git+https://github.com/Lauszus/kivy.git@rpi4_auto#egg=kivy

Finally create a small test app:

cat <<EOF > ~/app.py
from kivy.app import App
from kivy.uix.button import Button


class TestApp(App):

    def build(self):
        return Button(text='hello world')


if __name__ == '__main__':
    TestApp().run()
EOF

Now reboot and enjoy :)

All 113 comments

same behavior found in RPi 4B: 1G version. Previously, I saw in other SBC forum, to use sdl2 window provider, needs to recompile the sdl2 with KMS support. Not sure if this will be helpful.
Tinker Board: https://groups.google.com/forum/m/#!topic/kivy-users/jwBnYxe969g
Jetson Nano:
https://devtalk.nvidia.com/default/topic/1057120/kivy-app-fails-on-jetson-nano-/

Likewise, I spent three days of testing, attempting to find a viable Raspbian Lite configuration which would display a GUI on the SunFounder 10" touchscreen (reasonably compatible with the standard Raspberry Pi Foundation display) on a Raspberry Pi 4B with 4GB RAM.

Error condition: Kivy app crash (unresponsive) requiring a kill from another session
Error message: "failed to add service - already in use?" (seen after subsequent attempts)
Error: No GUI output (when using Legacy KMS option) immediately after boot but seemingly-happy log output

Well, I've already had problems with HDMI not functioning properly due to the new dual micro-HDMI ports. I have not tested the 7" Official Touchscreen with the 4B models and can imagine there is problems with that. I've reported the micro-HDMI issue. Good luck with the DSI.

I encountered failed to add service - already in use? on buster full, when trying to use the egl_rpi backend. Fixing it by commenting out dtoverlay=vc4-kms-v3d in /boot/config.txt made the error go away, but then kivy didn't show anything at all.

I wonder if it's the same on buster lite?

I encountered failed to add service - already in use? on buster full, when trying to use the egl_rpi backend. Fixing it by commenting out dtoverlay=vc4-kms-v3d in /boot/config.txt made the error go away, but then kivy didn't show anything at all.

I wonder if it's the same on buster lite?

Had same problem but now got. Just disabled openGL in raspi-config
x11 - ImportError: No module named window_x11
File "/home/pi/project/venv/local/lib/python2.7/site-packages/kivy/core/__init__.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
Using raspbian buster, python2.7, virtualenv and kivy 1.10.1.

@Gawezi You need to set kivy to use the egl_rpi window, not x11 by setting KIVY_WINDOW=egl_rpi. If you did mean to run x11, then make sure to compile kivy with x11 support at installation time (USE_X11=1).

Having the same/similar issue on Pi 3B running Buster on #6418 thank you for posting your progress and i'm really hoping the solution comes soon!

@matham Can you elaborate where to set USE_X11=1? I think this is my problem with both Buster and ALARM (haven’t tested this same issue from console boot without desktop). I’ve been trying to run kivy without desktop and think that’s my problem. I need to compile kivy with x11 support as you say.

@frankgould export VIDEOCOREMESA=1 environment variable before compiling kivy (https://github.com/kivy/kivy/commit/fa9932d812afd74f8524d17f5a85365e64ac39d7)

Otherwise it will always compile against proprietary drivers on rpi.
Further you must install x11 and start a session and start the kivy app inside the x11 session.
You can use a minimal window manager like i3wm which make things simpler.

@rnixx Thanks for the info. I’ll take a shot at that today.

USE_X11=1 needs to be in the environment when you compile kivy.

However, that is not likely to fix your issues of running kivy without desktop because if you run without desktop I'm guessing you're running without x support in the OS, so having x support in kivy won't help.

Only egl_rpi is supposed to work without x support afaik.

Thanks @matham. I added that key=Val combo in /etc/environment along with KIVY_GRAPHICS=“gles” and VIDEOCOREMESA=1 but none worked without the desktop. It could not open a window. I need to go dig into an older RPi3A+ to see how I installed it to get it to run without a desktop on ALARM.

Update: The above test were on ALARM 4.19, not Buster. So, this comment is outside this thread but relevant. I will be testing this on Buster next.

Today I tested RPi4B:4GB Raspbian 4.19 kivy installed with the following /etc/environment contents:

USE_X11=1
VIDEOCOREMESA=1
KIVY_GRAPHICS="gles"

Here is the results of the run using default environment values:

pi@SlideShowPi:~/SlideShow $ python3 test.py
[INFO   ] [Logger      ] Record log in /home/pi/.masterpics/logs/SlideShowPi_19-08-23_15.txt
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "/usr/local/lib/python3.7/dist-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.7.3 (default, Apr  3 2019, 05:39:12) 
[GCC 8.2.0]
[INFO   ] [Python      ] Interpreter at "/usr/bin/python3"
[INFO   ] [Factory     ] 184 symbols loaded
[DEBUG  ] [Cache       ] register <kv.lang> with limit=None, timeout=None
[DEBUG  ] [Cache       ] register <kv.image> with limit=None, timeout=60
[DEBUG  ] [Cache       ] register <kv.atlas> with limit=None, timeout=None
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[DEBUG  ] [Cache       ] register <kv.texture> with limit=1000, timeout=60
[DEBUG  ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600
[DEBUG  ] [Text        ] Provider <pango> ignored by config
[INFO   ] [Text        ] Provider: sdl2(['text_pango'] ignored)
[DEBUG  ] [App         ] Loading kv <./test.kv>
[DEBUG  ] [App         ] kv <./test.kv> not found
[DEBUG  ] [Window      ] Ignored <egl_rpi> (import error)
[INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
[DEBUG  ] [Window      ] Ignored <x11> (import error)
[CRITICAL] [Window      ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
egl_rpi - ImportError: cannot import name 'bcm' from 'kivy.lib.vidcore_lite' (/usr/local/lib/python3.7/dist-packages/kivy/lib/vidcore_lite/__init__.py)
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/window_egl_rpi.py", line 12, in <module>
    from kivy.lib.vidcore_lite import bcm, egl

sdl2 - RuntimeError: b'Could not initialize EGL'
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/__init__.py", line 71, in core_select_lib
    cls = cls()
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/window_sdl2.py", line 152, in __init__
    super(WindowSDL, self).__init__()
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/__init__.py", line 981, in __init__
    self.create_window()
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/window/window_sdl2.py", line 290, in create_window
    self.get_gl_backend_name())
  File "kivy/core/window/_window_sdl2.pyx", line 224, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window
  File "kivy/core/window/_window_sdl2.pyx", line 74, in kivy.core.window._window_sdl2._WindowSDL2Storage.die

x11 - ModuleNotFoundError: No module named 'kivy.core.window.window_x11'
  File "/usr/local/lib/python3.7/dist-packages/kivy/core/__init__.py", line 63, in core_select_lib
    fromlist=[modulename], level=0)

[CRITICAL] [App         ] Unable to get a Window, abort.
  • Raspberry Pi 4B with 4GB
  • Raspbian Buster Lite 7-10-2019
  • Kivy 1.11.1
  • Python 3.7.3
  • SunFounder 10.1" capacitive TFT display

I'm getting a segmentation fault on my rig.

gdb --args python3 test.py # then press 'r' to run it

GNU gdb (Raspbian 8.2.1-2) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python3...(no debugging symbols found)...done.
(gdb) r

Starting program: /usr/bin/python3 test.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[INFO   ] [Logger      ] Record log in /home/pi/.kivy/logs/kivy_19-08-23_16.txt
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "/usr/local/lib/python3.7/dist-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.7.3 (default, Apr  3 2019, 05:39:12) 
[GCC 8.2.0]
[INFO   ] [Python      ] Interpreter at "/usr/bin/python3"
[Detaching after fork from child process 3301]
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2(['text_pango'] ignored)
[INFO   ] [Window      ] Provider: sdl2(['window_egl_rpi'] ignored)
[New Thread 0xb4171460 (LWP 3302)]
[New Thread 0xb37ff460 (LWP 3303)]
[New Thread 0xb2ffe460 (LWP 3304)]
[New Thread 0xb27fd460 (LWP 3305)]
[INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
[INFO   ] [GL          ] Backend used <gl>

Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0xb6fbc1dc in strlen () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so

I think I found my solution for Arch Linux build on RPi3A+. Below is what the boot executes on auto-login and my start screen systemd service, also below. So, it appears the boot starts X11 and that's how kivy starts (on pastebin). I need to test this on Buster to see if I get the same results.

.xinitrc content:

#!/bin/sh
# ~/.xinitrc
# Executed by startx (run your window manager from here)
if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi

exec startlxde

My screen-start.service:

[Unit]
Description=Remote Control Screen
Requires=time-sync.target
After=time-sync.target

[Service]
Environment="DISPLAY=:0.0"
ExecStart=/usr/bin/python3 /home/remote/app/main.py
RemainAfterExit=yes
Restart=always
RestartSec=3

[Install]
WantedBy=default.target

The kivy environment value at startup:

#! /usr/bin/python3
import os
os.environ['KIVY_VIDEO']='ffpyplayer'

This runs both ways on Buster with Pi3B+
But for the Pi4 I've found a few things I should investigate. But that's on Monday @OutsourcedGuru ?!

Actually, I'm here on a Saturday testing this nonsense.

Same Raspbian Lite rig as stated above, plus attempting to add the x11 interface. I tried to just get the bare minimum but that wouldn't bring up the GUI desktop. Starting it from the Pi itself having started x then worked as seen below.

sudo apt-get install --no-install-recommends xserver-xorg # Trying for the PIXEL desktop
sudo apt-get install --no-install-recommends xinit # Need the startx script
sudo pip3 install --force-reinstall kivy
python3 test.py # Didn't work - segmentation fault
startx # Didn't work - wouldn't start the desktop
sudo apt-get install --yes raspberrypi-ui-mods # Desktop
python3 test.py # Didn't work - segmentation fault
startx # Worked - then open a terminal from the upper menu
python3 test.py # Works - displays a window

Same Raspbian Lite rig (with x11/Desktop added) still suffers in the Python2 world. It freezes up, isn't responsive to Ctl-C, doesn't display another window, logs normally otherwise.

@OutsourcedGuru You should ignore using python2 from the beginning. Its support ends this year.
So what you should do is only install for python3 and use only pip3. I don't know why Raspbian haven't put python3 to be the default python. If you follow up with Arch Linux you'll know python3 is the default version which is perfect.

And yet, since January I've been working on a plugin for OctoPrint. It doesn't yet support Py3 on the master branch. I've just spent all morning rigging up something to their devel branch to test this. I'll likely spend days modifying my plugin in an effort to get it to work on something that's not even pushed to the viable platform. And then I can cross my fingers and hope that their code-in-development doesn't break my own stuff. (This is for what will be a production printer and beta code isn't normally what you prefer in a case like this.)

“Alas, poor Yorick, I knew him well.”

@OutsourcedGuru, I once read a Raspberry Pi moderator say that no one should base a business model on Raspbian, or Raspberry Pi for that matter. He could be right at the time but over time, they make progress for more possibilities. As you can see above, I got ALARM to work with my app; however, since then the HDMI audio is hosed. It’s clean in python command line but when running from systemd, it’s garbage.

So, it’s a tech curve that developers are chasing. You can pound on it all day, like I did today, and still get no results. Just keep pounding, if it’s worth it for you.

Did anyone try this suggestion? Looks like he's changing KIVY_TEXT as well. I will try this weekend if I get a chance.

https://stackoverflow.com/questions/56947840/kivy-1-10-1-and-1-11-0-not-working-on-raspberry-pi4-buster

So everyone still unable to get Kivy running on Buster..?

It's easy to run Kivy programs on the desktop version, but still didn't find a way to work myself to start it in console boot.

Anyone else?

Thanks haha, I feel pretty dumb for not trying that now... I had only been trying through ssh but just gave it a shot through vnc and it did indeed work. If it's of any interest, tkinter (other python UI library) also does not work through console but does with desktop.

I do really need a reliable way to start from console or at least startup but thank you for mentioning this I finally have a workaround!

@masynthetic On ALARM, my .xinitrc starts windows then my Kivy app autoruns after windows are up. I can give more info if you need it. I’m not in my office right now and need to boot the tablet to see exactly how I implemented it.

That would be extremely helpful thanks, no rush as I mostly just need a
development environment at this time

On Sat, Sep 14, 2019, 3:17 AM Frank Gould notifications@github.com wrote:

@masynthetic https://github.com/masynthetic On ALARM, my .xinitrc
starts windows then my Kivy app autoruns after windows are up. I can give
more info if you need it. I’m not in my office right now and need to boot
the tablet to see exactly how I implemented it.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/kivy/kivy/issues/6474?email_source=notifications&email_token=AEOWUVKTRWPPLKDVSMG2ERDQJS25HA5CNFSM4IL7DFSKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6WY6MA#issuecomment-531468080,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEOWUVMTOIQUCNBD7EKOK3TQJS25HANCNFSM4IL7DFSA
.

That would be useful. @frankgould

I do think we need a good solution for the the Desktop-less version of this. I'm hoping to just return to this later and the underlying operating system and driver set works as it did before. Being cynical, I kind of doubt it though.

I never got kivy to work on debian Jessie without a patch either. But if you are okay with using egl, then I have found it useful in the past to patch the initializer in kivy/core/window/window_egl_rpi.py, by replacing:

-    def create_window(self):
+    def create_window(self, *args):

I had similar issues with an older version of kivy a couple of months ago, and this did the trick.

If I remember correctly, creating a window using egl fails by default because extra arguments are passed. The exception is caught somewhere, and ignored.

On Debian Jessie, this patch solved all problems for me, but I have not tested this on Buster.

It could still be that the egl option is ignored due to this commit: 333a4cc9c7b4b3168f7427d27f4fdea2a69bc52b.

Anyway, ymmv.

@ahendriksen Assuming a virtual environment, does one just patch the file in place or is some reinstall necessary after patching? (Thanks.)

You can do it in-place, but I doubt this is the issue here, because I have not seen this in any traceback posted in the buster issues. But, if there is a traceback showing this error though, it would be helpful to post so we ca fix it.

@OutsourcedGuru In my experience, patching in-place should work.

@matham, I have just installed buster on a raspberry pi. I will post back soon.

I can report that on a Pi 3 Model B+ with Buster the current master branch (2.0.0-dev0) works fine.
No patch to window_egl_rpi.pi was necessary.

It doesn't seem to be working for me, for what it's worth. I bailed on that and spent the day on the Buster Desktop with Python 3 attempt.

So far, no solution to Kivy on Buster Lite on Raspberry Pi 4, right?
RPi4 4GB
Rpi Official Display
Raspbian Buster 2019-09-26
Python: 3.7.3
Kivy: v2.0.0.dev0

First time running a simple Kivy file after boot I have the following log and no screen:
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_19-10-02_7.txt
[INFO ] [Kivy ] v2.0.0.dev0, git-f223133, 20191002
[INFO ] [Kivy ] Installed at "/usr/local/lib/python3.7/dist-packages/kivy/__init__.py"
[INFO ] [Python ] v3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0]
[INFO ] [Python ] Interpreter at "/usr/bin/python"
[INFO ] [Factory ] 184 symbols loaded
[DEBUG ] [Cache ] register with limit=None, timeout=None
[DEBUG ] [Cache ] register with limit=None, timeout=60
[DEBUG ] [Cache ] register with limit=None, timeout=None
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[DEBUG ] [Cache ] register with limit=1000, timeout=60
[DEBUG ] [Cache ] register with limit=1000, timeout=3600
[DEBUG ] [App ] Loading kv <./test.kv>
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: egl_rpi
[DEBUG ] [Window ] Actual display size: 800x480
[INFO ] [GL ] Using the "OpenGL ES 2" graphics system
[DEBUG ] [GL ] glShaderBinary is not available
[INFO ] [GL ] Backend used
[INFO ] [GL ] OpenGL version
[INFO ] [GL ] OpenGL vendor
[INFO ] [GL ] OpenGL renderer
[INFO ] [GL ] OpenGL parsed version: 2, 0
[INFO ] [GL ] Shading version
[INFO ] [GL ] Texture max size <2048>
[INFO ] [GL ] Texture max units <8>
[DEBUG ] [Shader ] Fragment compiled successfully
[DEBUG ] [Shader ] Vertex compiled successfully
[DEBUG ] [ImageSDL2 ] Load
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[DEBUG ] [Resource ] add in path list
[DEBUG ] [Resource ] add in path list
[DEBUG ] [Resource ] add in path list
[DEBUG ] [Resource ] add in path list
[DEBUG ] [Resource ] add in path list
[DEBUG ] [Base ] Create provider from mouse
[DEBUG ] [Base ] Create provider from probesysfs,provider=mtdev
[DEBUG ] [ProbeSysfs ] using probesysfs!
[DEBUG ] [ProbeSysfs ] found device: FT5406 memory based driver at /dev/input/event0
[INFO ] [ProbeSysfs ] device match: /dev/input/event0
[INFO ] [MTD ] Read event from
[DEBUG ] [Base ] Create provider from probesysfs,provider=hidinput
[DEBUG ] [ProbeSysfs ] using probesysfs!
[DEBUG ] [ProbeSysfs ] found device: FT5406 memory based driver at /dev/input/event0
[INFO ] [ProbeSysfs ] device match: /dev/input/event0
[INFO ] [HIDInput ] Read event from
[INFO ] [Base ] Start application main loop
[INFO ] [MTD ] range position X is 0 - 800
[INFO ] [MTD ] range position Y is 0 - 480
[INFO ] [MTD ] range touch major is 0 - 0
[INFO ] [MTD ] range touch minor is 0 - 0
[INFO ] [MTD ] range pressure is 0 - 255
[INFO ] [MTD ] axes invertion: X is 0, Y is 0
[INFO ] [MTD ] rotation set to 0
[INFO ] [HIDMotionEvent] using
[INFO ] [GL ] NPOT texture support is available
[INFO ] [HIDMotionEvent] range ABS X position is 0 - 800
[INFO ] [HIDMotionEvent] range ABS Y position is 0 - 480
[INFO ] [HIDMotionEvent] range position X is 0 - 800
[INFO ] [HIDMotionEvent] range position Y is 0 - 480
[DEBUG ] [Atlas ] Load
[DEBUG ] [Atlas ] Need to load 1 images
[DEBUG ] [Atlas ] Load
[DEBUG ] [ImageSDL2 ] Load

And the second time I have no screen, but my log is smaller:
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_19-10-02_8.txt
[INFO ] [Kivy ] v2.0.0.dev0, git-f223133, 20191002
[INFO ] [Kivy ] Installed at "/usr/local/lib/python3.7/dist-packages/kivy/__init__.py"
[INFO ] [Python ] v3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0]
[INFO ] [Python ] Interpreter at "/usr/bin/python"
[INFO ] [Factory ] 184 symbols loaded
[DEBUG ] [Cache ] register with limit=None, timeout=None
[DEBUG ] [Cache ] register with limit=None, timeout=60
[DEBUG ] [Cache ] register with limit=None, timeout=None
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[DEBUG ] [Cache ] register with limit=1000, timeout=60
[DEBUG ] [Cache ] register with limit=1000, timeout=3600
[DEBUG ] [App ] Loading kv <./test.kv>
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: egl_rpi
[DEBUG ] [Window ] Actual display size: 800x480

Has anyone managed to make it work?

The same SD Card works well on the RPi3B+. These logs are from RPI4 4GB.

I haven't been able to get anything to work on the Desktop-less Raspbian Buster. It's probably due to the OpenGL ES v3 interface (rather than the expected v2) in Raspbian's driver stack. Or it's something odd due to the dual HDMI adapters.

So far, no solution to Kivy on Buster Lite on Raspberry Pi 4, right?
RPi4 4GB
Rpi Official Display
Raspbian Buster 2019-09-26
Python: 3.7.3
Kivy: v2.0.0.dev0

First time running a simple Kivy file after boot I have the following log and no screen:
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_19-10-02_7.txt
[INFO ] [Kivy ] v2.0.0.dev0, git-f223133, 20191002
[INFO ] [Kivy ] Installed at "/usr/local/lib/python3.7/dist-packages/kivy/init.py"
[INFO ] [Python ] v3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0]
[INFO ] [Python ] Interpreter at "/usr/bin/python"
[INFO ] [Factory ] 184 symbols loaded
[DEBUG ] [Cache ] register with limit=None, timeout=None
[DEBUG ] [Cache ] register with limit=None, timeout=60
[DEBUG ] [Cache ] register with limit=None, timeout=None
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[DEBUG ] [Cache ] register with limit=1000, timeout=60
[DEBUG ] [Cache ] register with limit=1000, timeout=3600
[DEBUG ] [App ] Loading kv <./test.kv>
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: egl_rpi
[DEBUG ] [Window ] Actual display size: 800x480
[INFO ] [GL ] Using the "OpenGL ES 2" graphics system
[DEBUG ] [GL ] glShaderBinary is not available
[INFO ] [GL ] Backend used
[INFO ] [GL ] OpenGL version
[INFO ] [GL ] OpenGL vendor
[INFO ] [GL ] OpenGL renderer
[INFO ] [GL ] OpenGL parsed version: 2, 0
[INFO ] [GL ] Shading version
[INFO ] [GL ] Texture max size <2048>
[INFO ] [GL ] Texture max units <8>
[DEBUG ] [Shader ] Fragment compiled successfully
[DEBUG ] [Shader ] Vertex compiled successfully
[DEBUG ] [ImageSDL2 ] Load
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[DEBUG ] [Resource ] add in path list
[DEBUG ] [Resource ] add in path list
[DEBUG ] [Resource ] add in path list
[DEBUG ] [Resource ] add in path list
[DEBUG ] [Resource ] add in path list
[DEBUG ] [Base ] Create provider from mouse
[DEBUG ] [Base ] Create provider from probesysfs,provider=mtdev
[DEBUG ] [ProbeSysfs ] using probesysfs!
[DEBUG ] [ProbeSysfs ] found device: FT5406 memory based driver at /dev/input/event0
[INFO ] [ProbeSysfs ] device match: /dev/input/event0
[INFO ] [MTD ] Read event from
[DEBUG ] [Base ] Create provider from probesysfs,provider=hidinput
[DEBUG ] [ProbeSysfs ] using probesysfs!
[DEBUG ] [ProbeSysfs ] found device: FT5406 memory based driver at /dev/input/event0
[INFO ] [ProbeSysfs ] device match: /dev/input/event0
[INFO ] [HIDInput ] Read event from
[INFO ] [Base ] Start application main loop
[INFO ] [MTD ] range position X is 0 - 800
[INFO ] [MTD ] range position Y is 0 - 480
[INFO ] [MTD ] range touch major is 0 - 0
[INFO ] [MTD ] range touch minor is 0 - 0
[INFO ] [MTD ] range pressure is 0 - 255
[INFO ] [MTD ] axes invertion: X is 0, Y is 0
[INFO ] [MTD ] rotation set to 0
[INFO ] [HIDMotionEvent] using
[INFO ] [GL ] NPOT texture support is available
[INFO ] [HIDMotionEvent] range ABS X position is 0 - 800
[INFO ] [HIDMotionEvent] range ABS Y position is 0 - 480
[INFO ] [HIDMotionEvent] range position X is 0 - 800
[INFO ] [HIDMotionEvent] range position Y is 0 - 480
[DEBUG ] [Atlas ] Load
[DEBUG ] [Atlas ] Need to load 1 images
[DEBUG ] [Atlas ] Load
[DEBUG ] [ImageSDL2 ] Load

And the second time I have no screen, but my log is smaller:
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_19-10-02_8.txt
[INFO ] [Kivy ] v2.0.0.dev0, git-f223133, 20191002
[INFO ] [Kivy ] Installed at "/usr/local/lib/python3.7/dist-packages/kivy/init.py"
[INFO ] [Python ] v3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0]
[INFO ] [Python ] Interpreter at "/usr/bin/python"
[INFO ] [Factory ] 184 symbols loaded
[DEBUG ] [Cache ] register with limit=None, timeout=None
[DEBUG ] [Cache ] register with limit=None, timeout=60
[DEBUG ] [Cache ] register with limit=None, timeout=None
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[DEBUG ] [Cache ] register with limit=1000, timeout=60
[DEBUG ] [Cache ] register with limit=1000, timeout=3600
[DEBUG ] [App ] Loading kv <./test.kv>
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: egl_rpi
[DEBUG ] [Window ] Actual display size: 800x480

Has anyone managed to make it work?

The same SD Card works well on the RPi3B+. These logs are from RPI4 4GB.

By now it is impossible to run any kivy app in a Desktop-less RPi4. It's a drivers failure, so we have to wait for some patch in the next kivy release (or master).

[INFO ] [Window ] Provider: egl_rpi

I really don't think you're going to get Kivy (any version) to talk to the egl_rpi Window provider because Kivy's linked with gles2.h rather than some unicorn named gles3.h which doesn't exist from what I can see. The Pi4B uses OpenGL ES v3.

Try adjusting the configuration so that Kivy asks for sdl2 or something else. Read through Frank's posts here.

Is there some way to install the Google Angle code on the Pi (to get the OpenGL ES 3.0 headers perhaps) and then patch the Kivy egl_rpi provider to pull in the gles3.h instead of gles2.h (or similar)?

Here are the instructions on how to install and run a Kivy app at boot on Buster lite:

First install xserver-org, as we need it to show the actual window:

sudo apt-get -y install xserver-xorg

Next I install nodm from source, so it includes the following fix: https://github.com/spanezz/nodm/pull/10:

sudo apt-get -y install libpam0g-dev help2man libx11-dev debhelper
git clone https://github.com/slashblog/nodm.git
pushd nodm
    git checkout d48a8f6266d3f464138e0e95b65896917c35c89f
    source /etc/os-release  # Will set the 'VERSION' variable
    if [ "$(echo $VERSION | sed -En 's/[0-9]+ \(([a-z]+)\)/\1/p')" == "buster" ]; then
        wget http://deb.debian.org/debian/pool/main/n/nodm/nodm_0.13-5.debian.tar.xz
    else
        wget http://deb.debian.org/debian/pool/main/n/nodm/nodm_0.13-1.3.debian.tar.xz
    fi
    tar xf nodm_0.13-*.debian.tar.xz
    sudo dpkg-buildpackage -us -uc -b
popd
sudo dpkg -i nodm_0.13-*_armhf.deb
sudo rm -rf nodm*

Now enable graphical login:

sudo systemctl set-default graphical.target

Configure nodm and start our app at boot:

# Has the same effect as calling 'sudo dpkg-reconfigure nodm'
sudo sh -c 'echo "NODM_ENABLED=true" > /etc/default/nodm'
sudo sh -c 'echo "NODM_USER=$SUDO_USER" >> /etc/default/nodm' # Note that the variable SUDO_USER is used
sudo sh -c 'echo "NODM_FIRST_VT='\''7'\''" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_XSESSION=/etc/X11/Xsession" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_X_OPTIONS='\''-nolisten tcp'\''" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_MIN_SESSION_TIME=60" >> /etc/default/nodm'
sudo sh -c 'echo "NODM_X_TIMEOUT=300" >> /etc/default/nodm'

# Start the app using nodm
echo '#!/bin/bash' > ~/.xsession
echo 'export DISPLAY=:0.0' >> ~/.xsession
echo "~/venv-kivy/bin/python3 ~/app.py" >> ~/.xsession

Setup a virtual enveriment:

sudo apt-get -y install python3-pip python3-venv
sudo pip3 install -U pip
python3 -m venv venv-kivy
source ~/venv-kivy/bin/activate

Install Kivy dependencies:

sudo apt-get -y install python3-dev libmtdev1 libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev
sudo apt-get -y install pkg-config libgl1-mesa-dev libgles2-mesa-dev libgstreamer1.0-dev gstreamer1.0-plugins-{bad,base,good,ugly} gstreamer1.0-{omx,alsa} libmtdev-dev
pip3 install -U pygments docutils Cython==0.29.10 wheel

Now it's time for compiling and installing Kivy. Note that I use my fork with a patch, so it does not use the proprietary Broadcom drivers that are not available on the Raspberry Pi 4 (https://github.com/Lauszus/kivy/commit/9cdcada34a6149b7fd6bd4c57285afc828d69948):

export VIDEOCOREMESA=1; pip3 install git+https://github.com/Lauszus/kivy.git@rpi4_auto#egg=kivy

Finally create a small test app:

cat <<EOF > ~/app.py
from kivy.app import App
from kivy.uix.button import Button


class TestApp(App):

    def build(self):
        return Button(text='hello world')


if __name__ == '__main__':
    TestApp().run()
EOF

Now reboot and enjoy :)

Need Install Instructions for RPi4B with Raspbian Buster full

Test:

RPi4 4GB
7' HDMI Display ( work by one micro hdmi near type-C)
config.ini

max_usb_current=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 1024 600 60 6 0 0 0
hdmi_drive=1

Raspbian Buster 2019-09-26 full

Log: Error "* failed to add service - already in use?"

pi@raspberrypi:~/kivy-examples/3Drendering $ python main.py
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_19-10-19_10.txt
[INFO ] [Kivy ] v1.11.0
[INFO ] [Kivy ] Installed at "/usr/local/lib/python2.7/dist-packages/kivy/__init__.pyc"
[INFO ] [Python ] v2.7.16 (default, Apr 6 2019, 01:42:57)
[GCC 8.2.0]
[INFO ] [Python ] Interpreter at "/usr/bin/python"
[WARNING] [Deprecated ] Python 2 Kivy support has been deprecated. The Kivy release after 1.11.0 will not support Python 2 anymore
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO ] [Window ] Provider: egl_rpi

  • failed to add service - already in use?

@Lauszus I'll test this sometime this weekend. Thanks for your help on this. :)

@diamond2nv "...with Raspbian Buster full" If by this you mean Raspbian Buster _Desktop_ then the instructions are in a Kivy Issue here.

Thanks a lot !
Problem solved by that instruction.

PS. "2019-09-26-raspbian-buster-full.img"

@Lauszus Okay, I've tested this on...

  • Raspberry Pi 4B (4GB)
  • elo 10.1" capacitive touchscreen
  • Raspbian Buster Lite 9/26/2019 -> "Linux octopi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l"
  • sudo apt-get update && sudo apt-get -y upgrade to start
  • sudo raspi-config with Localization, auto-boot to CLI _and for my install, Interfaces changes (I2C/UART/camera)_

I'm noting that I prepped all this by performing the Raspbian recovery process because I'd earlier run rpi-update in an attempt to make this work. This is known to change firmware stored on a chip, so I reverted to the released version.

Otherwise, I followed your instructions. Additionally, I updated the configuration to allow the touchscreen device to work.

Edit to ~/.kivy/config.ini:

[input]
mouse = mouse
#%(name)s = probesysfs,provider=hidinput
mtdev_%(name)s = probesysfs,provider=mtdev
hid_%(name)s = probesysfs,provider=hidinput

Fix for fullscreen

It isn't coming up "fullscreen" so I'm thinking that I'll need to play with the settings a little. It's perhaps 800x640 instead of the expected 1280x800. This might be in the Raspbian /boot/config.txt, the Kivy ~/.kivy/config.ini file or the xsession configuration...

On a hunch, though, I just adjusted the test app by including the following near the top:

from kivy.core.window import Window
Window.fullscreen = True

This appears to do the trick to adjust the app to be fullscreen, as expected.

Many thanks! I'd be very much interested to know when this is pulled into the master branch of Kivy itself.

@OutsourcedGuru please see the PR I opened: https://github.com/kivy/kivy/pull/6562.

It would be great if you could try it with VIDEOCOREMESA=0 and VIDEOCOREMESA=1 and see if there is any performance difference.

@Lauszus: Nice work - works very nicely.

Also to @OutsourcedGuru.

@Lauszus I went to re-test earlier but I thought you deleted that branch...(?) so I couldn't.

@OutsourcedGuru as I wrote earlier. I ended up opening a new one that will auto detect when it's running in a Raspberry Pi 4. Anyway I also found a way to cross compile the wheel, so users do not have to compile Kivy themselves. Please download the wheel here: https://github.com/Lauszus/kivy/suites/285162135/artifacts/197175 and then comment on the following PR when you have tested it: https://github.com/kivy/kivy/pull/6568.

@Lauszus Thanks to your help I got an older app from RPI3B+ running on RPI4 with your nodm method.
It starts automatically at boot and it's great, it's how I plan on using it.
But I'm having some other issues with the app that I need to debug and I'm not sure now how to get normal output from it as when I start the app from the cli as in 'python3 app.py'.
Do you have any tips on how I can achieve that?
It would be really appreciated.
Thanks so much again, I wouldn't have made it this far without your post.
Cheers!

@lucasnzone I simply use the logger functionality instead of print statements: https://kivy.org/doc/stable/api-kivy.logger.html.

Then I use the following script to restart Kivy and follow the log:

#!/bin/bash -e

if [[ $* == *--restart* ]]; then
    sudo service nodm restart
    inotifywait -q ~/.kivy/logs -e create --format %w%f | xargs tail -f
else
    ls -t -d ~/.kivy/logs/* | head -n1 | xargs tail -f
fi

I haven't been able to test this, sorry for the delay. It's about two weeks for FormNext so we're scrambling here, for what it's worth.

As I recall from my earlier testing, the small Kivy test program worked but the OctoPrint plugin which used Kivy did not seem to be happy. I spent a fair bit of time trying to change-up the way that OctoPrint loaded (to allow nodm to control that service). The OctoPrint plugin needs to load within a virtual environment and normally happens as a service. I didn't have the quality time to chase that rabbit to the bottom of its hole.

@Lauszus Thank you so much for that, I hadn't thought of it, i'll give it a try.
Thanks again mate

Frabjous day. I've managed to get a working platform for the following:

  • Kivy 1.10.1 installed in a virtual environment
  • Python 2.7
  • Raspbian Buster Lite
  • OctoPrint 1.3.12 (from the OctoPi 0.17.0 IMG)
  • ffpyplayer (had to revert to the gstplayer due to Pi4B incompatibilities)
  • nodm
  • OctoPrint plugin using Kivy

It successfully brings up a fullscreen GUI at bootup and on reboots.

From the Python code...

    if pi_type == '4B':
        os.environ['VIDEOCOREMESA'] =       '1'
        os.environ['KIVY_WINDOW'] =         'sdl2'
        os.environ['KIVY_GL_BACKEND'] =     'gl'
        os.environ['rpi'] =                 '0'
        from kivy.core.window               import Window
        Window.fullscreen =                 True

The config.ini needs to include the screen dimensions as well as to adjust for the TFT screen's input device.

Need Install Instructions for RPi4B with Raspbian Buster full

Test:

RPi4 4GB
7' HDMI Display ( work by one micro hdmi near type-C)
config.ini

max_usb_current=1
hdmi_group=2
hdmi_mode=87
hdmi_cvt 1024 600 60 6 0 0 0
hdmi_drive=1

Raspbian Buster 2019-09-26 full

Log: Error "* failed to add service - already in use?"

pi@raspberrypi:~/kivy-examples/3Drendering $ python main.py
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_19-10-19_10.txt
[INFO ] [Kivy ] v1.11.0
[INFO ] [Kivy ] Installed at "/usr/local/lib/python2.7/dist-packages/kivy/init.pyc"
[INFO ] [Python ] v2.7.16 (default, Apr 6 2019, 01:42:57)
[GCC 8.2.0]
[INFO ] [Python ] Interpreter at "/usr/bin/python"
[WARNING] [Deprecated ] Python 2 Kivy support has been deprecated. The Kivy release after 1.11.0 will not support Python 2 anymore
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO ] [Window ] Provider: egl_rpi

  • failed to add service - already in use?

Hi @diamond2nv, Can you run kivy from the CLI already?

@elisandrom please see my comment: https://github.com/kivy/kivy/issues/6474#issuecomment-542679712

@elisandrom please see my comment: #6474 (comment)

Thanks !!!!!! Works perfect !!!

For anyone that is interested, then a cross compiled wheel can be downloaded here: https://github.com/kivy/kivy/suites/364981942/artifacts/751103.

Simply follow these instructions on how to install all the dependencies: https://github.com/kivy/kivy/issues/6474#issuecomment-542679712, but instead of compiling Kivy from source you should be able to install it using the precompiled wheel:

pip install Kivy-2.0.0.dev0-cp37-cp37m-linux_armv7l.whl

It would be great if we could get a couple of people to test this, so #6568 can get merged.

@Lauszus Can we confirm the Kivy version on that wheel? I have to assume that it's 2.0.0.dev0 from the title of the wheel. I'm really not sure what's in this. I assume that it requires Python 3 for the virtual environment, though.

@OutsourcedGuru yes that is correct. It's basically just the master branch with the commits in #6568. Here's the action where it was build: https://github.com/kivy/kivy/runs/354828981.

Yes it requires Python 3.7, as that is standard in Buster. You can install it either globally or in a virtual environment, that's up to you.

For what it's worth, I've managed to upgrade my production platform to Python 3 + Kivy 1.11.1 on Raspbian Lite, having installed nodm with limited x windows support as seen below. It works as expected on the Pi 4B. The install was simply pip install kivy==1.11.1 in the virtual environment.

sudo apt-get -y install xserver-xorg libpam0g-dev help2man libx11-dev debhelper

Given https://github.com/kivy/kivy/issues/6474#issuecomment-542679712, it seems that the only solution so far on the Raspberry Pi 4 is to use X11. Is there no longer support for the non-X framebuffer as there was on previous RPis? I'm trying to upgrade my project from a Raspberry Pi 3B+ to a Raspberry Pi 4, but I don't want to start installing X11 just to be able to display things.

@whitelynx I experimented with compiling SDL2 without X on the Raspberry Pi 4. However it kept complaining about that it could not find a Window: https://github.com/kivy/kivy/pull/6662#issuecomment-573423540. So far I can only get it working if I use a window manager like nodm.

Here's a code example that creates a opengles window on rpi4 without X.
https://github.com/matusnovak/rpi-opengl-without-x/blob/master/triangle_rpi4.c
https://www.raspberrypi.org/forums/viewtopic.php?t=243707#p1499181
Is it possible some similar code could be used to draw a kivy window?

Note that the first example brings in gl2.h. To the best of my knowledge the Pi4B uses gl3.

I tested them both on my rpi4b and they worked without issue. The first example writes to a raw file and you can view the triangle onscreen by uncommenting line 384.

@Lauszus The issue with not being able to find a window when running with SDL2 w/o X11 is because the SDL2 create window code specifies 8 alpha bits for the window. If it's changed to 0 alpha bits in kivy.core.window._window_sdl2.pyx then it'll work.

@ddimensia I tried changing
138: SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8)
to
138: SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 0)
But I'm still getting the same errors when trying to create a window:
[CRITICAL] [Window ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes sdl2 - RuntimeError: Could not initialize EGL File "/usr/local/lib/python2.7/dist-packages/Kivy-1.11.0-py2.7-linux-armv7l.egg/kivy/core/__init__.py", line 71, in core_select_lib cls = cls() File "/usr/local/lib/python2.7/dist-packages/Kivy-1.11.0-py2.7-linux-armv7l.egg/kivy/core/window/window_sdl2.py", line 152, in __init__ super(WindowSDL, self).__init__() File "/usr/local/lib/python2.7/dist-packages/Kivy-1.11.0-py2.7-linux-armv7l.egg/kivy/core/window/__init__.py", line 969, in __init__ self.create_window() File "/usr/local/lib/python2.7/dist-packages/Kivy-1.11.0-py2.7-linux-armv7l.egg/kivy/core/window/window_sdl2.py", line 289, in create_window self.fullscreen, resizable, state) File "kivy/core/window/_window_sdl2.pyx", line 225, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window File "kivy/core/window/_window_sdl2.pyx", line 75, in kivy.core.window._window_sdl2._WindowSDL2Storage.die

Do you have a repo with all the changes required to get sdl2 + kivy to work on a rpi4 without X?

I basically follow the Amiberry instructions for compiling SDL2 (https://github.com/midwan/amiberry/wiki/Compile-SDL2-from-source) with the minimum requirements and also compile SDL2_mixer from source, which requires a few other libs if you want mp3, flac, etc support. Then I modified the Alpha bits to 0 in the _window_sdl2.pyx file. Finally I modified the setup.py to force use_x11 to False (in the one spot it sets it to True) and ran export VIDEOCOREMESA=1 and then pip install .. I believe that was it. One thing I did different when compiling all of the SDL2 libraries is when I ran configure I added --prefix=/usr to the args to install the libs in the normal location rather than /usr/local/lib.

@ddimensia thank you! That worked :)

@ddimensia I just opened up a PR with the changes: https://github.com/kivy/kivy/pull/6769. I'm waiting for the CI to complete the build, so I can verify that the wheel build by it will work as well.

@ddimensia the VIDEOCOREMESA=1 was not needed, so I left it out.

@Lauszus Hi again mate.
I found your kivy container at https://hub.docker.com/u/lauszus
I was wondering if you could point me in the right direction with getting kivy running inside a container.
I mean, I got it running fine, it displays on a touchscreen.
But no matter what I do, I can't get the touchscreen working inside the container.
Would you know anything about that?
Thanks in advance.
Cheers

@lucasnzone that's an old container I used when experimenting with cross compiling Kivy to speed up my builds. I never actually ran Kivy inside the contrainer I just used it for compiling it.

Anyway a quick search tell me that it should be possible using the --device argument when running the container i.e:

--device /dev/input/event0

should add your touchscreen to the container.

See: https://docs.docker.com/engine/reference/commandline/run/

@Lauszus hey mate, thanks for your answer.
this is in my docker run command
--privileged --net host --device /dev/gpiomem:/dev/gpiomem --device /dev/ttyAMA0:/dev/ttyAMA0 -v /boot/overlay:/boot/overlay
I've just tested it with adding --device /dev/input/event0
but still no luck.
I'm about to give up trying with a container all together. I can't even get the kivy samples working.
I'm even running the container with --privileged with no luck.
Would you say this is a docker configuration issue or a kivy configuration issue?
I'm honestly lost, i've spent a week on this and couldn't figure it out.
thanks again for your reply mate, really appreciated

Have you verified that your touchscreen actually is /dev/input/event0?

Why do you want to run it in a container anyway if you are just messing around with the examples? Just use a Python virtual environment and install the required dependencies for your OS using the package manage i.e. apt etc.

@lucasnzone I forgot to ask if you are using a Raspberry Pi or some other platform? Also which OS are you using?

@Lauszus RPI4 with raspbian lite
oh, no, i've got an actuall app that I want to run in a container because it'll make distribution and version control way easier.
I was trying with the examples because if I got them working, I could do the same with my kivy app.
How can I verify that what device my touchscreen is in /dev/input? I haven't done that, no

@lucasnzone here's the output on my system:

$ cat /proc/bus/input/devices | grep -P '^[NH]: ' | paste - -
N: Name="eGalax Inc. eGalaxTouch EXC3110-3883-08.00.00" H: Handlers=mouse0 event0

This means that the touchscreen is at /dev/input/event0.

yeah, mine is event - as well
N: Name="ADS7846 Touchscreen" H: Handlers=mouse0 event0

Okay. Does the app work with the touchscreen outside of the container?

@Lauszus
yes, i've done it with Kivy-2.0.0rc1-cp37-cp37m-linux_armv7l.whl wheel
originally with your fork that doesn't use the broadcom drivers

Okay. What errors are you getting? Is the /dev/input/event0? device present inside the container?

yes @Lauszus
i've got crw-rw---- 1 root i2c 13, 64 Mar 12 22:56 event0 and crw-rw---- 1 root i2c 13, 64 Mar 12 22:56 mouse0 inside the container

Try to just cat the output i.e. cat /dev/input/event0. Does it print anything when you touch the screen?

@Lauszus it does, random characters
now i'm more confused than before

Super that means that the container is getting the input. What you are seeing is the raw byte stream, so it will not make sense to you. Anyway this means that it's something in your Kivy configuration is not correct.

Can you try to compile and run this C code (it's some old code I used for debugging my screen):

#include <stdio.h>
#include <linux/input.h>
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>

static volatile sig_atomic_t run = 1;

void sigint(int sig) {
    run = 0;
}

int main() {
    signal(SIGINT, sigint);

    int fd = open("/dev/input/event0", /*O_NONBLOCK |*/ O_RDONLY);
    if (fd < 0) {
        printf("Failed to open device\n");
        return 1;
    }

    while (run) {
        struct input_event ev;
        int num_bytes = read(fd, &ev, sizeof(ev));
        if (num_bytes != sizeof(ev)) {
            printf("Failed to read device\n");
            return 1;
        }
        printf("%u, %u, %u, %u, %d\n", ev.time.tv_sec, ev.time.tv_usec, ev.type, ev.code, ev.value);
    }

    printf("Closing device\n");
    close(fd);
    return 0;
}

You can compile and run it like so:

gcc touch.c -o touch && ./touch

@Lauszus
I get some output from touch:

1584058230, 998152, 1, 330, 1
1584058230, 998152, 3, 0, 477
1584058230, 998152, 3, 1, 3477
1584058230, 998152, 3, 24, 64790
1584058230, 998152, 0, 0, 0
1584058231, 15687, 1, 330, 0
1584058231, 15687, 3, 24, 0
1584058231, 15687, 0, 0, 0

that's bottom left corner

Okay. Try to add the following to the very top of the code (it's important that's it's above any other imports):

from kivy.config import Config
Config.set('input', 'mtdev_%(name)s', 'probesysfs,provider=mtdev')

ok, this is the output when I run my app, with that code at the very top:

[INFO ] Logger: Record log in /root/.kivy/logs/kivy_20-03-13_3.txt
[INFO ] Kivy: v2.0.0.dev0, git-cef99e4, 20191024
[INFO ] Kivy: Installed at "/root/venv-kivy/lib/python3.7/site-packages/kivy/__init__.py"
[INFO ] Python: v3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0]
[INFO ] Python: Interpreter at "/root/venv-kivy/bin/python3"
[INFO ] Factory: 184 symbols loaded
[INFO ] Image: Providers: img_tex, img_dds, img_sdl2, img_gif (img_pil, img_ffpyplayer ignored)
[INFO ] Text: Provider: sdl2
[INFO ] Window: Provider: sdl2(['window_egl_rpi'] ignored)
[INFO ] GL: Using the "OpenGL ES 2" graphics system
[INFO ] GL: Backend used
[INFO ] GL: OpenGL version
[INFO ] GL: OpenGL vendor
[INFO ] GL: OpenGL renderer
[INFO ] GL: OpenGL parsed version: 2, 1
[INFO ] GL: Shading version
[INFO ] GL: Texture max size <4096>
[INFO ] GL: Texture max units <16>
[INFO ] Window: auto add sdl2 input provider
[INFO ] Window: virtual keyboard not allowed, single mode, not docked
[INFO ] Base: Start application main loop
[INFO ] GL: NPOT texture support is available

it still doesn't respond to touch

Can you try to install the libmtdev1 package?

sure can, i'll try now and run it again

@Lauszus it was already installed, same issues

@Lauszus I got it working! Thanks for all your help mate!
%(name)s = hidinput,/dev/input/event0
I added that line to the [input] section in .kivy/config.ini
Thanks again mate!

@lucasnzone great to hear that :)

For anyone reading this; https://github.com/kivy/kivy/pull/6769 has now been merged, so no changes to Kivy is no longer needed, but you still need to compile SDL2 from source. Instructions can be found in the official docs: https://kivy.org/doc/master/installation/installation-rpi.html.

@Lauszus ,
I followed your instruction with 1Gb version Raspberry pi 4 with 2020-02-13 Lite OS. But still can not find a valuable window provider. Any thought?

Best,

@somber02 It would be better if you ask for further support on our official support channels (e.g. discord). We prefer to use github issues primarily for actual bugs and not support.

@matham the issue is that there is a problem with the CI workflow that generates the docs, so it's not updated on the website: https://github.com/kivy/kivy/runs/506000991.

@somber02 for now you can find the documentation here: https://github.com/Lauszus/kivy/blob/45f7ec3851e09220b2b5dc8f34523d6eebff17c2/doc/sources/installation/installation-rpi.rst until the website gets updated.

Ok, my bad, I forgot to merge https://github.com/kivy/kivy-server/pull/17. Should be fixed now.

@matham thanks. Please see: https://github.com/kivy/kivy/pull/6775, as that is preventing the docs from being built.

@Lauszus , Hi Lauszus. Thank you for the instruction. I followed the link with updated information but it still failed with "Unable to find any window provider". and "sdl2-runtimeError"could not initialze EGL" Test condition:

  1. raspberry pi 4 1Gb version 2020-02-13 Lite Raspberrian.
  2. after recompiled sdl2, restart
  3. tested with global install from latest release pypi, from master branch, from latest wheel and from latest development version.
  4. In few situations error message shows it can not find x11 window provider, I will KIVY_WINDOW=sdl2 to force it use sdl2 in that case.

Am I doing something wrong?

@somber02 did you compile Kivy from the master branch? If not please do so, as the pre-built wheels has not been updated yet.

@somber02 also note that you should NOT install these dependencies using apt:

libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev

As you want to use the version you compiled yourselves.

@Lauszus Thank you. I just copied the dependencies without close look.... Thank you that is the reason. After I purged these package and reinstalled the compiled sdl2 package, it works.

Thank you so much for your hard work.

@somber02 great to hear that. I just send yet another PR to make it more clear: https://github.com/kivy/kivy/pull/6780.

Btw did you experience this issue as well: https://github.com/kivy/kivy/pull/6778? Or was it hardware accelerated?

@Lauszus , I can confirm that it is hardware accelerated. Thank you

@Lauszus

note that you should NOT install these dependencies using apt:

In a case like this for the Kivy installation instructions you might even suggest that the user actively do a sudo apt-get remove ... or sudo apt-get purge ... for that short list at the beginning before then compiling sdl2. For most of us, we're probably trying to fix an earlier attempt and so we would have installed the default package version.

@Lauszus Amazing work - this resolved all the issues of getting kivy running on buster lite for me.

Can I suggest just for clarification that the guide state that step 2 altogether is skipped if you are doing a buster lite setup on pi 4?

Additionally, is there a work around for maintaining hardware acceleration that would enable you to rotate orientation for configuration? The only way I can see that this works is with x11 or by disabling the V3D driver.

https://github.com/pimoroni/hyperpixel4/issues/39

@pwdavari step 2 should not be skipped if you are using Buster lite, as you need to compile SDL2 from source unless they have updated the SDL2 package?

You can rotate the display by adding the following kernel commands in /boot/cmdline.txt:

video=HDMI-A-1:1920x1080M@60,margin_left=0,margin_right=0,margin_top=0,margin_bottom=0,rotate=90,reflect_x

See: https://www.raspberrypi.org/documentation/configuration/cmdline-txt.md

If you only want to rotate the display in Kivy:

from kivy.config import Config
Config.set('input', 'mtdev_%(name)s', 'probesysfs,provider=mtdev,param=rotation=90,param=invert_y=1')

@Lauszus Thanks for the reply

I was just referring to this point from step 3 of the documentation:

3. Now simply follow the Raspberry Pi 1-4 installation instructions to install Kivy, but do NOT install the SDL2 packages using apt.

Should we not just skip step 2 of the normal Pi 1-4 setup if you have already installed sdl packages from source and followed the steps -> sudo make install for each?

Or is it saying that you should follow the steps but do not install with apt so you would do:

install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev

@Lauszus

I wasn't putting the video= parameters on the same line. Wasn't until you pointed me back to the documentation that I noticed it very explicitly states that all cmdline.txt parameters/configs need to be on one line. Rookie mistake.

Thanks for your help!

@pwdavari yes you need to skip step 2 under "Raspberry Pi 1-4 installation".

Was this page helpful?
0 / 5 - 0 ratings