Installing MythTV On AppleTV with Mythbuntu 9.10

From MythTV Official Wiki
Jump to: navigation, search

Important.png Note: These instructions are for the original Apple TV. Not the second generation unit released at the end of 2010.

Warning.png Warning: The Apple TV is built using a 1GHz Pentium M, a GeForce 7300, and 256MB of memory. The limited processor, and graphics only capable of XvMC, mean this unit will only have enough power for standard definition content. Lower bitrate HD MPEG2 may be possible, but not advised. Further, the limited amount of memory may result in UI responsiveness issues.

The AppleTV (ATV) is an compact, efficient, and relatively inexpensive piece of hardware capable of running HD recordings (1080i) through the MythTV front-end. However, as one might imagine, getting Mythbuntu installed is no simple task. This HowTo explains how to install Mythbuntu 9.10 on an AppleTV. It is intended as a supplement to sdavilla's excellent work with the ATV-Bootloader.

Requirements

  • AppleTV
  • Mythbuntu 9.10 CD
  • USB drive (formatable)
  • USB keyboard & mouse
  • USB CD-ROM drive
  • USB hub

Download

I was unable to get Mythbuntu 11.04 to install. It would boot to the live CD but the installer would not start. Mirrors of 9.10 are hard to find but one is here. Once you have installed 9.10 you can use the Ubuntu update manager to upgrade to 10.10, and then to 11.04.

Create the ATV-Bootloader

Follow the instructions on the ATV-Bootloader Google Code page. This requires a formatable USB drive. For a hybrid ATV setup (keeping ATV-OS and Mythbuntu), the USB drive will be necessary every time one boots Linux.

Decide on Installation Scheme

There are several schemes for installing Mythbuntu on the ATV:

  • All-in (overwrite the ATV-OS)
  • Hybrid (ATV-OS and Mythbuntu on the same drive)
  • USB (keep ATV-OS and install Mythbuntu on a USB drive)

For the purposes of this guide, this installation will proceed as a hybrid installation. For more details on these three configurations, see the Installing Linux ATV-Bootloader page.

Boot the Mythbuntu Live CD

Hook up all the USB devices to the ATV and let it boot off the USB drive. This will yield a "penbuntu" login prompt. Use "root" as for the user name and password. Mount the Live CD:

mkdir /cdrom
mount -o loop /dev/sr0 /cdrom

Then type the following kexec to prepare to boot the image:

kexec --load /cdrom/casper/vmlinuz \
--initrd=/cdrom/casper/initrd.lz \
--command-line="boot=casper initrd=/casper/initrd.lz nosplash vesa" 

Finally, execute the kexec:

kexec -e

Re-partition (Hybrid Installation)

Once the Live CD is booted, space needs to be created for the install. To obtain the necessary hard drive space on the ATV, the "Media" partition needs to be resized. With this free space, a linux partition as well as a swap partition will be created. For the sake of not repeating information, read the Alternate Partitioning page on the ATV-Bootloader webpage for a detailed explanation on the steps.

Install Mythbuntu

Once the partitioning scheme has been established, it's time for the installation. Proceed as one normally would, selecting the system's role as a Desktop Front-end. Enable SSH. If prompted, select the 185 NVIDIA restricted driver. Before the system reboots, some fixes need to be implemented.

Fixing GRUB

ATV-Bootloader looks for /boot/grub/menu.lst on the internal hard drive. Unfortunately, Ubuntu 9.10 uses GRUB2 which handles the boot menu differently. Accordingly, menu.lst must be created. Mount the now-installed partition (for this example, it's on sda5):

mkdir /atvdrive
mount -o loop /dev/sda5 /atvdrive

Create /atvdrive/boot/grub/menu.lst

%sudo nano /atvdrive/boot/grub/menu.lst
default 0
title Mythbuntu
root (hd0,4)
kernel /boot/vmlinuz-2.6.31-14-generic root=/dev/sda5 ro quiet processor.max_cstate=2
initrd /boot/initrd.img-2.6.31-14-generic
boot

Note the additional kernel parameter "processor.max_cstate=2". This resolves some performance issues.

Reboot

Reboot and see if the GRUB fix took hold. If everything worked, once ATV-Bootloader finishes booting, it will find the Mythbuntu and boot.

Fixing the Video

With the restricted drivers installed, it is now time to underclock the GPU. This is done due to poor playback issues experienced when running full-throttle. Credit for these fixes goes to Robert Baptista over on the ATB-Bootloader forums.

This part is most easily accomplished via SSH to allow for tinkering if the X Server doesn't come back. Create /etc/modprobe.d/options.conf and add:

%sudo nano /etc/modprobe.d/options.conf

options nvidia NVreg_RegistryDwords="PerfLevelSrc=0x2222" 
options nvidia NVreg_Mobile=0

This sets makes it so the graphics card does not appear to be a mobile chipset, thus allowing for over(under)clocking. Next, create /home/$user/.mythtv/session:

%sudo nano /home/$user/.mythtv/session

#!/bin/sh 
xset -dpms 
xset s off 
nvidia-settings -a GPUOverclockingState=1 
nvidia-settings -a GPU2DClockFreqs=200,760

This script sets underclocks the GPU clock speed to 200 MHz (from 360 MHz) and sets the memory clock to around 760 MHz.

Next, run the following:

sudo sed -i -e 's/^libXvMC.so.1$/libXvMCNVIDIA_dynamic.so.1/' /etc/X11/XvMCConfig

Finally, to set the X Server to display 1920x1080, edit /etc/X11/xorg.conf to reflect the following:

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 1.0  (buildmeister@builder63)  Fri Aug 14 17:54:58 PDT 2009

Section "ServerLayout"
   Identifier     "Layout0"
   Screen      0  "Screen0"
   InputDevice    "Keyboard0" "CoreKeyboard"
   InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
   # generated from default
   Identifier     "Mouse0"
   Driver         "mouse"
   Option         "Protocol" "auto"
   Option         "Device" "/dev/psaux"
   Option         "Emulate3Buttons" "no"
   Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
   # generated from default
   Identifier     "Keyboard0"
   Driver         "kbd"
EndSection

Section "Monitor"
   Identifier     "Monitor0"
   VendorName     "Unknown"
   ModelName      "SAMSUNG"
   HorizSync       26.0 - 68.0
   VertRefresh     23.0 - 61.0
   Option         "DPMS"
EndSection

Section "Device"
   Identifier     "Device0"
   Driver         "nvidia"
   VendorName     "NVIDIA Corporation"
   Option	   "RegistryDwords" "RMDisableRenderToSysmem=1" 
EndSection

Section "Screen"
   Identifier     "Screen0"
   Device         "Device0"
   Monitor        "Monitor0"
   DefaultDepth    24
   Option         "metamodes" "1920x1080 +0+0; nvidia-auto-select +0+0; 1280x720 +0+0; 720x480 +0+0; 800x600 +0+0; 640x480 +0+0"
   Option         "UseEvents" "1"
   Option         "NoLogo" "True"
   Option         "Coolbits" "1" 
   SubSection     "Display"
       Depth       24
   EndSubSection
EndSection

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

Note, this "Screen" is for a Samsung 1080p television connected via HDMI. Settings for other televisions/monitors may vary. To test the fixes, one could restart the X Server using:

sudo /etc/init.d/gdm restart

or just reboot the system. To verify the underclocking, run:

nvclock -i  

which should generate some output similar to:

-- General info --
Card:           nVidia Geforce Go 7300
Architecture:   NV46/G72 A3
PCI id:         0x1d7
GPU clock:      200.000 MHz
Bustype:        PCI-Express

-- Pipeline info --
Pixel units: 2x2 (11b)
Vertex units: 3x1 (111b)
HW masked units: None
SW masked units: None 

-- Memory info --
Amount:         64 MB
Type:           128 bit DDR3
Clock:          756.000 MHz 

-- PCI-Express info --
Current Rate:   2X
Maximum rate:   16X

-- Sensor info --
Sensor: GPU Internal Sensor
GPU temperature: 60C

-- VideoBios information --
Version: 05.72.22.68.00
Signon message: GeForce Go 7300 VGA BIOS (Apple M63)
Performance level 0: gpu 360MHz/memory 720MHz/100%

Stopping the LED flashing amber

Download and compile atvclient. Note, this is written for XBMC so it will override your remote and stop it working for MythTV. You can hack the source if you know what you are doing but to use it as-is, your choices are:

  • Have the LED flashing amber and have the remote control working
  • Have the LED white but remote control not working
  • Configure it/hack the source code to get it working properly.

Upgrading

The best way of upgrading Mythbuntu is to use Ubuntu's update manager. However, by default it will use LTS versions (Long Term Support) only. Change the following line in /etc/update-manager/release-upgrades:

Prompt=normal

Then run the update manager. When prompted to install grub-pc, do not tick any boxes (as we do not want to mess up our grub installation) and just click forward. It will warn you that you are not installing grub. This is OK as it is already installed. After it has installed and before you reboot, edit the /boot/grub/menu.lst file to point to the new kernel:

default 0
title Mythbuntu
root (hd0,4)
kernel /boot/vmlinuz-2.6.35-30-generic root=/dev/sda5 ro quiet processor.max_cstate=2
initrd /boot/initrd.img-2.6.35-30-generic
boot

Once rebooted, perform the procedure again to upgrade to 11.04 (current at time of writing)