AnsweredAssumed Answered

Porting Kivy to i.MX6

Question asked by Cleiton Bueno on Nov 25, 2016
Latest reply on Dec 1, 2016 by Bio_TICFSL

Hello guys,


A while ago I met the Kivy project (, very interesting mainly for being open-source and in Python.

I did some testing on my computer (Linux AMD64) and saw that there was a port for Raspberry PI, so I decided to try installing on NXP/Freescale i.MX6.


After a long time, I resolved all dependencies for Linux Embedded:


SDL2 (libs all) -> OK
Python -> OK
Python-dev -> OK
Python-pip -> OK
FFmpeg -> OK
Libav (all) -> OK

I used Yocto Project, I created recipes, patches, .bbappends until success!

I open the terminal and the first test:



root@colibri-imx6:~# python -c "import kivy"
[INFO ] [Logger ] Record log in /home/root/.kivy/logs/kivy_16-05-27_6.txt
[INFO ] [Kivy ] v1.9.2-dev0
[INFO ] [Python ] v2.7.11 (default, May 21 2016, 16:26:47)
[GCC 5.3.0]

I can import several modules, get various information, and now running a simple example:


root@colibri-imx6:~# python /usr/share/kivy-examples/canvas/
[INFO ] [Logger ] Record log in /home/root/.kivy/logs/kivy_16-05-31_6.txt
[INFO ] [Kivy ] v1.9.1
[INFO ] [Python ] v2.7.11 (default, May 21 2016, 16:26:47) 
[GCC 5.3.0]
[INFO ] [Factory ] 179 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_sdl2 (img_pil, img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [VideoGstplayer] Using Gstreamer
[INFO ] [Video ] Provider: gstplayer
[INFO ] [OSC ] using for socket
[INFO ] [Window ] Provider: sdl2
[ 912.983335] mxc_sdc_fb fb.18: 640x480 h_sync,r,l: 64,16,80 v_sync,l,u: 4,13,3 pixclock=23750000 Hz
[CRITICAL ] [Window ] Unable to find any valuable Window provider at all!
sdl2 - RuntimeError: Could not initialize OpenGL / GLES library
File "/usr/lib/python2.7/site-packages/kivy/core/", line 67, in core_select_lib
cls = cls()
File "/usr/lib/python2.7/site-packages/kivy/core/window/", line 138, in init
super(WindowSDL, self).init()
File "/usr/lib/python2.7/site-packages/kivy/core/window/", line 722, in init
File "/usr/lib/python2.7/site-packages/kivy/core/window/", line 237, in create_window
self.fullscreen, resizable, state)
File "kivy/core/window/_window_sdl2.pyx", line 133, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivy/core/window/_window_sdl2.c:2284)
File "kivy/core/window/_window_sdl2.pyx", line 55, in kivy.core.window._window_sdl2._WindowSDL2Storage.die (kivy/core/window/_window_s[ 913.094420] mxc_sdc_fb fb.18: 640x480 h_sync,r,l: 64,16,80 v_sync,l,u: 4,13,3 pixclock=23750000 Hz
[CRITICAL ] [App ] Unable to get a Window, abort.


What I have already analyzed:

1) Configuration to compile SDL2 to i.MX6:


SDL2 Configure Summary:
Building Shared Libraries
Enabled modules : atomic audio video render events joystick haptic power filesystem threads timers file loadso cpuinfo assembly
Assembly Math :
Audio drivers : dummy alsa(dynamic) pulse(dynamic)
Video drivers : dummy x11(dynamic) opengl opengl_es1 opengl_es2 vivante
X11 libraries : xdbe xinput2 xinput2_multitouch xrandr xshape xvidmode
Input drivers : linuxev linuxkd
Using libudev : YES
Using dbus : YES
Using ibus : NO

Yeah, it has support for VIVANTE and OpenGLES2

2) I used the libs libEGL, libGLESv2, libGLES_CM of framebuffer and created a symbolic link as defined in the SDL2 code. Before that I could not find the Vivante driver, in src/video/SDL_egl.c.


49 /* Android */
50 #define DEFAULT_EGL ""
51 #define DEFAULT_OGL_ES2 ""
52 #define DEFAULT_OGL_ES_PVR ""
53 #define DEFAULT_OGL_ES ""


3) The "sdl2 - RuntimeError: Could not initialize OpenGL / GLES library" error is in the SDL_EGL_LoadLibrary function in src/video/SDL_egl.c in the line below:


219 _this->egl_data->egl_dll_handle = egl_dll_handle;
221 if (egl_dll_handle == NULL) {
222 return SDL_SetError("Could not initialize OpenGL / GLES library");
223 }
225 /* Loading libGL* in the previous step took care of loading, but we future proof by double checking */
226 if (egl_path != NULL) {
227 dll_handle = SDL_LoadObject(egl_path);
228 }

Resolved with the environment variable:

Export SDL_VIDEO_GL_DRIVER = '/usr/lib/'

But it still causes an exception!


4) Variables environments and script for tests:


#! /bin/sh


export KIVY_WINDOW='sdl2'
export KIVY_TEXT='sdl2'
export KIVY_IMAGE='sdl2'
export KIVY_CLIPBOARD='sdl2'


export SDL_VIDEODRIVER='vivante'


#FIX: sdl2 - RuntimeError: Could not initialize OpenGL / GLES library
# It finds the driver but still causes error, even getting information.
export SDL_VIDEO_GL_DRIVER='/usr/lib/'


export SDL_FBDEV='/dev/fb1'
export SDL_MOUSEDEV='/dev/input/touchscreen0'

python /usr/share/kivy-examples/widgets/ -c kivy:log_level:trace

I got a deadlock (in my head) I do not know if this problem is SDL2, Driver Vivante or something I still do not know in Kivy for correct operation of the Window, however, the error is reported by SDL2 ;/



Cleiton Bueno

Blog | Linkedin | B2Open | Portal Embarcados | Twitter