Saturday, 1 September 2012

Debian on Pandaboard: Graphics

NOTE: Not finished !!! 3d doesn't work !!!

What is the choice ?

In relation to PandaBoard, we have a choice of 4 drivers:

---> FBDev (Linux framebuffer) - xserver-xorg-video-fbdev - a generic, hardware independent, primitive driver for Xserver
     * It is very easy to install
     * It is a framebuffer driver :P - no 2d acceleration, no 3d acceleration, no Xorg video (xv) output acceleration, etc
     * But, it will work, when everything else fails. You may need it initially to have at least GUI, or you may need it when the other two drivers crash.

---> OMAPFB - xf86-video-omapfb - open-source Xorg driver for OMAP boards, which uses DSS (display sub-system);a=summary
     * It is better than fbdev, as it is optimized for OMAP boards, specifically for DSS
     * It is a framebuffer driver; with support for overlays, XV video output, etc; but it doesn't provide 2d or 3d acceleration
     * It is open-source, so it shouldn't be too hard to install

---> x86-video-omap - open-source Xorg driver for OMAP boards, but which uses closed-source submodule for EXA acceleration.
     * It requires omapdrm support in kernel and (as I understood) SGX binaries.

---> PVR OMAP4 - pvr-omap4 - closed source driver for OMAP4 SGX GPU, which has the best performance and provides all the features
     * It is what we want the most - overlays, XV, GLES, GLES2, EGL, etc
     * It is closed source + depends on particular kernel version + depends on Xorg ABI major version + depends on armel / armhf arch. Thus, it can be a pain to install this driver. It will be ... for Debian

fbdev driver - xserver-xorg-video-fbdev

To install this driver, simply do:
sudo apt-get install xserver-xorg-video-fbdev
or just install your desktop environment straight away, e.g. LXDE
sudo apt-get install lxde
That's all. You have your driver. No need to configure anything. The default resolution I got on my HDMI TV was 640 x 480.

omapfb driver - xf86-video-omapfb

(This is not complete yet.)
Getting xf86-video-ompafb driver to work shouldn't be too hard (in theory), however the driver is old now and is no longer updated. Newest kernels seem to cause issues for this driver.
The driver can be installed as a package or built from source:

a) Installing via apt:
Two packages are provided:
--- xserver-xorg-video-omap3, which was built with -mfpu=neon flag and is thus optimized for NEON extension (which we have - gives performance boost)
--- xserver-xorg-video-omapfb, which is the same as -omap3, but is not optimized for NEON
To install the driver, simply run:
sudo apt-get install xserver-xorg-video-omap3
or, if you want the one without NEON optimizations:
sudo apt-get install xserver-xorg-video-omapfb
and set up the Xorg (will be described further).

b) Building and installing from source:
0) Install all the necessary tools and developmental packages:
sudo apt-get install build-essential autoconf libtool gettext xutils-dev x11proto-render-dev xorg-dev
(Some of them you might already have.)
1) Clone any of the following git repos:
(They give same results anyway)
git clone
git clone git://
2) Configure the driver:
cd xf86-video-omapfb
./configure --prefix=/usr --with-xorg-module-dir=/usr/lib/xorg/modules --enable-neon CFLAGS="-O2 -mtune=cortex-a9 -mfpu=neon"
3) Check makefiles (in xf86-video-omapfb and xf86-video-omapfb/src dirs) for CFLAGS variable, which should have "-mfpu=neon" flag. If this flag is missing, add it. Otherwise, the build will fail.
4) Compile and install the driver:
sudo make install
5) Configure Xorg

Configuring Xorg for xf86-video-omapfb:
We will create new configuration file in /usr/share/X11/xorg.conf.d directory. I have looked at Xorg configuration file for pvr-omap4 drivers, so I named the file "99-omapfb.conf" (you can give it any other name). So:
sudo nano /usr/share/X11/xorg.conf.d/99-omapfb.conf
and add the following configuration (true for HDMI certainly), or something similar:
Section "Device"
    Identifier    "OMAPFB Video Device"
    Driver        "omapfb"
    Option        "fb"    "/dev/fb0"

Section "Monitor"
    Identifier "hdmi"

Section "Screen"
    Identifier    "Screen0"
    Monitor        "hdmi"
    Device        "OMAPFB Video Device"
    DefaultDepth     16
Save and exit. Reboot:
sudo reboot
Xorg should start.

Current result:
It did start. Resolution is still the same though - 640x480. XRandr doesn't give any choices. XVideo is still useless - "No adaptors present." The following is my Xorg.0.log output, in relation to omapfb:
anton@arm:~$ cat /var/log/Xorg.0.log | grep omapfb
[    20.313] Kernel command line: console=ttyO2,115200n8 console=tty0 vram=16MB omapfb.mode=hdmi:1280x720MR-16@60 omapdss.def_disp=hdmi root=/dev/mmcblk0p2 ro rootfstype=ext4 rootwait fixrtc buddy= buddy2=
[    20.427] (II) LoadModule: "omapfb"
[    20.432] (II) Loading /usr/lib/xorg/modules/drivers/
[    20.436] (II) Module omapfb: vendor="X.Org Foundation"
[    20.437] (II) omapfb: Driver for OMAP framebuffer (omapfb) and external LCD controllers:
[    20.437] (WW) Error opening /sys/devices/platform/omapfb/ctrl/name: No such file or directory
[    20.438] (II) omapfb(0): Base plane capabilities:
[    20.438] (II) omapfb(0): Base plane supports the following image formats:
[    20.438] (II) omapfb(0): VideoRAM: 600KiB (SDRAM)
[    20.438] (II) omapfb(0): Creating default Display subsection in Screen section
[    20.438] (--) omapfb(0): Depth 16, (==) framebuffer bpp 16
[    20.438] (==) omapfb(0): RGB weight 565
[    20.438] (==) omapfb(0): Default visual is TrueColor
[    20.438] (II) omapfb(0): Detecting outputs
[    20.438] (II) omapfb(0): Output dvi using monitor section hdmi
[    20.438] (II) omapfb(0): Output hdmi using monitor section hdmi
[    20.439] (II) omapfb(0): overlayPoolInit: Found 3 framebuffers, 4 overlays and 3 managers
[    20.440] (II) omapfb(0): Printing probed modes for output dvi
[    20.440] (II) omapfb(0): Modeline "640x480"x59.5   23.50  640 688 720 800  480 483 487 494 (29.4 kHz P)
[    20.440] (II) omapfb(0): Printing probed modes for output hdmi
[    20.440] (II) omapfb(0): Modeline "640x480"x60.1   25.18  640 656 688 800  480 491 511 524 (31.5 kHz P)
[    20.440] (II) omapfb(0): Output dvi connected
[    20.440] (II) omapfb(0): Output hdmi connected
[    20.440] (II) omapfb(0): Using exact sizes for initial modes
[    20.440] (II) omapfb(0): Output dvi using initial mode 640x480
[    20.440] (II) omapfb(0): Output hdmi using initial mode 640x480
[    20.440] (II) omapfb(0): Using default gamma of (1.0, 1.0, 1.0) unless otherwise stated.
[    20.440] (II) omapfb(0): XRandR extension initialized
[    20.440] (--) omapfb(0): Virtual size is 640x480 (pitch 640)
[    20.440] (**) omapfb(0):  Mode "640x480": 25.2 MHz, 31.5 kHz, 60.1 Hz
[    20.440] (II) omapfb(0): Modeline "640x480"x60.1   25.18  640 656 688 800  480 491 511 524 (31.5 kHz P)
[    20.440] (==) omapfb(0): DPI set to (96, 96)
[    20.458] (EE) omapfb(0): FBIOBLANK: Invalid argument
[    20.458] (==) omapfb(0): DPMS enabled
[    20.458] (II) omapfb(0): RandR 1.2 enabled, ignore the following RandR disabled message.
[    20.640] (II) omapfb(0): Setting screen physical size to 169 x 127
[    20.922] (WW) omapfb(0): overlayPoolApplyConnections: Disconnecting overlay 0
[    20.922] (WW) omapfb(0): overlayPoolApplyConnections: Connecting 0 -> 0 -> 1
I played a lot with options in Xorg configurations. I will try to build custom kernel and test this driver. Also I will try omapfb optimized mplayer. This driver should be useful, at least better than fbdev.

omap driver - xf86-video-omap

Will test later ...

pvr-omap4 driver

The problem:
Debian Wheezy currently provides Xserver version, which is not supported and ,most likely, will not be supported by OMAP PPA team:!topic/pandaboard/BYFaLYzCniQ
(Thanks to ndec for letting me know.)
So, what does it mean ? Well, the pvr-omap4 driver depends on Xorg server version. Ubuntu OMAP ppa trunk provides drivers for Xserver version 13 (for Ubuntu 12.10 ), which is not yet out. Ubuntu OMAP ppa release provides drivers for Xserver version 11 (for Ubuntu 12.04), which is older than what we have. If you try to install these drivers without upgrading / downgrading your Xorg, the Xorg will crash and you will get:
"module ABI major version (11) doesn't match the server's version (12)"

"module ABI major version (13) doesn't match the server's version (12)"
Thus we have only 2 choices in this situation:
---- a) Downgrade Xorg from 1.12.xx to 1.11.xx and install drivers for Xserver version 11
---- b) Wait when Xorg 1.13.xx becomes available, upgrade Xorg from 1.12.xx to 1.13.xx and install the drivers for Xserver version 13
Upgrade is much safer than downgrade, usually. But I hate to wait.

Option A - Xorg downgrade, using the drivers for Xserver ABI 11:

1) Build and install Ubuntu kernel, if you haven't done it already:
2) Uninstall Xorg (1.12.xx), if you have it:
sudo apt-get remove xserver-xorg-core xserver-xephyr
(don't worry about other packages, which will be removed).
3) Download specific .debs, which will give us Xserver ABI 11, keyboard / mouse support and fbdev:
(Source page: )
4) In the same directory (where your downloaded packages are), run the following to install the packages:
sudo dpkg -i xserver-xephyr_1.11.4-1_armhf.deb xserver-common_1.11.4-1_all.deb xserver-xorg-core_1.11.4-1_armhf.deb xserver-xorg-input-evdev_2.6.0-2_armhf.deb xserver-xorg-video-fbdev_0.4.2-4_armhf.deb
OR run this, if you are lazy and have nothing else in that directory:
sudo dpkg -i *
5) If you have got NO errors, reboot to test your downgraded Xserver:
sudo reboot
 and verify that you mouse / keyboard still work.
(If you have errors during installation, remove the problematic packages, reinstall the working Xserver and try again. If you fail to install fbdev - you will have no video, if you fail to install evdev - your keyboard + mouse will be unresponsive.)

Building and installing the omapdrm_pvr module (from pvr-omap4-dkms source):

0) Install dos2unix (needed for building), if you don't have it:
sudo apt-get install dos2unix
1) Download the right version of pvr-omap4-dkms:
    a) For Xorg 1.11.xx
2) Extract the source:
tar xzf pvr-omap4-dkms_$DKMS.orig.tar.gz
3) Set some variables (DISCIMAGE variable is probably useless...):
export KERNELDIR=$HOME/ubuntu-precise
export DISCIMAGE=/
This, of course, assumes that your kernel source is ubuntu-precise folder in your home directory. Change the value of the variable if it is not the case. (The module needs kernel sources to be built.)
4) Cd into driver directory and build the module:
cd git-import-orig/sgx/eurasiacon/build/linux2/omap4430_linux
5) Install the module (uname -r extracts the release number of the kernel - it is needed to make a correct directory for modules):
sudo mkdir /lib/modules/$KERNELRELEASE
sudo mkdir /lib/modules/$KERNELRELEASE/kernel
sudo mkdir /lib/modules/$KERNELRELEASE/kernel/extra
sudo cp $HOME/git-import-orig/sgx/eurasiacon/binary2_omap4430_linux_release/target/omapdrm_pvr.ko /lib/modules/$KERNELRELEASE/kernel/extra

Loading omapdrm_pvr module:

Now that we have installed the module, we need to load it. To check that your module is not loaded indeed, run:
and you will get nothing, i.e. this:
Module                  Size  Used by
which means that no modules are currently loaded.

If you want to check that your module can be loaded, run the following:
sudo insmod /lib/modules/$KERNELRELEASE/kernel/extra/omapdrm_pvr.ko
and you should get this:
Module                  Size  Used by
omapdrm_pvr           157683  0
which means that the module is loadable. But this is not exactly what we want ... We need auto-loading, at boot time

To load the omapdrm_pvr module at boot, proceed as follows:
0) Gain root privileges and set a variable
1) Create modules.builtin and modules.order files in your kernel modules directory
touch /lib/modules/$KERNELRELEASE/modules.builtin
touch /lib/modules/$KERNELRELEASE/modules.order
2) Add "kernel/extra/omapdrm_pvr.ko" as the contents for both of them
echo "kernel/extra/omapdrm_pvr.ko" > /lib/modules/$KERNELRELEASE/modules.builtin
echo "kernel/extra/omapdrm_pvr.ko" > /lib/modules/$KERNELRELEASE/modules.order
3) Run depmod (this will create all the necessary files for automatic loading of the module)
depmod -a
4) Edit /etc/modules file, which will load the module for us at boot
nano /etc/modules
and add the following line
to the end, save and exit.
5) Reboot your system to test the module
and at the next boot, use lsmod again. You should have the module loaded at each boot.

Installing pvr-omap4 libraries, binaries and configuration files:

1) Download, extract the correct version of the pvr-omap4 drivers to your home directory, gain root privileges and set a variable:
    a) For Xorg 1.11.xx:

tar xzf pvr-omap4_1.
2) Copy all the necessary files (including headers, but without debug data and documents):
cp -f usr/lib/$PVRVERS usr/lib/$PVRVERS usr/lib/ usr/lib/$PVRVERS usr/lib/$PVRVERS usr/lib/$PVRVERS usr/lib/$PVRVERS usr/lib/$PVRVERS usr/lib/$PVRVERS usr/lib/$PVRVERS usr/lib/$PVRVERS usr/lib/$PVRVERS usr/lib/$PVRVERS usr/lib/$PVRVERS /usr/lib
cp -f usr/lib/pkgconfig/* /usr/lib/pkgconfig
cp -f usr/lib/xorg/modules/drivers/ /usr/lib/xorg/modules/drivers
cp -f usr/share/X11/xorg.conf.d/99-pvr.conf.panda /usr/share/X11/xorg.conf.d
cp -r -f usr/share/sgx-lib /usr/share
cp -f usr/bin/* /usr/bin
cp -r -f usr/include/KHR /usr/include
cp -r -f usr/include/GLES /usr/include
cp -r -f usr/include/VG /usr/include
cp -r -f usr/include/EGL /usr/include
cp -r -f usr/include/GLES2 /usr/include
3) Make all the necessary symbolic links:
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/ /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/ /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/ /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
ln -s /usr/lib/ /usr/lib/
ln -s /usr/lib/$PVRVERS /usr/lib/
 4) Warning: The next command will apply changes to your Xorg configuration ! Up to this point your Xorg was untouched. Now, you have a potential to crash your Xorg at the next boot ! You have been warned.
Run this to use PVR driver at the next boot:
mv /usr/share/X11/xorg.conf.d/99-pvr.conf.panda /usr/share/X11/xorg.conf.d/99-pvr.conf
5) Reboot your system:

And, this is as far as I can get. What are the results you ask ? Well:
- Xorg starts
- From the logs, I can state that pvr driver is being used indeed
- Mouse pointer freezes from time to time and I can assume that there is a massive SD card I/O activity
- Xrandr works and I can switch between resolutions
- Rendering doesn't work !!! All tests fail. Xeglinfo fails.
- Details are here:!topic/pandaboard/FLegeDRqzzQ

So, pvr driver works, but 3d doesn't. I would love to finish the guide and get the 3d to work, but I run out of time (I am a dental student - my term starts from the 3d of Sept).

Thus, I would be very happy if someone could finish this thing off and get the rendering to work :) But please, let me know !

Additional details:
- All versions of sources have been used as stated in the guide
- libdrm was installed (most likely when I have installed lxde)
- libdri was not installed (well, apt-get stated that it could not locate the package: libdr, libdri2, etc - but if DRM is installed, DRI must also be installed, or, at least, installable ???)
- I tried to install libdrm from source from OMAP PPA Release. Succeeded. But no effect - no 3d :(
- Tried to apply OMAP patch to libdrm (for OMAP support - but I don't think it is needed - armin76 didn't tell anything about it ?). Failed, couldn't successfully run autoconf and configure (i have installed autoconf beforehand ).
- Tried to install libdri2 from source from OMAP PPA Release. Asked for xorg-macros. Tried to install it from source (1.10, debian unstable) - failed. Configure failed.
- Made extensive changes to kernel configuration - changed all things that are related / could be related to GPU, DRM, Power Saving, DMA, etc to be the same as in Ubuntu configuration - didn't help in any way - same results.
- Used modprobe - no effect
- Installed Modules.symvers from built pvr-omap4-dkms - no effect ...
- Tried passing BUILD=debug for pvr-omap4-dkms. Failed to compile ...
- Tried BUILD=timing ... Succeeded, but no effect ...
- Tried passing W=1 for pvr-omap4-dkms - lots of warning ! No effect
- Tried to install kernel with modules (Ubuntu configuration, modules as modules). Failed ! make modules install gives me errors and doesn't work no matter what I do ! This is why I make them all built-in (if I can) ....
- Tried 3.2.0-1412.16 kernel ... Changed some commands to download, extract ... The procedure didn't work. Armin76's config didn't work after using sed commands. And I can't install kernel with modules ...
- Tried 3.2.0-1412.16 kernel with omap4_defconfig + all odules built-in ... Failed - didn't boot successfully.
- Tried the newest 3.4 kernel (from OMAP release ppa) with omap4plus_defconfig + all modules built-in. Failed again - didn't boot successfully
- I run out of ideas :(