I am using an Apalis i.MX8QM module from Toradex. I installed Torizon, which is a Linux OS mantained by the manufacturer. It's designed to be used with debian-based Docker containers. They provide a container running Weston (Wayland + XWayland) to be able to render graphics. In another container, I compiled OGRE3D graphics engine (source code: www.github.com/OGRECave/ogre) using the following Dockerfile:
FROM --platform=linux/arm64 torizon/wayland-base-vivante:2 AS base
RUN apt-get -y update && apt-get install -y --no-install-recommends \
apt-utils \
&& apt-mark hold dash && apt-get -y upgrade && apt-mark unhold dash \
&& apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
ARG ACCEPT_FSL_EULA=1
RUN apt-get -y update && apt-get install -y --no-install-recommends \
libwayland-client0 \
libwayland-server0 \
libgal-vivante1 \
libvsc-vivante1 \
libgbm-vivante1 \
libegl-vivante1 \
libgl-vivante1 \
libglesv2-vivante1 \
libglesv1-cm-vivante1 \
libglslc-vivante1 \
&& apt-get clean && apt-get autoremove && rm -rf /var/lib/apt/lists/*
# Make sure the user can access DRM and video devices
RUN usermod -a -G video,render torizon
# UP TO HERE ITS CODE PROVIDED BY TORADEX
RUN apt-get -y update && apt-get install -y git cmake gcc g++ make libxrandr-dev libglu1-mesa-dev libzip-dev libfreeimage-dev libpoco-dev libois-dev libzzip-0-13 libzzip-dev doxygen libcgal-dev libcppunit-dev libxt-dev libxaw7-dev pkg-config gdb x11-apps nano libsdl2-2.0 libegl-vivante1-dev
USER torizon
RUN cd /home/torizon/ && git clone https://github.com/OGRECave/ogre
RUN mkdir -p /home/torizon/ogre/bld && cd /home/torizon/ogre/bld && cmake -DCMAKE_BUILD_TYPE=Debug -DOGRE_GLSUPPORT_USE_EGL=1 -DOGRE_BUILD_RENDERSYSTEM_GLES2=1 -DOGRE_BUILD_SAMPLES=1 -DOGRE_CONFIG_THREADS=0 -DOGRE_INSTALL_DOCS=0 -DOGRE_BUILD_PLUGIN_CG=0 -DOGRE_INSTALL_MEDIA=1 -DOGRE_BUILD_TOOLS=0 -DOGRE_BUILD_TESTS=0 -DOGRE_INSTALL_SAMPLES=1 ../
RUN cd /home/torizon/ogre/bld && make
USER root
RUN cd /home/torizon/ogre/bld && make install
The above container is ran with the following command (maybe some env variables aren't needed to really make this work):
docker run -e ACCEPT_FSL_EULA=1 -e X11_UNIX_SOCKET=/tmp/.X11-unix -e WAYLAND_DISPLAY=wayland-0 -e XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR -e DISPLAY=:0 -it --rm --name=wayland-app --user=torizon -v /dev/dri:/dev/dri -v /dev/galcore:/dev/galcore -v /tmp:/tmp -v /run/:/run/ --device-cgroup-rule='c 199:* rmw' --device-cgroup-rule='c 226:* rmw' --cap-add=SYS_PTRACE --security-opt seccomp=unconfined ogre-way-base-egl-j1
When I try to run the first sample compiled after the compilation of OGRE3D, I get some errors. I ran it with gdb to help debugging. Output is shown below:
torizon@0c2f3e5ed77f:~/ogre/bld/bin$ gdb SampleBrowser
GNU gdb (Debian 9.2-1) 9.2
Copyright (C) 2020 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 "aarch64-linux-gnu".
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 SampleBrowser...
(gdb) catch throw
Catchpoint 1 (throw)
(gdb) r
Starting program: /home/torizon/ogre/bld/bin/SampleBrowser
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
Creating resource group General
Creating resource group OgreInternal
Creating resource group OgreAutodetect
SceneManagerFactory for type 'DefaultSceneManager' registered.
Registering ResourceManager for type Material
Registering ResourceManager for type Mesh
Registering ResourceManager for type Skeleton
MovableObjectFactory for type 'ParticleSystem' registered.
ArchiveFactory for archive type FileSystem registered.
ArchiveFactory for archive type Zip registered.
ArchiveFactory for archive type EmbeddedZip registered.
DDS codec registering
ETC codec registering
ASTC codec registering
Registering ResourceManager for type HighLevelGpuProgram
Registering ResourceManager for type Compositor
MovableObjectFactory for type 'Entity' registered.
MovableObjectFactory for type 'Light' registered.
MovableObjectFactory for type 'BillboardSet' registered.
MovableObjectFactory for type 'ManualObject' registered.
MovableObjectFactory for type 'BillboardChain' registered.
MovableObjectFactory for type 'RibbonTrail' registered.
Loading library /home/torizon/ogre/bld/lib/RenderSystem_GLES2.so.1.12.12
Installing plugin: OpenGL ES 2.0 RenderSystem
OpenGL ES 2.x Rendering Subsystem created.
[New Thread 0xffffe5601170 (LWP 22)]
[New Thread 0xffffe4e00170 (LWP 23)]
Thread 1 "SampleBrowser" received signal SIGSEGV, Segmentation fault.
0x0000fffff6e6dbd0 in pthread_mutex_lock () from /lib/aarch64-linux-gnu/libpthread.so.0
(gdb) bt
#0 0x0000fffff6e6dbd0 in pthread_mutex_lock () from /lib/aarch64-linux-gnu/libpthread.so.0
#1 0x0000fffff69432f0 in wl_proxy_create_wrapper () from /usr/lib/aarch64-linux-gnu/libwayland-client.so.0
#2 0x0000fffff6ba1b50 in ?? () from /usr/lib/aarch64-linux-gnu/libEGL.so.1
#3 0x0000fffff6b94534 in eglInitialize () from /usr/lib/aarch64-linux-gnu/libEGL.so.1
#4 0x0000fffff6c7d694 in Ogre::EGLSupport::getGLDisplay (this=0xaaaaaab17b90) at /home/torizon/ogre/RenderSystems/GLSupport/src/EGL/OgreEGLSupport.cpp:65
#5 0x0000fffff6c618c4 in Ogre::X11EGLSupport::getGLDisplay (this=0xaaaaaab17b90) at /home/torizon/ogre/RenderSystems/GLSupport/src/EGL/X11/OgreX11EGLSupport.cpp:280
#6 0x0000fffff6c60ba4 in Ogre::X11EGLSupport::X11EGLSupport (this=0xaaaaaab17b90, profile=4) at /home/torizon/ogre/RenderSystems/GLSupport/src/EGL/X11/OgreX11EGLSupport.cpp:51
#7 0x0000fffff6c60b44 in Ogre::getGLSupport (profile=4) at /home/torizon/ogre/RenderSystems/GLSupport/src/EGL/X11/OgreX11EGLSupport.cpp:45
#8 0x0000fffff6c3d1c4 in Ogre::GLES2RenderSystem::GLES2RenderSystem (this=0xaaaaaab17180) at /home/torizon/ogre/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp:178
#9 0x0000fffff6c3cb18 in Ogre::GLES2Plugin::install (this=0xaaaaaab17100) at /home/torizon/ogre/RenderSystems/GLES2/src/OgreGLES2Plugin.cpp:48
#10 0x0000fffff79c026c in Ogre::Root::installPlugin (this=0xaaaaaab00b20, plugin=0xaaaaaab17100) at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:1188
#11 0x0000fffff6c28bc4 in Ogre::dllStartPlugin () at /home/torizon/ogre/RenderSystems/GLES2/src/OgreGLES2EngineDll.cpp:41
#12 0x0000fffff79c064c in Ogre::Root::loadPlugin (this=0xaaaaaab00b20, pluginName="/home/torizon/ogre/bld/lib/RenderSystem_GLES2") at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:1237
#13 0x0000fffff79bf2c4 in Ogre::Root::loadPlugins (this=0xaaaaaab00b20, pluginsfile="./plugins.cfg") at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:973
#14 0x0000fffff79bc9ac in Ogre::Root::Root (this=0xaaaaaab00b20, pluginFileName="./plugins.cfg", configFileName="./ogre.cfg", logFileName="./ogre.log")
at /home/torizon/ogre/OgreMain/src/OgreRoot.cpp:227
#15 0x0000fffff7f76d3c in OgreBites::ApplicationContextBase::createRoot (this=0xfffffffff238) at /home/torizon/ogre/Components/Bites/src/OgreApplicationContextBase.cpp:191
#16 0x0000fffff7f7663c in OgreBites::ApplicationContextBase::initApp (this=0xfffffffff238) at /home/torizon/ogre/Components/Bites/src/OgreApplicationContextBase.cpp:55
#17 0x0000aaaaaaab6b28 in OgreBites::SampleContext::go (this=0xfffffffff238, initialSample=0x0) at /home/torizon/ogre/Samples/Common/include/SampleContext.h:143
#18 0x0000aaaaaaab44e4 in main (argc=1, argv=0xfffffffff648) at /home/torizon/ogre/Samples/Browser/src/main.cpp:89
As we can see, it crashes at pthread_mutex_lock(), being called from libwayland-client.
Just before calling eglInitialize() (exactly in this line of code), the arguments values are:
(gdb) step
65 if (eglInitialize(mGLDisplay, &mEGLMajor, &mEGLMinor) == EGL_FALSE)
(gdb) print mGLDisplay
$3 = (EGLDisplay) 0xaaaaaab16180
(gdb) print *mEGLMajor
Cannot access memory at address 0x0
(gdb) print mEGLMajor
$4 = 0
(gdb) print mEGLMinor
$5 = 0
I searched in the Internet but I can't find any solution suitable to my situation, and I don't know how to proceed in order to try to solve this.
Any information is appreciated.