Running enigma2 in the sh4 arch

In a previous post I described how to compile enigma2 for the sh4 architecture. In this follow-up post I describe what you would need in order to run it properly since there has been some confusion on how to execute a software that was created and tested for another architecture (mips).

As before,  the procedure I describe was done on a STb7109 cut 3.0 board, also called cocoref MB442 from ST.

Enigma2 is a nice piece of software that runs without problems in a MIPS-based decoder like the DM8000 that contains a specific filesystem configuration and drivers written for that hardware. Obviously, these drivers are dependent of the underneath architecture and you cannot expect them to work in another architecture like the sh4.

The ideal solution to this issue would be to have a porting of enigma2 to the sh4, specifically to the Kathrein UFS-910. In fact, some guys (the Duck Tales team) ported enigma2 to this decoder that mounts an STb710x processor. Therefore, you would only need to download the source code (that is GPL), compile it, create the filesystem structure that enigma2 expects like the default skins that are in /usr/share/enigma2, and run it.

Unfortunately, I haven’t been able to find that source code nor to contact that team (feel free to contact me if you have information about where to download it or how to contact them).

The consequence of this fact is that you would have to download a ‘vanilla’ enigma2 and modify it according to the drivers that you have in your decoder or modify the drivers so they send/receive the data that enigma2 expects.

I chose the first option that seemed better in my case. Therefore, I started to modify enigma2 in at least the following areas:

  • Modify the framebuffer access for the On-Screen-Display (OSD)
  • Modify the front-panel LCD access
  • Modify the infrared port (remote control) access.
  • Create several soft links and new directories that enigma2 expects. Eg. I installed enigma2 in /usr/local, whilst in the dm8000 is in /usr.
  • Substitute the use of /proc filesystem. Enigma2 uses information given by the /proc filesystem, this information basically does not change over time, so it can be substituted by normal files (this is done in the UFS-910).

Notice that in my case I’m not porting enigma2 to the UFS-910, but to a completely new board. This means that even if the processor is the same (an STb710x) the devices like the front-panel LCD are different. But if I had the enigma2 sources for the UFS-910, it would have saved me a lot of time because some of the aforementioned modifications would not be necessary (they would have been already included in those sources).

Conclusion, I hope this post clarifies all the doubts that compiling a ‘vanilla’ enigma2 for another architecture may not be sufficient for running it due to the fact that enigma2 is quite dependent of the Dreambox hardware.

Installing Python packages for enigma2

In a previous post I described how to compile enigma2 for the sh4 arch. That procedure works as expected if you have Python 2.5 or greater. In my case I had Python 2.4 that does not contain some packages that enigma2 requires.

In this post I describe which packages are missing and how to compile and install them.
As before, my target is an STb7109 cut 3.0 board, also called cocoref MB442, that is part of the sh4 arch family.

These are the four packages:

  • elementtree-1.2.6-20050316
  • cElementTree-1.0.5-20051216
  • zope.interface-3.3.0.tar.gz
  • Twisted-8.1.0.tar.bz2

The elementtree and cElementTree packages are needed only if you have Python version <2.5, whilst zope.interface and Twisted must be downloaded and installed independently of the Python version because they are not included in any Python release.

elementtre and cElementTree are used for optimizing XML parsing with low memory use. Typically, cElementTree is 15-20 times faster than the Python version of ElementTree, and uses 2-5 times less memory. Both packages can be downloaded from here: http://effbot.org/zone/celementtree.htm

zope.interface is a web application server that publishes on the web Python objects persisted in an object database such as documents, images and page templates. It can be downloaded from here: http://zope.org/Products/ZopeInterface

Twisted is an event-driven networking engine. It can be downloaded from here: http://twistedmatrix.com/trac


Compiling and installing

Copy the packages to your rootfs and connect to your target. This will be a native compilation, not a cross-compilation as in the previous post.
Remember that PREFIX is the path in your host of the rootfs of your target. In my case is the following. Adjust it according to your configuration:

$ export PREFIX=/opt/oe/STM/STLinux-2.2/devkit/sh4/target

Copy and connect to target:

$ cp elementtree-1.2.6-20050316.tar.gz $PREFIX/home
$ cp cElementTree-1.0.5-20051216.tar.gz $PREFIX/home
$ cp zope.interface-3.3.0.tar.gz $PREFIX/home
$ cp Twisted-8.1.0.tar.bz2 $PREFIX/home
$ ssh root@target

Untar the packages and install them:


elementtree

$ cd /home
$ tar xvfz elementtree-1.2.6-20050316.tar.gz
$ cd elementtree-1.2.6-20050316
$ python setup.py install


cElementTree

$ cd ..
$ tar xvfz cElementTree-1.0.5-20051216.tar.gz
$ cd cElementTree-1.0.5-20051216
$ python setup.py install


zope.interface

$ cd ..
$ tar xvfz zope.interface-3.3.0.tar.gz
$ cd zope.interface-3.3.0
$ python setup.py build


Twisted

$ cd ..
$ tar xvfj Twisted-8.1.0.tar.bz2
$ cd Twisted-8.1.0
$ python setup.py install

As you can see, it’s a very simple and standard procedure normally used for installing Python packages.
However, notice that for installing cElementTree, zope.interface and Twisted, Python will compile C source code. Since this is a native compilation in the target it will take significantly more time than in your host.
Once you have these packages installed enigma2 will not give any errors regarding missing Python packages and will have all its default functionality activated.

Cross-compiling Swfdec over DirectFB v0.2

This guide describes how to cross-compile the OSS Flash player Swfdec for a SH4 processor.


Intro

Sfwdec 0.6.6 has made significant progress since version 0.5.2. Building it is almost straight forward compared to older versions in which you had to heavily tweak the Makefiles.

Since Swfdec 0.6.6 uses its GTK+ player in order to run in standalone mode, it needs GTK+ and all the libraries below it.

The procedure for compiling GTK+ is described in the post Cross-compiling GTK+ over DirectFB v0.2 .

There is a DirectFB player for Swfdec 0.5.2, but it needs to be ported to the 0.6.6 and I haven’t had time for doing it, but when we tested it several months ago, it was significant faster than the GTK+ player. If you are interested in how to compile the DirectFB player check the post  Cross-compiling swfdec over DirectFB

Additionally to the GTK+ libs, Sfwdec needs some other libs for working like libsoup.
These are the packages and their versions used for compiling Swfdec 0.6.6

I tested this procedure in a STMicroelectronics ST40 processor (SH4 architecture). If you’re using this processor, this is the configuration I have:

  • Board: STB7109 cut 3.0, also called cocoref_gold_7109
  • Linux distribution: STLinux 2.2
  • DirectFB driver: stgfb-3.0_stm23_0008-4


Environment configuration

Suppose that Swfdec and its libraries will be installed in /opt/oe/STM/STLinux-2.2/devkit/sh4/target and that the cross-toolchain (compiler, linker…) is in your path

Set the following environment variables:

$ export PREFIX=/opt/oe/STM/STLinux-2.2/devkit/sh4/target/usr/local
$ export LD_LIBRARY_PATH=$PREFIX/lib
$ export PKG_CONFIG_PATH=$LD_LIBRARY_PATH/pkgconfig
$ export COMPILER=sh4-linux-gcc
$ export HOST=sh4-linux
$ export BUILD=i386-linux


Building the requirements


liboil 0.3.15

Configure, compile and install:

$ ./configure --build=$BUILD --host=$HOST --prefix=$PREFIX
$ make
$ make install


libsoup 2.4.1

Configure, compile and install:

$ ./configure --build=$BUILD --host=$HOST --prefix=$PREFIX 
  --disable-glibtest --disable-ssl --enable-debug=no
$ make
$ make install


libmad 0.15.1b

Configure, compile and install:

$ ./configure --build=$BUILD --host=$HOST --prefix=$PREFIX 
  --disable-debugging --enable-speed
$ make
$ make install

Building Swfdec 0.6.6

Change to $PREFIX and uncompress it:

$ cd $PREFIX
$ tar xvfz swfdec-0.6.6.tar.gz

Configure:

$ PANGO_CFLAGS="-I$PREFIX/include/pango-1.0 
    -I$PREFIX/include/glib-2.0 
    -I$PREFIX/lib/glib-2.0/include" 
  PANGO_LIBS="-L$PREFIX/lib -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0" 
  GTK_CFLAGS="-D_REENTRANT -I$PREFIX/include/gtk-2.0 
    -I$PREFIX/lib/gtk-2.0/include 
    -I$PREFIX/include/cairo 
    -I$PREFIX/include/freetype2 
    -I$PREFIX/include 
    -I$PREFIX/include/libpng12 
    -I$PREFIX/../../usr/include/directfb 
    -I$PREFIX/include/atk-1.0 
    -I$PREFIX/include/pango-1.0 
    -I$PREFIX/include/glib-2.0 
    -I$PREFIX/lib/glib-2.0/include 
    -I$PREFIX/include/libsoup-2.4" 
  GTK_LIBS="-L$PREFIX/lib 
    -lgtk-directfb-2.0 -lgdk-directfb-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 
    -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0 -lsoup-2.4" 
  HTTP_CFLAGS="-I$PREFIX/include/libsoup-2.4 
    -I$PREFIX/include/libxml2 
    -I$PREFIX/include/glib-2.0 
    -I$PREFIX/lib/glib-2.0/include" 
  HTTP_LIBS="-L$PREFIX/lib 
    -lsoup-2.4 -lxml2 -lglib-2.0" 
  ./configure 
  --build=$BUILD 
  --host=$HOST 
  --prefix=$PREFIX 
  --disable-gstreamer 
  --enable-mad 
  --with-audio=none

Edit tools/Makefile:
Set the LIBS variable the following value:

LIBS = -ldirectfb -ldirect -lfusion -lfontconfig -lpangocairo-1.0

Compile and install:

$ make
$ make install

That’s it.