Archive for the ‘Gentoo’ Category

Articles

Gentoo XBMC Installation

In Gentoo,XBMC on 18/04/2011 by pier0w

With the Gentoo Installation and Gentoo XBMC Pre-Setup complete it should just be able to be emerged with our any hassle.

#> emerge -av xbmc

When that completes XBMC should be able to be started by simply running the command xbmc from an xterm within an X environment.

#> startx

Now from inside one of the xterms.
#> xbmc

XBMC should now be running.

To get XBMC to display on the TV we need to do create a couple X11 configuration files within the /usr/share/X11/xorg.conf.d/.

The first configuration file will tell X11 to always use the intel driver and also provide labels for the TV and laptop monitor.

/usr/share/X11/xorg.conf.d/11-intel.conf:
Section "Device"
    Identifier "Intel Graphics Card"
    Driver "intel"
    Option "Monitor-LVDS1" "LCD screen"
    Option "Monitor-VGA1" "VGA screen"
EndSection
Section "dri"
    Mode 0666
EndSection

The files name starts with 11 so that it will be executed after the original config file which starts with 10. Any additional config files can have their execution order set in this way.

The "Device" section is where the driver and monitor labels are set, the first name in the Option lines is the actual name that X11 gives the physical devices. X11 gives all video outputs a name that starts with “Monitor-” it then appends that device name on to that, to find the device name of a monitor you can use the xrandr -q command.

Screen 0: minimum 320 x 200, current 3200 x 1080, maximum 4096 x 4096
LVDS1 connected 1280x800+1920+0 (normal left inverted right x axis y axis) 331mm x 207mm
   1280x800       61.0*+
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 886mm x 498mm
   1920x1080      60.0 +
   1600x1200      60.0  
   1680x1050      60.0  
   1280x1024      75.0     60.0  
   1440x900       75.0     59.9  
   1280x960       60.0  
   1360x768       60.0  
   1280x800       59.8* 
   1152x864       75.0  
   1024x768       75.1     70.1     60.0  
   832x624        74.6  
   800x600        72.2     75.0     60.3  
   640x480        72.8     75.0     66.7     60.0  
   720x400        70.1  
TV1 unknown connection (normal left inverted right x axis y axis)
   848x480        30.0 +
   640x480        30.0 +
   1024x768       30.0  
   800x600        30.0

From the output of this you can see that the laptop screen is called LVD1 and the vga plug is called VGA1 so the X11 names will be Monitor-LVD1 and Monitor-VGA1 respectively.

The "dri" turns on the hardware acceleration.

Now that the monitors have been labelled we need to tell X11 what configuration they are in, this I have done in another config file.

/usr/share/X11/xorg.conf.d/12-dual-screen.conf:
Section "Monitor"
    Identifier "LCD screen"
EndSection

Section "Monitor"
    Identifier "VGA screen"
    Option "LeftOf" "LCD screen"
    Option "PreferredMode" "1920x1080"
EndSection

This tells X11 that there are two monitors associated to the two output devices, it also tells X11 that the "VGA screen" (the TV) should be set to the resolution 1920×1080 and that it is to the left of the "LCD screen".

Now this should work fine with XBMC… and it sort of does. If you start up the X11 server then start up XBMC inside of it you will see that the resolution will be set to the 1280×800, the laptops resolution, but if you then close XBMC but NOT the X11 server then start XBMC again it will be at the right resolution. I have no idea why this is but there you go. Because of this I have created a hack in the next section.

But, if you want to have XBMC start in the correct resolution in a more correct way there are two things you can do.

The first is tell X11 to turn off the laptop monitor, this is good because it saves power and won’t burn out the monitor, but it means when X11 shuts down the monitor won’t turn back on so you are stuck with having to use the TV as the only monitor. In reality this isn’t that bad because you’ll surely be using ssh to do anything with the command line on the laptop any way. So to turn of the laptop monitor use this configuration.

/usr/share/X11/xorg.conf.d/12-dual-screen.conf:
Section "Monitor"
    Identifier "LCD screen"
    Option "Disable" "True"
EndSection

Section "Monitor"
    Identifier "VGA screen"
    Option "PreferredMode" "1920x1080"
EndSection

Though, if for some reason you want the laptop monitor to stay on but still want XBMC to start correctly you can set X11 to ignore the laptop monitor. This is good because it stays on, but bad because it ALWAYS stays on even with the lid close so may burn out the monitor.

/usr/share/X11/xorg.conf.d/12-dual-screen.conf:
Section "Monitor"
    Identifier "LCD screen"
    Option "Ignore" "True"
EndSection

Section "Monitor"
    Identifier "VGA screen"
    Option "PreferredMode" "1920x1080"
EndSection

So now that X11 is configured XBMC should start up and run perfectly on your TV.

Articles

Gentoo XBMC Pre-Setup

In Gentoo,XBMC on 18/04/2011 by pier0w

There is some extra configuration that is required before XBMC can be installed. This is mostly to do with unmasking some packages and setting up some USE flags.

So first create the /etc/portage/ directory, this is where the unmask, keyword, and use files will go.

Next create the following files:

/etc/portage/package.use:
media-video/mplayer fbcon
x11-base/xorg-server udev
x11-base/xorg-x11 udev opengl
sys-fs/udev extras
sys-auth/pambase consolekit
x11-libs/cairo X
dev-libs/libgcrypt static-libs
dev-libs/libgpg-error static-libs
media-libs/libsdl X opengl
sys-auth/consolekit policykit
sys-block/parted device-mapper
media-tv/xbmc webserver

/etc/portage/package.keywords:
dev-util/debhelper ~*
app-misc/cwiid ~*
net-libs/libmicrohttpd ~*
media-tv/xbmc ~*

/etc/portage/package.unmask:
app-misc/cwiid
net-libs/libmicrohttpd
media-tv/xbmc

With that done XBMC should now be able to be emerged.

Articles

Gentoo Installation (Inspiron 6400)

In Gentoo on 17/04/2011 by pier0w

Here is a run down of the Gentoo installation I did on an Inspiron 6400. I will walk through the configuration I used in the different stages of the Gentoo Handbook installation.

I chose to install the x86 version of Gentoo because it has better compatibility with closed sources applications like Java and Flash.

I’m not going to walk through how I set up my network for the install.

4. Preparing the Disks

The disk layout I chose is the same as the one the Gentoo Handbook recommends. That is a very small boot partition at the start of the disk, then a 512Meg swap partition after that, and lastly the rest of the disk is an ext3 partition that will be used for the root file system.

Here is the output of fdisk -l:

Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xab6ad924

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048       67583       32768   83  Linux
/dev/sda2           67584     1116159      524288   82  Linux swap / Solaris
/dev/sda3         1116160   488397167   243640504   83  Linux

As you can see I have added a larger hard drive to this laptop but otherwise the partition layout is nice and simple. I decided not to use ext4 because I don’t think I will require any of it’s new features and maybe it’s not as light wait as ext3, but I am not certain of that.

5. Installing the Gentoo Installation Files

The only thing that I did different in this section was to set the MAKEOPTS to use three threads.

MAKEOPTS="-j3"

6. Installing the Gentoo Base System

I have added a large number of USE flags to the make.conf file, this is just to make sure that all the required features are compiled in. Also the video card driver has been set to the intel driver.

Here is the make.conf file:

# These settings were set by the catalyst build script that automatically
# built this stage.
# Please consult /usr/share/portage/config/make.conf.example for a more
# detailed example.
CFLAGS="-O2 -march=i686 -pipe"
CXXFLAGS="${CFLAGS}"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="i686-pc-linux-gnu"
MAKEOPTS="-j3"

USE="a52 aac acpi aim alsa cdda cddb cdr css dts dv dvd dvdr encode ffmpeg flac gif
gphoto2 icq ios ipod jpeg jpeg2k lame lirc matroska mmx mp3 mp4 mpeg mplayer msn
musicbrainz ogg opengl png quicktime raw samba smp sound sse sse2 svg svga theora truetype
udev usb v4l v4l2 vcd vorbis wifi win32codecs wmf x264 xvid"

GENTOO_MIRRORS="ftp://mirror.bytemark.co.uk/gentoo/ http://mirror.bytemark.co.uk/gentoo/ rsync://mirror.bytemark.co.uk/gentoo/ ftp://mirror.qubenet.net/mirror/gentoo/ http://mirror.qubenet.net/mirror/gentoo/ rsync://rsync.mirrorservice.org/www.ibiblio.org/gentoo/ http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo/ ftp://ftp.mirrorservice.org/sites/www.ibiblio.org/gentoo/ ftp://gentoo.virginmedia.com/sites/gentoo http://gentoo.virginmedia.com/"

SYNC="rsync://rsync.uk.gentoo.org/gentoo-portage"

VIDEO_CARDS="intel"

7. Configuring the Kernel

I have customised the kernel (2.6.36-gentoo-r8) quite a bit to fit this laptop and to add some extra functionality for wireless and XBMC support.

Below are the custom settings that I used.

Processor:
Processor type and features  --->
    Processor family (Core 2/newer Xeon)  --->
        (X) Core 2/newer Xeon

File System:
File systems  --->
    <*> Second extended fs support
    [*]   Ext2 extended attributes
    [*]     Ext2 POSIX Access Control Lists
    [*]     Ext2 Security Labels
    [*]   Ext2 execute in place support
    <*> Ext3 journalling file system support
    [*]   Ext3 extended attributes
    [*]     Ext3 POSIX Access Control Lists
    [*]     Ext3 Security Labels
    <*> The Extended 4 (ext4) filesystem
    [*]   Ext4 extended attributes
    [*]     Ext4 POSIX Access Control Lists
    [*]     Ext4 Security Labels
    [*] Dnotify support
    [*] Inotify support for userspace
    [*] Quota support
    [*] Report quota messages through netlink interface
    <*> Quota format vfsv0 and vfsv1 support
    <*> Kernel automounter version 4 support (also supports v3)
    <*> FUSE (Filesystem in Userspace) support
    CD-ROM/DVD Filesystems  --->
        <*> ISO 9660 CDROM file system support
        [*]   Microsoft Joliet CDROM extensions
        [*]   Transparent decompression extension
        <*> UDF file system support 
    DOS/FAT/NT Filesystems  --->
        <*> MSDOS fs support
        <*> VFAT (Windows-95) fs support
        (437) Default codepage for FAT
        (iso8859-1) Default iocharset for FAT
        <*> NTFS file system support
        [*]   NTFS write support
    [*] Network File Systems  --->
        <*>   NFS client support
        [*]     NFS client support for NFS version 3
        [*]       NFS client support for the NFSv3 ACL protocol extension
        [*]     NFS client support for NFS version 4
        [*]     Root file system on NFS
        <*>   CIFS support (advanced network filesystem, SMBFS successor)

Intel Graphics: (Intel GMA, Gentoo 3D Acceleration, GLX)
Device Drivers  --->
    Graphics support  --->
        Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)  --->
            <*>   Intel I810
            <*>   Intel 830M, 845G, 852GM, 855GM, 865G (i915 driver)  --->
                (X) i915 driver
            [*]     Enable modesetting on intel by default

Sound: (Gentoo Alsa)
Device Drivers  --->
    <*> Sound card support  --->
        <*>   Advanced Linux Sound Architecture  --->
            [*]   PCI sound devices  --->
                <*>   Intel HD Audio  --->
                    [*]   Build hwdep interface for HD-audio driver
                    [*]   Build Realtek HD-audio codec support
                    [*]   Build Analog Device HD-audio codec support
                    [*]   Build IDT/Sigmatel HD-audio codec support
                    [*]   Build VIA HD-audio codec support
                    [*]   Build ATI HDMI HD-audio codec support
                    [*]   Build NVIDIA HDMI HD-audio codec support
                    [*]   Build INTEL HDMI HD-audio codec support
                    [*]   Build Cirrus Logic codec support
                    [*]   Build Conexant HD-audio codec support
                    [*]   Build Creative CA0110-IBG codec support
                    [*]   Build C-Media HD-audio codec support
                    [*]   Build Silicon Labs 3054 HD-modem codec support
                    [*]   Enable generic HD-audio codec parser

Network:
Device Drivers  --->
    [*] Network device support  --->
        <*>   Broadcom 440x/47xx ethernet support

Wireless: (Iwlwifi, Gentoo Wireless):
The wireless drivers are loaded as modules because they need to access the file system (/lib/firmware) which is loaded AFTER the kernel loads.
General setup  --->
    [*] Prompt for development and/or incomplete code/drivers
[*] Networking support  --->
    -*-   Wireless  --->
        <*>   cfg80211 - wireless configuration API
        [*]     nl80211 testmode command
        [*]     enable powersave by default
        [*]     cfg80211 wireless extensions compatibility
        [*]   Wireless extensions sysfs files
        <*>   Common routines for IEEE802.11 drivers
        <*>   Generic IEEE 802.11 Networking Stack (mac80211)
        [*]   Enable LED triggers
Device Drivers  --->
    Generic Driver Options  --->
        -*- Userspace firmware loading support
    [*] Network device support  --->
        [*]   Wireless LAN  --->
            <M>   Intel Wireless Wifi
            [*]     Enable full debugging output in iwlagn and iwl3945 drivers
            <M>     Intel Wireless WiFi Next Gen AGN (iwlagn)
            [*]       Intel Wireless WiFi 4965AGN
            [*]       Intel Wireless-N/Advanced-N/Ultimate-N WiFi Link
            <M>     Intel PRO/Wireless 3945ABG/BG Network Connection (iwl3945)
-*- Cryptographic API  --->
    -*-   Cryptographic algorithm manager
    [*]   Disable run-time self tests
    -*-   Authenc support
    -*-   CBC support
    -*-   ECB support
    <*>   PCBC support
    -*-   HMAC support
    -*-   MD5 digest algorithm
    <*>   Michael MIC keyed digest algorithm
    -*-   SHA1 digest algorithm
    <*>   SHA224 and SHA256 digest algorithm
    -*-   AES cipher algorithms
    <*>   AES cipher algorithms (i586)
    -*-   ARC4 cipher algorithm
    -*-   DES and Triple DES EDE cipher algorithms

SD Card:
Device Drivers  --->
    <*> MMC/SD/SDIO card support  --->
        <*>   MMC block device driver
        [*]     Use bounce buffer for simple hosts
        <*>   Secure Digital Host Controller Interface support
        <*>   SDHCI support on PCI bus
        <*>   SDHCI support on the platform specific bus

You’ll notice that in the wireless section some of the drivers have been compiled as modules so they need to be registered to load on start up. I have added them to my /etc/modules.autoload.d/kernel-2.6 file, they are the only modules in there.

# /etc/modules.autoload.d/kernel-2.6:  kernel modules to load when system boots.
#
# Note that this file is for 2.6 kernels.
#
# Add the names of modules that you'd like to load when the system
# starts into this file, one per line.  Comments begin with # and
# are ignored.  Read man modules.autoload for additional details.

# For example:
# aic7xxx

iwlcore
iwlagn
iwl3945

Also for the sound to work the alsa needs to be configured. So first install alsa.
#> emerge -av alsa-utils

Once alsa has finished installing start it up.

#> /etc/init.d/alsasound start

Next unmute the volume so that it is possible to actually hear something. Do this by starting alsamixer then highlighting the Master and PCM channels and pressing the ‘m’ key to make sure they have 00 instead of MM at the bottom.

#> alsamixer

Lastly set alsa to start at boot.

#> rc-update add alsasound boot

8. Configuring your System

I set up fstab in the a exact same way as the handbook, but the networking I had to do a little differently.

Firstly to get the wireless working I had to install an extra package called iwl3945-ucode which is used by the drivers.

#> emerge -av iwl3945-ucode

Also a symlink needs to be created in the /etc/init.d/ directory for the wireless network.

#> cd /etc/init.d/
#> ln -s net.lo net.wlan0

Now the Gentoo handbook says to register the net.eth0 interface to start at boot, don’t do this because it will be started anyway. One thing that can be done is to tell Gentoo which interface to start net.eth0 or net.wlan0, this is done within the /etc/conf.d/rc script in the RC_PLUG_SERVICES variable.

Below is the RC_PLUG_SERVICES setting that I used to only start the wlan0 interface.

RC_PLUG_SERVICES="net.lo net.wlan0 !net.eth*"

Next the wired and wireless network need to be setup so they start correctly, I have configured them both with static IP’s, this is so that later I will be able to control XBMC with the Android remote.

/etc/conf.d/net:
# This blank configuration will automatically use DHCP for any net.*
# scripts in /etc/init.d.  To create a more complete configuration,
# please review /etc/conf.d/net.example and save your configuration
# in /etc/conf.d/net (this file :]!).

config_eth0=( "192.168.1.32 netmask 255.255.255.0 brd 192.168.1.255" )
routes_eth0=( "default via 192.168.1.254" )

# Prefer wpa_supplicant over wireless-tools
modules=( "wpa_supplicant" )

# It's important that we tell wpa_supplicant which driver we should
# be using as it's not very good at guessing yet
wpa_supplicant_wlan0="-Dwext"

config_wlan0=( "192.168.1.42 netmask 255.255.255.0 brd 192.168.1.255" )
routes_wlan0=( "default via 192.168.1.254" )

My wpa_supplicant configuration is very simple.

/etc/wpa_supplicant/wpa_supplicant.conf:
# The below line not be changed otherwise we refuse to work
ctrl_interface=/var/run/wpa_supplicant

# Ensure that only root can read the WPA configuration
ctrl_interface_group=0

# Let wpa_supplicant take care of scanning and AP selection
ap_scan=1

# Simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers
network={
    ssid="MyWireless"
    psk="password"
    # The higher the priority the sooner we are matched
    priority=5
}

# Same as previous, but request SSID-specific scanning (for APs that reject
# broadcast SSID)
network={
    ssid="MyWireless"
    scan_ssid=1
    psk="password"
    priority=2
}

The last extra piece of configuration that I carried out is to do with the key mapping, I created mappings for the buttons on the front of the laptop that are meant to be used to control the DVD drive. I have mapped these keys to the keyboard letters that correspond to the volume and play controls of XBMC.

Custom key mappings need to be placed in a file under the /usr/share/keymaps/include/ directory and can have any name as long as they have the “.map” extension.

The file I created was called facebuttons.map and had the following content.
/usr/share/keymaps/include/facebuttons.map:
keycode 113 = 0x0030
keycode 114 = 0x002d
keycode 115 = 0x002b
keycode 164 = 0x0020
keycode 165 = 0x0072
keycode 163 = 0x0066
keycode 166 = 0x0078

This creates the following mapping:
Mute Button -> 0
Volume Down Button -> –
Volume Up Button -> +
Play Button -> Space
Track Back Button -> r
Track Forward Button -> f
Stop Button -> x

To find the values of the face buttons use the showkey program, just run it and start pressing the face buttons you should get output like this:
#> showkey
...
keycode 113 press    <-- When I Pressed Mute
keycode 113 release
keycode 114 press    <-- When I Pressed Volume Down
keycode 114 release
keycode 115 press    <-- When I Pressed Volume Up
keycode 115 release
keycode 164 press    <-- When I Pressed Play
keycode 164 release

Now to find the “keysym” (the last value in the key mapping) for the keys that you want the buttons to represent run the dumpkeys -l command and grep the keys you want.
#> dumpkeys -l | grep zero
0x0030    zero
0x0830    Meta_zero
#> dumpkeys -l | grep plus
0x002b    plus
0x00b1    plusminus
0x082b    Meta_plus
#> dumpkeys -l | grep minus
0x002d    minus
0x00b1    plusminus
0x082d    Meta_minus
#> dumpkeys -l | grep space
0x0020    space
0x00a0    nobreakspace
0x0820    Meta_space
no-break_space  for nobreakspace
#> dumpkeys -l | grep "r$"
0x0012    Control_r
0x0024    dollar
0x0034    four
0x003e    greater
0x0072    r
0x007c    bar
0x00a6    brokenbar
0x00b2    twosuperior
0x00b3    threesuperior
0x00b9    onesuperior
0x00bc    onequarter
0x0118    Prior
0x030e    KP_Enter
0x0701    AltGr
0x0812    Meta_Control_r
0x0824    Meta_dollar
0x0834    Meta_four
0x083e    Meta_greater
0x0872    Meta_r
0x087c    Meta_bar
0x0c01    SAltGr
PageUp          for Prior
AltR            for AltGr
Alt_R           for AltGr
AltGr_R         for AltGr
#> dumpkeys -l | grep "f$"
    0x0000 - 0x00ff
    0x0100 - 0x01ff
    0x0500 - 0x05ff
    0x0800 - 0x08ff
    0x0b00 - 0x0bff
    0x0d00 - 0x0dff
0x0006    Control_f
0x0066    f
0x00bd    onehalf
0x0806    Meta_Control_f
0x0866    Meta_f
#> dumpkeys -l | grep "x$"
0x0018    Control_x
0x0036    six
0x0078    x
0x00c2    Acircumflex
0x00ca    Ecircumflex
0x00ce    Icircumflex
0x00d4    Ocircumflex
0x00db    Ucircumflex
0x00e2    acircumflex
0x00ea    ecircumflex
0x00ee    icircumflex
0x00f4    ocircumflex
0x00fb    ucircumflex
0x0402    dead_circumflex
0x0818    Meta_Control_x
0x0836    Meta_six
0x0878    Meta_x
dead_caron      for dead_circumflex

Now that the mappings have been setup we need to tell Gentoo to use them, this is done by putting the name of our mappings file minus the extension into the EXTENDED_KEYMAPS variable of the /etc/conf.d/keymaps file.

# /etc/conf.d/keymaps

# Use KEYMAP to specify the default console keymap.  There is a complete tree
# of keymaps in /usr/share/keymaps to choose from.

KEYMAP="us"

# Should we first load the 'windowkeys' console keymap?  Most x86 users will
# say "yes" here.  Note that non-x86 users should leave it as "no".

SET_WINDOWKEYS="no"

# The maps to load for extended keyboards.  Most users will leave this as is.

EXTENDED_KEYMAPS="facebuttons"

# Tell dumpkeys(1) to interpret character action codes to be 
# from the specified character set.
# This only matters if you set UNICODE="yes" in /etc/rc.conf.
# For a list of valid sets, run `dumpkeys --help`

DUMPKEYS_CHARSET=""

That is the end of the extra configuration for this section.

10. Configuring the Bootloader

I installed GRUB and used the following kernel line so that the console runs in a nice frame buffer.

kernel /boot/kernel-2.6.36-gentoo-r8 root=/dev/sda3 video=uvesafb:mtrr:3,ywrap,1280x800-32@60

11. Finalizing your Gentoo Installation

The very last peace of Gentoo specific configuration I did was to create an xbmc user. I made sure the user had video, audio, usb, and dvd privileges.

#> useradd -d /home/xbmc -m -G audio,cdrom,video,cdrw,usb,users xbmc

Now reboot the laptop and hopefully everything works, if it does now would be a good time to run a global update.

#> emerge --update --deep world

Once this has completed there is a good chance that Python will have been updated to version 3. XBMC and it’s dependencies do not like this version of Python so will fail to compile or run. To fix this use eselect to set Python back to version 2.6.

#> eselect python list
Available Python interpreters:
  [1]   python2.6
  [2]   python3.1 *

#> eselect python set 1
#> eselect python list
Available Python interpreters:
  [1]   python2.6 *
  [2]   python3.1