Porting Kivy to i.MX6

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Porting Kivy to i.MX6

2,540 Views
cleitonbueno
Contributor I

Hello guys,

A while ago I met the Kivy project (https://kivy.org), 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]
root@colibri-imx6:~#


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

root@colibri-imx6:~# python /usr/share/kivy-examples/canvas/canvas_stress.py
[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 1.6.3.0
[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/init.py", line 67, in core_select_lib
cls = cls()
File "/usr/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 138, in init
super(WindowSDL, self).init()
File "/usr/lib/python2.7/site-packages/kivy/core/window/init.py", line 722, in init
self.create_window()
File "/usr/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", 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
dl2.c:1479)
[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.

48 #elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE
49 /* Android */
50 #define DEFAULT_EGL "libEGL.so"
51 #define DEFAULT_OGL_ES2 "libGLESv2.so"
52 #define DEFAULT_OGL_ES_PVR "libGLES_CM.so"
53 #define DEFAULT_OGL_ES "libGLESv1_CM.so"

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;
220
221 if (egl_dll_handle == NULL) {
222 return SDL_SetError("Could not initialize OpenGL / GLES library");
223 }
224
225 /* Loading libGL* in the previous step took care of loading libEGL.so, 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/libGLESv2.so'

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/libGLESv2.so'

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


python /usr/share/kivy-examples/widgets/textinput.py -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 ;/

Att,
Cleiton Bueno

Blog | Linkedin | B2Open | Portal Embarcados | Twitter 

0 Kudos
Reply
3 Replies

1,398 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hi Chelton,

Hope you success porting kivy and shared with us your results. I do not exactly which is the root of the issue, but I suggest to change your bootargs to bpp from 24bpp to 32 bpp to avoid that display error about egl.

Let us know if this helps

0 Kudos
Reply

1,398 Views
cleitonbueno
Contributor I

Thanks for the answer Alfred, I will test the change from 24 to 32.

The problem is how much the Kivy Window, but I do not know if it is something with a VIVANTE or SDL2 driver, because Kivy uses SDL2 for this too.

0 Kudos
Reply

1,398 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hi Cleiton,

For SDL2, you should try Sam's solutions:

GitHub - mastermind-/SDL-mx6: SDL with Freescale iMX6 video driver, merged to upstream 

Regards

0 Kudos
Reply