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)
http://git.pingu.fi/xf86-video-omapfb/
http://gitweb.pingu.fi/?p=xf86-video-omapfb.git;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.
https://github.com/robclark/xf86-video-omap
http://cgit.freedesktop.org/xorg/driver/xf86-video-omap/
     * 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
https://launchpad.net/~tiomap-dev/+archive/release 
https://launchpad.net/~tiomap-dev/+archive/omap-trunk
     * 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:
http://git.pingu.fi/xf86-video-omapfb/
git://anonscm.debian.org/collab-maint/xf86-video-omapfb.git
(They give same results anyway)
git clone http://git.pingu.fi/xf86-video-omapfb.git
OR
git clone git://anonscm.debian.org/collab-maint/xf86-video-omapfb.git
2) Configure the driver:
cd xf86-video-omapfb
./autogen.sh
./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:
make
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"
EndSection

Section "Monitor"
    Identifier "hdmi"
EndSection

Section "Screen"
    Identifier    "Screen0"
    Monitor        "hdmi"
    Device        "OMAPFB Video Device"
    DefaultDepth     16
EndSection
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/omapfb_drv.so
[    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
anton@arm:~$
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 1.12.xxx version, which is not supported and ,most likely, will not be supported by OMAP PPA team:
https://groups.google.com/forum/?fromgroups#!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)"
or

"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
OR
---- 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:
http://alastordmcblog.blogspot.ie/2012/05/debian-on-pandaboard-building-ubuntu.html
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: http://snapshot.debian.org/package/xorg-server/2%3A1.11.4-1/ )
wget http://snapshot.debian.org/archive/debian/20120305T093701Z/pool/main/x/xorg-server/xserver-xephyr_1.11.4-1_armhf.deb
wget http://snapshot.debian.org/archive/debian/20120305T052015Z/pool/main/x/xorg-server/xserver-common_1.11.4-1_all.deb
wget http://snapshot.debian.org/archive/debian/20120305T093701Z/pool/main/x/xorg-server/xserver-xorg-core_1.11.4-1_armhf.deb
wget http://snapshot.debian.org/archive/debian/20120305T224435Z/pool/main/x/xserver-xorg-input-evdev/xserver-xorg-input-evdev_2.6.0-2_armhf.deb
wget http://snapshot.debian.org/archive/debian/20120305T224435Z/pool/main/x/xserver-xorg-video-fbdev/xserver-xorg-video-fbdev_0.4.2-4_armhf.deb
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
DKMS="1.7.10.0.1.20"
wget https://launchpad.net/~tiomap-dev/+archive/release/+files/pvr-omap4-dkms_$DKMS.orig.tar.gz
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
make
5) Install the module (uname -r extracts the release number of the kernel - it is needed to make a correct directory for modules):
KERNELRELEASE=$(uname -r)
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:
lsmod
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:
KERNELRELEASE=$(uname -r)
sudo insmod /lib/modules/$KERNELRELEASE/kernel/extra/omapdrm_pvr.ko
lsmod
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
su
KERNELRELEASE=$(uname -r)
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
omapdrm_pvr
to the end, save and exit.
5) Reboot your system to test the module
reboot
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:
cd

wget https://launchpad.net/~tiomap-dev/+archive/release/+files/pvr-omap4_1.7.10.0.1.21.orig.tar.gz
tar xzf pvr-omap4_1.7.10.0.1.21.orig.tar.gz
su
PVRVERS="1.7.10.0"
2) Copy all the necessary files (including headers, but without debug data and documents):
cp -f usr/lib/libusc.so.$PVRVERS usr/lib/libTIPVR2DBLT.so.$PVRVERS usr/lib/libpvrPVR2D_DRIWSEGL.so.1.7.10.0 usr/lib/libpvr2d.so.$PVRVERS usr/lib/libsrv_um.so.$PVRVERS usr/lib/libOpenVG.so.$PVRVERS usr/lib/libEGL.so.$PVRVERS usr/lib/libGLESv2.so.$PVRVERS usr/lib/libOpenVGU.so.$PVRVERS usr/lib/libPVRScopeServices.so.$PVRVERS usr/lib/libIMGegl.so.$PVRVERS usr/lib/libsrv_init.so.$PVRVERS usr/lib/libGLESv1_CM.so.$PVRVERS usr/lib/libglslcompiler.so.$PVRVERS /usr/lib
cp -f usr/lib/pkgconfig/* /usr/lib/pkgconfig
cp -f usr/lib/xorg/modules/drivers/pvr_drv.so /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/libusc.so.$PVRVERS /usr/lib/libusc.so
ln -s /usr/lib/libTIPVR2DBLT.so.$PVRVERS /usr/lib/libTIPVR2DBLT.so
ln -s /usr/lib/libpvrPVR2D_DRIWSEGL.so.$PVRVERS /usr/lib/libpvrPVR2D_DRIWSEGL.so
ln -s /usr/lib/libpvr2d.so.$PVRVERS /usr/lib/libpvr2d.so
ln -s /usr/lib/libsrv_um.so.$PVRVERS /usr/lib/libsrv_um.so
ln -s /usr/lib/libOpenVG.so.$PVRVERS /usr/lib/libOpenVG.so.1
ln -s /usr/lib/libOpenVG.so.1 /usr/lib/libOpenVG.so
ln -s /usr/lib/libEGL.so.$PVRVERS /usr/lib/libEGL.so.1
ln -s /usr/lib/libEGL.so.1 /usr/lib/libEGL.so
ln -s /usr/lib/libGLESv2.so.$PVRVERS /usr/lib/libGLESv2.so.2
ln -s /usr/lib/libGLESv2.so.2 /usr/lib/libGLESv2.so
ln -s /usr/lib/libOpenVGU.so.$PVRVERS /usr/lib/libOpenVGU.so
ln -s /usr/lib/libPVRScopeServices.so.$PVRVERS /usr/lib/libPVRScopeServices.so
ln -s /usr/lib/libIMGegl.so.$PVRVERS /usr/lib/libIMGegl.so
ln -s /usr/lib/libsrv_init.so.$PVRVERS /usr/lib/libsrv_init.so
ln -s /usr/lib/libGLESv1_CM.so.$PVRVERS /usr/lib/libGLESv1_CM.so.1
ln -s /usr/lib/libGLESv1_CM.so.1 /usr/lib/libGLESv1_CM.so
ln -s /usr/lib/libglslcompiler.so.$PVRVERS /usr/lib/libglslcompiler.so
 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:
reboot

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:
https://groups.google.com/forum/?fromgroups=#!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 :(




4 comments:

  1. I'm trying the same thing...
    I want pvr-omap4 3D graphics with Debian Wheezy on my pandaboard.

    Would it help if we combine our efforts?
    I'm planning a gentoo install based on armin76's documentation and ebuilds. If it works on gentoo, maybe we can compare version numbers...

    ReplyDelete
    Replies
    1. Hi, thanks, ye it would certainly help. But ... I would be unable to do anything with my Panda for at least 6 weeks or so, because I have a lot of studies to do (dental student). Feel free to use this page. However, please do post me a link to you own work when you try do get 3d to work :)
      So, I think your idea is good. I know, 3d on Gentoo does work, but 3d on Debian doesn't work for some reason. I think I have used the same kernel, same dkms, same user-space binaries. The difference might be in Xorg, DRM, or something else. Too bad most other kernels fail to boot for me - can't try the newest 3d drivers :(
      Good luck and keep me updated (through comments or something) !

      Delete
  2. Hello, great post.

    I'd to know if is possible compile pvr-omap4 in a distro like Buildroot ?

    Thanks..
    Fabio

    ReplyDelete
    Replies
    1. You mean the DKMS ? Ye, should be possible. But it would need to be compiled against particular kernel, Xorg, etc. I think it would be more problematic ... Even if you do succeed building omapdrm_pvr.ko module, you will then need to install it, load and test it. Good luck if you want to give it a try !

      Delete