Linux on Apple TV

From AwkwardTV
Revision as of 22:28, 13 April 2007 by Kad77 (talk | contribs) (Geek Notes)
Jump to: navigation, search


Current Status

Linux HOWTO may be written as early as Friday night by community member "beyond"

Sourceforge SVN access (client needed):

"mach_linux_boot" is the only code you need from mactel!

View the current SVN with your browser. The Linux side actively requires testing. As you will read below, the results are phenomenal so far.

This page is being slowly reworked (old, and confusing data removed) and may be in flux for a few days. Please add to it, and do see page history for some previous data regarding EFI, and previous Linux on Mac projects.

DO NOT REMOVE THIS NOTICE UNTIL AN ANSWER WITH LINKS HAS BEEN WIKI'D (kad77): We need to establish whether the official NVidia Linux binary supports PureVideo/CUDA for MPEG hardware acceleration. Without hardware MPEG decoding, we are at a severe disadvantage using Linux for video applciation. See these links (please add): [1] [2]

AwkwardTV Linux Project

Many of us would like to see a minimal source distribution, targeted for AppleTV and utilizing the Linux kernel, emerge with boot and kernel configs. Extras might include scripts for USB or disk image builds. Currently we will be working with gimli's Mach-O wrapper approach to bootstrapping, and this will require a MacOS X setup. Recently Information has been added to the mactel wiki for using a darwin cross-compiler on Linux to compile the mach-binary.

Basic Rundown Borrowed from the mactel-wiki

   * alien must be installed
* Change to mach_linux_boot and execute the script
* Move darwin-cross to /opt/
* Execute
* Crosscompiler is from this Page

Please discuss your ideas on the #awkwardtv IRC Channel!

It bears mentioning that we recommend a complete backup of your original AppleTV drive before any experimentation. We have a wiki page dedicated to this subject. Remember, if you pipe the dd through gzip or bzip2, the virgin drive image created should only be ~2.5gb!

Basic Gentoo Install Guide -arodd-

Basic Instructions(Assuming you are on OSX and have Xcode Installed and are installing to the internal atv hd)
The guide also assumes Gentoo for the Linux OS
You need to use a livecd that supports EFI GPT partition tables.
The Ubuntu InstallCD does.

In Linux
The best way to do this step would be to hook up the atv hd to your computer running OSX and create the proper gpt partition for linux and format it as ext3.

More detailed instructions for this will be included later.

The basic rundown would be to make a backup image of the media partition data. Then use gpt to kill the 4th partition on the atv hd. Create a new media partition that doesn't use up the rest of the drive and set as type hfs. Then make a 5th partition as type linux to fill the rest of the drive. Then recover the data to the Media partition

You will need the ext2/3 driver for OSX installed you will then have the tools to format the partition as ext3 and access it from OSX.

newfs_ext2 -j /dev/diskXs5

Boot to the Ubuntu Live CD and then reach the graphical terminal.

sudo su
apt-get install subversion
mkdir /mnt/gentoo
mount /dev/deviceforatvhd /mnt/gentoo
This will probably be hda5/hdb5/sda5/sdb5 or something similar
dd if=/dev/zero of=/mnt/gentoo/swap bs=1024 count=2097152 Creates a 2GB swap file on the root partition
mkswap /mnt/gentoo/swap
cd /mnt/gentoo/usr/src/
tar -xjvf linux-
svn co
patch -p0 < mach_linux_boot/kernel/
cp mach_linux_boot/kernel/config-2.6.20-appletv linux-

Start at 5.b on the Gentoo Handbook and continue to the portion before you emerge gentoo-sources 7.b and then continue on below. Make sure you are in the chrooted environment

cd /usr/src/linux-
make menuconfig

Add any other features that you may want. Probably not a requirement. Personally I moved some of the things from module to built in. File System support in particular this way you don't need to load a module for hfs/hfs+

make all && make modules_install

Wait for compilation to finish.....and then cleanup

cp arch/i386/boot/bzImage ../mach_linux_boot/ cd /usr/src/
mv mach_linux_boot /
rm linux-
ln -s linux- linux
cd /lib/modules
ln -s
Seem to have missed a patch somewhere so it's looking for both folders when you load a module

Now the bzImage file is located in /usr/src/linux- as well as in the mach_linux_boot folder which we will copy to OSX later. Continue with the Gentoo Handbook from 8.a. all the way up through 9. Make the fstab look similar to below.

/dev/sda5 / ext3 defaults,errors=remount-ro 0 1
proc /proc proc defaults 0 0
shm /dev/shm tmpfs nodev,nosuid,noexec 0 0
/swapfile swap swap defaults 0 0

Skip all of the bootloader stuff in 10. You can follow 10.d to unmount filesystems etc. Reboot back into OSX


Open Terminal and begin the OSX portion of the mach_kernel loader compilation.

Since the svn-client in fink doesn't support ssl the easiest way is just to cp it from the ext2 partition.

sudo cp -Rv /Volumes/linuxatvpartition/mach_linux_boot /Users/you/
cd /Users/you/mach_linux_boot
Make sure that your bzImage file is located inside this folder...If not copy it here from your linux partition.
sudo make

Now you have a mach_kernel loader with a linux kernel image enclosed. The ideal method would be to store this on the Media partition alongside boot.efi/ copied from the OSBoot partition. Modify to look similar to below

       <key>Background Color</key>
       <key>Boot Logo</key>
       <key>Kernel Flags</key>
       <string>root=/dev/sda5 rootdelay=10 irqpoll</string>

Needs Testing/More Documented work

root= may need to be changed to whatever partition number your ext3 partition is at.

The only problem was that I was only able to get it to boot the kernel from the OSBoot partition by removing the atv mach_kernel.prelink from the root directory and customizing the in /System/Library/CoreServices/ That didn't allow me to dual boot. There is no reason why we shouldn't be able to do the same from the Media partition and swap between atvos/linux and eventually atv/osx/linux, I just haven't got it working yet. In order for it to boot to a specific partition you need to use the bless command either from the ATV via ssh or via an Intel mac. Example...

bless --device=/dev/disk0s4 --setBoot --nextonly

Hardware Support

Much of the AppleTV's hardware is supported natively under the Linux kernel. In this section, we will be expanding on the Linux driver details.

Intel CPU Core

  • Speedstep functionality - WORKING

GeForce 7300 Go (NV40) Note: framebuffer fixes in SVN as of April 6, 2007 - please recompile

  • Official NVidia binary driver works without modification. Full 3D and framebuffer acceleration.
  • OSS NVidia driver works without modification (also provides acceleration)
(==) NV(0): Write-combining range (0x10000000,0x4000000)
(II) NV(0): Using XFree86 Acceleration Architecture (XAA)
	Screen to screen bit blits
	Solid filled rectangles
	8x8 mono pattern filled rectangles
	Indirect CPU to Screen color expansion
	Solid Lines
	Scanline Image Writes
	Offscreen Pixmaps
	Setting up tile and stipple cache:
	32 128x128 slots
	32 256x256 slots
	16 512x512 slots
  • HDMI - WORKING (DVI tested)
  • Component - not tested

Intel HD Audio

  • HDA-Intel driver recognized by default
  • Analogue RCA - not tested
  • Optical SPDIF - WORKING

irDA interface

  • mactel-linux driver recognizes it - untested otherwise

Broadcom BCM94321MC wireless


  • USB booting works when you disable ehci-hcd in kernel

Our components wiki has further information about the specific chips involved.

Barebones Distro Notes

Our preferred base distrubutions:

There are a few Linux distributions specialized for Media Center usage:

Some useful components:

We would prefer a lightweight X alternative or optimized/minimal X11 build. Note: KDrive is framebuffer only.


Geek Notes

April 5, 2007 dmseg output: (from gimli @ mactel)