Linux on Apple TV
Linux HOWTO may be written as early as Friday night by community member "beyond"
- Edgar (gimli) Hucek from the mactel-linux project, and AwkwardTV contributor, has gotten the Linux kernel to boot via a custom loader-- which is itself loaded by the AppleTV boot.efi loader. gimli first got linux running on EFI-based intel Macs.
Sourceforge SVN access (client needed): https://mactel-linux.svn.sourceforge.net/svnroot/mactel-linux/trunk/mach_linux_boot
"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):  
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.
Information has been posted to the mactel wiki regarding a Darwin cross-compiler for Linux to compile the Mach-O binary. gimli reports this to work on Ubuntu Fiesty.
* 'alien' package must be installed
* Change to 'mach_linux_boot' and execute the script 'get_cross.sh'
* Move 'darwin-cross' to /opt/
* Execute 'make.sh'
* Cross-compiler download: Darwin/MacOS X Cross-Compiler for Linux
(Sourced from the mactel-wiki)
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 http://www.gentoo.org/doc/en/handbook/handbook-x86.xml
You need to use a livecd that supports EFI GPT partition tables.
The Ubuntu InstallCD does. http://www.ubuntu.com/getubuntu/download
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 http://sourceforge.net/projects/ext2fsx/ 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 This will probably be hda5/hdb5/sda5/sdb5 or something similar
apt-get install subversion
mount /dev/deviceforatvhd /mnt/gentoo
dd if=/dev/zero of=/mnt/gentoo/swap bs=1024 count=2097152 Creates a 2GB swap file on the root partition
tar -xjvf linux-220.127.116.11.tar.bz2
svn co https://mactel-linux.svn.sourceforge.net/svnroot/mactel-linux/trunk/mach_linux_boot
patch -p0 < mach_linux_boot/kernel/18.104.22.168-apletv.patch
cp mach_linux_boot/kernel/config-2.6.20-appletv linux-22.214.171.124/.config
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
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/
mv mach_linux_boot /
ln -s linux-126.96.36.199 linux
ln -s 188.8.131.52-appletv 184.108.40.206
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-220.127.116.11/arch/i386/boot/bzImage 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/Make sure that your bzImage file is located inside this folder...If not copy it here from your linux partition.
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/com.apple.Boot.plist copied from the OSBoot partition. Modify com.apple.Boot.plist to look similar to below
<key>Background Color</key> <integer>0</integer> <key>Boot Logo</key> <string>BootLogo.png</string> <key>Kernel</key> <string>mach_kernel</string> <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 com.apple.Boot.plist in /System/Library/CoreServices/com.apple.Boot.plist. 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
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
- 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:
- Lunar Linux 1.61 A full source based distro, customizable and friendly.
- ttylinux 6.0 A micro distro (8MB w/kernel)
There are a few Linux distributions specialized for Media Center usage:
Some useful components:
- elilo bootloader 3.6 (stable)
- The Linux kernel 18.104.22.168 (recent)
- NVidia binary driver (latest)
- BusyBox 1.4.2 (stable)
- MatchBox Window Manager
- XOrg X11R7.2
We would prefer a lightweight X alternative or optimized/minimal X11 build. Note: KDrive is framebuffer only.
- ATV/Gentoo Wallpaper BigBaconAndEggs
April 5, 2007 dmseg output: (from gimli @ mactel)