Using Kivy in Buildroot on RPi4

196 views
Skip to first unread message

Jimmy

unread,
May 12, 2020, 11:37:04 PM5/12/20
to Kivy users support
Good evening all,

I'm trying to get Kivy running inside of a Buildroot based system on the Raspberry Pi 4 (Python 3.7). I've gotten the package to compile/install, but it doesn't look like its able to spin up a window using either the sdl2 or rpi_egl backends. I've installed the rpi_userland and rpi_firmware packages which provide the native Broadcom blobs and OpenGL backend.  I can see where the application enters the main loop, but I never see any graphics on screen. The console just logs the following text and the cursor continues to blink. I can even ctrl+C out of the program, so its not like its freezing. (This is with KIVY_GL_BACKEND=gl set)

[INFO   ] Logger: Record log in /root/.kivy/logs/kivy_20-05-13_1.txt
[INFO   ] Kivy: v1.11.0
[INFO   ] Kivy: Installed at "/usr/lib/python3.7/site-packages/kivy/__init__.pyc"
[INFO   ] Python: v3.7.4 (default, May 12 2020, 15:19:35)
[GCC 7.5.0]
[INFO   ] Python: Interpreter at "/usr/bin/python"
[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   ] ImageLoaderFFPy: Using ffpyplayer 4.3.1
[INFO   ] Image: Providers: img_tex, img_dds, img_sdl2, img_pil, img_ffpyplayer, img_gif
[DEBUG  ] Cache: register <kv.texture> with limit=1000, timeout=60
[DEBUG  ] Cache: register <kv.shader> with limit=1000, timeout=3600
[INFO   ] Text: Provider: sdl2
[DEBUG  ] App: Loading kv <./my.kv>
[DEBUG  ] App: kv <./my.kv> not found
[INFO   ] Window: Provider: egl_rpi
[DEBUG  ] Window: Actual display size: 1920x1080
[INFO   ] GL: Using the "OpenGL ES 2" graphics system
[DEBUG  ] GL: glShaderBinary is not available
[INFO   ] GL: Backend used <gl>
[INFO   ] GL: OpenGL version <b'OpenGL ES 2.0'>
[INFO   ] GL: OpenGL vendor <b'Broadcom'>
[INFO   ] GL: OpenGL renderer <b'VideoCore IV HW'>
[INFO   ] GL: OpenGL parsed version: 2, 0
[INFO   ] GL: Shading version <b'OpenGL ES GLSL ES 1.00'>
[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 </usr/lib/python3.7/site-packages/kivy/data/glsl/default.png>
[INFO   ] Window: virtual keyboard not allowed, single mode, not docked
[DEBUG  ] Resource: add </usr/lib/python3.7/site-packages/kivy/data/fonts> in path list
[DEBUG  ] Base: Create provider from mouse
[DEBUG  ] Base: Create provider from probesysfs
[DEBUG  ] ProbeSysfs: using probesysfs!
[INFO   ] Base: Start application main loop
[INFO   ] GL: NPOT texture support is available



My package build file is based on James Moore's. I've tried with both Kivy 1.11.0 and 2.0.0rc2.

PYTHON_KIVY_VERSION = 2.0.0rc2
PYTHON_KIVY_SITE = $(call github,kivy,kivy,$(PYTHON_KIVY_VERSION))
PYTHON_KIVY_SETUP_TYPE = distutils
PYTHON_KIVY_LICENSE = MIT
PYTHON_KIVY_LICENSE_FILES = LICENSE
PYTHON_KIVY_DEPENDENCIES = host-python-cython libgl

PYTHON_KIVY_ENV += KIVY_CROSS_PLATFORM=rpi

ifeq ($(BR2_PACKAGE_GSTREAMER),y)
PYTHON_KIVY_DEPENDENCIES += gstreamer
PYTHON_KIVY_ENV += USE_GSTREAMER=1
else
PYTHON_KIVY_ENV += USE_GSTREAMER=0
endif

ifeq ($(BR2_PACKAGE_HAS_LIBEGL),y)
PYTHON_KIVY_DEPENDENCIES += libegl
PYTHON_KIVY_ENV += USE_EGL=1
else
PYTHON_KIVY_ENV += USE_EGL=0
endif

ifeq ($(BR2_PACKAGE_SDL2)$(BR2_PACKAGE_SDL2_IMAGE)$(BR2_PACKAGE_SDL2_MIXER)$(BR2_PACKAGE_SDL2_TTF),yyyy)
PYTHON_KIVY_DEPENDENCIES += sdl2 sdl2_image sdl2_mixer sdl2_ttf
PYTHON_KIVY_ENV += USE_SDL2=1
PYTHON_KIVY_ENV += KIVY_SDL2_PATH=$(STAGING_DIR)/usr/include/SDL2
else
PYTHON_KIVY_ENV += USE_SDL2=0
endif

ifeq ($(BR2_PACKAGE_WAYLAND),y)
PYTHON_KIVY_DEPENDENCIES += wayland
PYTHON_KIVY_ENV += USE_WAYLAND=1
else
PYTHON_KIVY_ENV += USE_WAYLAND=0
endif

ifeq ($(BR2_PACKAGE_XLIB_LIBX11)$(BR2_PACKAGE_XLIB_LIBXRENDER),yy)
PYTHON_KIVY_DEPENDENCIES += xlib_libX11 xlib_libXrender
PYTHON_KIVY_ENV += USE_X11=1
else
PYTHON_KIVY_ENV += USE_X11=0
endif

define PYTHON_KIVY_REMOVE_EXAMPLES
rm -rf $(TARGET_DIR)/usr/share/kivy-examples
endef

PYTHON_KIVY_POST_INSTALL_TARGET_HOOKS += PYTHON_KIVY_REMOVE_EXAMPLES

$(eval $(python-package))

I've also got SDL/SDL2 (TTF/Image/Mixer) installed on the cross build system prior to Kivy, and it looks like its being detected in the compilation:

Build configuration is:
 * use_rpi = 1
 * use_egl = 1
 * use_opengl_es2 = 1
 * use_opengl_mock = 0
 * use_sdl2 = 1
 * use_pangoft2 = 0
 * use_ios = 0
 * use_android = 0
 * use_mesagl = 0
 * use_x11 = 0
 * use_wayland = 0
 * use_gstreamer = 0
 * use_avfoundation = 0
 * use_osx_frameworks = 0
 * debug_gl = 0
 * kivy_sdl_gl_alpha_size = 8
 * debug = False

Has anyone run into this before? I imagine getting a good buildroot based package on something as low-cost as a RPi would be good for embedded touch systems.

The test code is a simple Kivy example:
import kivy
kivy.require('1.10.0')

from kivy.app import App
from kivy.uix.label import Label


class MyApp(App):
    def build(self):
        return Label(text='Hello World')

if __name__ == '__main__':
    MyApp().run()



Thanks in advance! I feel like I'm so close to solving this!

-- Jimmy

Jimmy

unread,
May 15, 2020, 1:53:19 PM5/15/20
to Kivy users support
Still trying to troubleshoot this. Any help would be appreciated.

I've gotten to the point where I'm forcing the KIVY_CROSS_PLATFORM variable to be 'vc' as I understand that the rpi4 doesn't actually use the 'rpi' platform configuration.

Unfortunately for some reason with the way the setup.py is constructed it forces a requirement for X11?
Reply all
Reply to author
Forward
0 new messages