Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iMX8 support needed - Please help #7232

Open
bluetulip89 opened this issue Nov 27, 2020 · 11 comments
Open

iMX8 support needed - Please help #7232

bluetulip89 opened this issue Nov 27, 2020 · 11 comments
Labels
SDL2 SDL2 provider

Comments

@bluetulip89
Copy link

Hello Team and fellow guys !

We are using kivy for long time and have developed many applications based on kivy and all were running without any issues these days. Recently one of our requirements come with Ubuntu porting on ARM like iMX8M based SBC. We successfully installed kivy with the following command "sudo apt-get install python3-kivy". Yet while running kivy we encounter the following error:

[INFO ] [OSC ] using for socket
[INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored)
[CRITICAL] [Window ] Unable to find any valuable Window provider at all!
egl_rpi - ImportError: cannot import name 'bcm'
File "/usr/lib/python3/dist-packages/kivy/core/init.py", line 59, in core_select_lib
fromlist=[modulename], level=0)
File "/usr/lib/python3/dist-packages/kivy/core/window/window_egl_rpi.py", line 12, in
from kivy.lib.vidcore_lite import bcm, egl

sdl2 - TypeError: expected bytes, str found
File "/usr/lib/python3/dist-packages/kivy/core/init.py", line 67, in core_select_lib
cls = cls()
File "/usr/lib/python3/dist-packages/kivy/core/window/window_sdl2.py", line 138, in init
super(WindowSDL, self).init()
File "/usr/lib/python3/dist-packages/kivy/core/window/init.py", line 722, in init
self.create_window()
File "/usr/lib/python3/dist-packages/kivy/core/window/window_sdl2.py", line 237, in create_window
self.fullscreen, resizable, state)
File "kivy/core/window/_window_sdl2.pyx", line 94, in kivy.core.window._window_sdl2._WindowSDL2Storage.setup_window (kivy/core/window/_window_sdl2.c:2204)

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

[CRITICAL] [App ] Unable to get a Window, abort.

While I searched around the forums, I came a fact that the Kivy runs only on RPI and not on other arm based platforms with ubuntu. So is there any way to run the kivy in iMX platforms?

Kindly help me out. Thanks in advance

@matham
Copy link
Member

matham commented Nov 27, 2020

I'm only aware of one person on discord who mentioned they are using Kivy on that platform. So I'd suggest you ask them if they have any insights: https://discord.com/channels/423249981340778496/490493814281338890/771097327380463616.

But as a thought, I wouldn't use python3-kivy package as that is old by now and probably won't work on that platform. Instead, I'd install kivy from scratch (I'd use the RPi install instructions as a guide).

@bluetulip89
Copy link
Author

bluetulip89 commented Nov 28, 2020

Thank you for the reply. I will tried accessing the channel on discord, but it is not allowing me to see the chats. can you help me on this?

And I tried compiling it using source also but it fails due to platform not supported

@wileur
Copy link

wileur commented Sep 28, 2022

Even though this thread is a bit old by now I haven't found a solution anywhere on the net, so I'll post what I got to work in the hopes that it will help someone else.

After a couple of days of compiling and testing I've finally gotten kivy to run om i.IMX8. I'm using the VAR-SOM-MX8M-MINI from Variscite, with Yocto Hardknott.

As far as I can tell there are two issues with the default options:
A) Downloading kivy through pip on the target installs a version that is compiled to use X11 through SDL2. As we know i.mx8 doesn't run X11. The solution is build a custom version from scratch. This requires that dependencies are installs, which leads to the second issue.
B) SDL2 libraries as installed through yocto are built to use X11. Again, the the solution is to build them too from source.

The steps that worked for me are;

  1. Add a complete build environment to the target: In the yocto local.conf add the following:
IMAGE_INSTALL_append += "  packagegroup-core-buildessential"
EXTRA_IMAGE_FEATURES += "dev-pkgs"
  1. Build and deploy the image. Login to the target
  2. Download, build and install SDL2 packages from source, change versions to newer ones if needed
    This comes from https://kivy.org/doc/stable/installation/installation-rpi.html?highlight=mtdev
wget https://libsdl.org/release/SDL2-2.24.0.tar.gz
tar -zxvf SDL2-2.24.0.tar.gz
pushd SDL2-2.24.0
./configure --prefix=/usr --enable-video-kmsdrm --disable-video-opengl --disable-video-x11 --disable-video-rpi
make -j$(nproc)
make install
popd

wget https://libsdl.org/projects/SDL_image/release/SDL2_image-2.6.2.tar.gz
tar -zxvf SDL2_image-2.6.2.tar.gz
pushd SDL2_image-2.6.2
./configure --prefix=/usr
make -j$(nproc)
make install
popd

wget https://libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.6.2.tar.gz
tar -zxvf SDL2_mixer-2.6.2.tar.gz
pushd SDL2_mixer-2.6.2
./configure --prefix=/usr
make -j$(nproc)
make install
popd

wget https://libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.20.1.tar.gz
tar -zxvf SDL2_ttf-2.20.1.tar.gz
pushd SDL2_ttf-2.20.1
./configure --prefix=/usr
make -j$(nproc)
make install
popd

  1. Set environment variables for kivy build: (Might not need al of these, but it worked)
export USE_SDL2=1
export USE_X11=0

export USE_EGL=1
export USE_OPENGL_ES2=1
export USE_WAYLAND=1
  1. Build kivy from source through pip:
    I got this line from https://matham-kivy.readthedocs.io/en/latest/installation/installation-linux-venvs.html, thanks Matham!

pip install --no-binary kivy kivy

  1. Test installation:
    The export is only needed if called from a remote terminal.
export DISPLAY=:0
python3 -m kivy.core.window

gives the following output on my system

[INFO   ] [Logger      ] Record log in /home/root/.kivy/logs/kivy_22-09-28_55.txt
[INFO   ] [Kivy        ] v2.1.0
[INFO   ] [Kivy        ] Installed at "/usr/lib/python3.9/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.9.9 (main, Nov 15 2021, 18:05:17)
[GCC 10.3.0]
[INFO   ] [Python      ] Interpreter at "/usr/bin/python3"
[INFO   ] [Logger      ] Purge log fired. Processing...
[INFO   ] [Logger      ] Purge finished!
[INFO   ] [Factory     ] 189 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
[INFO   ] [GL          ] Backend used <sdl2>
[INFO   ] [GL          ] OpenGL version <b'OpenGL ES 2.0 V6.4.3.p2.336687'>
[INFO   ] [GL          ] OpenGL vendor <b'Vivante Corporation'>
[INFO   ] [GL          ] OpenGL renderer <b'Vivante GC7000NanoUltra'>
[INFO   ] [GL          ] OpenGL parsed version: 2, 0
[INFO   ] [GL          ] Shading version <b'OpenGL ES GLSL ES 1.0.0'>
[INFO   ] [GL          ] Texture max size <8192>
[INFO   ] [GL          ] Texture max units <8>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
 /usr/bin/python3: No module named kivy.core.window.__main__; 'kivy.core.window' is a package and cannot be directly executed

In a production environment these steps should preferably be written as bitbake recipes, but I'm posting this here as a pointer for now.

@WolsYang
Copy link

WolsYang commented Feb 7, 2023

Hi @wileur
I try to build by Yocto but failed, do you have any suggestions?
I think my SDL2 is already based on wayland due to :

PACKAGECONFIG="     opengl     alsa pulseaudio     wayland gles2      "

And my Kivy build log show it is on wayland too.

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

I put full log at discord
https://discord.com/channels/423249981340778496/1072002050092711946/1072067298325696563

@wileur
Copy link

wileur commented Feb 7, 2023

Hi @WolsYang,

I'll give it a try in yocto myself as I also need it automated. The solution above was more of a proof that it could be done, but not so practical. I'll report back when I get it working.

@WolsYang
Copy link

WolsYang commented Feb 8, 2023

Hi @wileur ,
Thank you.
There is already has a Kivy recipe in Yocto, I just no idea why it doesn't work.
Add this line to imx-image-full.bb.
IMAGE_INSTALL += " python3-kivy"
This recipe is in /meta-openembedded/meta-python/
And SDL2 is also in imx-image-full.bb too.

The flag you add, some is already in the recipe.

export USE_SDL2=1 << This add by patch in Kivy recipe
export USE_X11=0   << In the recipe,, auto-detect

export USE_EGL=1 << This add by patch in Kivy recipe
export USE_OPENGL_ES2=1  << << In the recipe, turn on by KIVY_GRAPHICS = "gles"
export USE_WAYLAND=1 << In the recipe, auto-detect

Then when you try to build, may get X11error, you need to remove this feature in python3-kivy_%.bbappend.
REQUIRED_DISTRO_FEATURES:remove = "x11"

@WolsYang
Copy link

WolsYang commented Feb 9, 2023

Since I follow wileur step ' Build SDL2 from source '.
My app can be run now, now I am sure it's SDL2 problem.
But no window show on the screen, and also no error message.

root@myC:~/kivyT# python3 main.py 
[INFO   ] [Logger      ] Record log in /home/root/.kivy/logs/kivy_23-02-09_1.txt
[INFO   ] [Kivy        ] v2.1.0.dev0
[INFO   ] [Kivy        ] Installed at "/usr/lib/python3.10/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.10.4 (main, Mar 23 2022, 20:25:24) [GCC 11.3.0]
[INFO   ] [Python      ] Interpreter at "/usr/bin/python3"
[INFO   ] [Logger      ] Purge log fired. Processing...
[INFO   ] [Logger      ] Purge finished!
[INFO   ] [Factory     ] 189 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
[INFO   ] [GL          ] Backend used <sdl2>
[INFO   ] [GL          ] OpenGL version <b'OpenGL ES 3.1 V6.4.3.p4.398061'>
[INFO   ] [GL          ] OpenGL vendor <b'Vivante Corporation'>
[INFO   ] [GL          ] OpenGL renderer <b'Vivante GC7000L'>
[INFO   ] [GL          ] OpenGL parsed version: 3, 1
[INFO   ] [GL          ] Shading version <b'OpenGL ES GLSL ES 3.10'>
[INFO   ] [GL          ] Texture max size <8192>
[INFO   ] [GL          ] Texture max units <16>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[INFO   ] [Text        ] Provider: sdl2(['text_pango'] ignored)
[INFO   ] [Base        ] Start application main loop
[INFO   ] [GL          ] NPOT texture support is available

@wileur
Copy link

wileur commented Feb 10, 2023

I've now successfully built and deployed kivy completely through yocto.

I'm using Variscite's imx8mm and their provided build system so my recipes are likely a bit different from yours, bu here is what I did:

There was no python3-kivy recipe so I grabbed the one from openembedded, python3 including the patch for GLES.
I then added a bbappend file to simply override the USE_x exports and ended up with the following file structure in my meta layer:

recipes-python
recipes-python/python3-kivy
recipes-python/python3-kivy/python3-kivy_2.1.0.bb
recipes-python/python3-kivy/python3-kivy_%.bbappend
recipes-python/python3-kivy/files
recipes-python/python3-kivy/files/0001-add-support-for-glesv2.patch

The .bbappend contains the same exports as in my post above:

export USE_SDL2="1"
export USE_X11="0"
export USE_EGL="1"
export USE_OPENGL_ES2="1"
export USE_WAYLAND="1"

I also added a .bbappend file for libsdl2 in
recipes-graphics/libsdl/libsdl2_%.bbappend

# Remove any options for x11
PACKAGECONFIG[x11] = " "

EXTRA_OECONF:append = "	--enable-video-kmsdrm --disable-video-opengl --disable-video-x11 "

Not sure if the PACKAGECONFIG override is needed but I didn't want to dig deeper in the image features at the moment.

in my layer.conf I added the recipes:

IMAGE_INSTALL_append  += " libsdl2 libsdl2-ttf libsdl2-image libsdl2-mixer"
IMAGE_INSTALL_append  += " python3-kivy"

I built the image, run the test and got the same result as in my post above.

export DISPLAY=:0
python3 -m kivy.core.window

@wileur
Copy link

wileur commented Feb 10, 2023

But no window show on the screen, and also no error message.

It seems like you got Kivy itself to work now!
I wonder if you would get a better answer to this problem in another Kivy forum dedicated to the use of it, instead of the kivy issues reporting here.

@WolsYang
Copy link

WolsYang commented Feb 13, 2023

It seems like you got Kivy itself to work now! I wonder if you would get a better answer to this problem in another Kivy forum dedicated to the use of it, instead of the kivy issues reporting here.

I try to ask this question on Kivy Discord but seems like no one knows what's going on. :'(
If someone knows the reason "Why not work on imx-image-full" please tell me.
Anyway, I try another build config, and it's working now.
Here is what I do, in imx-image-multimedia.bb add :

IMAGE_INSTALL += " python3-kivy"
IMAGE_INSTALL += " packagegroup-core-buildessential"
EXTRA_IMAGE_FEATURES += " dev-pkgs"

If get X11 error, add this to python3-kivy_%.bbappend.

REQUIRED_DISTRO_FEATURES:remove = "x11"

@AccelQuasarDragon
Copy link

Just an update on kivy on yocto, it was reported in this discord thread that kivy has a hard time playing video, even with the basic example from https://stackoverflow.com/a/54119556, but gst works fine.
It was reported that blitting itself takes 179 ms, way to slow for any kind of video playing. I suspect it has something to do with OpenGL ES 2.0 since Wols was working on an embedded system.

@Julian-O Julian-O added the SDL2 SDL2 provider label Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SDL2 SDL2 provider
Projects
None yet
Development

No branches or pull requests

6 participants