Table of Contents

Links

Booting

  • get a copy of boot.efi

    $ md5sum boot.efi 280323d8700e4cfef15116f7e50590e3 boot.efi

Installation

Needed ncurses for "make menuconfig", not strictly necessary

$ wget http://www.mythic-beasts.com/resources/appletv/mb_boot_tv/mb_boot_tv.gz
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.20.6.tar.bz2
$ wget http://www.mythic-beasts.com/resources/appletv/kernel/config
$ wget 'http://svn.sourceforge.net/viewvc/*checkout*/mactel-linux/trunk/mach_linux_boot/kernel/2.6.20.6-apletv.patch'
$ wget http://www.mythic-beasts.com/resources/appletv/kernel/appletv-rtc.patch
$ wget http://www.mythic-beasts.com/resources/appletv/kernel/appletv-audio.patch
$ sudo apt-get install libncurses5-dev
$ tar -xjvf linux-2.6.20.6.tar.bz2
$ cp ./config linux-2.6.20.6/.config
$ cd linux-2.6.20.6
$ patch -p1 < ../2.6.20.6-apletv.patch
$ patch -p1 < ../appletv-rtc.patch
$ patch -p1 < ../appletv-audio.patch
$ make

http://www.mythic-beasts.com/resources/appletv/mb_boot_tv/stick.html

sudo apt-get install refit
sudo apt-get install hfsplus

Make mkfs.hfsplus and fsck.hfsplus

gentoo-wiki-com/HOWTO_hfsplus

mkdir hfsplus
cd hfsplus
wget http://dev.gentoo.org/~josejx/diskdev_cmds-332.11.patch.bz2
wget http://markferry.net/dl/diskdev_cmds-332.11.9.patch.bz2
# Requires an AppleID login cookie.
wget http://www.opensource.apple.com/darwinsource/tarballs/apsl/diskdev_cmds-332.11.9.tar.gz
tar -xzvf diskdev_cmds-332.11.9.tar.gz
cd diskdev_cmds-332.11.9
bzcat ../diskdev_cmds-332.11.9.patch.bz2 | patch -p1
make -f Makefile.lnx
cp fsck_hfs.tproj/fsck_hfs $HOME/bin/fsck.hfsplus
cp newfs_hfs.tproj/newfs_hfs $HOME/bin/mkfs.hfsplus

Prepare the image

dd if=/dev/zero of=usb-boot.img bs=1M count=63
sudo losetup -f usb-boot.img
parted /dev/loop0
(parted) mklabel gpt
(parted) mkpart EFI 0 4
(parted) set 1 boot on

(parted) mkpart Recovery 4 8
(parted) mkpart OSBoot 8 12
(parted) mkpart Media 

Oops. That loopback partitioning patch never made it into the kernel. So can't do much with this image now...

parted print /dev/sdb
Disk /dev/sdb: 64.5MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name      Flags
 1      17.4kB  4000kB  3983kB               EFI       boot 
 2      4000kB  8001kB  4000kB               Recovery       
 3      8001kB  12.0MB  4000kB               OSBoot         
 4      12.0MB  64.5MB  52.5MB               Media

In FreeBSD this time:

gpt destroy /dev/da0
gpt create -f /dev/da0
gpt add -b 34 -s 41950 -i 1 -t 5265636F-7665-11AA-AA11-00306543ECAC /dev/da0
gpt add -b 41984 -s 83935 -i 2 -t 48465300-0000-11AA-AA11-00306543ECAC /dev/da0
  • create gpt disk label
  • create fat32 EFI boot
  • create recovery, osboot and media

Log

2007-06-27

  • apple TV seems to be trying to boot from usb stick
  • check USB stick
  • opened Apple TV
  • need 44-pin to 40-pin IDE adapter

Backup

2007-07-13

  • connect appletv to
  • backup disk

    $ dd if=/dev/hdc | gzip -1 | nc -w 5 192.168.1.5 31066

And on the backup machine (192.168.1.5):

$ nc -l -p 31066 > appletv-backup.img.gz
$ ls -l appletv-backup.img.gz
-rw-r--r--  1 backup users 4018217943 2007-07-14 06:30 appletv-backup.img.gz

Installation

2007-07-14

  • install mb_boot_tv
  • repartition disk
  • install Linux

On the machine used for partitioning and installing Linux, the appletv HDD is /dev/sdb

# mount /dev/sdb3 -t hfsplus /media/OSBoot
# mount /dev/sdb2 -t hfsplus /media/Recovery
# cp ~/appletv/mb_boot_tv /media/OSBoot/
# cp ~/appletv/mb_boot_tv /media/Recovery/
# chmod 755 /media/{OSBoot,Recovery}/mb_boot_tv
# umount /media/OSBoot
# umount /media/Recovery

Repartition

Repartition the disk. Create boot, root and swap

# parted /dev/sdb
(parted) print

Disk /dev/sdb: 40.0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End     Size    File system  Name      Flags
 1      20.5kB  35.7MB  35.7MB  fat32        EFI       boot 
 2      35.7MB  455MB   419MB   hfs+         Recovery       
 3      455MB   1399MB  944MB   hfs+         OSBoot         
 4      1399MB  39.9GB  38.5GB  hfs+         Media          

(parted) rm 4
# should instead have shrunk the original Media partition!
(parted) mkpart
Partition name?  []? Media
File system type?  [ext2]? hfs+
Start? 1399
End? 11639

(parted) unit MB
(parted) print                                                            

Disk /dev/sdb: 40008MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start   End      Size     File system  Name      Flags
 1      0.02MB  35.7MB   35.7MB   fat32        EFI       boot 
 2      35.7MB  455MB    419MB    hfs+         Recovery       
 3      455MB   1399MB   944MB    hfs+         OSBoot         
 4      1399MB  11639MB  10240MB  hfs+         Media          

(parted) mkpart                                                           
Partition name?  []? LinBoot                                              
File system type?  [ext2]? ext3                                           
Start? 11639M
End? 11689M                                                               

(parted) mkpart
Partition name?  []? Swap                                                 
File system type?  [ext2]? linux-swap
Start? 11689                                                              
End? 12201                                                                
(parted) print free                                                       
(parted) mkpart                                                           
Partition name?  []? Linux                                                
File system type?  [ext2]? ext3                                           
Start? 12201
End? 40008                                                                
(parted) print                                                            

Disk /dev/sdb: 40008MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start    End      Size     File system  Name      Flags
 1      0.02MB   35.7MB   35.7MB   fat32        EFI       boot 
 2      35.7MB   455MB    419MB    hfs+         Recovery       
 3      455MB    1399MB   944MB    hfs+         OSBoot         
 4      1399MB   11639MB  10240MB  hfs+         Media          
 5      11639MB  11689MB  50.0MB                LinBoot        
 6      11689MB  12201MB  512MB                 Swap           
 7      12201MB  40008MB  27807MB               Linux          

(parted) 

Filesystems

Create filesystems

# mkfs.hfsplus -v Media /dev/sdb4
# mkfs.ext3 -m 0 /dev/sdb5
# mkswap /dev/sdb6
# mkfs.ext3 /dev/sdb7
# tune2fs -c -1 -i 0 /dev/sdb5
# tune2fs -c -1 -i 0 /dev/sdb7
# mkdir -p /mnt/appletv/{LinBoot,Linux}
# mount /dev/sdb5 /mnt/appletv/LinBoot
# mount /dev/sdb7 /mnt/appletv/Linux

Debootstrap and Kernel

Install base system and kernel

# debootstrap etch /mnt/appletv/Linux http://ftp.debian.org
# cd /mnt/appletv
# wget http://www.mythic-beasts.com/resources/appletv/kernel/kernel-kit-2.6.20.6.tar.g
# mount -o bind /mnt/appletv/LinBoot /mnt/appletv/Linux/boot
# cd Linux/
# tar xzvf ../kernel-kit-2.6.20.6.tar.gz 
# vim boot/mb_boot_tv.conf 

Chroot and Post-install Config

Chroot and finish configuration (http://www.linux.com/articles/114165)

# mount -t proc  proc Linux/proc
# mount -o bind /dev Linux/dev
# mount -o bind /sys Linux/sys
# chroot Linux /bin/bash
(now within the chroot)
cd /etc
vim fstab
echo "appletv" > /etc/hostname
vim /etc/network/interfaces 
apt-get install console-tools
apt-get install console-tools console-data
tzconfig
passwd
exit

Continue by installing some utilities (http://www.mythtv.org/wiki/index.php/Installing_MythTV_on_Debian_Etch)

Bootloader Config

Edit bootloader configuration (http://www.mythic-beasts.com/resources/appletv/mb_boot_tv/walk-through.html)

# vim /mnt/appletv/OSBoot/System/Library/CoreServices/com.apple.Boot.plist
# vim /mnt/appletv/Recovery/com.apple.Boot.plist

Reboot

# umount /mnt/appletv/Linux/{sys,dev,proc}
# umount /mnt/appletv/Linux
# shutdown -r now

http://wiki.debian.org/NvidiaGraphicsDrivers

2007-07-15

  • installed Debian
  • installed mythtv, nVidia non-free drivers, X, fluxbox

2007-10-01

  • mount mythvideo samba share from Hastur

    mount -t smbfs -o username=mythtv,password=$MYTHPW //hastur/mythvideo /var/lib/mythvideo

Get Hauppauge remote working

  • Show USB IR device

    $ cat /proc/bus/usb/devices ... T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#= 6 Spd=1.5 MxCh= 0 D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=05ac ProdID=8241 Rev= 2.42 S: Manufacturer=Apple Computer, Inc. S: Product=IR Receiver C:* #Ifs= 2 Cfg#= 1 Atr=a0 MxPwr=100mA I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=00 Prot=00 Driver=usbhid E: Ad=82(I) Atr=03(Int.) MxPS= 8 Ivl=10ms I: If#= 1 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none) E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=10ms

  • Configure LIRC

    vim /etc/lirc/hardware.conf

    DRIVER="dev/input" DEVICE="/dev/input/by-id/usb-Apple_Computer,_Inc._IR_Receiver-event-ir" EOF

2007-10-6

Configure XvMC

Kernel Build

2007-10-3

Cross-compile updated kernel

Cross-Compile an AppleTV kernel on an AMD64 and install.

Extract

$ wget http://www.eu.kernel.org/pub/linux/kernel/v2.6/linux-2.6.22.2.tar.bz2
$ #[[http://forum.awkwardtv.org/viewtopic.php?f=23&t=167&hilit=&start=70|rca-patch]]
$ wget http://hester.no-ip.org/appletv-rca-sound.patch.gz
$ wget -O appletv-ir.patch http://cbg.dyndns.org/store/apple-remote-quirk-hiddev.patch
$ svn co http://mactel-linux.svn.sourceforge.net/svnroot/mactel-linux/trunk/mach_linux_boot/kernel/
$ tar -xjvf linux-2.6.22.2

Patch

$ cd linux-2.6.22.2
$ cp ../kernel/config-2.6.22.2-appletv .config
$ patch -p1 < ../kernel/2.6.22.2-appletv.patch
$ cat ../appletv-rca-sound.patch.gz | gunzip - | patch -p1
$ patch -p1 < ../appletv-rtc.patch
$ patch -p1 < ../appletv-ir.patch

What the patches do:

  • appletv-rca-sound - changes the detection of the RCA sound chip
  • appletv-rtc - disables RTC, preventing oopses
  • appletv-ir - forces AppleTV IR to be detected as an HID device

Build

$ make ARCH=i386 CROSS_COMPILE= menuconfig
$ make-kpkg --arch i386 --cross_compile - clean
$ CONCURRENCY_LEVEL=6; fakeroot make-kpkg --arch i386 --cross_compile - kernel_image kernel_headers

Switch to AppleTV

Install kernel

# dpkg --force-architecture -i linux-image-2.6.22.2-appletv_2.6.22.2-appletv-10.00.Custom_amd64.deb
# dpkg --force-architecture -i linux-headers-2.6.22.2-appletv_2.6.22.2-appletv-10.00.Custom_amd64.deb

Update nVidia drivers

Add non-free and contrib sources to host /etc/apt/sources.list

# vim /etc/apt/sources.list
deb http://ftp.uk.debian.org/debian/ etch main non-free contrib
deb-src http://ftp.uk.debian.org/debian/ etch main non-free contrib
EOF
# apt-get update

Get nVidia kernel source

# apt-get install nvidia-kernel-source
# cd /usr/src
# tar -xzvf nvidia-kernel-source.tar.gz
# cd linux-2.6.22.2
# make-kpkg modules_image

Install new nVidia binary kernel

# dpkg -i nvidia-kernel-2.6.22.2-appletv-01_1.0.8776-4+2.6.22.2-appletv-01_i386.deb

Window Manager

.profile

if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
while [ 1 == 1 ]
        do
                startx
                sleep 10
        done
fi

Remove fluxbox, use ratpoison instead

# apt-get install ratpoison
# su mythtv
$ cat > ~/.ratpoisonrc
escape C-r   #Make escape (default C-t) not clash with mythTV key bindings
addhook switchwin banish #Banish the mouse cursor out of the way.
EOF
$ vim ~/.xinitrc
(replace fluxbox with ratpoison)
$ exit
# apt-get remove fluxbox

"Ctrl-R ?" shows ratpoison options

2007-12-04

Fix .xinitrc so it restarts mythfrontend following a crash

$ cat > .xinitrc
exec xset s off &
exec xsetroot -solid black &
exec ratpoison & ratpid=$!
exec $HOME/launch_myth.sh &
wait $ratpid
EOF




$ cat > /home/mythtv/launch_myth.sh
#!/bin/sh
for i in {1..25} ; do
        mythfrontend 2>> $HOME/MYTHERRORS
        EXIT=$?
        if (( $EXIT == 0 )) ;
                then exit $EXIT
        fi
done
EOF
$ chmod u+x launch_myth.sh

This now restarts mythfrontend up to 25 times. If X crashes then .profile restarts it.

Samba

2007-10-10

Fix Samba streaming

$ echo "cache=1024" >> ~/.mplayer/config

Forces mplayer to precache 1MB of a media file

IR

2007-10-16

On compile host

$ sudo apt-get install dpkg-dev debhelper devscripts fakeroot linda linux32
$ sudo apt-get build-dep lirc
$ wget -O lirc_0.8.2.orig.tar.gz http://surfnet.dl.sourceforge.net/sourceforge/lirc/lirc-0.8.2.tar.gz
$ wget -O lirc-0.8.2-macmini-repeat.patch "http://sourceforge.net/tracker/download.php?group_id=5444&atid=305444&file_id=249079&aid=1810963"
$ FIXME wget debian-lirc-0.8.2-macmini.patch

debian-lirc-0.8.2-macmini.patch

diff -urN debian.orig/rules debian/rules
--- debian.orig/rules   2007-10-16 17:32:22.000000000 +0100
+++ debian/rules        2007-10-16 18:25:04.000000000 +0100
@@ -18,7 +18,7 @@
                --infodir=\$${prefix}/share/info \
                --libdir=\$${prefix}/lib \
                --sysconfdir=/etc/lirc/ \
-               --with-driver=userspace \
+               --with-driver=macmini \
                --with-syslog=LOG_DAEMON \
                --enable-sandboxed \
                --build=$(DEB_BUILD_GNU_TYPE)

Get debian build stuff from Debian SVN

$ tar -xzvf lirc_0.8.2.orig.tar.gz
$ cd lirc-0.8.2
$ patch -p1 < ../lirc-0.8.2-macmini-repeat.patch
$ svn co svn://svn.debian.org/svn/pkg-lirc/lirc/branches/0.8.2/debian
$ cd debian
$ patch -p1 < ../../debian-lirc-0.8.2-macmini.patch
$ cd ..

Build i386 package on amd64

  • https://alioth.debian.org/docman/view.php/30192/21/debian-amd64-howto.html#id292281

    apt-get install debootstrap dchroot

    mkdir -p /var/chroot/etch-ia32

    debootstrap --arch i386 etch /var/chroot/etch-ia32 http://ftp.uk.debian.org/debian/

    mount -o bind /home /var/chroot/etch-ia32/home

    mount -o tmp {,/var/chroot/etch-ia32}/tmp

    mount -o bind {,/var/chroot/etch-ia32}/tmp

    mount -o bind {,/var/chroot/etch-ia32}/dev

    mount -o bind {,/var/chroot/etch-ia32}/proc

    cp /etc/passwd /etc/shadow /etc/group /var/chroot/etch-ia32/etc/

    cp /etc/apt/sources.list /var/chroot/etch-ia32/etc/apt/

    cat > /etc/dchroot.conf

    ia32 /var/chroot/etch-ia32 linux32 EOF

    cat > /usr/local/bin/ia32-dpkg-buildpackage

    !/bin/sh

    rpath=pwd dchroot -c ia32 "cd $rpath && linux32 dpkg-buildpackage -ai386 $@" EOF

    chmod ugo+x /usr/local/bin/ia32-dpkg-buildpackage

    dchroot -c ia32

    chroot# apt-get update chroot# apt-get build-dep lirc chroot# apt-get install dialog # needed by lirc chroot# apt-get install fakeroot chroot# dpkg -i liblircclient0_0.8.2-1_i386.deb lirc_0.8.2-1_i386.deb chroot# exit

    $ ia32-dpkg-buildpackage $ cd .. $ scp liblircclient0_0.8.2-1_i386.deb lirc_0.8.2-1_i386.deb appletv:~/

To AppleTV

# dpkg -i liblircclient0_0.8.2-1_i386.deb lirc_0.8.2-1_i386.deb
# wget http://cbg.dyndns.org/store/config/hardware.conf
# cp hardware.conf /etc/lirc/
#

Upgrade to Lenny

2008-02-24

dist-upgraded to Lenny in order to test Elisa and other media systems

Kernel Update

Update to 2.6.23.11

Run the NVIDIA installer, but do not replace the kernel module installed from the non-free repos

Frontrow

OK, issues with Lenny graphics drivers. So no go. Perhaps I could downgrade again...

Either way, MythTV UI just doesn't cut it, so I'm dumping it and moving to Frontrow plus Plugins...


XBMC on Linux on AppleTV

  • Howto
  • Using Karmic instead of Hardy (no Boxee for Hardy)

Penboot Creation

Netboot Install

$ telnet appletv
Trying 192.168.0.136...
Connected to 192.168.0.136.
Escape character is '^]'.

penbuntu login: root
Password: 

#
  • Partitions

    parted -s /dev/sda unit s print

    Model: ATA FUJITSU MHW2040A (scsi) Disk /dev/sda: 78140160s Sector size (logical/physical): 512B/512B Partition Table: gpt

    Number Start End Size File system Name Flags
    1 40s 69671s 69632s fat32 EFI boot
    2 69672s 888823s 819152s hfs+ Recovery atvrecv 3 888824s 2732015s 1843192s hfs+ OSBoot
    4 2732016s 22732421s 20000406s hfs+ Media
    5 22732422s 22830078s 97657s ext3 LinBoot
    6 22830079s 23830078s 1000000s linux-swap Swap
    7 23830079s 78140126s 54310048s ext3 Linux

  • Execute netboot

    mount /dev/sdb2 /tmp kexec --load tmp/linux --initrd=tmp/initrd.gz --command-line="nosplash vesa video=vesafb" kexec -e

Software Install

Install Boxee

Configuration

Xorg

  • NVIDIA drivers # Xorg -configure # vim /root/xorg.conf.new Section "Device" Identifier "Device0" Driver "nvidia" VendorName "NVIDIA Corporation" + Option "RegistryDwords" "RMDisableRenderToSysmem=1" + Option "DynamicTwinView" "false" EndSection #

  • Disable Composite Section "Extensions" Option "Composite" "Disable" EndSection

Crystal HD

sudo apt-get install subversion autoconf
svn checkout http://crystalhd-for-osx.googlecode.com/svn/tags/crystalhd-for-osx-3.6.0
cd crystalhd-for-osx-3.6.0/crystalhd/linux_lib/libcrystalhd
make
sudo make install
cd ../../driver/linux
autoconf
./configure
make
sudo make install
sudo modprobe crystalhd
cd

XBMC

  • Download nightly from http://sshcs.com/xbmc/Binaries/Builds/XBMC_Linux_34311.rar
  • Remove old XBMC and install dependencies

    $ sudo apt-get remove xbmc xbmc-bin xbmc-data $ sudo apt-get install libavcodec52 libssh-3 libass4

  • No libass4 so upgrade to later distro?

  • Install svn version from ppa

    $ sudo apt-get install xbmc=2:10.00~svn33778-karmic1

Fix Green Tint

  • Set video renderer to GLSL

Restart on crash

  • cat .xinitrc

    !/bin/sh

    while (! xbmc --standalone ) do sleep 2 done

Autostart on Boot

Reduce stream timeouts

Set system-wide TCP connect retries

# echo "net.ipv4.tcp_syn_retries=2" >> /etc/sysctl.d/60-xbmc-tweaks.conf

Custom Keymap

  • Edit ~/.xbmc/userdata/keymaps/joystick.AppleRemote.xml
  • Set fullscreen video plus and minus to BigStepBack or SkipPrevious

AAC mono bug

Solution

  • set speaker setup to 2.1 in XBMC
  • multichannel lossy encodings would play as 2.1 only
  • passthrough is unaffected

Slow Slideshow bug

Upgrade to Precise and XBMC Eden

2012-04-29

Lucid

  • Update to Ubuntu LTS - 10.04 (Lucid)
  • Generate Ubuntu Lucid sources list from http://repogen.simplylinux.ch/generate.php
  • Update to Lucid sudo aptitude update && sudo aptitude dist-upgrade

  • Oops. Killed it. Won't boot after installation of 10.04.

Possibly just have to update the patchstick.

Lucid Patchstick

Dammit, actually it was fine all along! SSH'd in without problems.

Precise Pangolin (12.04)

  • Sources ############################################################# ################### OFFICIAL UBUNTU REPOS ################### #############################################################

    ###### Ubuntu Main Repos
    deb http://uk.archive.ubuntu.com/ubuntu/ precise main restricted universe 
    deb-src http://uk.archive.ubuntu.com/ubuntu/ precise main restricted universe 
    
    ###### Ubuntu Update Repos
    deb http://uk.archive.ubuntu.com/ubuntu/ precise-security main restricted universe 
    deb http://uk.archive.ubuntu.com/ubuntu/ precise-updates main restricted universe 
    deb-src http://uk.archive.ubuntu.com/ubuntu/ precise-security main restricted universe 
    deb-src http://uk.archive.ubuntu.com/ubuntu/ precise-updates main restricted universe 
    
  • Upgrade sudo aptitude update && sudo aptitude upgrade

  • Failure to configure python-minimal

    • Launchpad #990740 E: Could not perform immediate configuration on 'python-minimal'.Please see man 5 apt.conf under APT::Immediate-Configure for details. (2)

    • Workaround (via stefanor) is to upgrade apt first, then do-release-upgrade.

    • Too late for do-release-upgrade, so install python-minimal then the rest.
  • Other packages sudo aptitude install xbmc sudo aptitude install nvidia-current

  • Rebooted, screwed up the kernel images

  • Installed nvidia, failed to initialize GLX Failed to initialize the GLX module; please check in your X log file that the GLX module has been loaded in your X Server, and that the module is the NVIDIA GLX module. If you continue to encounter problems, Please try reinstalling the NVIDIA driver.

    • run nvidia-xconfig to fix it sudo nvidia-xconfig

OpenELEC

  • Dumped XBMC on Ubuntu after because of freezing on home screen issue

Install

  • Created OpenELEC patchstick
  • Wouldn't boot (possibly the backup GPT table) so zeroed the USB stick and recreated it
  • Booted successfully

Configuration

  • OpenELEC wiped the whole of the old installation
  • Reinstate Xeebo skin
  • Re-add media sources and update libraries

Users and SSH

  • add gnome user, disable root login, disable password login

ToDo