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
rm libEGL.so.1.0 libEGL.so.1 libEGL.so
ln -s libEGL-fb.so libEGL.so.1.0
ln -s libEGL-fb.so libEGL.so.1
ln -s libEGL-fb.so libEGL.so 

rm libGAL.so
ln -s libGAL-fb.so libGAL.so

rm libVIVANTE.so 
ln -s libVIVANTE-fb.so libVIVANTE.so 

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
./tutorial7

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

rm libEGL.so.1.0 libEGL.so.1 libEGL.so
ln -s libEGL-x11.so libEGL.so.1.0
ln -s libEGL-x11.so libEGL.so.1
ln -s libEGL-x11.so libEGL.so 

rm libGAL.so
ln -s libGAL-x11.so libGAL.so

rm libVIVANTE.so 
ln -s libVIVANTE-x11.so libVIVANTE.so 

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/vivante_drv.so
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
glxinfo
es2_info

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

Sunday, 1 September 2013

Mixtile - Exynos 4412 Development Board

As most of you are aware there are plenty of ARM development boards to choose from, well here is a another one to add to the growing list. It's known as Mixtile (Chinese name: m too)  and is promoted as a low cost Quad Core board deploying Samung's Exynos 4412 (1.4GHz) processor accompanied with 1GB RAM, all for $79 (excluding shipping). It originates from China and surprisingly the schematics are freely available.

The board itself is large (12cm x 12cm) and I guess similarities would be drawn against Hardkernels older offerings namely ORDROID-U/X. The major differentiator is the plethora of on-board ports and I/O:

Sadly there's no SATA port but the 50 pin dual header (2.54mm)  supports I2C, SPI, ADC, PWM, Serial and I think an LCD interface (haven't verified these are working). The downside is that the I/O is probably 1.8v and sourcing a 3.3v/5v level shifter may not be easy. Furthermore what's unclear is how well these interfaces are supported in the kernel source. The 2.54mm pitch is ideal because the connectors are cheap and readily available. Quite a few of the peripheral ports (wifi, ethernet, SD cards, usb) are driven from 2 USB controllers, a SMC USB4640 and a LAN9514. It will be interesting to see if there are noticeable bottlenecks as the controllers are daisy chained. Audio support is provided by a WM8960, with the board providing a headphone jack and on board microphone. There are also solder pads for connecting a pair of speakers, the WM8960 datasheet indicates 1Watt output.

The board requires a 5v power supply and protection is provided by an on board fuse. By default the board boots from the micro sd slot, apparently it is possible to reconfigure the boot device through DIP switches although I couldn't find any documentation describing the settings. Although not obvious there are a number of LED's populated on both the front and back of the PCB. Once the board is powered 4 bright green LED light up indicating the 4 USB ports are powered. I have no idea of their relevance, however they are an irritation giving the level of brightness emitted. I also noticed some LEDs  on the underside of the PCB, again I can't see the purpose as that part of the board is not directly visible.



Another oddity is the location of the 4412 processor, its on the back of the PCB. Giving that the processor probably requires some level of cooling, it would indicate the PCB should be mounted using spacers/pillar so that air can flow to the underside of the PCB. Therefore it is advisable to have some pcb spacers handy if your planning to purchase. Fortunately I located some spare brass hex pillars that matched the mounting holes. I suspect the processor will also require some kind of passive cooling although there are no mounting holes or points to affix one.



To access the serial console you require a USB to TTL Serial Adapter which supports 1.8v these can be difficult to source and expensive.

Currently there is pre-view Android and Ubuntu (no h/w acceleration) images available for download, along with uboot and kernel source. I gave the ubuntu image a quick test, however to do so I needed to set the HDMI resolution to 720P, by default it is set to 1080P in the kernel.

As a quick workaround to set 720p I changed the following line in drivers/media/video/exynos/tv/hdmi_drv.c .

#define HDMI_DEFAULT_PRESET V4L2_DV_1080P60                                                                   

to
                    
#define HDMI_DEFAULT_PRESET V4L2_DV_720P60

To compile the kernel for ubuntu, you need Sourcery G++ Lite  I used  2010.09-50 v4.5.1. 

To compile the kernel:

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- mixtile_garage_ubuntu_defconfig

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- modules INSTALL_MOD_PATH=output

make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- modules_install INSTALL_MOD_PATH=output

To copy the kernel to the ubuntu SD card image (where <drive> is SD card device):

sudo dd if=arch/arm/boot/zImage of=/dev/<drive> bs=512 seek=6144; sync;

To copy the kernel modules, you would do something like this, where <mount path> is the path to SD card rootfs :

sudo cp -r output/lib/modules/3.0.15 /<mount path>/lib/module

The user and password for the ubuntu image is 'ubuntu'. The preview ubuntu image has a default Locale of Chinese, to change this edit /etc/default/locale. You also need to change the Language settings from within the Unity desktop. Select Settings->Language Support.

I did test a HDMI to VGA adapter at 720p and it ran fine against my monitor.

Given this is a fairly new board (albeit using an older processor), there seems to be little support available at present which can make it daunting and challenging at the same time.

Friday, 17 May 2013

I.MX6 GK802 - Uboot multi-boot

I spent some re-factoring the current uboot to enable the possibility of booting a roofs located on either:

1. Internal SD
2. External SD
3. Usb drive

Here's how it works, the new boot searches for a uboot script file called "boot.scr" on each of the above devices. The boot.scr is loaded and executed from the first device it encounters containing the file. We assume the device contains an ext2/3/4 partition and the boot.scr is located in /. Within the boot.scr file the variable 'boot_normal' has to be set to contain the uboot commands to run next, the contents of this variable are then executed.

You can download multi-uboot from here and 'dd' to an sd card that will reside in the internal sd card slot. Potentially this can be a very small SD card if you have no intentions of hosting a rootfs on it.

sudo dd if=u-boot_multi_boot.imx bs=1k seek=1 of=/dev/<internal SD card device> && sync


Lets start with an example, lets say we want to execute our ubuntu image from the external SD card. I am assuming the ubuntu rootfs exists on an sd card . First we create a text file I call them 'boot.cmd' (you can give it any name) containing the uboot commands to run as shown below:

setenv console 'ttymxc3,115200'
setenv root '/dev/mmcblk1p1 rootwait'
setenv rootfstype 'ext4'
setenv kernel 'uImage'
setenv video 'mxcfb0:dev=hdmi,1280x720M@60,if=RGB24'
setenv extra ''
setenv boot_normal 'setenv bootargs console=${console} root=${root} rootfstype=${rootfstype} video=${video} ${extra};  mmc dev 1; ext2load mmc 1:1 0x10800000 /boot/uImage; bootm'

For the above :

1. 'root' is set to the external sd card (/dev/mmcblk1p1).
2. 'video' contains the video resolution we want the kernel to set. Note setting the resolution may disable sound. So you could remove the video variable from the file to let the kernel detect the resolution using EDID. There is also a kernel patch from wolfgar that fixes the sound when the resolution is set to 720p or 1080. You can download precompiled kernel and modules with the patch. Copy kernel (uImage) to /boot and untar modules_3.0.35-02708-g899792c-dirty.tar.gz and copy modules directory to /lib/modules.

3. 'boot_normal' is told to use the external sd slot by  'mmc dev 1' and then to load the kernel located at /boot/uImage.

Next the text file has to be converted to a uboot script image file using the mkimage command to create  the boot.scr file.

mkimage -A arm -O linux -T script -n "boot" -d boot.cmd boot.scr


Copy the boot.src to the root directory of your external sd card containing the rootfs.

Ensure internal sd slot has a the sd card containing the mutli-boot uboot on in it and does not contain a /boot.scr. Place the sd card containing the rootfs in the external sd card slot and boot.

Here are some example script files (remember to rename compiled file to boot.scr) :
Note the source files contain a mistake that should be fixed: 
     setenv fbmem "fbmem=28M";  
SHOULD BE  
    setenv fbmem ''; 

1. Boot from external SD (no video set)


2. Boot from from USB (assumes a single mass storage device is available).

3. Boot from internal SD (no video set)

Sunday, 5 May 2013

I.MX6 GK802 Xubuntu 12.04

This is an attempt at producing at fast and lightweight desktop release based upon xfce. Given that the majority of the Debian based ARM desktop distros still rely on Open GL Window Managers, the desktop makes use of the Open GL Vivante library where possible. However as the Vivante libraries don't seem to support all the mesa-gl api's this works with limited success.

Ideally the next step would be to rework/recompile some of the applications to use GLES instead of Open GL or find desktop with GLES support.

Given this is a rootfs, it can be tested on other imx6 devices but no guarantees.

What is working:

1. GPU acceleration
2. Video playback using totem
3. Chromium (with GPU acceleration, webgl does not work)
4. Numerous desktop applications
5. Wifi

As per the previous ubuntu 12.04 image, to deploy:

1. Download roofs.

2. Extract rootfs onto your sdcard.


There is a bug in ubuntu with dbus disabling wifi (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=659953). After booting execute the following and reboot to configure wifi from within xfce:

chgrp messagebus /usr/lib/dbus-1.0/dbus-daemon-launch-helper
chmod +s /usr/lib/dbus-1.0/dbus-daemon-launch-helper 



You can also download the Vivante GPU demos, these demonstrate the performance of the GC2000 core. Extract the tar file and the samples are in located in "viv_samples/vdk", there are number  tutorial files that you can run eg "tutorial1, tutorial1_es20".

Thursday, 4 April 2013

I.MX6 GK802 - Ubuntu 12.04 preview image

Following on from the oneiric preview image, I've put together a rootfs based on Linaro 12.04. Thanks to the Otavio from the yocto project for help building the gpu drivers. It should be possible to deploy the rootfs on other imx6 devices by deploying the correct uboot, kernel + modules.

Note: updated rootfs has working VPU.

What's working :

1. GPU + VPU acceleration.
2. Wifi
3. Choice of Unity 2D or Xubuntu desktop
4. Chromium
5. glxgears/glmark2-es2/es2gears working in Unity 2D and Xubuntu.

What's currently not working:

1. Bluetooth
2. Pre-installed Neverball (3D ball game) - broken something





If you prefer not to follow the manual instructions listed below user hste (aka
Haakon Stende
) on freenode imx6dongle has created a script to build and deploy. Script is here, any problems contact hste on freenode for advice.

To install (assuming oneiric image already on sd card):

1. Download rootfs linaro_12_04_gpu_vpu.tar.gz. Thanks to hste for hosting.
2. Delete existing rootfs from oneiric image (this is the "ubuntu" partition on the SD card).
 
    rm -rf <sd card mount point>/ubuntu/*
    sync

3. Extract new rootfs:

    cd <sd card mount point>/ubuntu
    tar xvf linaro_12_04_gpu.tar.gz
    sync

4.  Download kernel with cpu frequency or without (requires a good heatsink) and 'dd' to sd card.

    dd if=arch/arm/boot/uImage_cpufreq of=/dev/sdc bs=1048576 seek=1 && sudo sync 

         OR


    dd if=arch/arm/boot/uImage_no_cpufreq of=/dev/sdc bs=1048576 seek=1 && sudo sync 

5. Download uboot and 'dd' to sd card.
    dd if=u-boot.imx bs=1k seek=1 of=/dev/sdc && sync


4. Remove SD card and place in internal SD slot and power up.

Sunday, 10 March 2013

GK802 - Ubuntu oneiric preview image


For those of you waiting for a pre-built image, here goes!

If you want to find out more about our development efforts or want to contribute 

1. irc channel  #imx6-dongle on freenode
2. Kernel/Uboot Source 
3. Wiki Page
4. Google Group

I've called this a preview image because it's still work in progress. What's working:

1. New uboot - based on abrasive's (aka James Laids) excellent work.
2. GPU and VPU h/w acceleration
3. Working wifi (although performance can be below par)
4. Working internal/external SD slots.
5. Working usb ports.

Instructions:

1. Download image (thanks to miniand.com for hosting).

2. Unzip image and dd to an SD card. This image is for a 8GB SD card, however the ext4 file partition is only 3GB therefore should work on a 4GB card. Fix the partition (by expanding it) after completing the dd.

3. Download a new uboot and 'dd' to your sd card (replace <drive> with the correct value):

    sudo dd if=u-boot.imx bs=1k seek=1 of=/dev/<drive> && sync

Update: To fix the problem of sound not working, down a pre-built kernel with the fix or compile your own using the our latest kernel source. To use pre-built follow instructions below:

3a. Down the pre-built kernel with cpu frequency scaling enabled or without it and 'dd' to sd card. Replace <cpu_freq_option> with cpu_freq or no_cpu_freq depending on which file you downloaded :

    sudo dd if=uImage_3.0.35-0269_<cpu_freq_option> of=/dev/<drive> bs=1048576 seek=1 && sudo sync 
                                                   
3b. Download the kernel modules for the prebuilt kernel and copy to the sd card (replace <sd card> with mount point of your sd card:

 tar xvf modules_3.0.35-02695.tar
 cp -r modules/3.0.35-02695-ga09806b-dirty <sd card>/lib/modules

4. Place image in the internal sd card slot (you need to remove the casing to access the internal sd slot) and fingers crossed it should boot (useful to have a serial console open). The image defaults to 1280x720 screen resolution, once the desktop appears, plug-in a keboard/mouse via the usb port.

5. Next configure wifi, and it may be useful to reboot after setting wifi so that the correct time is picked up.

6. Then enjoy the desktop experience!

Unfortunately shutting down from the desktop just takes you back to the logon screen. To force a  proper shut down open a command shell and issue "sudo shutdown -P now", wait a minute or so to ensure shut down is complete and then remove the usb power cable.

To verify GPU acceleration you can run glmark2-es or es2gears. To verfiy VPU run totem with a file of your choice.