XBMC Set-top box from the ground up on Jaunty
#1
i'm moving this post to a new thread since it was pretty off-topic... anyway, i'm trying to chart my setup of xbmc as a set-top box for the living room with jaunty and attempting to adhere to the "recommended" method to install xbmc (ie, on a full ubuntu desktop install with a special autologin user) ...

original post:
So, Day 1 of my "recommended" method project has passed.

So far I've been able to:
* Install Jaunty
* Setup an autologin XBMC user
* Install build dependencies and compile XBMC from svn
* Get HDMI audio working (more on this later)
* Install the userspace xbox360 pad driver

To do:
* Restart XBMC on crash -- currently it drops me to a login prompt (boourns!)
* Figure out a way to define a keyboard mapping which mimicks the xbox reboot command (Left Trigger + Right Trigger + Back + Start) to kill X in case of XBMC lockup. Those keys in combination should trigger a Ctrl+Alt+Backspace, however in Jaunty it seems even that key combo is disabled??


Step 1: Install Jaunty
Did this from USB. Seems easy enough except that on my HTPC, it dropped me to busybox / initramfs cli. Durrr what to do? Amazingly I typed "exit," walked away and came back later to find it had booted into GUI. Commenced installation - no issues.

Step 2: Create XBMC user
Easy enough, did this via Administration/Users and Groups. Started with the unpriv'd profile and added the things I think the xbmc user needs such as fuse, audio, mount shares, etc.
For autologin, you can do this via... Admin or Prefs / Login Screen (I wish I could remember more clearly) At this point the system will auto-login the XBMC user and start a GNOME desktop.

Step 3: Install build deps and compile XBMC from svn
Because I'm lazy, I used the guide for this using Intrepid steps.

Step 4: HDMI Audio
Jaunty uses ALSA 1.0.18 out of the box which, even though it is not the newest ALSA, still supported my chipset+HDMI out of the box! All I had to do was slave the HDMI audio off the analog and viola! Slaving HDMI is as simple as adding the following to /etc/asound.conf:
Code:
pcm.!default {
    type plug
    slave {
        pcm "hdmi"
    }
}
This way HDMI works (including navigation sounds) without any modification to XBMC's audio settings, and it resolves the issue of the HDMI codec only supporting 48k input. (see http://www.xbmc.org/forum/showpost.php?p...tcount=404 )

Step 5: installed grumbel's xbox360 userspace driver
I find this driver to be much better than the xpad kernel driver. For some idiotic reason, xpad defines the dpad as axis however xbmc needs dpad as buttons. So, the choices are to modify kernel source and recompile the driver to fix the issue, or nix xpad and use the userspace driver. I chose the latter because the userspace driver allows me to define a deadzone which helps a lot.
First I downloaded the source from here: http://pingus.seul.org/~grumbel/xboxdrv/
And the Keymap from here: http://www.stolennotebook.com/anthony/20...r-xboxdrv/
Grumbel's README has all the compilation instructions you need. After compilation, copy xboxdrv and xboxdrv-daemon.py to /usr/local/bin
Make sure kernel modules uinput and joydev load on boot. If not you can add them to /etc/modules to make it so.

Step 6: auto load XBMC and xboxdrv-daemon.py
For the xbmc user create a .xsession file in its home directory and add
Code:
#!/bin/bash

sudo xboxdrv-daemon.py -- -s --dpad-as-button --deadzone 6000 &
xbmc -fs
I was unable to get xboxdrv to load properly as a regular user so I had to allow it to be run as root. You can do this by running
Code:
sudo visudo
and adding the following entry:
Code:
xbmc    ALL=NOPASSWD: /usr/local/bin/xboxdrv-daemon.py
Perhaps someone can help me with this little bit of suck?

That's all for now. Later this week I hope to further refine .xsession to restart xbmc on crash, similar to but not exactly the same as the XBMCLive .xsession script. If anyone has any comments or suggestions on that, I would be more than happy to hear them Smile

Long term goal: magical button mapping that will trigger an X restart. Anyone? Smile
Reply
#2
didn't do a whole heck of a lot today... but i did decide to take a peek in the tools/Linux folder to see what useful goodies i would find in there. turns out there is a xbmc.sh script which appears to continually re-run xbmc until a certain condition (errorlevel?) is met.

i'm hoping this will satisfy my need to have xbmc restart itself on crash.. so i cp'd the script to /usr/share/sbin and chmod +x'd it and edited my .xsession to run xbmc.sh instead of calling xbmc directly. xbmc is running, but i will have to wait until it crashes via regular usage before i know if the script actually helps Smile

b

..oh, and i picked up a Eee 1000HA today.. thinking about Mac'ing it up... still undecided as i will need to purchase a new wifi card for it... which is amazingly easy to change apparently... ... that and i don't have an external dvdrom, so i'm HOPING i can figure out a usb stick install method Wink but that's OT too, PM me if you want to talk about that more.
Reply
#3
Quote:Restart XBMC on crash -- currently it drops me to a login prompt (boourns!)

create a cron job that runs teh following script every 30secs

Code:
#!/bin/bash

if [ `ps ax | grep -v grep | grep -i -c xbmc` -eq 0 ]; then
    /usr/bin/xbmc --standalone
fi

I cant remember if the switch & location for xbmc in that is right, as that is off the top of my head..

You can run it much more frequently but it will incurr a small penelty in CPU usage.. If you have CPU time to spare then I wouldn't go lower than every 5secs as tbh it wouldnt be worth it.

1 line version, just paste this straight into crontab, this will run every 5seconds
Code:
*/5 * * * * [[ `ps ax | grep -v grep | grep -i -c xbmc` -eq 0 ]] && /usr/bin/xbmc --standalone
Reply
#4
Quote:* Figure out a way to define a keyboard mapping which mimicks the xbox reboot command (Left Trigger + Right Trigger + Back + Start) to kill X in case of XBMC lockup. Those keys in combination should trigger a Ctrl+Alt+Backspace, however in Jaunty it seems even that key combo is disabled??

Yes apparently idiot users "accidently" hit that key combo and it was resulting in data loss so it is disabled by default in jaunty. (How the f**k you hit 3 keys that are no where near each other and that require both hands to press I'll never know..)
To enable it:


sudo vi /etc/X11/xorg.conf

Code:
Section "ServerFlags"
    Option        "DontZap"    "off"
EndSection
Reply
#5
Pvt_Ryan Wrote:create a cron job that runs teh following script every 30secs

The problem I see with a cron job is that the way it works now is, the xbmc user is auto-logged-in by gdm on bootup, which runs .xsession. if xbmc crashes, .xsession ends and the user is logged out. If .xsession ends and the user is logged out, there won't be any logged in user-context in which cron can run xbmc.

However, I found xbmc.sh in tools/Linux which looks like it may have the answer. it contains a while loop that runs xbmc so long as the exit code is not 65, which I believe is returned when you choose "Exit XBMC" from the shutdown menu.

Thanks for the tip to re-enable Ctrl-Alt-Backspace. Now I just need to figure out how I can trigger that key combination when I hit LT+RT+Back+Start on my controller. Smile
Reply
#6
This looks like it could be relevent

http://www.mythtv.org/wiki/Frontend_Auto_Login

Or perhaps a way of cheating. modify my script to:
if xbmc is not running then change run lvl to 3
then in the init lvl 3 tell it to start run lvl 5

the last entry in run lvl 5 should be to start xbmc

(look in the /etc/rc.* folders)
Reply
#7
i think i got it..
Code:
#!/bin/bash

export XBMC_PLATFORM_MODE=1

sudo xboxdrv-daemon.py -- --dpad-as-button --deadzone 6000 &

while true
do
    xbmc -fs --standalone
    case "$?" in
        0 ) # Quit
            touch /tmp/noRestartXBMC
            break ;;
        64 ) # Shutdown System
            sleep 10 ;;
        65 ) # Warm Reboot
            echo "Restarting XBMC ..." ;;
        66 ) # Reboot System
            sleep 10 ;;
         * ) ;;
    esac

    if [ -e /tmp/noRestartXBMC ] ; then
        rm /tmp/noRestartXBMC
        break
    fi

done

with this it starts, restarts on crash. the shutdown/reboot commands work and if i select exit xbmc it drops me to a gdm login prompt. Smile
Reply
#8
I would add a sleep within the loop itself to slow it down a bit (the computer will loop it as fast as it possibly can) otherwise because it's an ifinite loop which will eat CPU & ram.
Reply
#9
Pvt_Ryan Wrote:I would add a sleep within the loop itself to slow it down a bit (the computer will loop it as fast as it possibly can) otherwise because it's an ifinite loop which will eat CPU & ram.

The xbmc --standalone call will stop further execution of the script so no need for sleep.

BTW, -fs is not needed when --standalone is active, --standalone implies -fs
If you have problems please read this before posting

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

Image

"Well Im gonna download the code and look at it a bit but I'm certainly not a really good C/C++ programer but I'd help as much as I can, I mostly write in C#."
Reply
#10
Topfs2 Wrote:The xbmc --standalone call will stop further execution of the script so no need for sleep.

BTW, -fs is not needed when --standalone is active, --standalone implies -fs

You're right.. I misread the script.
Reply
#11
this has been an interesting and fun experiment, but i think i'm going to reformat and go down to hardy. xbmc is bleeding-edge enough, i would like a stable OS behind it so its easier to point the finger when something goes wrong Wink

plus, i'm having some wacky xbox360 controller-axis issues that don't make any sense to me. when i test the controller with jstest, it works fine, but xbmc does not respond the same way...
Reply
#12
try getting the 2.6.29 kernel from ubuntu:
http://www.ramoonus.nl/2009/03/24/linux-...ian-linux/

see if that helps. the .29 kernel is a lot better in terms of driver support and driver api interface.


As of yesterday 9.04 is stable.
Reply
#13
bobb0 Wrote:To do:
* Restart XBMC on crash -- currently it drops me to a login prompt (boourns!)
* Figure out a way to define a keyboard mapping which mimicks the xbox reboot command (Left Trigger + Right Trigger + Back + Start) to kill X in case of XBMC lockup. Those keys in combination should trigger a Ctrl+Alt+Backspace, however in Jaunty it seems even that key combo is disabled??
I have a startup script to put xbmc in spawn mode and it works very reliable.

Save the following as start-xbmc.py, to start xbmc in spawn mode
Code:
python start-xbmc.py -s

You can also specify whether you want to launch xbmc from /usr/local/bin/xbmc in case you have a customized xbmc installed. You can also send a key event to xbmc when it starts up, (in my case I send "backslash").

You can accomplish the second task via ircrc

Code:
# http://code.google.com/p/xbox-remote/source/browse/trunk/scripts/start-xbmc.py
#!/usr/bin/env python

import subprocess,sys,os,os.path,time,datetime
from optparse import OptionParser

full = False
local = False
spawn = False


p = OptionParser()
p.add_option('--fullscreen', '-f', dest="full", action="store_true" , default=False , help="automatic toggle fullscreen mode")
p.add_option('--local-prefered', '-l', dest="local", action="store_true", default = False, help="prefer /usr/local in the searching path ")
p.add_option('--spawn', '-s', dest="spawn", action="store_true", default= False, help="start in spawn mode")
options, arguments = p.parse_args()
if options.full:
    full = options.full
if options.local:
    local = options.local
if options.spawn:
    spawn = options.spawn




xbmc_binary = 'xbmc'
if local == True:
    os.environ['PATH'] = '/usr/local/sbin:/usr/local/bin:/usr/games:/usr/sbin:/usr/bin:/sbin:/bin'
    print os.environ['PATH']
pathdirs = os.environ['PATH'].split(os.pathsep)

cmd = os.path.join('/','usr','bin','xbmc')

for dir in pathdirs:
        if os.path.isdir(dir):
            if os.path.isfile(os.path.join(dir,xbmc_binary)):
                cmd = os.path.join(dir,xbmc_binary)
                break

if spawn == True:
    print "staring xbmc as", cmd, 'in spawn mode'
else:
    print "starting xbmc as ",cmd

XBMC = subprocess.Popen(cmd , stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

if full == True:
    from xbmcclient import *
    from socket import *    
    host = "127.0.0.1"
    xbmc = XBMCClient("", "", ip=host)

def fullscreen():
    time.sleep(2)
    xbmc.connect()
    time.sleep(2)
    xbmc.send_keyboard_button("backslash")
    time.sleep(0.2)
    xbmc.release_button()

if full == True:
    fullscreen()

XBMC.wait()

if spawn == True:
    while XBMC.poll() != None:
        XBMC = subprocess.Popen(cmd , stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
        if full == True:
            fullscreen()
        XBMC.wait()
Reply
#14
Just wondering if you all have had trouble building the latest svn (from this morning... r19710)... configure goes well for me but make fails. I am booted into hardy right now but if this doesnt resolve itself I'll open a new thread to troubleshoot this....

also has anyone else run into the automake issue?
Reply

Logout Mark Read Team Forum Stats Members Help
XBMC Set-top box from the ground up on Jaunty0