References:
Frescale Linux 3.10.17_1.0.0 GA Release (registration required)
Direct link to i.MX 6Dual/6Quad Linux Reference Manual (BSP release L3.0.35_4.1.0) uploaded to Freescale forum - Chapter 9 Graphics Processing Unit
Direct link to i.MX 6 Linux Reference Manual (BSP release L3.10.17_1.0.0-ga) uploaded to Freescale forum (Chapter 13 Graphics Processing Unit.)
Summary of L3.10.17_1.0.2 i.MX 6 Yocto Project Patch Release
Installing Xorg
With the system bootstrapped to Ubuntu 13.10, a minimal Xorg 1.14.6 (runs xterm but no window manager) can be installed as follows:
apt-get install --no-install-recommends xserver-xorg-core xserver-xorg-input-all xserver-xorg-video-fbdev
apt-get install xinit
Run startx and make sure an xterm shows up. Make sure the following entry exists in /etc/apt/sources.list and install mesa-utils:
deb http://ports.ubuntu.com/ubuntu-ports saucy universe
With everything setup correctly so far, glxgears -info shows the following:
GL_RENDERER = Software Rasterizer
GL_VERSION = 1.4 (2.1 Mesa 9.2.0)
GL_VENDOR = Mesa Project
GL_EXTENSIONS =
423 frames in 5.1 seconds = 83.247 FPS
GL_VERSION = 1.4 (2.1 Mesa 9.2.0)
GL_VENDOR = Mesa Project
GL_EXTENSIONS =
423 frames in 5.1 seconds = 83.247 FPS
Installing Binary GPU Libraries
http://downloads.yoctoproject.org/mirror/sources/xserver-xorg-video-imx-viv-3.10.17-1.0.2.tar.gz
http://downloads.yoctoproject.org/mirror/sources/gpu-viv-bin-mx6q-3.10.17-1.0.2-hfp.bin
Setup gpu-viv-bin-
The system may already have files which the content of gpu-viv-bin- will overlap. This can be checked as follows:
debian@arm:~/yocto/gpu-viv-bin-mx6q-3.10.17-1.0.0-hfp/usr$ for fn in `find`; do [ -f /opt/xorg/$fn ] && ls /opt/xorg/$fn && done
On Ubuntu, the existing libraries will need to be removed from arm-linux-gnueabihf-mesa and arm-linux-gnueabihf-mesa-egl. Alternatively, they can be hidden from ld.so by commenting entries in /etc/ld.so.conf.d/arm-linux-gnueabihf_GL.conf etc. (you may see that those are links to corresponding files in /etc/alternatives/).
On Debian, libGL.so and company are installed into /usr/lib.
My system wanted to prioritize the from-scratched libraries in /opt/xorg, so I had to resort to explicitly setting the library path order in order to pick up the blobs from /usr/lib:
LD_LIBRARY_PATH=/lib/arm-linux-gnueabihf:/usr/lib/arm-linux-gnueabihf:/usr/local/lib:/usr/lib:/opt/xorg/lib
Confirming DRI device
The running kernel must be built with CONFIG_DRM_VIVANTE=m and CONFIG_MXC_GPU_VIV=y (add 'vivante' to /etc/modules'). Verify that vivante and drm modules are loaded.
One additional rule to add:
KERNEL=="mxc_asrc", MODE="0666"
ASRC stands for Asynchronous Sample Rate Converter.
Verify that the device nodes appear as follows ...
crw-rw---- 1 root video 226, 0 Jan 10 17:31 /dev/dri/card0
Also, make sure your user had been added to group 'video' e.g.
sudo usermod -a -G video ubuntu
(Remember this hint when glxgears stubbornly defers to rasterizer instead of GC2000!)
od /dev/dri/card0 # this works while X running, otherwise 'Invalid argument'
Testing with Vivante (FB) tutorials
Before trying to build the Vivante EXA driver for Xorg, first try to test GPU acceleration in the framebuffer. Exit X if it is running.
Refer to Table 13-2 of i.MX 6 Linux Reference Manual for overview of the GPU Library structure. For each library, a symbolic link must be made from either the X11 or the framebuffer version to the soname (this was documented a bit more explicitly in the L3.0.35_4.1.0 Linux manual):
cd /usr/lib
rm libGAL.so
rm libEGL.so
rm libEGL.so.1
rm libVIVANTE.so
sudo ln -s libGAL-fb.so libGAL.so
sudo ln -s libEGL-fb.so libEGL.so
sudo ln -s libEGL-fb.so libEGL.so.1
sudo ln -s libVIVANTE-fb.so libVIVANTE.so
Tutorial may also fail silently if ld.so paths are not setup properly, or udev rules not configured correctly (refer to previous section).
Testing with X
Refer to Chapter 18 of Linux Reference Manual L3.10.17_1.0.0-ga for background information. Assuming the library sonames need to be relinked to the -x11 versions:
cd /usr/lib
rm libGAL.so
rm libEGL.so
rm libEGL.so.1
rm libVIVANTE.so
rm libGLESv2.so
ln -s libGAL-x11.so libGAL.so
ln -s libEGL-x11.so libEGL.so
ln -s libEGL-x11.so libEGL.so.1
ln -s libVIVANTE-x11.so libVIVANTE.so
ln -s libGLESv2-x11.so libGLESv2.so
ln -s libGLESv2-x11.so libGLESv2.so.2
Building the Vivante Xorg EXA Driver
apt-get install xserver-xorg-dev
If $xorg is something different from default i.e. "/usr" it could present a problem, as system include files are referenced in the following manner:
-I$(sysroot)/usr/include
If the $xorg string does not end in 'usr', then it requires modification to all occurrences of $(sysroot)/usr in EXA/src/makefile.linux
In addition, the path to libdrm includes may need modified e.g.
LOCAL_CFLAGS += -I$(sysroot)/include/libdrm
If all is well, vivante_drv.so will be built with the following compile line (addition of sysroot= if necessary):
BUILD_HARD_VFP=1 XSERVER_GREATER_THAN_13=1 BUSID_HAS_NUMBER=1 ./fastbuild.sh sysroot=/opt/xorg
Install the EXA driver:
sudo cp EXA/src/vivante_drv.so /opt/xorg/lib/xorg/modules/drivers/
The Vivante driver must be enabled in /etc/X11/xorg.conf - the file may not even exist on the system yet since it is typically not needed for the default framebuffer driver. A minimal xorg.conf is adequate to get my system working.
After firing up xorg (startx or window manager if one is installed), verify in Xorg.log that Vivante is loaded:
[ 1610.413] (II) VIVANTE: driver for vivante fb: VivanteGC500, VivanteGC2100,
VivanteGCCORE
You should not see this:
[ 90.587] (II) GLX: Initialized DRISWRAST GL provider for screen 0
Everything should now be in place for glxgears.
debian@arm:~$ glxgears -info
GL_RENDERER = Vivante GC2000
GL_VERSION = 2.1 2.0.1
GL_VENDOR = Vivante Corporation
GL_EXTENSIONS = WGL_ARB_extensions_string WGL_EXT_extensions_string WGL_EXT_swap_control GL_EXT_texture_env_add GL_ARB_multitexture GL_ARB_multi
...
875 frames in 5.0 seconds = 174.912 FPS
If things are not setup correctly, glxgears does not perform as expected (e.g. jerky display) or possibly not at all. If Xorg confirmed to have loaded VIVANTE, and glxgears output appears as below (uses software rasterizer), and the framebuffer tutorials worked, it's likely a permissions problem (check that your user is added to group video ... you were warned!)
libGL error: open DRM failed (Operation not permitted)
libGL error: reverting to (slow) indirect rendering
GL_RENDERER = Software Rasterizer
GL_VERSION = 1.4 (2.1 Mesa 9.2.0)
GL_VENDOR = Mesa Project
GL_EXTENSIONS =
423 frames in 5.1 seconds = 83.247 FPS
Chapter 18 of Linux Reference Manual L3.10.17_1.0.0-ga makes it pretty clear that the drm-update-arm.patch must be applied to libdrm ("adding the ARM lock implementation", which might be a compelling reason to build xorg-xserver from source.
Next exercise is to build glmark2 and mesa-utils.