Monday, 28 October 2013

I.MX6 Ubuntu 13.04 Debugging GPU Acceleration

You've probably reached here because your having problems getting the rootfs in my previous post to work for X11. So here some debugging tips to help you out:

1. The kernel I used is 4.1.0  and can be found in my repo and is a branch of the FSL repo. An additional patch to set the correct busid for the vivante driver may need to be made if not present in the kernel:

--- a/drivers/gpu/drm/vivante/vivante_drv.c
+++ b/drivers/gpu/drm/vivante/vivante_drv.c
@@ -55,7 +55,7 @@

#include "drm_pciids.h"

-static char platformdevicename[] = "Vivante GCCore";
+static char platformdevicename[] = "Vivante GCCore:00";
static struct platform_device *pplatformdev;

static struct drm_driver driver = {

Here is my  defconfig (I'm compiling for a custom board). Note: the FSL patch (ENGR00264288-1) to upgrade the Vivante libraries to 4.6.9p12.

2. Once you have a booting kernel, you should first test that kernel works against the Vivante framebuffer libraries. To do this we simply switch to the fb libraries (need to be root):

cd /usr/lib
ln -s
ln -s
ln -s 

ln -s

ln -s 

Now test with one of the Vivante tutorial examples (pick any of the tutorials)

cd /root/gpu-viv-bin-mx6q-3.5.7-1.0.0-alpha.2-hfp/opt/viv_samples/vdk

If the tutorial doesn't run it may indicate there is a mismatch between the kernel Vivante code and the libraries or the Vivante libraries may be missing a dependency.

3. If everything is fine with the framebuffer libraries we can now switch back to x11:

cd /usr/lib

ln -s
ln -s
ln -s 

ln -s

ln -s 

Now reboot.

4. Before we test with X, we need to check that kernel vivante/drm modules are loaded:

root@ubuntu-imx6:~# lsmod
Module                  Size  Used by
vivante                  947  1 
drm                   137567  2 vivante

If the modules aren't loaded then X will revert to software rendering because the device /dev/dri/card0 does not exist. The loading of the module is configured in /etc/modules

5. I suggest starting a simple X server to test that the Vivante drivers get correctly loaded:

startx &

The output of the /var/log/Xorg.0.log should be similar to this. If errors are reported it may be because:

1. The vivante kernel module didn't load
2. Check the exa driver is present /usr/lib/xorg/modules/drivers/
3. Least likely, missing permissions on the gpu device, these should be setup in  /etc/udev/rules.d/10-imx.rules.

6. Validate the output of glxinfo and es2_info (they should show the presence of the Vivante drivers):

export DISPLAY=:0

If you are not seeing "OpenGL renderer string: GC2000 Graphics Engine" and/or "EGL_VENDOR = Vivante Corporation" in the output then it may be possible that the mesa libraries are being picked up. If the directories /usr/lib/arm-linux-gnueabihf/mesa and/or /usr/lib/arm-linux-gnueabihf/mesa-egl are present then move these to another location. They shouldn't be present on my rootfs unless the mesa packages were reinstalled.

Sunday, 27 October 2013

I.MX6 - Ubuntu 13.04 with GPU acceleration

One of the main drawbacks with the existing freescale BSP releases (up to 4.1.0) was the lack of support beyond xorg-server version 11. This was due to lack of support within the Vivante GPU libraries. With the introduction of a new BSP based on kernel 3.5.7,  it is finally possible to build support for xorg-server beyond version 11. The added bonus is support for armhf, however this is offset by the fact that the Vivante libraries are currently marked as alpha.


I've put together a preview Xubuntu Raring (13.04) rootfs to demonstrate this, 13.04 is based on xorg-server 13.3. Sadly there no video acceleration, this is work in progress, the major hurdle is that existing fsl gstreamer plugins are coded against 0.10 and there are compatibility issues with a later GLib version. The short video above gives an indication of how the libraries performs (video shows running  glmark2-es2,  vivante sdk sample and the 3D game Neverball at 720p). Note, not all OpenGL applications (eg FireFox) are compatible with the Vivante libraries because of limited API.

The rootfs has been updated to use the latest Vivante libraries producing better performance figures for OpenGL.

The origins of my rootfs is this minimal console rootfs  which I think was put together by Robert Nelson (this has no GPU/VPU support). My rootfs is fairly clean, sanitised and contains a minimal xbuntu installation. The intention was include just enough to get an accelerated desktop functioning and for the rest to be customised depending on the target device.

Another goal was to make the rootfs available to be deployable to any i.mx6 device. It should be possible to deploy this to any i.mx6 device (eg boundarydevices, wandboard, utilite, udoo, cubox-i) assuming it contains a dual or quad processor. By the way I don't own any of the mentioned devices but glad to accept hardware donations. All you require is a working uboot and kernel (4.1.0) or (3.5.7). I haven't tested again a 3.5.7 kernel, furthermore it may be possible to run against a later kernel again not tested. If you plan to derive a new rootfs from mine, please acknowledge the author.

Extract the rootfs to your designated media and copy your kernel and modules as required. The rootfs is configured to output to the serial console with auto-logon for root. By default the image boots to display a console logon prompt, if hdmi is configured. The user and password are 'ubuntu'.

Xfce4 is not configured to auto start, you can start it by:

service lightdm start

If you require auto start, remove lightdm override:

rm /etc/init/lightdm.override

You will need to configure networking as per your requirements. I decided not to install network-manager due the dependencies on gnome. You may need to edit the nameserver entry in /etc/resolvconf/resolv.conf.d/tail .

The mesa utilities glxgears,es2gears, glmark2, glmark2-es2 are pre-installed. glmark2 will end after the jellyfish demo with a segmentation fault.

The Vivante samples are located in /root/gpu-viv-bin-mx6q-3.10.9-1.0.0-hfp/opt/viv_samples.

If your deployment fails to run X, then my next post has some debugging steps. Also available to answer questions  IRC Freenode #imx6-dongle