Difference between revisions of "MythTV On NSLU2"

From MythTV Official Wiki
Jump to: navigation, search
(Building GCC for ARM: added errors section when building crosstool)
Line 50: Line 50:
  
 
The crosscompiler has been generated in $HOME/crosstool/arm/gcc-4.1.2-glibc-2.3.2/arm-linux-gnu
 
The crosscompiler has been generated in $HOME/crosstool/arm/gcc-4.1.2-glibc-2.3.2/arm-linux-gnu
 +
 +
----
 +
 +
===Errors during crosstool build===
 +
 +
'''IF''' you happen to get errors during your build of crosstool...
 +
 +
====Error: configure complains that gcc is too old or missing:====
 +
 +
glibc is VERY picky about which compiler compiles it. You may have gcc-4.2 and glibc won't allow that, just because.
 +
 +
To fix:
 +
*We also need to modify a patch to allow 4.2+ gcc compilers.
 +
 +
  edit patches/glibc-2.3.2/glibc-2.3.3-allow-gcc-4.0-configure.patch
 +
  # Change the line
 +
  '+    3.[2-9]*|4.[01]*)' to
 +
  '+    3.[2-9]*|4.[012]*)'
 +
 +
With thanks to: [http://code.google.com/p/robotvisionexp/wiki/Ubuntu_Setup]
 +
 +
====Error: Missing Terminating " character====
 +
 +
Somewhere in the configure process, the Makefile generated with errors and when that file (version-info.h) is used, this error is caught during the make process:
 +
 +
  version-info.h:3: error: missing terminating " character
 +
 +
To fix:
 +
*create a patch file (versioninfo.patch) in crosstool-0.43/patches/glibc-2.3.2 with contents:
 +
 +
{{Code box | versioninfo.patch|
 +
<pre>
 +
--- glib-2.3.2/csu/Makefile.orig        2008-12-05 16:34:43.000000000 +0100
 +
+++ glib-2.3.2/csu/Makefile    2008-12-05 16:38:20.000000000 +0100
 +
@@ -223,12 +223,12 @@
 +
                    os=Linux; \
 +
                  fi; \
 +
                  echo "\"Compiled on a $$os $$version system" \
 +
-                      "on `date +%Y-%m-%d`.\\n\"" ;; \
 +
+                      "on `date +%Y-%m-%d`.\"\\n" ;; \
 +
          *) ;; \
 +
        esac; \
 +
        files="$(all-Banner-files)";                          \
 +
        if test -n "$$files"; then                            \
 +
-          echo "\"Available extensions:\\n\"";                \
 +
+          echo "\"Available extensions:\"\\n";                \
 +
          sed -e '/^#/d' -e 's/^[[:space:]]*/  /'              \
 +
              -e 's/\(^.*$$\)/\"\1\\n\"/' $$files;            \
 +
        fi) > $@T
 +
</pre>
 +
}}
 +
 +
With thanks to: [http://sourceware.org/ml/crossgcc/2005-12/msg00104.html]
 +
 +
Finding and solving these 2 problems took me almost a day. Hopefully, this information has helped you save some time and frustration!
  
 
== Install and setup DISTCC ==
 
== Install and setup DISTCC ==

Revision as of 17:56, 5 December 2008

Here is a explanation about compiling and running mythtv on a slug (aka nslu2) and howto setup a crosscompiler to reduce compile time whith distcc.

Setup cross compiling environment

Building GCC for ARM

First, on a powerfull computer running linux we need to setup a crosscompiler to speed up further compilations : download crosstool from http://kegel.com/crosstool/

# tar zxf crosstool-0.43.tar.gz
# cd crosstool-0.43
# edit arm.dat to change : TARGET=arm-linux-gnu

On the slug, the version of gcc is : 4.1.2. This version (0.43) allow you to try build any version of gcc, but not all works. By default, the version built for arm is 4.1.0, so we are going to tell it to build the same version as we have on our slug : 4.1.2 Create a file called : gcc-4.1.2-glibc-2.3.2-tls.dat and put in :

Script.png gcc-4.1.2-glibc-2.3.2-tls.dat

BINUTILS_DIR=binutils-2.16.1
GCC_CORE_DIR=gcc-3.3.6
GCC_DIR=gcc-4.1.2
GLIBC_DIR=glibc-2.3.2
LINUX_DIR=linux-2.6.15.4
LINUX_SANITIZED_HEADER_DIR=linux-libc-headers-2.6.12.0
GLIBCTHREADS_FILENAME=glibc-linuxthreads-2.3.2
GDB_DIR=gdb-6.5
GLIBC_EXTRA_CONFIG="$GLIBC_EXTRA_CONFIG --with-tls --with-__thread  --enable-kernel=2.4.18"


edit demo-arm.sh and changed the following variables to :

Script.png demo-arm.sh

TARBALLS_DIR=$HOME/crosstool/downloads
RESULT_TOP=$HOME/crosstool/arm

add the following line juste before the last out and comment out the other line beginning by "eval"

Script.png demo-arm.sh

#eval `cat arm.dat gcc-4.1.0-glibc-2.3.2-tls.dat` sh all.sh --notest
eval `cat arm.dat gcc-4.1.2-glibc-2.3.2-tls.dat` sh all.sh --notest

next run :

# ./demo-arm.sh

It takes about 1 hour on a Athlon XP 2200+.

The crosscompiler has been generated in $HOME/crosstool/arm/gcc-4.1.2-glibc-2.3.2/arm-linux-gnu


Errors during crosstool build

IF you happen to get errors during your build of crosstool...

Error: configure complains that gcc is too old or missing:

glibc is VERY picky about which compiler compiles it. You may have gcc-4.2 and glibc won't allow that, just because.

To fix:

  • We also need to modify a patch to allow 4.2+ gcc compilers.
 edit patches/glibc-2.3.2/glibc-2.3.3-allow-gcc-4.0-configure.patch
 # Change the line
 '+    3.[2-9]*|4.[01]*)' to
 '+    3.[2-9]*|4.[012]*)'

With thanks to: [1]

Error: Missing Terminating " character

Somewhere in the configure process, the Makefile generated with errors and when that file (version-info.h) is used, this error is caught during the make process:

 version-info.h:3: error: missing terminating " character

To fix:

  • create a patch file (versioninfo.patch) in crosstool-0.43/patches/glibc-2.3.2 with contents:


Script.png versioninfo.patch

--- glib-2.3.2/csu/Makefile.orig        2008-12-05 16:34:43.000000000 +0100
+++ glib-2.3.2/csu/Makefile     2008-12-05 16:38:20.000000000 +0100
@@ -223,12 +223,12 @@
                     os=Linux; \
                   fi; \
                   echo "\"Compiled on a $$os $$version system" \
-                       "on `date +%Y-%m-%d`.\\n\"" ;; \
+                       "on `date +%Y-%m-%d`.\"\\n" ;; \
           *) ;; \
         esac; \
         files="$(all-Banner-files)";                           \
         if test -n "$$files"; then                             \
-          echo "\"Available extensions:\\n\"";                 \
+          echo "\"Available extensions:\"\\n";                 \
           sed -e '/^#/d' -e 's/^[[:space:]]*/  /'              \
               -e 's/\(^.*$$\)/\"\1\\n\"/' $$files;             \
         fi) > $@T

With thanks to: [2]

Finding and solving these 2 problems took me almost a day. Hopefully, this information has helped you save some time and frustration!

Install and setup DISTCC

As root :

# apt-get install distccd

edit /etc/default/distcc and adjust the settings

Script.png /etc/default/distcc

STARTDISTCC="YES"
ALLOWEDNETS="192.168.3.0/24"
LISTENER=""

edit /etc/init.d/distcc in order to add the crosscompiler to the path :

Script.png /etc/init.d/distcc

PATH=/home/tux/crosstool/arm/gcc-4.1.2-glibc-2.3.2/arm-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

restart distcc daemon :

# /etc/init.d/distcc stop
# /etc/init.d/distcc start


Compilation on the slug

Prerequisitory : building and installing some libs and programs

The following assume that you have :

  1. debian etch
  2. a swap already configured

As root : add the following in /etc/apt/sources.list :

Script.png /etc/apt/sources.list

deb-src http://www.debian-multimedia.org etch main

install some libs and programs

# apt-get update
# apt-get install make qt3-dev-tools libqt3-mt-dev libqt3-mt libqt3-mt-mysql mysql-server distccd gcc-4.1 g++-4.1 dpkg-dev build-essential

take a break, it is long

we need to disable distccd at boot as we don't need it

# update-rc.d -f distcc remove

as a regular user, setup some environnements variables :

# export CC="distcc arm-linux-gnu-gcc"
# export CXX="distcc arm-linux-gnu-g++"

setup the host we want to do the crosscompilation, I just add my powerfull computer on which crosstool has been ran :

# export DISTCC_HOSTS="tux"

now building lame as mythtv refuse to compile whithout it :

# cd /usr/src
# mkdir lame
# cd lame

as root :

# apt-get build-dep lame

as a normal user :

# apt-get -b source lame

as root :

# dpkg -i liblame-dev_3.97-0.0_arm.deb liblame0_3.97-0.0_arm.deb

Compiling Mythtv

as a regular user, setup some environnements variables :

# export CC="distcc arm-linux-gnu-gcc"
# export CXX="distcc arm-linux-gnu-g++"

setup the host we want to do the crosscompilation, I just add my powerfull computer on which crosstool has been ran :

# export DISTCC_HOSTS="tux"

get the latest version of mythtv 0.20-fixes

# cd mythtv-0.20-fixes

apply the patch as explained in http://svn.mythtv.org/trac/ticket/3661 next compile mythtv :

# ./configure --prefix=/usr
# make -j4

It takes about 2 hours. Sometimes, gcc may segfault. I didn't find where it comes from. Just run again

# make -j4

when the compilation is finished, as root :

# make install

Setup the database

Setup the root password

# /usr/bin/mysqladmin -u root password 'enter-your-good-new-password-here'
# mysql -p
# mysql> CREATE DATABASE mythconverg;
# mysql> CREATE USER mythtv IDENTIFIED BY 'mythtv';
# mysql> GRANT ALL ON mythconverg.* TO mythtv@localhost;

Setup password for mythtv

# su mythtv
# mysql
# mysql> set password = password("mythtv");


next, we need to run mythtv-setup. The little difficultie is that our slug don't have any X running. As we are connected throug ssh, we can export the display of the slug to another computer. On the powerfull computer is X : open a terminal ant type :

# xhost +

on the slug as a normal user :

# export DISPLAY=<ip of the powerfull computer>:0.0
# mythtv-setup

Et voila ! Now you can setup yout slug as a master backend.